Skip to content

Commit b76dfbe

Browse files
SivapiriyanKumarasamyalexdeucher
authored andcommitted
drm/amd/display: Clip all remaining regamma points after first clipped point
[Why] All values computed in the gamma curve after the first upperbound clipped point will need to be clipped anyways. We can avoid unnecessary computations and potential fixed point overflow by instead clipping these values to 1 automatically. [How] Track if upper-bound clipping has been done, and clip all values after this threshold is reached without computing the output gamma point. Signed-off-by: SivapiriyanKumarasamy <sivapiriyan.kumarasamy@amd.com> Reviewed-by: Krunoslav Kovac <Krunoslav.Kovac@amd.com> Acked-by: Leo Li <sunpeng.li@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 1fd8375 commit b76dfbe

1 file changed

Lines changed: 26 additions & 18 deletions

File tree

‎drivers/gpu/drm/amd/display/modules/color/color_gamma.c‎

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
820820
struct fixed31_32 clip = dc_fixpt_one;
821821
struct fixed31_32 output;
822822
bool use_eetf = false;
823+
bool is_clipped = false;
823824
struct fixed31_32 sdr_white_level = dc_fixpt_from_int(fs_params->sdr_white_level);
824825

825826
if (fs_params == NULL || fs_params->max_content == 0 ||
@@ -844,25 +845,32 @@ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
844845
rgb += 32; // first 32 points have problems with fixed point, too small
845846
coord_x += 32;
846847
for (i = 32; i <= hw_points_num; i++) {
847-
if (use_eetf) {
848-
/*max content is equal 1 */
849-
scaledX1 = dc_fixpt_div(coord_x->x,
850-
dc_fixpt_div(max_content, sdr_white_level));
851-
hermite_spline_eetf(scaledX1, max_display, min_display,
852-
max_content, &scaledX);
853-
} else
854-
scaledX = dc_fixpt_div(coord_x->x,
855-
dc_fixpt_div(max_display, sdr_white_level));
856-
857-
if (dc_fixpt_lt(scaledX, clip)) {
858-
if (dc_fixpt_lt(scaledX, dc_fixpt_zero))
859-
output = dc_fixpt_zero;
860-
else
861-
output = calculate_gamma22(scaledX);
848+
if (!is_clipped) {
849+
if (use_eetf) {
850+
/*max content is equal 1 */
851+
scaledX1 = dc_fixpt_div(coord_x->x,
852+
dc_fixpt_div(max_content, sdr_white_level));
853+
hermite_spline_eetf(scaledX1, max_display, min_display,
854+
max_content, &scaledX);
855+
} else
856+
scaledX = dc_fixpt_div(coord_x->x,
857+
dc_fixpt_div(max_display, sdr_white_level));
858+
859+
if (dc_fixpt_lt(scaledX, clip)) {
860+
if (dc_fixpt_lt(scaledX, dc_fixpt_zero))
861+
output = dc_fixpt_zero;
862+
else
863+
output = calculate_gamma22(scaledX);
862864

863-
rgb->r = output;
864-
rgb->g = output;
865-
rgb->b = output;
865+
rgb->r = output;
866+
rgb->g = output;
867+
rgb->b = output;
868+
} else {
869+
is_clipped = true;
870+
rgb->r = clip;
871+
rgb->g = clip;
872+
rgb->b = clip;
873+
}
866874
} else {
867875
rgb->r = clip;
868876
rgb->g = clip;

0 commit comments

Comments
 (0)