This source file includes following definitions.
- opp2_set_disp_pattern_generator
- opp2_dpg_set_blank_color
- opp2_dpg_is_blanked
- opp2_program_left_edge_extra_pixel
- dcn20_opp_construct
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 #include "dm_services.h"
  27 #include "dcn20_opp.h"
  28 #include "reg_helper.h"
  29 
  30 #define REG(reg) \
  31         (oppn20->regs->reg)
  32 
  33 #undef FN
  34 #define FN(reg_name, field_name) \
  35         oppn20->opp_shift->field_name, oppn20->opp_mask->field_name
  36 
  37 #define CTX \
  38         oppn20->base.ctx
  39 
  40 
  41 void opp2_set_disp_pattern_generator(
  42                 struct output_pixel_processor *opp,
  43                 enum controller_dp_test_pattern test_pattern,
  44                 enum dc_color_depth color_depth,
  45                 const struct tg_color *solid_color,
  46                 int width,
  47                 int height)
  48 {
  49         struct dcn20_opp *oppn20 = TO_DCN20_OPP(opp);
  50         enum test_pattern_color_format bit_depth;
  51         enum test_pattern_dyn_range dyn_range;
  52         enum test_pattern_mode mode;
  53 
  54         
  55         uint32_t src_bpc = 16;
  56         
  57         uint32_t dst_bpc;
  58         uint32_t index;
  59         
  60 
  61 
  62 
  63 
  64         uint16_t src_color[6] = {0xFFFF, 0xFFFF, 0xFFFF, 0x0000,
  65                                                 0x0000, 0x0000};
  66         
  67         uint16_t dst_color[6];
  68         uint32_t inc_base;
  69 
  70         
  71         switch (color_depth) {
  72         case COLOR_DEPTH_666:
  73                 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_6;
  74         break;
  75         case COLOR_DEPTH_888:
  76                 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_8;
  77         break;
  78         case COLOR_DEPTH_101010:
  79                 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_10;
  80         break;
  81         case COLOR_DEPTH_121212:
  82                 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_12;
  83         break;
  84         default:
  85                 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_8;
  86         break;
  87         }
  88 
  89         
  90         REG_SET_2(DPG_DIMENSIONS, 0,
  91                 DPG_ACTIVE_WIDTH, width,
  92                 DPG_ACTIVE_HEIGHT, height);
  93 
  94         switch (test_pattern) {
  95         case CONTROLLER_DP_TEST_PATTERN_COLORSQUARES:
  96         case CONTROLLER_DP_TEST_PATTERN_COLORSQUARES_CEA:
  97         {
  98                 dyn_range = (test_pattern ==
  99                                 CONTROLLER_DP_TEST_PATTERN_COLORSQUARES_CEA ?
 100                                 TEST_PATTERN_DYN_RANGE_CEA :
 101                                 TEST_PATTERN_DYN_RANGE_VESA);
 102 
 103                 REG_UPDATE_6(DPG_CONTROL,
 104                         DPG_EN, 1,
 105                         DPG_MODE, TEST_PATTERN_MODE_COLORSQUARES_RGB,
 106                         DPG_DYNAMIC_RANGE, dyn_range,
 107                         DPG_BIT_DEPTH, bit_depth,
 108                         DPG_VRES, 6,
 109                         DPG_HRES, 6);
 110         }
 111         break;
 112 
 113         case CONTROLLER_DP_TEST_PATTERN_VERTICALBARS:
 114         case CONTROLLER_DP_TEST_PATTERN_HORIZONTALBARS:
 115         {
 116                 mode = (test_pattern ==
 117                         CONTROLLER_DP_TEST_PATTERN_VERTICALBARS ?
 118                         TEST_PATTERN_MODE_VERTICALBARS :
 119                         TEST_PATTERN_MODE_HORIZONTALBARS);
 120 
 121                 switch (bit_depth) {
 122                 case TEST_PATTERN_COLOR_FORMAT_BPC_6:
 123                         dst_bpc = 6;
 124                 break;
 125                 case TEST_PATTERN_COLOR_FORMAT_BPC_8:
 126                         dst_bpc = 8;
 127                 break;
 128                 case TEST_PATTERN_COLOR_FORMAT_BPC_10:
 129                         dst_bpc = 10;
 130                 break;
 131                 default:
 132                         dst_bpc = 8;
 133                 break;
 134                 }
 135 
 136                 
 137                 for (index = 0; index < 6; index++) {
 138                         
 139 
 140 
 141                         dst_color[index] =
 142                                 src_color[index] >> (src_bpc - dst_bpc);
 143                 
 144 
 145 
 146 
 147 
 148                         dst_color[index] <<= (16 - dst_bpc);
 149                 }
 150 
 151                 REG_SET_2(DPG_COLOUR_R_CR, 0,
 152                                 DPG_COLOUR1_R_CR, dst_color[0],
 153                                 DPG_COLOUR0_R_CR, dst_color[3]);
 154                 REG_SET_2(DPG_COLOUR_G_Y, 0,
 155                                 DPG_COLOUR1_G_Y, dst_color[1],
 156                                 DPG_COLOUR0_G_Y, dst_color[4]);
 157                 REG_SET_2(DPG_COLOUR_B_CB, 0,
 158                                 DPG_COLOUR1_B_CB, dst_color[2],
 159                                 DPG_COLOUR0_B_CB, dst_color[5]);
 160 
 161                 
 162                 REG_UPDATE_6(DPG_CONTROL,
 163                         DPG_EN, 1,
 164                         DPG_MODE, mode,
 165                         DPG_DYNAMIC_RANGE, 0,
 166                         DPG_BIT_DEPTH, bit_depth,
 167                         DPG_VRES, 0,
 168                         DPG_HRES, 0);
 169         }
 170         break;
 171 
 172         case CONTROLLER_DP_TEST_PATTERN_COLORRAMP:
 173         {
 174                 mode = (bit_depth ==
 175                         TEST_PATTERN_COLOR_FORMAT_BPC_10 ?
 176                         TEST_PATTERN_MODE_DUALRAMP_RGB :
 177                         TEST_PATTERN_MODE_SINGLERAMP_RGB);
 178 
 179                 switch (bit_depth) {
 180                 case TEST_PATTERN_COLOR_FORMAT_BPC_6:
 181                         dst_bpc = 6;
 182                 break;
 183                 case TEST_PATTERN_COLOR_FORMAT_BPC_8:
 184                         dst_bpc = 8;
 185                 break;
 186                 case TEST_PATTERN_COLOR_FORMAT_BPC_10:
 187                         dst_bpc = 10;
 188                 break;
 189                 default:
 190                         dst_bpc = 8;
 191                 break;
 192                 }
 193 
 194                 
 195 
 196 
 197 
 198                 inc_base = (src_bpc - dst_bpc);
 199 
 200                 switch (bit_depth) {
 201                 case TEST_PATTERN_COLOR_FORMAT_BPC_6:
 202                 {
 203                         REG_SET_3(DPG_RAMP_CONTROL, 0,
 204                                 DPG_RAMP0_OFFSET, 0,
 205                                 DPG_INC0, inc_base,
 206                                 DPG_INC1, 0);
 207                         REG_UPDATE_2(DPG_CONTROL,
 208                                 DPG_VRES, 6,
 209                                 DPG_HRES, 6);
 210                 }
 211                 break;
 212                 case TEST_PATTERN_COLOR_FORMAT_BPC_8:
 213                 {
 214                         REG_SET_3(DPG_RAMP_CONTROL, 0,
 215                                 DPG_RAMP0_OFFSET, 0,
 216                                 DPG_INC0, inc_base,
 217                                 DPG_INC1, 0);
 218                         REG_UPDATE_2(DPG_CONTROL,
 219                                 DPG_VRES, 6,
 220                                 DPG_HRES, 8);
 221                 }
 222                 break;
 223                 case TEST_PATTERN_COLOR_FORMAT_BPC_10:
 224                 {
 225                         REG_SET_3(DPG_RAMP_CONTROL, 0,
 226                                 DPG_RAMP0_OFFSET, 384 << 6,
 227                                 DPG_INC0, inc_base,
 228                                 DPG_INC1, inc_base + 2);
 229                         REG_UPDATE_2(DPG_CONTROL,
 230                                 DPG_VRES, 5,
 231                                 DPG_HRES, 8);
 232                 }
 233                 break;
 234                 default:
 235                 break;
 236                 }
 237 
 238                 
 239                 REG_UPDATE_4(DPG_CONTROL,
 240                         DPG_EN, 1,
 241                         DPG_MODE, mode,
 242                         DPG_DYNAMIC_RANGE, 0,
 243                         DPG_BIT_DEPTH, bit_depth);
 244         }
 245         break;
 246         case CONTROLLER_DP_TEST_PATTERN_VIDEOMODE:
 247         {
 248                 REG_WRITE(DPG_CONTROL, 0);
 249                 REG_WRITE(DPG_COLOUR_R_CR, 0);
 250                 REG_WRITE(DPG_COLOUR_G_Y, 0);
 251                 REG_WRITE(DPG_COLOUR_B_CB, 0);
 252                 REG_WRITE(DPG_RAMP_CONTROL, 0);
 253         }
 254         break;
 255         case CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR:
 256         {
 257                 opp2_dpg_set_blank_color(opp, solid_color);
 258                 REG_UPDATE_2(DPG_CONTROL,
 259                                 DPG_EN, 1,
 260                                 DPG_MODE, TEST_PATTERN_MODE_HORIZONTALBARS);
 261 
 262                 REG_SET_2(DPG_DIMENSIONS, 0,
 263                                 DPG_ACTIVE_WIDTH, width,
 264                                 DPG_ACTIVE_HEIGHT, height);
 265         }
 266         break;
 267         default:
 268                 break;
 269 
 270         }
 271 }
 272 
 273 void opp2_dpg_set_blank_color(
 274                 struct output_pixel_processor *opp,
 275                 const struct tg_color *color)
 276 {
 277         struct dcn20_opp *oppn20 = TO_DCN20_OPP(opp);
 278 
 279         
 280         ASSERT(color);
 281         REG_SET_2(DPG_COLOUR_B_CB, 0,
 282                         DPG_COLOUR1_B_CB, color->color_b_cb << 6,
 283                         DPG_COLOUR0_B_CB, color->color_b_cb << 6);
 284         REG_SET_2(DPG_COLOUR_G_Y, 0,
 285                         DPG_COLOUR1_G_Y, color->color_g_y << 6,
 286                         DPG_COLOUR0_G_Y, color->color_g_y << 6);
 287         REG_SET_2(DPG_COLOUR_R_CR, 0,
 288                         DPG_COLOUR1_R_CR, color->color_r_cr << 6,
 289                         DPG_COLOUR0_R_CR, color->color_r_cr << 6);
 290 }
 291 
 292 bool opp2_dpg_is_blanked(struct output_pixel_processor *opp)
 293 {
 294         struct dcn20_opp *oppn20 = TO_DCN20_OPP(opp);
 295         uint32_t dpg_en, dpg_mode;
 296         uint32_t double_buffer_pending;
 297 
 298         REG_GET_2(DPG_CONTROL,
 299                         DPG_EN, &dpg_en,
 300                         DPG_MODE, &dpg_mode);
 301 
 302         REG_GET(DPG_STATUS,
 303                         DPG_DOUBLE_BUFFER_PENDING, &double_buffer_pending);
 304 
 305         return (dpg_en == 1) &&
 306                 (double_buffer_pending == 0);
 307 }
 308 
 309 void opp2_program_left_edge_extra_pixel (
 310                 struct output_pixel_processor *opp,
 311                 bool count)
 312 {
 313         struct dcn20_opp *oppn20 = TO_DCN20_OPP(opp);
 314 
 315         
 316 
 317 
 318 
 319         REG_UPDATE(FMT_422_CONTROL, FMT_LEFT_EDGE_EXTRA_PIXEL_COUNT, count);
 320 }
 321 
 322 
 323 
 324 
 325 
 326 static struct opp_funcs dcn20_opp_funcs = {
 327                 .opp_set_dyn_expansion = opp1_set_dyn_expansion,
 328                 .opp_program_fmt = opp1_program_fmt,
 329                 .opp_program_bit_depth_reduction = opp1_program_bit_depth_reduction,
 330                 .opp_program_stereo = opp1_program_stereo,
 331                 .opp_pipe_clock_control = opp1_pipe_clock_control,
 332                 .opp_set_disp_pattern_generator = opp2_set_disp_pattern_generator,
 333                 .dpg_is_blanked = opp2_dpg_is_blanked,
 334                 .opp_dpg_set_blank_color = opp2_dpg_set_blank_color,
 335                 .opp_destroy = opp1_destroy,
 336                 .opp_program_left_edge_extra_pixel = opp2_program_left_edge_extra_pixel,
 337 };
 338 
 339 void dcn20_opp_construct(struct dcn20_opp *oppn20,
 340         struct dc_context *ctx,
 341         uint32_t inst,
 342         const struct dcn20_opp_registers *regs,
 343         const struct dcn20_opp_shift *opp_shift,
 344         const struct dcn20_opp_mask *opp_mask)
 345 {
 346         oppn20->base.ctx = ctx;
 347         oppn20->base.inst = inst;
 348         oppn20->base.funcs = &dcn20_opp_funcs;
 349 
 350         oppn20->regs = regs;
 351         oppn20->opp_shift = opp_shift;
 352         oppn20->opp_mask = opp_mask;
 353 }
 354