Skip to contentSkip to conversation

drm/amd/display: follow-up fixes for LUT segmentation

PATCH Superseded Melissa Wen 2 participants 7 messages Aug 19 – Aug 20

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover drm/amd/display: follow-up fixes for LUT segmentation

Extend halving distribution for all curves/custom-LUT in a encode-to-linear operation, not only PQ/SRGB. This fixes failures in IGT kms_colorop test after [1]. Also use the CM3 degamma helper that translates curves to hw points for DCN30-based family, not only DCN32, since the banding issue is present on both.

[1] https://lore.kernel.org/amd-gfx/[email protected]/

Melissa

Melissa Wen (2):
drm/amd/display: use halving distribution for all encode-to-linear
curves
drm/amd/display: use translate_curve_to_degamma_hw_format on DCN30

 .../amd/display/dc/dcn30/dcn30_cm_common.c    | 34 ++++++-------------
 .../amd/display/dc/hwss/dcn30/dcn30_hwseq.c   | 10 +++---
 2 files changed, 14 insertions(+), 30 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/2 drm/amd/display: use halving distribution for all encode-to-linear curves

In encode-to-linear conversions, LUT entries should be uniformly distributed across the input range: non-linear encodings are already approximately perceptually uniform, so every input code carries the same weight. A fixed count per region does the opposite, concentrating entries on the darker values and leaving few for the bright end, whereas halving distribution spaces all 256 entries uniformly. This holds for any encoded input, so remove the PQ/sRGB condition from de17c6bb7072 and apply halving to all encode-to-linear operations (pre-defined TF or user LUTs).

It fixes the following IGT kms_colorop subtests:
- plane-XR30-XR30-srgb_inv_eotf_lut-srgb_eotf_lut
- plane-XR30-XR30-gamma_2_2-gamma_2_2_inv-gamma_2_2

Fixes de17c6bb7072 ("drm/amd/display: use halving distribution for PQ/sRGB linearizing LUT")
---
 .../amd/display/dc/dcn30/dcn30_cm_common.c    | 34 ++++++-------------
 1 file changed, 10 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c +10 -24
index 66fe7f313ea3..62ca235cd649 100644
@@ -320,6 +320,8 @@ static struct fixed31_32 interp_tf_pts(const struct fixed31_32 *output_tf_channe
 	return value;
 }
 
+#define NUM_DEGAMMA_REGIONS    9
+
 bool cm3_helper_translate_curve_to_degamma_hw_format(
 				const struct dc_transfer_func *output_tf,
 				struct pwl_params *lut_params)
@@ -343,31 +345,15 @@ bool cm3_helper_translate_curve_to_degamma_hw_format(
 	memset(lut_params, 0, sizeof(struct pwl_params));
 	memset(seg_distr, 0, sizeof(seg_distr));
 
-	if (output_tf->tf == TRANSFER_FUNCTION_PQ ||
-	    output_tf->tf == TRANSFER_FUNCTION_SRGB) {
-		/* 9 segments
-		 * segments are from 2^-9 to 0
-		 */
-		const uint8_t SEG_COUNT = 9;
-		seg_distr[0] = 0; // Since we only have one point in darkest region
-		for (k = 1; k < SEG_COUNT; k++)
-			seg_distr[k] = k - 1; // 2^(k-1) points per region; halves as k decreases
+	/* 9 segments
+	 * segments are from 2^-9 to 2^0
+	 */
+	seg_distr[0] = 0; // Since we only have one point in darkest region
+	for (k = 1; k < NUM_DEGAMMA_REGIONS; k++)
+		seg_distr[k] = k - 1; // 2^(k-1) points per region; halves as k decreases
 
-		region_start = -SEG_COUNT;
-		region_end = 0;
-	} else {
-		/* 12 segments
-		 * segments are from 2^-12 to 2^0
-		 * There are less than 256 points, for optimization
-		 */
-		const uint8_t SEG_COUNT = 12;
-
-		for (i = 0; i < SEG_COUNT; i++)
-			seg_distr[i] = 4;
-
-		region_start = -SEG_COUNT;
-		region_end = 0;
-	}
+	region_start = -NUM_DEGAMMA_REGIONS;
+	region_end = 0;
 
 	for (i = region_end - region_start; i < MAX_REGIONS_NUMBER ; i++)
 		seg_distr[i] = -1;
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 1/2] drm/amd/display: use halving distribution for all encode-to-linear curves

checkpatch reports the following error and warning. Are they intentional?

ERROR: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit de17c6bb7072 ("drm/amd/display: use halving distribution for PQ/sRGB linearizing LUT")' #13:
any encoded input, so remove the PQ/sRGB condition from de17c6bb7072 and

WARNING: Possible repeated word: 'segments'
#67: FILE: drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c:349:
+ /* 9 segments
+ * segments are from 2^-9 to 2^0

total: 1 errors, 1 warnings, 47 lines checked

Quoted 73 lines · Melissa Wen

In encode-to-linear conversions, LUT entries should be uniformly
distributed across the input range: non-linear encodings are already
approximately perceptually uniform, so every input code carries the same
weight. A fixed count per region does the opposite, concentrating
entries on the darker values and leaving few for the bright end, whereas
halving distribution spaces all 256 entries uniformly. This holds for
any encoded input, so remove the PQ/sRGB condition from de17c6bb7072 and> apply halving to all encode-to-linear operations (pre-defined TF or user LUTs).

It fixes the following IGT kms_colorop subtests:
- plane-XR30-XR30-srgb_inv_eotf_lut-srgb_eotf_lut
- plane-XR30-XR30-gamma_2_2-gamma_2_2_inv-gamma_2_2

Fixes de17c6bb7072 ("drm/amd/display: use halving distribution for PQ/sRGB linearizing LUT")
---
  .../amd/display/dc/dcn30/dcn30_cm_common.c    | 34 ++++++-------------
  1 file changed, 10 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c +10 -24
index 66fe7f313ea3..62ca235cd649 100644
@@ -320,6 +320,8 @@ static struct fixed31_32 interp_tf_pts(const struct fixed31_32 *output_tf_channe
  	return value;
  }
 
+#define NUM_DEGAMMA_REGIONS    9
+
  bool cm3_helper_translate_curve_to_degamma_hw_format(
  				const struct dc_transfer_func *output_tf,
  				struct pwl_params *lut_params)
@@ -343,31 +345,15 @@ bool cm3_helper_translate_curve_to_degamma_hw_format(
  	memset(lut_params, 0, sizeof(struct pwl_params));
  	memset(seg_distr, 0, sizeof(seg_distr));
 
-	if (output_tf->tf == TRANSFER_FUNCTION_PQ ||
-	    output_tf->tf == TRANSFER_FUNCTION_SRGB) {
-		/* 9 segments
-		 * segments are from 2^-9 to 0
-		 */
-		const uint8_t SEG_COUNT = 9;
-		seg_distr[0] = 0; // Since we only have one point in darkest region
-		for (k = 1; k < SEG_COUNT; k++)
-			seg_distr[k] = k - 1; // 2^(k-1) points per region; halves as k decreases
+	/* 9 segments
+	 * segments are from 2^-9 to 2^0
+	 */
+	seg_distr[0] = 0; // Since we only have one point in darkest region
+	for (k = 1; k < NUM_DEGAMMA_REGIONS; k++)
+		seg_distr[k] = k - 1; // 2^(k-1) points per region; halves as k decreases
 
-		region_start = -SEG_COUNT;
-		region_end = 0;
-	} else {
-		/* 12 segments
-		 * segments are from 2^-12 to 2^0
-		 * There are less than 256 points, for optimization
-		 */
-		const uint8_t SEG_COUNT = 12;
-
-		for (i = 0; i < SEG_COUNT; i++)
-			seg_distr[i] = 4;
-
-		region_start = -SEG_COUNT;
-		region_end = 0;
-	}
+	region_start = -NUM_DEGAMMA_REGIONS;
+	region_end = 0;
 
  	for (i = region_end - region_start; i < MAX_REGIONS_NUMBER ; i++)
  		seg_distr[i] = -1;
#3 lore raw

PATCH 2/2 drm/amd/display: use translate_curve_to_degamma_hw_format on DCN30

In reply to Melissa Wen

DCN3.01 presents the same banding issue as reported in the link below, but the previous fix doesn't cover this hw. Change the helper for degamma/blend curves for DCN30-based family.

Fixes 3719314af322 ("drm/amd/display: use a separate helper to translate degamma curves")
---
 .../gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c    | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c +4 -6
index cb163902e12e..6980f622db0a 100644
@@ -243,10 +243,9 @@ bool dcn30_set_blend_lut(
 	if (plane_state->cm.blend_func.type == TF_TYPE_HWPWL)
 		blend_lut = &plane_state->cm.blend_func.pwl;
 	else if (plane_state->cm.blend_func.type == TF_TYPE_DISTRIBUTED_POINTS) {
-		result = cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
+		result = cm3_helper_translate_curve_to_degamma_hw_format(
 				&plane_state->cm.blend_func,
-				&dpp_base->regamma_params,
-				false);
+				&dpp_base->regamma_params);
 		if (!result)
 			return result;
 
@@ -337,9 +336,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->ctx,
-							&plane_state->in_transfer_func,
-							&dpp_base->degamma_params, false))
+		cm3_helper_translate_curve_to_degamma_hw_format(&plane_state->in_transfer_func,
+								&dpp_base->degamma_params))
 		params = &dpp_base->degamma_params;
 
 	result = dpp_base->funcs->dpp_program_gamcor_lut(dpp_base, params);
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH 2/2] drm/amd/display: use translate_curve_to_degamma_hw_format on DCN30

Quoted 1 line · Melissa Wen

DCN3.01 presents the same banding issue as reported in the link below,

This affects more than just DCN301 as below:

drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_init.c: .set_blend_lut = dcn30_set_blend_lut, drivers/gpu/drm/amd/display/dc/hwss/dcn301/dcn301_init.c: .set_blend_lut = dcn30_set_blend_lut, drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_init.c: .set_blend_lut = dcn30_set_blend_lut, drivers/gpu/drm/amd/display/dc/hwss/dcn314/dcn314_init.c: .set_blend_lut = dcn30_set_blend_lut,

Quoted 39 lines

but the previous fix doesn't cover this hw. Change the helper for degamma/blend curves for DCN30-based family.

Fixes 3719314af322 ("drm/amd/display: use a separate helper to translate degamma curves")
---
  .../gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c    | 10 ++++------
  1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c +4 -6
index cb163902e12e..6980f622db0a 100644
@@ -243,10 +243,9 @@ bool dcn30_set_blend_lut(
  	if (plane_state->cm.blend_func.type == TF_TYPE_HWPWL)
  		blend_lut = &plane_state->cm.blend_func.pwl;
  	else if (plane_state->cm.blend_func.type == TF_TYPE_DISTRIBUTED_POINTS) {
-		result = cm3_helper_translate_curve_to_hw_format(plane_state->ctx,
+		result = cm3_helper_translate_curve_to_degamma_hw_format(
  				&plane_state->cm.blend_func,
-				&dpp_base->regamma_params,
-				false);
+				&dpp_base->regamma_params);
  		if (!result)
  			return result;
 
@@ -337,9 +336,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->ctx,
-							&plane_state->in_transfer_func,
-							&dpp_base->degamma_params, false))
+		cm3_helper_translate_curve_to_degamma_hw_format(&plane_state->in_transfer_func,
+								&dpp_base->degamma_params))
  		params = &dpp_base->degamma_params;
 
  	result = dpp_base->funcs->dpp_program_gamcor_lut(dpp_base, params);
#5 lore raw
In reply to Melissa Wen

Thanks Melissa.

I tested kms_colorop on DCN3.5 DCN3.14 without any problems. There are some comments regarding to commit messages which I replied to each patch.

I will send this patchset to next week's promotion test.

Quoted 19 lines · Melissa Wen

Extend halving distribution for all curves/custom-LUT in a encode-to-linear operation, not only PQ/SRGB. This fixes failures in IGT kms_colorop test after [1]. Also use the CM3 degamma helper that translates curves to hw points for DCN30-based family, not only DCN32, since the banding issue is present on both.

[1] https://lore.kernel.org/amd-gfx/[email protected]/

Melissa

Melissa Wen (2):
drm/amd/display: use halving distribution for all encode-to-linear
curves
drm/amd/display: use translate_curve_to_degamma_hw_format on DCN30

  .../amd/display/dc/dcn30/dcn30_cm_common.c    | 34 ++++++-------------
  .../amd/display/dc/hwss/dcn30/dcn30_hwseq.c   | 10 +++---
  2 files changed, 14 insertions(+), 30 deletions(-)
#6 lore raw
Quoted 5 lines · Alex Hung

Thanks Melissa.

I tested kms_colorop on DCN3.5 DCN3.14 without any problems. There are some comments regarding to commit messages which I replied to each patch.

I will send this patchset to next week's promotion test.

Nice! Thanks!

I sent a v2 addressing your comments in the commit message.
https://lore.kernel.org/amd-gfx/[email protected]/

Regarding the duplicated word segments, this follows the same pattern in similar color helpers and seems correct to me, since they are in different sentences.

Melissa

Quoted 22 lines · Melissa Wen
Quoted 19 lines

Extend halving distribution for all curves/custom-LUT in a encode-to-linear operation, not only PQ/SRGB. This fixes failures in IGT kms_colorop test after [1]. Also use the CM3 degamma helper that translates curves to hw points for DCN30-based family, not only DCN32, since the banding issue is present on both.

[1] https://lore.kernel.org/amd-gfx/[email protected]/

Melissa

Melissa Wen (2):
   drm/amd/display: use halving distribution for all encode-to-linear curves
   drm/amd/display: use translate_curve_to_degamma_hw_format on DCN30

  .../amd/display/dc/dcn30/dcn30_cm_common.c    | 34 ++++++------------- .../amd/display/dc/hwss/dcn30/dcn30_hwseq.c   | 10 +++---

  2 files changed, 14 insertions(+), 30 deletions(-)