2 * Copyright 2016 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "dm_services.h"
28 #include "core_types.h"
30 #include "reg_helper.h"
31 #include "dcn20_dpp.h"
32 #include "basics/conversion.h"
34 #include "dcn10/dcn10_cm_common.h"
39 #define IND_REG(index) \
46 #define FN(reg_name, field_name) \
47 dpp->tf_shift->field_name, dpp->tf_mask->field_name
50 static void dpp2_enable_cm_block(
53 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
55 unsigned int cm_bypass_mode
= 0;
56 //Temp, put CM in bypass mode
57 if (dpp_base
->ctx
->dc
->debug
.cm_in_bypass
)
60 REG_UPDATE(CM_CONTROL
, CM_BYPASS
, cm_bypass_mode
);
64 static bool dpp2_degamma_ram_inuse(
69 uint32_t status_reg
= 0;
70 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
72 REG_GET(CM_DGAM_LUT_WRITE_EN_MASK
, CM_DGAM_CONFIG_STATUS
,
75 if (status_reg
== 3) {
78 } else if (status_reg
== 4) {
85 static void dpp2_program_degamma_lut(
87 const struct pwl_result_data
*rgb
,
93 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
94 REG_UPDATE(CM_DGAM_LUT_WRITE_EN_MASK
,
95 CM_DGAM_LUT_WRITE_EN_MASK
, 7);
96 REG_UPDATE(CM_DGAM_LUT_WRITE_EN_MASK
, CM_DGAM_LUT_WRITE_SEL
,
97 is_ram_a
== true ? 0:1);
99 REG_SET(CM_DGAM_LUT_INDEX
, 0, CM_DGAM_LUT_INDEX
, 0);
100 for (i
= 0 ; i
< num
; i
++) {
101 REG_SET(CM_DGAM_LUT_DATA
, 0, CM_DGAM_LUT_DATA
, rgb
[i
].red_reg
);
102 REG_SET(CM_DGAM_LUT_DATA
, 0, CM_DGAM_LUT_DATA
, rgb
[i
].green_reg
);
103 REG_SET(CM_DGAM_LUT_DATA
, 0, CM_DGAM_LUT_DATA
, rgb
[i
].blue_reg
);
105 REG_SET(CM_DGAM_LUT_DATA
, 0,
106 CM_DGAM_LUT_DATA
, rgb
[i
].delta_red_reg
);
107 REG_SET(CM_DGAM_LUT_DATA
, 0,
108 CM_DGAM_LUT_DATA
, rgb
[i
].delta_green_reg
);
109 REG_SET(CM_DGAM_LUT_DATA
, 0,
110 CM_DGAM_LUT_DATA
, rgb
[i
].delta_blue_reg
);
116 void dpp2_set_degamma_pwl(
117 struct dpp
*dpp_base
,
118 const struct pwl_params
*params
)
120 bool is_ram_a
= true;
122 dpp1_power_on_degamma_lut(dpp_base
, true);
123 dpp2_enable_cm_block(dpp_base
);
124 dpp2_degamma_ram_inuse(dpp_base
, &is_ram_a
);
125 if (is_ram_a
== true)
126 dpp1_program_degamma_lutb_settings(dpp_base
, params
);
128 dpp1_program_degamma_luta_settings(dpp_base
, params
);
130 dpp2_program_degamma_lut(dpp_base
, params
->rgb_resulted
, params
->hw_points_num
, !is_ram_a
);
131 dpp1_degamma_ram_select(dpp_base
, !is_ram_a
);
134 void dpp2_set_degamma(
135 struct dpp
*dpp_base
,
136 enum ipp_degamma_mode mode
)
138 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
139 dpp2_enable_cm_block(dpp_base
);
142 case IPP_DEGAMMA_MODE_BYPASS
:
143 /* Setting de gamma bypass for now */
144 REG_UPDATE(CM_DGAM_CONTROL
, CM_DGAM_LUT_MODE
, 0);
146 case IPP_DEGAMMA_MODE_HW_sRGB
:
147 REG_UPDATE(CM_DGAM_CONTROL
, CM_DGAM_LUT_MODE
, 1);
149 case IPP_DEGAMMA_MODE_HW_xvYCC
:
150 REG_UPDATE(CM_DGAM_CONTROL
, CM_DGAM_LUT_MODE
, 2);
152 case IPP_DEGAMMA_MODE_USER_PWL
:
153 REG_UPDATE(CM_DGAM_CONTROL
, CM_DGAM_LUT_MODE
, 3);
161 static void program_gamut_remap(
162 struct dcn20_dpp
*dpp
,
163 const uint16_t *regval
,
164 enum dcn20_gamut_remap_select select
)
166 uint32_t cur_select
= 0;
167 struct color_matrices_reg gam_regs
;
169 if (regval
== NULL
|| select
== DCN2_GAMUT_REMAP_BYPASS
) {
170 REG_SET(CM_GAMUT_REMAP_CONTROL
, 0,
171 CM_GAMUT_REMAP_MODE
, 0);
175 /* determine which gamut_remap coefficients (A or B) we are using
176 * currently. select the alternate set to double buffer
177 * the update so gamut_remap is updated on frame boundary
179 IX_REG_GET(CM_TEST_DEBUG_INDEX
, CM_TEST_DEBUG_DATA
,
180 CM_TEST_DEBUG_DATA_STATUS_IDX
,
181 CM_TEST_DEBUG_DATA_GAMUT_REMAP_MODE
, &cur_select
);
183 /* value stored in dbg reg will be 1 greater than mode we want */
184 if (cur_select
!= DCN2_GAMUT_REMAP_COEF_A
)
185 select
= DCN2_GAMUT_REMAP_COEF_A
;
187 select
= DCN2_GAMUT_REMAP_COEF_B
;
189 gam_regs
.shifts
.csc_c11
= dpp
->tf_shift
->CM_GAMUT_REMAP_C11
;
190 gam_regs
.masks
.csc_c11
= dpp
->tf_mask
->CM_GAMUT_REMAP_C11
;
191 gam_regs
.shifts
.csc_c12
= dpp
->tf_shift
->CM_GAMUT_REMAP_C12
;
192 gam_regs
.masks
.csc_c12
= dpp
->tf_mask
->CM_GAMUT_REMAP_C12
;
194 if (select
== DCN2_GAMUT_REMAP_COEF_A
) {
195 gam_regs
.csc_c11_c12
= REG(CM_GAMUT_REMAP_C11_C12
);
196 gam_regs
.csc_c33_c34
= REG(CM_GAMUT_REMAP_C33_C34
);
198 gam_regs
.csc_c11_c12
= REG(CM_GAMUT_REMAP_B_C11_C12
);
199 gam_regs
.csc_c33_c34
= REG(CM_GAMUT_REMAP_B_C33_C34
);
202 cm_helper_program_color_matrices(
208 CM_GAMUT_REMAP_CONTROL
, 0,
209 CM_GAMUT_REMAP_MODE
, select
);
213 void dpp2_cm_set_gamut_remap(
214 struct dpp
*dpp_base
,
215 const struct dpp_grph_csc_adjustment
*adjust
)
217 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
220 if (adjust
->gamut_adjust_type
!= GRAPHICS_GAMUT_ADJUST_TYPE_SW
)
221 /* Bypass if type is bypass or hw */
222 program_gamut_remap(dpp
, NULL
, DCN2_GAMUT_REMAP_BYPASS
);
224 struct fixed31_32 arr_matrix
[12];
225 uint16_t arr_reg_val
[12];
227 for (i
= 0; i
< 12; i
++)
228 arr_matrix
[i
] = adjust
->temperature_matrix
[i
];
230 convert_float_matrix(
231 arr_reg_val
, arr_matrix
, 12);
233 program_gamut_remap(dpp
, arr_reg_val
, DCN2_GAMUT_REMAP_COEF_A
);
237 void dpp2_program_input_csc(
238 struct dpp
*dpp_base
,
239 enum dc_color_space color_space
,
240 enum dcn20_input_csc_select input_select
,
241 const struct out_csc_color_matrix
*tbl_entry
)
243 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
245 int arr_size
= sizeof(dpp_input_csc_matrix
)/sizeof(struct dpp_input_csc_matrix
);
246 const uint16_t *regval
= NULL
;
247 uint32_t cur_select
= 0;
248 enum dcn20_input_csc_select select
;
249 struct color_matrices_reg icsc_regs
;
251 if (input_select
== DCN2_ICSC_SELECT_BYPASS
) {
252 REG_SET(CM_ICSC_CONTROL
, 0, CM_ICSC_MODE
, 0);
256 if (tbl_entry
== NULL
) {
257 for (i
= 0; i
< arr_size
; i
++)
258 if (dpp_input_csc_matrix
[i
].color_space
== color_space
) {
259 regval
= dpp_input_csc_matrix
[i
].regval
;
263 if (regval
== NULL
) {
268 regval
= tbl_entry
->regval
;
271 /* determine which CSC coefficients (A or B) we are using
272 * currently. select the alternate set to double buffer
273 * the CSC update so CSC is updated on frame boundary
275 IX_REG_GET(CM_TEST_DEBUG_INDEX
, CM_TEST_DEBUG_DATA
,
276 CM_TEST_DEBUG_DATA_STATUS_IDX
,
277 CM_TEST_DEBUG_DATA_ICSC_MODE
, &cur_select
);
279 if (cur_select
!= DCN2_ICSC_SELECT_ICSC_A
)
280 select
= DCN2_ICSC_SELECT_ICSC_A
;
282 select
= DCN2_ICSC_SELECT_ICSC_B
;
284 icsc_regs
.shifts
.csc_c11
= dpp
->tf_shift
->CM_ICSC_C11
;
285 icsc_regs
.masks
.csc_c11
= dpp
->tf_mask
->CM_ICSC_C11
;
286 icsc_regs
.shifts
.csc_c12
= dpp
->tf_shift
->CM_ICSC_C12
;
287 icsc_regs
.masks
.csc_c12
= dpp
->tf_mask
->CM_ICSC_C12
;
289 if (select
== DCN2_ICSC_SELECT_ICSC_A
) {
291 icsc_regs
.csc_c11_c12
= REG(CM_ICSC_C11_C12
);
292 icsc_regs
.csc_c33_c34
= REG(CM_ICSC_C33_C34
);
296 icsc_regs
.csc_c11_c12
= REG(CM_ICSC_B_C11_C12
);
297 icsc_regs
.csc_c33_c34
= REG(CM_ICSC_B_C33_C34
);
301 cm_helper_program_color_matrices(
306 REG_SET(CM_ICSC_CONTROL
, 0,
307 CM_ICSC_MODE
, select
);
310 static void dpp20_power_on_blnd_lut(
311 struct dpp
*dpp_base
,
314 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
316 REG_SET(CM_MEM_PWR_CTRL
, 0,
317 BLNDGAM_MEM_PWR_FORCE
, power_on
== true ? 0:1);
321 static void dpp20_configure_blnd_lut(
322 struct dpp
*dpp_base
,
325 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
327 REG_UPDATE(CM_BLNDGAM_LUT_WRITE_EN_MASK
,
328 CM_BLNDGAM_LUT_WRITE_EN_MASK
, 7);
329 REG_UPDATE(CM_BLNDGAM_LUT_WRITE_EN_MASK
,
330 CM_BLNDGAM_LUT_WRITE_SEL
, is_ram_a
== true ? 0:1);
331 REG_SET(CM_BLNDGAM_LUT_INDEX
, 0, CM_BLNDGAM_LUT_INDEX
, 0);
334 static void dpp20_program_blnd_pwl(
335 struct dpp
*dpp_base
,
336 const struct pwl_result_data
*rgb
,
340 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
342 for (i
= 0 ; i
< num
; i
++) {
343 REG_SET(CM_BLNDGAM_LUT_DATA
, 0, CM_BLNDGAM_LUT_DATA
, rgb
[i
].red_reg
);
344 REG_SET(CM_BLNDGAM_LUT_DATA
, 0, CM_BLNDGAM_LUT_DATA
, rgb
[i
].green_reg
);
345 REG_SET(CM_BLNDGAM_LUT_DATA
, 0, CM_BLNDGAM_LUT_DATA
, rgb
[i
].blue_reg
);
347 REG_SET(CM_BLNDGAM_LUT_DATA
, 0,
348 CM_BLNDGAM_LUT_DATA
, rgb
[i
].delta_red_reg
);
349 REG_SET(CM_BLNDGAM_LUT_DATA
, 0,
350 CM_BLNDGAM_LUT_DATA
, rgb
[i
].delta_green_reg
);
351 REG_SET(CM_BLNDGAM_LUT_DATA
, 0,
352 CM_BLNDGAM_LUT_DATA
, rgb
[i
].delta_blue_reg
);
358 static void dcn20_dpp_cm_get_reg_field(
359 struct dcn20_dpp
*dpp
,
360 struct xfer_func_reg
*reg
)
362 reg
->shifts
.exp_region0_lut_offset
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION0_LUT_OFFSET
;
363 reg
->masks
.exp_region0_lut_offset
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION0_LUT_OFFSET
;
364 reg
->shifts
.exp_region0_num_segments
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION0_NUM_SEGMENTS
;
365 reg
->masks
.exp_region0_num_segments
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION0_NUM_SEGMENTS
;
366 reg
->shifts
.exp_region1_lut_offset
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION1_LUT_OFFSET
;
367 reg
->masks
.exp_region1_lut_offset
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION1_LUT_OFFSET
;
368 reg
->shifts
.exp_region1_num_segments
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION1_NUM_SEGMENTS
;
369 reg
->masks
.exp_region1_num_segments
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION1_NUM_SEGMENTS
;
371 reg
->shifts
.field_region_end
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION_END_B
;
372 reg
->masks
.field_region_end
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION_END_B
;
373 reg
->shifts
.field_region_end_slope
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION_END_SLOPE_B
;
374 reg
->masks
.field_region_end_slope
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION_END_SLOPE_B
;
375 reg
->shifts
.field_region_end_base
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION_END_BASE_B
;
376 reg
->masks
.field_region_end_base
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION_END_BASE_B
;
377 reg
->shifts
.field_region_linear_slope
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION_LINEAR_SLOPE_B
;
378 reg
->masks
.field_region_linear_slope
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION_LINEAR_SLOPE_B
;
379 reg
->shifts
.exp_region_start
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION_START_B
;
380 reg
->masks
.exp_region_start
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION_START_B
;
381 reg
->shifts
.exp_resion_start_segment
= dpp
->tf_shift
->CM_BLNDGAM_RAMA_EXP_REGION_START_SEGMENT_B
;
382 reg
->masks
.exp_resion_start_segment
= dpp
->tf_mask
->CM_BLNDGAM_RAMA_EXP_REGION_START_SEGMENT_B
;
385 /*program blnd lut RAM A*/
386 static void dpp20_program_blnd_luta_settings(
387 struct dpp
*dpp_base
,
388 const struct pwl_params
*params
)
390 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
391 struct xfer_func_reg gam_regs
;
393 dcn20_dpp_cm_get_reg_field(dpp
, &gam_regs
);
395 gam_regs
.start_cntl_b
= REG(CM_BLNDGAM_RAMA_START_CNTL_B
);
396 gam_regs
.start_cntl_g
= REG(CM_BLNDGAM_RAMA_START_CNTL_G
);
397 gam_regs
.start_cntl_r
= REG(CM_BLNDGAM_RAMA_START_CNTL_R
);
398 gam_regs
.start_slope_cntl_b
= REG(CM_BLNDGAM_RAMA_SLOPE_CNTL_B
);
399 gam_regs
.start_slope_cntl_g
= REG(CM_BLNDGAM_RAMA_SLOPE_CNTL_G
);
400 gam_regs
.start_slope_cntl_r
= REG(CM_BLNDGAM_RAMA_SLOPE_CNTL_R
);
401 gam_regs
.start_end_cntl1_b
= REG(CM_BLNDGAM_RAMA_END_CNTL1_B
);
402 gam_regs
.start_end_cntl2_b
= REG(CM_BLNDGAM_RAMA_END_CNTL2_B
);
403 gam_regs
.start_end_cntl1_g
= REG(CM_BLNDGAM_RAMA_END_CNTL1_G
);
404 gam_regs
.start_end_cntl2_g
= REG(CM_BLNDGAM_RAMA_END_CNTL2_G
);
405 gam_regs
.start_end_cntl1_r
= REG(CM_BLNDGAM_RAMA_END_CNTL1_R
);
406 gam_regs
.start_end_cntl2_r
= REG(CM_BLNDGAM_RAMA_END_CNTL2_R
);
407 gam_regs
.region_start
= REG(CM_BLNDGAM_RAMA_REGION_0_1
);
408 gam_regs
.region_end
= REG(CM_BLNDGAM_RAMA_REGION_32_33
);
410 cm_helper_program_xfer_func(dpp
->base
.ctx
, params
, &gam_regs
);
413 /*program blnd lut RAM B*/
414 static void dpp20_program_blnd_lutb_settings(
415 struct dpp
*dpp_base
,
416 const struct pwl_params
*params
)
418 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
419 struct xfer_func_reg gam_regs
;
421 dcn20_dpp_cm_get_reg_field(dpp
, &gam_regs
);
423 gam_regs
.start_cntl_b
= REG(CM_BLNDGAM_RAMB_START_CNTL_B
);
424 gam_regs
.start_cntl_g
= REG(CM_BLNDGAM_RAMB_START_CNTL_G
);
425 gam_regs
.start_cntl_r
= REG(CM_BLNDGAM_RAMB_START_CNTL_R
);
426 gam_regs
.start_slope_cntl_b
= REG(CM_BLNDGAM_RAMB_SLOPE_CNTL_B
);
427 gam_regs
.start_slope_cntl_g
= REG(CM_BLNDGAM_RAMB_SLOPE_CNTL_G
);
428 gam_regs
.start_slope_cntl_r
= REG(CM_BLNDGAM_RAMB_SLOPE_CNTL_R
);
429 gam_regs
.start_end_cntl1_b
= REG(CM_BLNDGAM_RAMB_END_CNTL1_B
);
430 gam_regs
.start_end_cntl2_b
= REG(CM_BLNDGAM_RAMB_END_CNTL2_B
);
431 gam_regs
.start_end_cntl1_g
= REG(CM_BLNDGAM_RAMB_END_CNTL1_G
);
432 gam_regs
.start_end_cntl2_g
= REG(CM_BLNDGAM_RAMB_END_CNTL2_G
);
433 gam_regs
.start_end_cntl1_r
= REG(CM_BLNDGAM_RAMB_END_CNTL1_R
);
434 gam_regs
.start_end_cntl2_r
= REG(CM_BLNDGAM_RAMB_END_CNTL2_R
);
435 gam_regs
.region_start
= REG(CM_BLNDGAM_RAMB_REGION_0_1
);
436 gam_regs
.region_end
= REG(CM_BLNDGAM_RAMB_REGION_32_33
);
438 cm_helper_program_xfer_func(dpp
->base
.ctx
, params
, &gam_regs
);
441 static enum dc_lut_mode
dpp20_get_blndgam_current(struct dpp
*dpp_base
)
443 enum dc_lut_mode mode
;
445 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
447 REG_GET(CM_BLNDGAM_LUT_WRITE_EN_MASK
,
448 CM_BLNDGAM_CONFIG_STATUS
, &state_mode
);
450 switch (state_mode
) {
467 bool dpp20_program_blnd_lut(
468 struct dpp
*dpp_base
, const struct pwl_params
*params
)
470 enum dc_lut_mode current_mode
;
471 enum dc_lut_mode next_mode
;
472 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
474 if (params
== NULL
) {
475 REG_SET(CM_BLNDGAM_CONTROL
, 0, CM_BLNDGAM_LUT_MODE
, 0);
478 current_mode
= dpp20_get_blndgam_current(dpp_base
);
479 if (current_mode
== LUT_BYPASS
|| current_mode
== LUT_RAM_A
)
480 next_mode
= LUT_RAM_B
;
482 next_mode
= LUT_RAM_A
;
484 dpp20_power_on_blnd_lut(dpp_base
, true);
485 dpp20_configure_blnd_lut(dpp_base
, next_mode
== LUT_RAM_A
? true:false);
487 if (next_mode
== LUT_RAM_A
)
488 dpp20_program_blnd_luta_settings(dpp_base
, params
);
490 dpp20_program_blnd_lutb_settings(dpp_base
, params
);
492 dpp20_program_blnd_pwl(
493 dpp_base
, params
->rgb_resulted
, params
->hw_points_num
);
495 REG_SET(CM_BLNDGAM_CONTROL
, 0, CM_BLNDGAM_LUT_MODE
,
496 next_mode
== LUT_RAM_A
? 1:2);
502 static void dpp20_program_shaper_lut(
503 struct dpp
*dpp_base
,
504 const struct pwl_result_data
*rgb
,
507 uint32_t i
, red
, green
, blue
;
508 uint32_t red_delta
, green_delta
, blue_delta
;
509 uint32_t red_value
, green_value
, blue_value
;
511 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
513 for (i
= 0 ; i
< num
; i
++) {
515 red
= rgb
[i
].red_reg
;
516 green
= rgb
[i
].green_reg
;
517 blue
= rgb
[i
].blue_reg
;
519 red_delta
= rgb
[i
].delta_red_reg
;
520 green_delta
= rgb
[i
].delta_green_reg
;
521 blue_delta
= rgb
[i
].delta_blue_reg
;
523 red_value
= ((red_delta
& 0x3ff) << 14) | (red
& 0x3fff);
524 green_value
= ((green_delta
& 0x3ff) << 14) | (green
& 0x3fff);
525 blue_value
= ((blue_delta
& 0x3ff) << 14) | (blue
& 0x3fff);
527 REG_SET(CM_SHAPER_LUT_DATA
, 0, CM_SHAPER_LUT_DATA
, red_value
);
528 REG_SET(CM_SHAPER_LUT_DATA
, 0, CM_SHAPER_LUT_DATA
, green_value
);
529 REG_SET(CM_SHAPER_LUT_DATA
, 0, CM_SHAPER_LUT_DATA
, blue_value
);
534 static enum dc_lut_mode
dpp20_get_shaper_current(struct dpp
*dpp_base
)
536 enum dc_lut_mode mode
;
538 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
540 REG_GET(CM_SHAPER_LUT_WRITE_EN_MASK
,
541 CM_SHAPER_CONFIG_STATUS
, &state_mode
);
543 switch (state_mode
) {
560 static void dpp20_configure_shaper_lut(
561 struct dpp
*dpp_base
,
564 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
566 REG_UPDATE(CM_SHAPER_LUT_WRITE_EN_MASK
,
567 CM_SHAPER_LUT_WRITE_EN_MASK
, 7);
568 REG_UPDATE(CM_SHAPER_LUT_WRITE_EN_MASK
,
569 CM_SHAPER_LUT_WRITE_SEL
, is_ram_a
== true ? 0:1);
570 REG_SET(CM_SHAPER_LUT_INDEX
, 0, CM_SHAPER_LUT_INDEX
, 0);
573 /*program shaper RAM A*/
575 static void dpp20_program_shaper_luta_settings(
576 struct dpp
*dpp_base
,
577 const struct pwl_params
*params
)
579 const struct gamma_curve
*curve
;
580 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
582 REG_SET_2(CM_SHAPER_RAMA_START_CNTL_B
, 0,
583 CM_SHAPER_RAMA_EXP_REGION_START_B
, params
->corner_points
[0].blue
.custom_float_x
,
584 CM_SHAPER_RAMA_EXP_REGION_START_SEGMENT_B
, 0);
585 REG_SET_2(CM_SHAPER_RAMA_START_CNTL_G
, 0,
586 CM_SHAPER_RAMA_EXP_REGION_START_G
, params
->corner_points
[0].green
.custom_float_x
,
587 CM_SHAPER_RAMA_EXP_REGION_START_SEGMENT_G
, 0);
588 REG_SET_2(CM_SHAPER_RAMA_START_CNTL_R
, 0,
589 CM_SHAPER_RAMA_EXP_REGION_START_R
, params
->corner_points
[0].red
.custom_float_x
,
590 CM_SHAPER_RAMA_EXP_REGION_START_SEGMENT_R
, 0);
592 REG_SET_2(CM_SHAPER_RAMA_END_CNTL_B
, 0,
593 CM_SHAPER_RAMA_EXP_REGION_END_B
, params
->corner_points
[1].blue
.custom_float_x
,
594 CM_SHAPER_RAMA_EXP_REGION_END_BASE_B
, params
->corner_points
[1].blue
.custom_float_y
);
596 REG_SET_2(CM_SHAPER_RAMA_END_CNTL_G
, 0,
597 CM_SHAPER_RAMA_EXP_REGION_END_G
, params
->corner_points
[1].green
.custom_float_x
,
598 CM_SHAPER_RAMA_EXP_REGION_END_BASE_G
, params
->corner_points
[1].green
.custom_float_y
);
600 REG_SET_2(CM_SHAPER_RAMA_END_CNTL_R
, 0,
601 CM_SHAPER_RAMA_EXP_REGION_END_R
, params
->corner_points
[1].red
.custom_float_x
,
602 CM_SHAPER_RAMA_EXP_REGION_END_BASE_R
, params
->corner_points
[1].red
.custom_float_y
);
604 curve
= params
->arr_curve_points
;
605 REG_SET_4(CM_SHAPER_RAMA_REGION_0_1
, 0,
606 CM_SHAPER_RAMA_EXP_REGION0_LUT_OFFSET
, curve
[0].offset
,
607 CM_SHAPER_RAMA_EXP_REGION0_NUM_SEGMENTS
, curve
[0].segments_num
,
608 CM_SHAPER_RAMA_EXP_REGION1_LUT_OFFSET
, curve
[1].offset
,
609 CM_SHAPER_RAMA_EXP_REGION1_NUM_SEGMENTS
, curve
[1].segments_num
);
612 REG_SET_4(CM_SHAPER_RAMA_REGION_2_3
, 0,
613 CM_SHAPER_RAMA_EXP_REGION2_LUT_OFFSET
, curve
[0].offset
,
614 CM_SHAPER_RAMA_EXP_REGION2_NUM_SEGMENTS
, curve
[0].segments_num
,
615 CM_SHAPER_RAMA_EXP_REGION3_LUT_OFFSET
, curve
[1].offset
,
616 CM_SHAPER_RAMA_EXP_REGION3_NUM_SEGMENTS
, curve
[1].segments_num
);
619 REG_SET_4(CM_SHAPER_RAMA_REGION_4_5
, 0,
620 CM_SHAPER_RAMA_EXP_REGION4_LUT_OFFSET
, curve
[0].offset
,
621 CM_SHAPER_RAMA_EXP_REGION4_NUM_SEGMENTS
, curve
[0].segments_num
,
622 CM_SHAPER_RAMA_EXP_REGION5_LUT_OFFSET
, curve
[1].offset
,
623 CM_SHAPER_RAMA_EXP_REGION5_NUM_SEGMENTS
, curve
[1].segments_num
);
626 REG_SET_4(CM_SHAPER_RAMA_REGION_6_7
, 0,
627 CM_SHAPER_RAMA_EXP_REGION6_LUT_OFFSET
, curve
[0].offset
,
628 CM_SHAPER_RAMA_EXP_REGION6_NUM_SEGMENTS
, curve
[0].segments_num
,
629 CM_SHAPER_RAMA_EXP_REGION7_LUT_OFFSET
, curve
[1].offset
,
630 CM_SHAPER_RAMA_EXP_REGION7_NUM_SEGMENTS
, curve
[1].segments_num
);
633 REG_SET_4(CM_SHAPER_RAMA_REGION_8_9
, 0,
634 CM_SHAPER_RAMA_EXP_REGION8_LUT_OFFSET
, curve
[0].offset
,
635 CM_SHAPER_RAMA_EXP_REGION8_NUM_SEGMENTS
, curve
[0].segments_num
,
636 CM_SHAPER_RAMA_EXP_REGION9_LUT_OFFSET
, curve
[1].offset
,
637 CM_SHAPER_RAMA_EXP_REGION9_NUM_SEGMENTS
, curve
[1].segments_num
);
640 REG_SET_4(CM_SHAPER_RAMA_REGION_10_11
, 0,
641 CM_SHAPER_RAMA_EXP_REGION10_LUT_OFFSET
, curve
[0].offset
,
642 CM_SHAPER_RAMA_EXP_REGION10_NUM_SEGMENTS
, curve
[0].segments_num
,
643 CM_SHAPER_RAMA_EXP_REGION11_LUT_OFFSET
, curve
[1].offset
,
644 CM_SHAPER_RAMA_EXP_REGION11_NUM_SEGMENTS
, curve
[1].segments_num
);
647 REG_SET_4(CM_SHAPER_RAMA_REGION_12_13
, 0,
648 CM_SHAPER_RAMA_EXP_REGION12_LUT_OFFSET
, curve
[0].offset
,
649 CM_SHAPER_RAMA_EXP_REGION12_NUM_SEGMENTS
, curve
[0].segments_num
,
650 CM_SHAPER_RAMA_EXP_REGION13_LUT_OFFSET
, curve
[1].offset
,
651 CM_SHAPER_RAMA_EXP_REGION13_NUM_SEGMENTS
, curve
[1].segments_num
);
654 REG_SET_4(CM_SHAPER_RAMA_REGION_14_15
, 0,
655 CM_SHAPER_RAMA_EXP_REGION14_LUT_OFFSET
, curve
[0].offset
,
656 CM_SHAPER_RAMA_EXP_REGION14_NUM_SEGMENTS
, curve
[0].segments_num
,
657 CM_SHAPER_RAMA_EXP_REGION15_LUT_OFFSET
, curve
[1].offset
,
658 CM_SHAPER_RAMA_EXP_REGION15_NUM_SEGMENTS
, curve
[1].segments_num
);
661 REG_SET_4(CM_SHAPER_RAMA_REGION_16_17
, 0,
662 CM_SHAPER_RAMA_EXP_REGION16_LUT_OFFSET
, curve
[0].offset
,
663 CM_SHAPER_RAMA_EXP_REGION16_NUM_SEGMENTS
, curve
[0].segments_num
,
664 CM_SHAPER_RAMA_EXP_REGION17_LUT_OFFSET
, curve
[1].offset
,
665 CM_SHAPER_RAMA_EXP_REGION17_NUM_SEGMENTS
, curve
[1].segments_num
);
668 REG_SET_4(CM_SHAPER_RAMA_REGION_18_19
, 0,
669 CM_SHAPER_RAMA_EXP_REGION18_LUT_OFFSET
, curve
[0].offset
,
670 CM_SHAPER_RAMA_EXP_REGION18_NUM_SEGMENTS
, curve
[0].segments_num
,
671 CM_SHAPER_RAMA_EXP_REGION19_LUT_OFFSET
, curve
[1].offset
,
672 CM_SHAPER_RAMA_EXP_REGION19_NUM_SEGMENTS
, curve
[1].segments_num
);
675 REG_SET_4(CM_SHAPER_RAMA_REGION_20_21
, 0,
676 CM_SHAPER_RAMA_EXP_REGION20_LUT_OFFSET
, curve
[0].offset
,
677 CM_SHAPER_RAMA_EXP_REGION20_NUM_SEGMENTS
, curve
[0].segments_num
,
678 CM_SHAPER_RAMA_EXP_REGION21_LUT_OFFSET
, curve
[1].offset
,
679 CM_SHAPER_RAMA_EXP_REGION21_NUM_SEGMENTS
, curve
[1].segments_num
);
682 REG_SET_4(CM_SHAPER_RAMA_REGION_22_23
, 0,
683 CM_SHAPER_RAMA_EXP_REGION22_LUT_OFFSET
, curve
[0].offset
,
684 CM_SHAPER_RAMA_EXP_REGION22_NUM_SEGMENTS
, curve
[0].segments_num
,
685 CM_SHAPER_RAMA_EXP_REGION23_LUT_OFFSET
, curve
[1].offset
,
686 CM_SHAPER_RAMA_EXP_REGION23_NUM_SEGMENTS
, curve
[1].segments_num
);
689 REG_SET_4(CM_SHAPER_RAMA_REGION_24_25
, 0,
690 CM_SHAPER_RAMA_EXP_REGION24_LUT_OFFSET
, curve
[0].offset
,
691 CM_SHAPER_RAMA_EXP_REGION24_NUM_SEGMENTS
, curve
[0].segments_num
,
692 CM_SHAPER_RAMA_EXP_REGION25_LUT_OFFSET
, curve
[1].offset
,
693 CM_SHAPER_RAMA_EXP_REGION25_NUM_SEGMENTS
, curve
[1].segments_num
);
696 REG_SET_4(CM_SHAPER_RAMA_REGION_26_27
, 0,
697 CM_SHAPER_RAMA_EXP_REGION26_LUT_OFFSET
, curve
[0].offset
,
698 CM_SHAPER_RAMA_EXP_REGION26_NUM_SEGMENTS
, curve
[0].segments_num
,
699 CM_SHAPER_RAMA_EXP_REGION27_LUT_OFFSET
, curve
[1].offset
,
700 CM_SHAPER_RAMA_EXP_REGION27_NUM_SEGMENTS
, curve
[1].segments_num
);
703 REG_SET_4(CM_SHAPER_RAMA_REGION_28_29
, 0,
704 CM_SHAPER_RAMA_EXP_REGION28_LUT_OFFSET
, curve
[0].offset
,
705 CM_SHAPER_RAMA_EXP_REGION28_NUM_SEGMENTS
, curve
[0].segments_num
,
706 CM_SHAPER_RAMA_EXP_REGION29_LUT_OFFSET
, curve
[1].offset
,
707 CM_SHAPER_RAMA_EXP_REGION29_NUM_SEGMENTS
, curve
[1].segments_num
);
710 REG_SET_4(CM_SHAPER_RAMA_REGION_30_31
, 0,
711 CM_SHAPER_RAMA_EXP_REGION30_LUT_OFFSET
, curve
[0].offset
,
712 CM_SHAPER_RAMA_EXP_REGION30_NUM_SEGMENTS
, curve
[0].segments_num
,
713 CM_SHAPER_RAMA_EXP_REGION31_LUT_OFFSET
, curve
[1].offset
,
714 CM_SHAPER_RAMA_EXP_REGION31_NUM_SEGMENTS
, curve
[1].segments_num
);
717 REG_SET_4(CM_SHAPER_RAMA_REGION_32_33
, 0,
718 CM_SHAPER_RAMA_EXP_REGION32_LUT_OFFSET
, curve
[0].offset
,
719 CM_SHAPER_RAMA_EXP_REGION32_NUM_SEGMENTS
, curve
[0].segments_num
,
720 CM_SHAPER_RAMA_EXP_REGION33_LUT_OFFSET
, curve
[1].offset
,
721 CM_SHAPER_RAMA_EXP_REGION33_NUM_SEGMENTS
, curve
[1].segments_num
);
724 /*program shaper RAM B*/
725 static void dpp20_program_shaper_lutb_settings(
726 struct dpp
*dpp_base
,
727 const struct pwl_params
*params
)
729 const struct gamma_curve
*curve
;
730 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
732 REG_SET_2(CM_SHAPER_RAMB_START_CNTL_B
, 0,
733 CM_SHAPER_RAMB_EXP_REGION_START_B
, params
->corner_points
[0].blue
.custom_float_x
,
734 CM_SHAPER_RAMB_EXP_REGION_START_SEGMENT_B
, 0);
735 REG_SET_2(CM_SHAPER_RAMB_START_CNTL_G
, 0,
736 CM_SHAPER_RAMB_EXP_REGION_START_G
, params
->corner_points
[0].green
.custom_float_x
,
737 CM_SHAPER_RAMB_EXP_REGION_START_SEGMENT_G
, 0);
738 REG_SET_2(CM_SHAPER_RAMB_START_CNTL_R
, 0,
739 CM_SHAPER_RAMB_EXP_REGION_START_R
, params
->corner_points
[0].red
.custom_float_x
,
740 CM_SHAPER_RAMB_EXP_REGION_START_SEGMENT_R
, 0);
742 REG_SET_2(CM_SHAPER_RAMB_END_CNTL_B
, 0,
743 CM_SHAPER_RAMB_EXP_REGION_END_B
, params
->corner_points
[1].blue
.custom_float_x
,
744 CM_SHAPER_RAMB_EXP_REGION_END_BASE_B
, params
->corner_points
[1].blue
.custom_float_y
);
746 REG_SET_2(CM_SHAPER_RAMB_END_CNTL_G
, 0,
747 CM_SHAPER_RAMB_EXP_REGION_END_G
, params
->corner_points
[1].green
.custom_float_x
,
748 CM_SHAPER_RAMB_EXP_REGION_END_BASE_G
, params
->corner_points
[1].green
.custom_float_y
);
750 REG_SET_2(CM_SHAPER_RAMB_END_CNTL_R
, 0,
751 CM_SHAPER_RAMB_EXP_REGION_END_R
, params
->corner_points
[1].red
.custom_float_x
,
752 CM_SHAPER_RAMB_EXP_REGION_END_BASE_R
, params
->corner_points
[1].red
.custom_float_y
);
754 curve
= params
->arr_curve_points
;
755 REG_SET_4(CM_SHAPER_RAMB_REGION_0_1
, 0,
756 CM_SHAPER_RAMB_EXP_REGION0_LUT_OFFSET
, curve
[0].offset
,
757 CM_SHAPER_RAMB_EXP_REGION0_NUM_SEGMENTS
, curve
[0].segments_num
,
758 CM_SHAPER_RAMB_EXP_REGION1_LUT_OFFSET
, curve
[1].offset
,
759 CM_SHAPER_RAMB_EXP_REGION1_NUM_SEGMENTS
, curve
[1].segments_num
);
762 REG_SET_4(CM_SHAPER_RAMB_REGION_2_3
, 0,
763 CM_SHAPER_RAMB_EXP_REGION2_LUT_OFFSET
, curve
[0].offset
,
764 CM_SHAPER_RAMB_EXP_REGION2_NUM_SEGMENTS
, curve
[0].segments_num
,
765 CM_SHAPER_RAMB_EXP_REGION3_LUT_OFFSET
, curve
[1].offset
,
766 CM_SHAPER_RAMB_EXP_REGION3_NUM_SEGMENTS
, curve
[1].segments_num
);
769 REG_SET_4(CM_SHAPER_RAMB_REGION_4_5
, 0,
770 CM_SHAPER_RAMB_EXP_REGION4_LUT_OFFSET
, curve
[0].offset
,
771 CM_SHAPER_RAMB_EXP_REGION4_NUM_SEGMENTS
, curve
[0].segments_num
,
772 CM_SHAPER_RAMB_EXP_REGION5_LUT_OFFSET
, curve
[1].offset
,
773 CM_SHAPER_RAMB_EXP_REGION5_NUM_SEGMENTS
, curve
[1].segments_num
);
776 REG_SET_4(CM_SHAPER_RAMB_REGION_6_7
, 0,
777 CM_SHAPER_RAMB_EXP_REGION6_LUT_OFFSET
, curve
[0].offset
,
778 CM_SHAPER_RAMB_EXP_REGION6_NUM_SEGMENTS
, curve
[0].segments_num
,
779 CM_SHAPER_RAMB_EXP_REGION7_LUT_OFFSET
, curve
[1].offset
,
780 CM_SHAPER_RAMB_EXP_REGION7_NUM_SEGMENTS
, curve
[1].segments_num
);
783 REG_SET_4(CM_SHAPER_RAMB_REGION_8_9
, 0,
784 CM_SHAPER_RAMB_EXP_REGION8_LUT_OFFSET
, curve
[0].offset
,
785 CM_SHAPER_RAMB_EXP_REGION8_NUM_SEGMENTS
, curve
[0].segments_num
,
786 CM_SHAPER_RAMB_EXP_REGION9_LUT_OFFSET
, curve
[1].offset
,
787 CM_SHAPER_RAMB_EXP_REGION9_NUM_SEGMENTS
, curve
[1].segments_num
);
790 REG_SET_4(CM_SHAPER_RAMB_REGION_10_11
, 0,
791 CM_SHAPER_RAMB_EXP_REGION10_LUT_OFFSET
, curve
[0].offset
,
792 CM_SHAPER_RAMB_EXP_REGION10_NUM_SEGMENTS
, curve
[0].segments_num
,
793 CM_SHAPER_RAMB_EXP_REGION11_LUT_OFFSET
, curve
[1].offset
,
794 CM_SHAPER_RAMB_EXP_REGION11_NUM_SEGMENTS
, curve
[1].segments_num
);
797 REG_SET_4(CM_SHAPER_RAMB_REGION_12_13
, 0,
798 CM_SHAPER_RAMB_EXP_REGION12_LUT_OFFSET
, curve
[0].offset
,
799 CM_SHAPER_RAMB_EXP_REGION12_NUM_SEGMENTS
, curve
[0].segments_num
,
800 CM_SHAPER_RAMB_EXP_REGION13_LUT_OFFSET
, curve
[1].offset
,
801 CM_SHAPER_RAMB_EXP_REGION13_NUM_SEGMENTS
, curve
[1].segments_num
);
804 REG_SET_4(CM_SHAPER_RAMB_REGION_14_15
, 0,
805 CM_SHAPER_RAMB_EXP_REGION14_LUT_OFFSET
, curve
[0].offset
,
806 CM_SHAPER_RAMB_EXP_REGION14_NUM_SEGMENTS
, curve
[0].segments_num
,
807 CM_SHAPER_RAMB_EXP_REGION15_LUT_OFFSET
, curve
[1].offset
,
808 CM_SHAPER_RAMB_EXP_REGION15_NUM_SEGMENTS
, curve
[1].segments_num
);
811 REG_SET_4(CM_SHAPER_RAMB_REGION_16_17
, 0,
812 CM_SHAPER_RAMB_EXP_REGION16_LUT_OFFSET
, curve
[0].offset
,
813 CM_SHAPER_RAMB_EXP_REGION16_NUM_SEGMENTS
, curve
[0].segments_num
,
814 CM_SHAPER_RAMB_EXP_REGION17_LUT_OFFSET
, curve
[1].offset
,
815 CM_SHAPER_RAMB_EXP_REGION17_NUM_SEGMENTS
, curve
[1].segments_num
);
818 REG_SET_4(CM_SHAPER_RAMB_REGION_18_19
, 0,
819 CM_SHAPER_RAMB_EXP_REGION18_LUT_OFFSET
, curve
[0].offset
,
820 CM_SHAPER_RAMB_EXP_REGION18_NUM_SEGMENTS
, curve
[0].segments_num
,
821 CM_SHAPER_RAMB_EXP_REGION19_LUT_OFFSET
, curve
[1].offset
,
822 CM_SHAPER_RAMB_EXP_REGION19_NUM_SEGMENTS
, curve
[1].segments_num
);
825 REG_SET_4(CM_SHAPER_RAMB_REGION_20_21
, 0,
826 CM_SHAPER_RAMB_EXP_REGION20_LUT_OFFSET
, curve
[0].offset
,
827 CM_SHAPER_RAMB_EXP_REGION20_NUM_SEGMENTS
, curve
[0].segments_num
,
828 CM_SHAPER_RAMB_EXP_REGION21_LUT_OFFSET
, curve
[1].offset
,
829 CM_SHAPER_RAMB_EXP_REGION21_NUM_SEGMENTS
, curve
[1].segments_num
);
832 REG_SET_4(CM_SHAPER_RAMB_REGION_22_23
, 0,
833 CM_SHAPER_RAMB_EXP_REGION22_LUT_OFFSET
, curve
[0].offset
,
834 CM_SHAPER_RAMB_EXP_REGION22_NUM_SEGMENTS
, curve
[0].segments_num
,
835 CM_SHAPER_RAMB_EXP_REGION23_LUT_OFFSET
, curve
[1].offset
,
836 CM_SHAPER_RAMB_EXP_REGION23_NUM_SEGMENTS
, curve
[1].segments_num
);
839 REG_SET_4(CM_SHAPER_RAMB_REGION_24_25
, 0,
840 CM_SHAPER_RAMB_EXP_REGION24_LUT_OFFSET
, curve
[0].offset
,
841 CM_SHAPER_RAMB_EXP_REGION24_NUM_SEGMENTS
, curve
[0].segments_num
,
842 CM_SHAPER_RAMB_EXP_REGION25_LUT_OFFSET
, curve
[1].offset
,
843 CM_SHAPER_RAMB_EXP_REGION25_NUM_SEGMENTS
, curve
[1].segments_num
);
846 REG_SET_4(CM_SHAPER_RAMB_REGION_26_27
, 0,
847 CM_SHAPER_RAMB_EXP_REGION26_LUT_OFFSET
, curve
[0].offset
,
848 CM_SHAPER_RAMB_EXP_REGION26_NUM_SEGMENTS
, curve
[0].segments_num
,
849 CM_SHAPER_RAMB_EXP_REGION27_LUT_OFFSET
, curve
[1].offset
,
850 CM_SHAPER_RAMB_EXP_REGION27_NUM_SEGMENTS
, curve
[1].segments_num
);
853 REG_SET_4(CM_SHAPER_RAMB_REGION_28_29
, 0,
854 CM_SHAPER_RAMB_EXP_REGION28_LUT_OFFSET
, curve
[0].offset
,
855 CM_SHAPER_RAMB_EXP_REGION28_NUM_SEGMENTS
, curve
[0].segments_num
,
856 CM_SHAPER_RAMB_EXP_REGION29_LUT_OFFSET
, curve
[1].offset
,
857 CM_SHAPER_RAMB_EXP_REGION29_NUM_SEGMENTS
, curve
[1].segments_num
);
860 REG_SET_4(CM_SHAPER_RAMB_REGION_30_31
, 0,
861 CM_SHAPER_RAMB_EXP_REGION30_LUT_OFFSET
, curve
[0].offset
,
862 CM_SHAPER_RAMB_EXP_REGION30_NUM_SEGMENTS
, curve
[0].segments_num
,
863 CM_SHAPER_RAMB_EXP_REGION31_LUT_OFFSET
, curve
[1].offset
,
864 CM_SHAPER_RAMB_EXP_REGION31_NUM_SEGMENTS
, curve
[1].segments_num
);
867 REG_SET_4(CM_SHAPER_RAMB_REGION_32_33
, 0,
868 CM_SHAPER_RAMB_EXP_REGION32_LUT_OFFSET
, curve
[0].offset
,
869 CM_SHAPER_RAMB_EXP_REGION32_NUM_SEGMENTS
, curve
[0].segments_num
,
870 CM_SHAPER_RAMB_EXP_REGION33_LUT_OFFSET
, curve
[1].offset
,
871 CM_SHAPER_RAMB_EXP_REGION33_NUM_SEGMENTS
, curve
[1].segments_num
);
876 bool dpp20_program_shaper(
877 struct dpp
*dpp_base
,
878 const struct pwl_params
*params
)
880 enum dc_lut_mode current_mode
;
881 enum dc_lut_mode next_mode
;
883 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
885 if (params
== NULL
) {
886 REG_SET(CM_SHAPER_CONTROL
, 0, CM_SHAPER_LUT_MODE
, 0);
889 current_mode
= dpp20_get_shaper_current(dpp_base
);
891 if (current_mode
== LUT_BYPASS
|| current_mode
== LUT_RAM_A
)
892 next_mode
= LUT_RAM_B
;
894 next_mode
= LUT_RAM_A
;
896 dpp20_configure_shaper_lut(dpp_base
, next_mode
== LUT_RAM_A
? true:false);
898 if (next_mode
== LUT_RAM_A
)
899 dpp20_program_shaper_luta_settings(dpp_base
, params
);
901 dpp20_program_shaper_lutb_settings(dpp_base
, params
);
903 dpp20_program_shaper_lut(
904 dpp_base
, params
->rgb_resulted
, params
->hw_points_num
);
906 REG_SET(CM_SHAPER_CONTROL
, 0, CM_SHAPER_LUT_MODE
, next_mode
== LUT_RAM_A
? 1:2);
912 static enum dc_lut_mode
get3dlut_config(
913 struct dpp
*dpp_base
,
915 bool *is_12bits_color_channel
)
917 uint32_t i_mode
, i_enable_10bits
, lut_size
;
918 enum dc_lut_mode mode
;
919 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
921 REG_GET_2(CM_3DLUT_READ_WRITE_CONTROL
,
922 CM_3DLUT_CONFIG_STATUS
, &i_mode
,
923 CM_3DLUT_30BIT_EN
, &i_enable_10bits
);
939 if (i_enable_10bits
> 0)
940 *is_12bits_color_channel
= false;
942 *is_12bits_color_channel
= true;
944 REG_GET(CM_3DLUT_MODE
, CM_3DLUT_SIZE
, &lut_size
);
949 *is_17x17x17
= false;
954 * select ramA or ramB, or bypass
955 * select color channel size 10 or 12 bits
956 * select 3dlut size 17x17x17 or 9x9x9
958 static void dpp20_set_3dlut_mode(
959 struct dpp
*dpp_base
,
960 enum dc_lut_mode mode
,
961 bool is_color_channel_12bits
,
962 bool is_lut_size17x17x17
)
965 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
967 if (mode
== LUT_BYPASS
)
969 else if (mode
== LUT_RAM_A
)
974 REG_UPDATE_2(CM_3DLUT_MODE
,
975 CM_3DLUT_MODE
, lut_mode
,
976 CM_3DLUT_SIZE
, is_lut_size17x17x17
== true ? 0 : 1);
979 static void dpp20_select_3dlut_ram(
980 struct dpp
*dpp_base
,
981 enum dc_lut_mode mode
,
982 bool is_color_channel_12bits
)
984 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
986 REG_UPDATE_2(CM_3DLUT_READ_WRITE_CONTROL
,
987 CM_3DLUT_RAM_SEL
, mode
== LUT_RAM_A
? 0 : 1,
989 is_color_channel_12bits
== true ? 0:1);
994 static void dpp20_set3dlut_ram12(
995 struct dpp
*dpp_base
,
996 const struct dc_rgb
*lut
,
999 uint32_t i
, red
, green
, blue
, red1
, green1
, blue1
;
1000 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
1002 for (i
= 0 ; i
< entries
; i
+= 2) {
1003 red
= lut
[i
].red
<<4;
1004 green
= lut
[i
].green
<<4;
1005 blue
= lut
[i
].blue
<<4;
1006 red1
= lut
[i
+1].red
<<4;
1007 green1
= lut
[i
+1].green
<<4;
1008 blue1
= lut
[i
+1].blue
<<4;
1010 REG_SET_2(CM_3DLUT_DATA
, 0,
1011 CM_3DLUT_DATA0
, red
,
1012 CM_3DLUT_DATA1
, red1
);
1014 REG_SET_2(CM_3DLUT_DATA
, 0,
1015 CM_3DLUT_DATA0
, green
,
1016 CM_3DLUT_DATA1
, green1
);
1018 REG_SET_2(CM_3DLUT_DATA
, 0,
1019 CM_3DLUT_DATA0
, blue
,
1020 CM_3DLUT_DATA1
, blue1
);
1026 * load selected lut with 10 bits color channels
1028 static void dpp20_set3dlut_ram10(
1029 struct dpp
*dpp_base
,
1030 const struct dc_rgb
*lut
,
1033 uint32_t i
, red
, green
, blue
, value
;
1034 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
1036 for (i
= 0; i
< entries
; i
++) {
1038 green
= lut
[i
].green
;
1041 value
= (red
<<20) | (green
<<10) | blue
;
1043 REG_SET(CM_3DLUT_DATA_30BIT
, 0, CM_3DLUT_DATA_30BIT
, value
);
1049 static void dpp20_select_3dlut_ram_mask(
1050 struct dpp
*dpp_base
,
1051 uint32_t ram_selection_mask
)
1053 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
1055 REG_UPDATE(CM_3DLUT_READ_WRITE_CONTROL
, CM_3DLUT_WRITE_EN_MASK
,
1056 ram_selection_mask
);
1057 REG_SET(CM_3DLUT_INDEX
, 0, CM_3DLUT_INDEX
, 0);
1060 bool dpp20_program_3dlut(
1061 struct dpp
*dpp_base
,
1062 struct tetrahedral_params
*params
)
1064 enum dc_lut_mode mode
;
1066 bool is_12bits_color_channel
;
1067 struct dc_rgb
*lut0
;
1068 struct dc_rgb
*lut1
;
1069 struct dc_rgb
*lut2
;
1070 struct dc_rgb
*lut3
;
1074 if (params
== NULL
) {
1075 dpp20_set_3dlut_mode(dpp_base
, LUT_BYPASS
, false, false);
1078 mode
= get3dlut_config(dpp_base
, &is_17x17x17
, &is_12bits_color_channel
);
1080 if (mode
== LUT_BYPASS
|| mode
== LUT_RAM_B
)
1085 is_17x17x17
= !params
->use_tetrahedral_9
;
1086 is_12bits_color_channel
= params
->use_12bits
;
1088 lut0
= params
->tetrahedral_17
.lut0
;
1089 lut1
= params
->tetrahedral_17
.lut1
;
1090 lut2
= params
->tetrahedral_17
.lut2
;
1091 lut3
= params
->tetrahedral_17
.lut3
;
1092 lut_size0
= sizeof(params
->tetrahedral_17
.lut0
)/
1093 sizeof(params
->tetrahedral_17
.lut0
[0]);
1094 lut_size
= sizeof(params
->tetrahedral_17
.lut1
)/
1095 sizeof(params
->tetrahedral_17
.lut1
[0]);
1097 lut0
= params
->tetrahedral_9
.lut0
;
1098 lut1
= params
->tetrahedral_9
.lut1
;
1099 lut2
= params
->tetrahedral_9
.lut2
;
1100 lut3
= params
->tetrahedral_9
.lut3
;
1101 lut_size0
= sizeof(params
->tetrahedral_9
.lut0
)/
1102 sizeof(params
->tetrahedral_9
.lut0
[0]);
1103 lut_size
= sizeof(params
->tetrahedral_9
.lut1
)/
1104 sizeof(params
->tetrahedral_9
.lut1
[0]);
1107 dpp20_select_3dlut_ram(dpp_base
, mode
,
1108 is_12bits_color_channel
);
1109 dpp20_select_3dlut_ram_mask(dpp_base
, 0x1);
1110 if (is_12bits_color_channel
)
1111 dpp20_set3dlut_ram12(dpp_base
, lut0
, lut_size0
);
1113 dpp20_set3dlut_ram10(dpp_base
, lut0
, lut_size0
);
1115 dpp20_select_3dlut_ram_mask(dpp_base
, 0x2);
1116 if (is_12bits_color_channel
)
1117 dpp20_set3dlut_ram12(dpp_base
, lut1
, lut_size
);
1119 dpp20_set3dlut_ram10(dpp_base
, lut1
, lut_size
);
1121 dpp20_select_3dlut_ram_mask(dpp_base
, 0x4);
1122 if (is_12bits_color_channel
)
1123 dpp20_set3dlut_ram12(dpp_base
, lut2
, lut_size
);
1125 dpp20_set3dlut_ram10(dpp_base
, lut2
, lut_size
);
1127 dpp20_select_3dlut_ram_mask(dpp_base
, 0x8);
1128 if (is_12bits_color_channel
)
1129 dpp20_set3dlut_ram12(dpp_base
, lut3
, lut_size
);
1131 dpp20_set3dlut_ram10(dpp_base
, lut3
, lut_size
);
1134 dpp20_set_3dlut_mode(dpp_base
, mode
, is_12bits_color_channel
,
1140 void dpp2_set_hdr_multiplier(
1141 struct dpp
*dpp_base
,
1142 uint32_t multiplier
)
1144 struct dcn20_dpp
*dpp
= TO_DCN20_DPP(dpp_base
);
1146 REG_UPDATE(CM_HDR_MULT_COEF
, CM_HDR_MULT_COEF
, multiplier
);