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>
This commit is contained in:
SivapiriyanKumarasamy 2018-10-09 12:59:46 -04:00 committed by Alex Deucher
parent 1fd8375236
commit b76dfbef06

View file

@ -820,6 +820,7 @@ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
struct fixed31_32 clip = dc_fixpt_one; struct fixed31_32 clip = dc_fixpt_one;
struct fixed31_32 output; struct fixed31_32 output;
bool use_eetf = false; bool use_eetf = false;
bool is_clipped = false;
struct fixed31_32 sdr_white_level = dc_fixpt_from_int(fs_params->sdr_white_level); struct fixed31_32 sdr_white_level = dc_fixpt_from_int(fs_params->sdr_white_level);
if (fs_params == NULL || fs_params->max_content == 0 || 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,
rgb += 32; // first 32 points have problems with fixed point, too small rgb += 32; // first 32 points have problems with fixed point, too small
coord_x += 32; coord_x += 32;
for (i = 32; i <= hw_points_num; i++) { for (i = 32; i <= hw_points_num; i++) {
if (use_eetf) { if (!is_clipped) {
/*max content is equal 1 */ if (use_eetf) {
scaledX1 = dc_fixpt_div(coord_x->x, /*max content is equal 1 */
dc_fixpt_div(max_content, sdr_white_level)); scaledX1 = dc_fixpt_div(coord_x->x,
hermite_spline_eetf(scaledX1, max_display, min_display, dc_fixpt_div(max_content, sdr_white_level));
max_content, &scaledX); hermite_spline_eetf(scaledX1, max_display, min_display,
} else max_content, &scaledX);
scaledX = dc_fixpt_div(coord_x->x, } else
dc_fixpt_div(max_display, sdr_white_level)); scaledX = dc_fixpt_div(coord_x->x,
dc_fixpt_div(max_display, sdr_white_level));
if (dc_fixpt_lt(scaledX, clip)) { if (dc_fixpt_lt(scaledX, clip)) {
if (dc_fixpt_lt(scaledX, dc_fixpt_zero)) if (dc_fixpt_lt(scaledX, dc_fixpt_zero))
output = dc_fixpt_zero; output = dc_fixpt_zero;
else else
output = calculate_gamma22(scaledX); output = calculate_gamma22(scaledX);
rgb->r = output; rgb->r = output;
rgb->g = output; rgb->g = output;
rgb->b = output; rgb->b = output;
} else {
is_clipped = true;
rgb->r = clip;
rgb->g = clip;
rgb->b = clip;
}
} else { } else {
rgb->r = clip; rgb->r = clip;
rgb->g = clip; rgb->g = clip;