Commit d25b32aa authored by Melissa Wen's avatar Melissa Wen Committed by Alex Deucher
Browse files

drm/amd/display: extend delta clamping logic to CM3 LUT helper



Commit 27fc10d1 ("drm/amd/display: Fix the delta clamping for shaper
LUT") fixed banding when using plane shaper LUT in DCN10 CM helper.  The
problem is also present in DCN30 CM helper, fix banding by extending the
same bug delta clamping fix to CM3.

Signed-off-by: default avatarMelissa Wen <mwen@igalia.com>
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 0274a548)
parent 8f959d37
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -105,7 +105,10 @@ void cm_helper_program_gamcor_xfer_func(
#define NUMBER_REGIONS     32
#define NUMBER_SW_SEGMENTS 16

bool cm3_helper_translate_curve_to_hw_format(
#define DC_LOGGER \
		ctx->logger

bool cm3_helper_translate_curve_to_hw_format(struct dc_context *ctx,
					     const struct dc_transfer_func *output_tf,
					     struct pwl_params *lut_params, bool fixpoint)
{
@@ -251,6 +254,10 @@ bool cm3_helper_translate_curve_to_hw_format(
	if (fixpoint == true) {
		i = 1;
		while (i != hw_points + 2) {
			uint32_t red_clamp;
			uint32_t green_clamp;
			uint32_t blue_clamp;

			if (i >= hw_points) {
				if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
					rgb_plus_1->red = dc_fixpt_add(rgb->red,
@@ -263,9 +270,20 @@ bool cm3_helper_translate_curve_to_hw_format(
							rgb_minus_1->delta_blue);
			}

			rgb->delta_red_reg   = dc_fixpt_clamp_u0d10(rgb->delta_red);
			rgb->delta_green_reg = dc_fixpt_clamp_u0d10(rgb->delta_green);
			rgb->delta_blue_reg  = dc_fixpt_clamp_u0d10(rgb->delta_blue);
			rgb->delta_red   = dc_fixpt_sub(rgb_plus_1->red,   rgb->red);
			rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
			rgb->delta_blue  = dc_fixpt_sub(rgb_plus_1->blue,  rgb->blue);

			red_clamp = dc_fixpt_clamp_u0d14(rgb->delta_red);
			green_clamp = dc_fixpt_clamp_u0d14(rgb->delta_green);
			blue_clamp = dc_fixpt_clamp_u0d14(rgb->delta_blue);

			if (red_clamp >> 10 || green_clamp >> 10 || blue_clamp >> 10)
				DC_LOG_ERROR("Losing delta precision while programming shaper LUT.");

			rgb->delta_red_reg   = red_clamp & 0x3ff;
			rgb->delta_green_reg = green_clamp & 0x3ff;
			rgb->delta_blue_reg  = blue_clamp & 0x3ff;
			rgb->red_reg         = dc_fixpt_clamp_u0d14(rgb->red);
			rgb->green_reg       = dc_fixpt_clamp_u0d14(rgb->green);
			rgb->blue_reg        = dc_fixpt_clamp_u0d14(rgb->blue);
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ void cm_helper_program_gamcor_xfer_func(
	const struct pwl_params *params,
	const struct dcn3_xfer_func_reg *reg);

bool cm3_helper_translate_curve_to_hw_format(
bool cm3_helper_translate_curve_to_hw_format(struct dc_context *ctx,
	const struct dc_transfer_func *output_tf,
	struct pwl_params *lut_params, bool fixpoint);

+5 −4
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ bool dcn30_set_blend_lut(
	if (plane_state->blend_tf.type == TF_TYPE_HWPWL)
		blend_lut = &plane_state->blend_tf.pwl;
	else if (plane_state->blend_tf.type == TF_TYPE_DISTRIBUTED_POINTS) {
		result = cm3_helper_translate_curve_to_hw_format(
		result = cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
				&plane_state->blend_tf, &dpp_base->regamma_params, false);
		if (!result)
			return result;
@@ -334,7 +334,8 @@ bool dcn30_set_input_transfer_func(struct dc *dc,
	if (plane_state->in_transfer_func.type == TF_TYPE_HWPWL)
		params = &plane_state->in_transfer_func.pwl;
	else if (plane_state->in_transfer_func.type == TF_TYPE_DISTRIBUTED_POINTS &&
		cm3_helper_translate_curve_to_hw_format(&plane_state->in_transfer_func,
		cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
							&plane_state->in_transfer_func,
							&dpp_base->degamma_params, false))
		params = &dpp_base->degamma_params;

@@ -406,7 +407,7 @@ bool dcn30_set_output_transfer_func(struct dc *dc,
				params = &stream->out_transfer_func.pwl;
			else if (pipe_ctx->stream->out_transfer_func.type ==
					TF_TYPE_DISTRIBUTED_POINTS &&
					cm3_helper_translate_curve_to_hw_format(
					cm3_helper_translate_curve_to_hw_format(stream->ctx,
					&stream->out_transfer_func,
					&mpc->blender_params, false))
				params = &mpc->blender_params;
+10 −7
Original line number Diff line number Diff line
@@ -486,7 +486,8 @@ bool dcn32_set_mcm_luts(
	if (plane_state->blend_tf.type == TF_TYPE_HWPWL)
		lut_params = &plane_state->blend_tf.pwl;
	else if (plane_state->blend_tf.type == TF_TYPE_DISTRIBUTED_POINTS) {
		result = cm3_helper_translate_curve_to_hw_format(&plane_state->blend_tf,
		result = cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
								 &plane_state->blend_tf,
								 &dpp_base->regamma_params, false);
		if (!result)
			return result;
@@ -502,7 +503,8 @@ bool dcn32_set_mcm_luts(
	else if (plane_state->in_shaper_func.type == TF_TYPE_DISTRIBUTED_POINTS) {
		// TODO: dpp_base replace
		ASSERT(false);
		cm3_helper_translate_curve_to_hw_format(&plane_state->in_shaper_func,
		cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
							&plane_state->in_shaper_func,
							&dpp_base->shaper_params, true);
		lut_params = &dpp_base->shaper_params;
	}
@@ -543,7 +545,8 @@ bool dcn32_set_input_transfer_func(struct dc *dc,
	if (plane_state->in_transfer_func.type == TF_TYPE_HWPWL)
		params = &plane_state->in_transfer_func.pwl;
	else if (plane_state->in_transfer_func.type == TF_TYPE_DISTRIBUTED_POINTS &&
		cm3_helper_translate_curve_to_hw_format(&plane_state->in_transfer_func,
		cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
							&plane_state->in_transfer_func,
							&dpp_base->degamma_params, false))
		params = &dpp_base->degamma_params;

@@ -575,7 +578,7 @@ bool dcn32_set_output_transfer_func(struct dc *dc,
				params = &stream->out_transfer_func.pwl;
			else if (pipe_ctx->stream->out_transfer_func.type ==
					TF_TYPE_DISTRIBUTED_POINTS &&
					cm3_helper_translate_curve_to_hw_format(
					cm3_helper_translate_curve_to_hw_format(stream->ctx,
					&stream->out_transfer_func,
					&mpc->blender_params, false))
				params = &mpc->blender_params;
+9 −7
Original line number Diff line number Diff line
@@ -430,7 +430,7 @@ void dcn401_populate_mcm_luts(struct dc *dc,
		if (mcm_luts.lut1d_func->type == TF_TYPE_HWPWL)
			m_lut_params.pwl = &mcm_luts.lut1d_func->pwl;
		else if (mcm_luts.lut1d_func->type == TF_TYPE_DISTRIBUTED_POINTS) {
			rval = cm3_helper_translate_curve_to_hw_format(
			rval = cm3_helper_translate_curve_to_hw_format(mpc->ctx,
					mcm_luts.lut1d_func,
					&dpp_base->regamma_params, false);
			m_lut_params.pwl = rval ? &dpp_base->regamma_params : NULL;
@@ -450,7 +450,7 @@ void dcn401_populate_mcm_luts(struct dc *dc,
			m_lut_params.pwl = &mcm_luts.shaper->pwl;
		else if (mcm_luts.shaper->type == TF_TYPE_DISTRIBUTED_POINTS) {
			ASSERT(false);
			rval = cm3_helper_translate_curve_to_hw_format(
			rval = cm3_helper_translate_curve_to_hw_format(mpc->ctx,
					mcm_luts.shaper,
					&dpp_base->regamma_params, true);
			m_lut_params.pwl = rval ? &dpp_base->regamma_params : NULL;
@@ -627,7 +627,8 @@ bool dcn401_set_mcm_luts(struct pipe_ctx *pipe_ctx,
	if (plane_state->blend_tf.type == TF_TYPE_HWPWL)
		lut_params = &plane_state->blend_tf.pwl;
	else if (plane_state->blend_tf.type == TF_TYPE_DISTRIBUTED_POINTS) {
		rval = cm3_helper_translate_curve_to_hw_format(&plane_state->blend_tf,
		rval = cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
							       &plane_state->blend_tf,
							       &dpp_base->regamma_params, false);
		lut_params = rval ? &dpp_base->regamma_params : NULL;
	}
@@ -639,7 +640,8 @@ bool dcn401_set_mcm_luts(struct pipe_ctx *pipe_ctx,
		lut_params = &plane_state->in_shaper_func.pwl;
	else if (plane_state->in_shaper_func.type == TF_TYPE_DISTRIBUTED_POINTS) {
		// TODO: dpp_base replace
		rval = cm3_helper_translate_curve_to_hw_format(&plane_state->in_shaper_func,
		rval = cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
							       &plane_state->in_shaper_func,
							       &dpp_base->shaper_params, true);
		lut_params = rval ? &dpp_base->shaper_params : NULL;
	}
@@ -674,7 +676,7 @@ bool dcn401_set_output_transfer_func(struct dc *dc,
				params = &stream->out_transfer_func.pwl;
			else if (pipe_ctx->stream->out_transfer_func.type ==
					TF_TYPE_DISTRIBUTED_POINTS &&
					cm3_helper_translate_curve_to_hw_format(
					cm3_helper_translate_curve_to_hw_format(stream->ctx,
					&stream->out_transfer_func,
					&mpc->blender_params, false))
				params = &mpc->blender_params;