Skip to content

Commit 27fc10d

Browse files
Harry Wentlandalexdeucher
authored andcommitted
drm/amd/display: Fix the delta clamping for shaper LUT
The shaper LUT requires a 10-bit value of the delta between segments. We were using dc_fixpt_clamp_u0d10() to do that but it doesn't do what we want it to do. It will preserve 10-bit precision after the decimal point, but that's not quite what we want. We want 14-bit precision and discard the 4 most-significant bytes. To do that we'll do dc_fixpt_clamp_u0d14() & 0x3ff instead. Tested-by: Daniel Wheeler <[email protected]> Reviewed-by: Krunoslav Kovac <[email protected]> Acked-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Harry Wentland <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent a28eb48 commit 27fc10d

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ bool cm_helper_convert_to_custom_float(
308308
#define NUMBER_REGIONS 32
309309
#define NUMBER_SW_SEGMENTS 16
310310

311-
bool cm_helper_translate_curve_to_hw_format(
311+
#define DC_LOGGER \
312+
ctx->logger
313+
314+
bool cm_helper_translate_curve_to_hw_format(struct dc_context *ctx,
312315
const struct dc_transfer_func *output_tf,
313316
struct pwl_params *lut_params, bool fixpoint)
314317
{
@@ -482,10 +485,18 @@ bool cm_helper_translate_curve_to_hw_format(
482485
rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
483486
rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue);
484487

488+
485489
if (fixpoint == true) {
486-
rgb->delta_red_reg = dc_fixpt_clamp_u0d10(rgb->delta_red);
487-
rgb->delta_green_reg = dc_fixpt_clamp_u0d10(rgb->delta_green);
488-
rgb->delta_blue_reg = dc_fixpt_clamp_u0d10(rgb->delta_blue);
490+
uint32_t red_clamp = dc_fixpt_clamp_u0d14(rgb->delta_red);
491+
uint32_t green_clamp = dc_fixpt_clamp_u0d14(rgb->delta_green);
492+
uint32_t blue_clamp = dc_fixpt_clamp_u0d14(rgb->delta_blue);
493+
494+
if (red_clamp >> 10 || green_clamp >> 10 || blue_clamp >> 10)
495+
DC_LOG_WARNING("Losing delta precision while programming shaper LUT.");
496+
497+
rgb->delta_red_reg = red_clamp & 0x3ff;
498+
rgb->delta_green_reg = green_clamp & 0x3ff;
499+
rgb->delta_blue_reg = blue_clamp & 0x3ff;
489500
rgb->red_reg = dc_fixpt_clamp_u0d14(rgb->red);
490501
rgb->green_reg = dc_fixpt_clamp_u0d14(rgb->green);
491502
rgb->blue_reg = dc_fixpt_clamp_u0d14(rgb->blue);

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ bool cm_helper_convert_to_custom_float(
106106
bool fixpoint);
107107

108108
bool cm_helper_translate_curve_to_hw_format(
109+
struct dc_context *ctx,
109110
const struct dc_transfer_func *output_tf,
110111
struct pwl_params *lut_params, bool fixpoint);
111112

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ bool dcn10_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx,
18431843
/* dcn10_translate_regamma_to_hw_format takes 750us, only do it when full
18441844
* update.
18451845
*/
1846-
else if (cm_helper_translate_curve_to_hw_format(
1846+
else if (cm_helper_translate_curve_to_hw_format(dc->ctx,
18471847
stream->out_transfer_func,
18481848
&dpp->regamma_params, false)) {
18491849
dpp->funcs->dpp_program_regamma_pwl(

drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ bool dcn20_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx,
867867
params = &stream->out_transfer_func->pwl;
868868
else if (pipe_ctx->stream->out_transfer_func->type ==
869869
TF_TYPE_DISTRIBUTED_POINTS &&
870-
cm_helper_translate_curve_to_hw_format(
870+
cm_helper_translate_curve_to_hw_format(dc->ctx,
871871
stream->out_transfer_func,
872872
&mpc->blender_params, false))
873873
params = &mpc->blender_params;
@@ -896,7 +896,7 @@ bool dcn20_set_blend_lut(
896896
if (plane_state->blend_tf->type == TF_TYPE_HWPWL)
897897
blend_lut = &plane_state->blend_tf->pwl;
898898
else if (plane_state->blend_tf->type == TF_TYPE_DISTRIBUTED_POINTS) {
899-
cm_helper_translate_curve_to_hw_format(
899+
cm_helper_translate_curve_to_hw_format(plane_state->ctx,
900900
plane_state->blend_tf,
901901
&dpp_base->regamma_params, false);
902902
blend_lut = &dpp_base->regamma_params;
@@ -918,7 +918,7 @@ bool dcn20_set_shaper_3dlut(
918918
if (plane_state->in_shaper_func->type == TF_TYPE_HWPWL)
919919
shaper_lut = &plane_state->in_shaper_func->pwl;
920920
else if (plane_state->in_shaper_func->type == TF_TYPE_DISTRIBUTED_POINTS) {
921-
cm_helper_translate_curve_to_hw_format(
921+
cm_helper_translate_curve_to_hw_format(plane_state->ctx,
922922
plane_state->in_shaper_func,
923923
&dpp_base->shaper_params, true);
924924
shaper_lut = &dpp_base->shaper_params;

drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ bool dwb3_ogam_set_input_transfer_func(
280280
dwb_ogam_lut = kzalloc(sizeof(*dwb_ogam_lut), GFP_KERNEL);
281281

282282
if (dwb_ogam_lut) {
283-
cm_helper_translate_curve_to_hw_format(
283+
cm_helper_translate_curve_to_hw_format(dwbc->ctx,
284284
in_transfer_func_dwb_ogam,
285285
dwb_ogam_lut, false);
286286

drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static bool dcn30_set_mpc_shaper_3dlut(struct pipe_ctx *pipe_ctx,
106106
if (stream->func_shaper->type == TF_TYPE_HWPWL) {
107107
shaper_lut = &stream->func_shaper->pwl;
108108
} else if (stream->func_shaper->type == TF_TYPE_DISTRIBUTED_POINTS) {
109-
cm_helper_translate_curve_to_hw_format(stream->func_shaper,
109+
cm_helper_translate_curve_to_hw_format(stream->ctx, stream->func_shaper,
110110
&dpp_base->shaper_params, true);
111111
shaper_lut = &dpp_base->shaper_params;
112112
}

drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ bool dcn32_set_mpc_shaper_3dlut(
448448
if (stream->func_shaper->type == TF_TYPE_HWPWL)
449449
shaper_lut = &stream->func_shaper->pwl;
450450
else if (stream->func_shaper->type == TF_TYPE_DISTRIBUTED_POINTS) {
451-
cm_helper_translate_curve_to_hw_format(
451+
cm_helper_translate_curve_to_hw_format(stream->ctx,
452452
stream->func_shaper,
453453
&dpp_base->shaper_params, true);
454454
shaper_lut = &dpp_base->shaper_params;
@@ -484,7 +484,7 @@ bool dcn32_set_mcm_luts(
484484
if (plane_state->blend_tf->type == TF_TYPE_HWPWL)
485485
lut_params = &plane_state->blend_tf->pwl;
486486
else if (plane_state->blend_tf->type == TF_TYPE_DISTRIBUTED_POINTS) {
487-
cm_helper_translate_curve_to_hw_format(
487+
cm_helper_translate_curve_to_hw_format(plane_state->ctx,
488488
plane_state->blend_tf,
489489
&dpp_base->regamma_params, false);
490490
lut_params = &dpp_base->regamma_params;
@@ -499,7 +499,7 @@ bool dcn32_set_mcm_luts(
499499
else if (plane_state->in_shaper_func->type == TF_TYPE_DISTRIBUTED_POINTS) {
500500
// TODO: dpp_base replace
501501
ASSERT(false);
502-
cm_helper_translate_curve_to_hw_format(
502+
cm_helper_translate_curve_to_hw_format(plane_state->ctx,
503503
plane_state->in_shaper_func,
504504
&dpp_base->shaper_params, true);
505505
lut_params = &dpp_base->shaper_params;

0 commit comments

Comments
 (0)