Commit 09757809 authored by Krunoslav Kovac's avatar Krunoslav Kovac Committed by Alex Deucher

drm/amd/display: Set gamma not working on MPO planes

[Why]
Set gamma not working on certain planes in MPO configuration
Root cause is that video format (YUV-420) isn't allowed for IGAM where
gamma is applied.
Fix is not easy though:
1. allowing will not work because IGAM is before ICSC so RGB gamma would
be applied on YUV pixels.
2. Moving OS gamma to DGAM or RGAM resulted in weird artifacts.

Ultimately the root cause for these artifacts was due to handling end
points and the fact that YUV->RGB conversion will frequently "overshoot"
FP 1.0 value. DCE  has a single end point and slope, so we would take max.
In nightlight mode, blue channel is reduced, sometimes to flat 0 line,
but red is virtually unchanged. Any "overshot" in blue will be clipped
to 1 (max R,G,B) instead of max blue value.

[How]
Fortunately, this can be fixed on DCN where we have end point and slope
for all three color channels. We cannot fix this problem on DCE.

Other things fixed:
- switch (back) to using RGAM for OS gamma instead of IGAM
- add coeffs for 709 YUV->RGB (we used RGB->YUV for both conversions)
- switch color temperature method to scaled bradford - otherwise we would
have clipping problems that caused us to switch to IGAM for OS gamma
in the first place.
- comments and some minor improvements - there are some more issues but
they will be addressed in separate commits.
Signed-off-by: default avatarKrunoslav Kovac <Krunoslav.Kovac@amd.com>
Reviewed-by: default avatarAric Cyr <Aric.Cyr@amd.com>
Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6e82c6e0
...@@ -98,7 +98,7 @@ void cm_helper_program_xfer_func( ...@@ -98,7 +98,7 @@ void cm_helper_program_xfer_func(
bool cm_helper_convert_to_custom_float( bool cm_helper_convert_to_custom_float(
struct pwl_result_data *rgb_resulted, struct pwl_result_data *rgb_resulted,
struct curve_points *arr_points, struct curve_points3 *corner_points,
uint32_t hw_points_num, uint32_t hw_points_num,
bool fixpoint); bool fixpoint);
......
...@@ -53,6 +53,12 @@ struct curve_points { ...@@ -53,6 +53,12 @@ struct curve_points {
uint32_t custom_float_slope; uint32_t custom_float_slope;
}; };
struct curve_points3 {
struct curve_points red;
struct curve_points green;
struct curve_points blue;
};
struct pwl_result_data { struct pwl_result_data {
struct fixed31_32 red; struct fixed31_32 red;
struct fixed31_32 green; struct fixed31_32 green;
...@@ -71,9 +77,17 @@ struct pwl_result_data { ...@@ -71,9 +77,17 @@ struct pwl_result_data {
uint32_t delta_blue_reg; uint32_t delta_blue_reg;
}; };
/* arr_curve_points - regamma regions/segments specification
* arr_points - beginning and end point specified separately (only one on DCE)
* corner_points - beginning and end point for all 3 colors (DCN)
* rgb_resulted - final curve
*/
struct pwl_params { struct pwl_params {
struct gamma_curve arr_curve_points[34]; struct gamma_curve arr_curve_points[34];
union {
struct curve_points arr_points[2]; struct curve_points arr_points[2];
struct curve_points3 corner_points[2];
};
struct pwl_result_data rgb_resulted[256 + 3]; struct pwl_result_data rgb_resulted[256 + 3];
uint32_t hw_points_num; uint32_t hw_points_num;
}; };
......
...@@ -1542,7 +1542,7 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, ...@@ -1542,7 +1542,7 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
/* we can use hardcoded curve for plain SRGB TF */ /* we can use hardcoded curve for plain SRGB TF */
if (output_tf->type == TF_TYPE_PREDEFINED && canRomBeUsed == true && if (output_tf->type == TF_TYPE_PREDEFINED && canRomBeUsed == true &&
output_tf->tf == TRANSFER_FUNCTION_SRGB && output_tf->tf == TRANSFER_FUNCTION_SRGB &&
(!mapUserRamp && ramp->type == GAMMA_RGB_256)) (ramp->is_identity || (!mapUserRamp && ramp->type == GAMMA_RGB_256)))
return true; return true;
output_tf->type = TF_TYPE_DISTRIBUTED_POINTS; output_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment