drm/amd/display: Fix low black values by increasing error
authorPeterson <peterson.guo@amd.com>
Mon, 23 Sep 2024 14:30:50 +0000 (10:30 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 7 Oct 2024 18:12:01 +0000 (14:12 -0400)
[WHY]
Regamma resolution for the first few black levels can have problems for
calibration.

[HOW]
HW LUT is divided into N power-of-2 regions each with K segments.  For
SDR mode we set min point at 2^-10 and increments of 2^-13. It's
generally more than 8-bit SDR needs, but some calibration tools and API
use 12-bit curves.
The fix shifts starting point to 2^-12 and starting increments at 2^-16.

Reviewed-by: Krunoslav Kovac <krunoslav.kovac@amd.com>
Signed-off-by: Peterson <peterson.guo@amd.com>
Signed-off-by: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c

index eaed5d1..dcd2cdf 100644 (file)
@@ -365,23 +365,18 @@ bool cm_helper_translate_curve_to_hw_format(struct dc_context *ctx,
                region_start = -MAX_LOW_POINT;
                region_end   = NUMBER_REGIONS - MAX_LOW_POINT;
        } else {
-               /* 11 segments
-                * segment is from 2^-10 to 2^1
+               /* 13 segments
+                * segment is from 2^-12 to 2^0
                 * There are less than 256 points, for optimization
                 */
-               seg_distr[0] = 3;
-               seg_distr[1] = 4;
-               seg_distr[2] = 4;
-               seg_distr[3] = 4;
-               seg_distr[4] = 4;
-               seg_distr[5] = 4;
-               seg_distr[6] = 4;
-               seg_distr[7] = 4;
-               seg_distr[8] = 4;
-               seg_distr[9] = 4;
-               seg_distr[10] = 1;
-
-               region_start = -10;
+               const uint8_t SEG_COUNT = 12;
+
+               for (i = 0; i < SEG_COUNT; i++)
+                       seg_distr[i] = 4;
+
+               seg_distr[SEG_COUNT] = 1;
+
+               region_start = -SEG_COUNT;
                region_end = 1;
        }
 
index f31f0e3..1e1038f 100644 (file)
@@ -140,23 +140,18 @@ bool cm3_helper_translate_curve_to_hw_format(
                region_start = -MAX_LOW_POINT;
                region_end   = NUMBER_REGIONS - MAX_LOW_POINT;
        } else {
-               /* 11 segments
-                * segment is from 2^-10 to 2^0
+               /* 13 segments
+                * segment is from 2^-12 to 2^0
                 * There are less than 256 points, for optimization
                 */
-               seg_distr[0] = 3;
-               seg_distr[1] = 4;
-               seg_distr[2] = 4;
-               seg_distr[3] = 4;
-               seg_distr[4] = 4;
-               seg_distr[5] = 4;
-               seg_distr[6] = 4;
-               seg_distr[7] = 4;
-               seg_distr[8] = 4;
-               seg_distr[9] = 4;
-               seg_distr[10] = 1;
-
-               region_start = -10;
+               const uint8_t SEG_COUNT = 12;
+
+               for (i = 0; i < SEG_COUNT; i++)
+                       seg_distr[i] = 4;
+
+               seg_distr[SEG_COUNT] = 1;
+
+               region_start = -SEG_COUNT;
                region_end = 1;
        }