Commit 60c118c6 authored by Leo (Sunpeng) Li's avatar Leo (Sunpeng) Li Committed by Alex Deucher

drm/amd/display: Rework DCE transform bit depth reduction programming.

Clear up the logic, and enable programming truncation as a bit reduction
mode.
Signed-off-by: default avatarLeo (Sunpeng) Li <sunpeng.li@amd.com>
Reviewed-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent aed7b06e
...@@ -618,80 +618,48 @@ static void program_bit_depth_reduction( ...@@ -618,80 +618,48 @@ static void program_bit_depth_reduction(
enum dc_color_depth depth, enum dc_color_depth depth,
const struct bit_depth_reduction_params *bit_depth_params) const struct bit_depth_reduction_params *bit_depth_params)
{ {
enum dcp_bit_depth_reduction_mode depth_reduction_mode; enum dcp_out_trunc_round_depth trunc_round_depth;
enum dcp_spatial_dither_mode spatial_dither_mode; enum dcp_out_trunc_round_mode trunc_mode;
bool frame_random_enable; bool spatial_dither_enable;
bool rgb_random_enable;
bool highpass_random_enable;
ASSERT(depth < COLOR_DEPTH_121212); /* Invalid clamp bit depth */ ASSERT(depth < COLOR_DEPTH_121212); /* Invalid clamp bit depth */
if (bit_depth_params->flags.SPATIAL_DITHER_ENABLED) { spatial_dither_enable = bit_depth_params->flags.SPATIAL_DITHER_ENABLED;
depth_reduction_mode = DCP_BIT_DEPTH_REDUCTION_MODE_DITHER; /* Default to 12 bit truncation without rounding */
frame_random_enable = true; trunc_round_depth = DCP_OUT_TRUNC_ROUND_DEPTH_12BIT;
rgb_random_enable = true; trunc_mode = DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE;
highpass_random_enable = true;
if (bit_depth_params->flags.TRUNCATE_ENABLED) {
} else { /* Don't enable dithering if truncation is enabled */
depth_reduction_mode = DCP_BIT_DEPTH_REDUCTION_MODE_DISABLED; spatial_dither_enable = false;
frame_random_enable = false; trunc_mode = bit_depth_params->flags.TRUNCATE_MODE ?
rgb_random_enable = false; DCP_OUT_TRUNC_ROUND_MODE_ROUND :
highpass_random_enable = false; DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE;
if (bit_depth_params->flags.TRUNCATE_DEPTH == 0 ||
bit_depth_params->flags.TRUNCATE_DEPTH == 1)
trunc_round_depth = DCP_OUT_TRUNC_ROUND_DEPTH_8BIT;
else if (bit_depth_params->flags.TRUNCATE_DEPTH == 2)
trunc_round_depth = DCP_OUT_TRUNC_ROUND_DEPTH_10BIT;
else {
/*
* Invalid truncate/round depth. Setting here to 12bit
* to prevent use-before-initialize errors.
*/
trunc_round_depth = DCP_OUT_TRUNC_ROUND_DEPTH_12BIT;
BREAK_TO_DEBUGGER();
}
} }
spatial_dither_mode = DCP_SPATIAL_DITHER_MODE_A_AA_A;
set_clamp(xfm_dce, depth); set_clamp(xfm_dce, depth);
set_round(xfm_dce, trunc_mode, trunc_round_depth);
switch (depth_reduction_mode) { set_dither(xfm_dce,
case DCP_BIT_DEPTH_REDUCTION_MODE_DITHER: spatial_dither_enable,
/* Spatial Dither: Set round/truncate to bypass (12bit), DCP_SPATIAL_DITHER_MODE_A_AA_A,
* enable Dither (30bpp) */ DCP_SPATIAL_DITHER_DEPTH_30BPP,
set_round(xfm_dce, bit_depth_params->flags.FRAME_RANDOM,
DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE, bit_depth_params->flags.RGB_RANDOM,
DCP_OUT_TRUNC_ROUND_DEPTH_12BIT); bit_depth_params->flags.HIGHPASS_RANDOM);
set_dither(xfm_dce, true, spatial_dither_mode,
DCP_SPATIAL_DITHER_DEPTH_30BPP, frame_random_enable,
rgb_random_enable, highpass_random_enable);
break;
case DCP_BIT_DEPTH_REDUCTION_MODE_ROUND:
/* Round: Enable round (10bit), disable Dither */
set_round(xfm_dce,
DCP_OUT_TRUNC_ROUND_MODE_ROUND,
DCP_OUT_TRUNC_ROUND_DEPTH_10BIT);
set_dither(xfm_dce, false, spatial_dither_mode,
DCP_SPATIAL_DITHER_DEPTH_30BPP, frame_random_enable,
rgb_random_enable, highpass_random_enable);
break;
case DCP_BIT_DEPTH_REDUCTION_MODE_TRUNCATE: /* Truncate */
/* Truncate: Enable truncate (10bit), disable Dither */
set_round(xfm_dce,
DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE,
DCP_OUT_TRUNC_ROUND_DEPTH_10BIT);
set_dither(xfm_dce, false, spatial_dither_mode,
DCP_SPATIAL_DITHER_DEPTH_30BPP, frame_random_enable,
rgb_random_enable, highpass_random_enable);
break;
case DCP_BIT_DEPTH_REDUCTION_MODE_DISABLED: /* Disabled */
/* Truncate: Set round/truncate to bypass (12bit),
* disable Dither */
set_round(xfm_dce,
DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE,
DCP_OUT_TRUNC_ROUND_DEPTH_12BIT);
set_dither(xfm_dce, false, spatial_dither_mode,
DCP_SPATIAL_DITHER_DEPTH_30BPP, frame_random_enable,
rgb_random_enable, highpass_random_enable);
break;
default:
/* Invalid DCP Depth reduction mode */
BREAK_TO_DEBUGGER();
break;
}
} }
static int dce_transform_get_max_num_of_supported_lines( static int dce_transform_get_max_num_of_supported_lines(
......
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