提交 529cad0f 编写于 作者: D Ding Wang 提交者: Alex Deucher

drm/amd/display: Add function to set dither option

Signed-off-by: NDing Wang <Ding.Wang@amd.com>
Acked-by: NHarry Wentland <Harry.Wentland@amd.com>
Reviewed-by: NTony Cheng <Tony.Cheng@amd.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 7cc9e7a6
master alk-4.19.24 alk-4.19.30 alk-4.19.34 alk-4.19.36 alk-4.19.43 alk-4.19.48 alk-4.19.57 ck-4.19.67 ck-4.19.81 ck-4.19.91 github/fork/deepanshu1422/fix-typo-in-comment github/fork/haosdent/fix-typo linux-next v4.19.91 v4.19.90 v4.19.89 v4.19.88 v4.19.87 v4.19.86 v4.19.85 v4.19.84 v4.19.83 v4.19.82 v4.19.81 v4.19.80 v4.19.79 v4.19.78 v4.19.77 v4.19.76 v4.19.75 v4.19.74 v4.19.73 v4.19.72 v4.19.71 v4.19.70 v4.19.69 v4.19.68 v4.19.67 v4.19.66 v4.19.65 v4.19.64 v4.19.63 v4.19.62 v4.19.61 v4.19.60 v4.19.59 v4.19.58 v4.19.57 v4.19.56 v4.19.55 v4.19.54 v4.19.53 v4.19.52 v4.19.51 v4.19.50 v4.19.49 v4.19.48 v4.19.47 v4.19.46 v4.19.45 v4.19.44 v4.19.43 v4.19.42 v4.19.41 v4.19.40 v4.19.39 v4.19.38 v4.19.37 v4.19.36 v4.19.35 v4.19.34 v4.19.33 v4.19.32 v4.19.31 v4.19.30 v4.19.29 v4.19.28 v4.19.27 v4.19.26 v4.19.25 v4.19.24 v4.19.23 v4.19.22 v4.19.21 v4.19.20 v4.19.19 v4.19.18 v4.19.17 v4.19.16 v4.19.15 v4.19.14 v4.19.13 v4.19.12 v4.19.11 v4.19.10 v4.19.9 v4.19.8 v4.19.7 v4.19.6 v4.19.5 v4.19.4 v4.19.3 v4.19.2 v4.19.1 v4.19 v4.19-rc8 v4.19-rc7 v4.19-rc6 v4.19-rc5 v4.19-rc4 v4.19-rc3 v4.19-rc2 v4.19-rc1 ck-release-21 ck-release-20 ck-release-19.2 ck-release-19.1 ck-release-19 ck-release-18 ck-release-17.2 ck-release-17.1 ck-release-17 ck-release-16 ck-release-15.1 ck-release-15 ck-release-14 ck-release-13.2 ck-release-13 ck-release-12 ck-release-11 ck-release-10 ck-release-9 ck-release-7 alk-release-15 alk-release-14 alk-release-13.2 alk-release-13 alk-release-12 alk-release-11 alk-release-10 alk-release-9 alk-release-7
无相关合并请求
......@@ -363,6 +363,44 @@ static void set_test_pattern(
cust_pattern_size);
}
void set_dither_option(const struct dc_stream *dc_stream,
enum dc_dither_option option)
{
struct core_stream *stream = DC_STREAM_TO_CORE(dc_stream);
struct bit_depth_reduction_params params;
struct core_link *core_link = DC_LINK_TO_CORE(stream->status.link);
struct pipe_ctx *pipes =
core_link->dc->current_context->res_ctx.pipe_ctx;
memset(&params, 0, sizeof(params));
if (!stream)
return;
if (option > DITHER_OPTION_MAX)
return;
if (option == DITHER_OPTION_DEFAULT) {
switch (stream->public.timing.display_color_depth) {
case COLOR_DEPTH_666:
stream->public.dither_option = DITHER_OPTION_SPATIAL6;
break;
case COLOR_DEPTH_888:
stream->public.dither_option = DITHER_OPTION_SPATIAL8;
break;
case COLOR_DEPTH_101010:
stream->public.dither_option = DITHER_OPTION_SPATIAL10;
break;
default:
option = DITHER_OPTION_DISABLE;
}
} else {
stream->public.dither_option = option;
}
resource_build_bit_depth_reduction_params(stream,
&params);
stream->bit_depth_params = params;
pipes->opp->funcs->
opp_program_bit_depth_reduction(pipes->opp, &params);
}
static void allocate_dc_stream_funcs(struct core_dc *core_dc)
{
core_dc->public.stream_funcs.stream_update_scaling = stream_update_scaling;
......@@ -380,6 +418,9 @@ static void allocate_dc_stream_funcs(struct core_dc *core_dc)
core_dc->public.stream_funcs.set_gamut_remap =
set_gamut_remap;
core_dc->public.stream_funcs.set_dither_option =
set_dither_option;
core_dc->public.link_funcs.set_drive_settings =
set_drive_settings;
......
......@@ -11,6 +11,7 @@
#include "dpcd_defs.h"
#include "core_dc.h"
#include "resource.h"
/* maximum pre emphasis level allowed for each voltage swing level*/
static const enum dc_pre_emphasis voltage_swing_to_pre_emphasis[] = {
......@@ -2245,8 +2246,7 @@ static void set_crtc_test_pattern(struct core_link *link,
case DP_TEST_PATTERN_VIDEO_MODE:
{
/* restore bitdepth reduction */
link->dc->res_pool->funcs->
build_bit_depth_reduction_params(pipe_ctx->stream,
resource_build_bit_depth_reduction_params(pipe_ctx->stream,
&params);
pipe_ctx->stream->bit_depth_params = params;
pipe_ctx->opp->funcs->
......
......@@ -2246,3 +2246,113 @@ bool pipe_need_reprogram(
return false;
}
void resource_build_bit_depth_reduction_params(const struct core_stream *stream,
struct bit_depth_reduction_params *fmt_bit_depth)
{
enum dc_dither_option option = stream->public.dither_option;
enum dc_pixel_encoding pixel_encoding =
stream->public.timing.pixel_encoding;
memset(fmt_bit_depth, 0, sizeof(*fmt_bit_depth));
if (option == DITHER_OPTION_DISABLE)
return;
if (option == DITHER_OPTION_TRUN6) {
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 0;
} else if (option == DITHER_OPTION_TRUN8 ||
option == DITHER_OPTION_TRUN8_SPATIAL6 ||
option == DITHER_OPTION_TRUN8_FM6) {
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 1;
} else if (option == DITHER_OPTION_TRUN10 ||
option == DITHER_OPTION_TRUN10_SPATIAL6 ||
option == DITHER_OPTION_TRUN10_SPATIAL8 ||
option == DITHER_OPTION_TRUN10_FM8 ||
option == DITHER_OPTION_TRUN10_FM6 ||
option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 2;
}
/* special case - Formatter can only reduce by 4 bits at most.
* When reducing from 12 to 6 bits,
* HW recommends we use trunc with round mode
* (if we did nothing, trunc to 10 bits would be used)
* note that any 12->10 bit reduction is ignored prior to DCE8,
* as the input was 10 bits.
*/
if (option == DITHER_OPTION_SPATIAL6_FRAME_RANDOM ||
option == DITHER_OPTION_SPATIAL6 ||
option == DITHER_OPTION_FM6) {
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 2;
fmt_bit_depth->flags.TRUNCATE_MODE = 1;
}
/* spatial dither
* note that spatial modes 1-3 are never used
*/
if (option == DITHER_OPTION_SPATIAL6_FRAME_RANDOM ||
option == DITHER_OPTION_SPATIAL6 ||
option == DITHER_OPTION_TRUN10_SPATIAL6 ||
option == DITHER_OPTION_TRUN8_SPATIAL6) {
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 0;
fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
fmt_bit_depth->flags.RGB_RANDOM =
(pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
} else if (option == DITHER_OPTION_SPATIAL8_FRAME_RANDOM ||
option == DITHER_OPTION_SPATIAL8 ||
option == DITHER_OPTION_SPATIAL8_FM6 ||
option == DITHER_OPTION_TRUN10_SPATIAL8 ||
option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 1;
fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
fmt_bit_depth->flags.RGB_RANDOM =
(pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
} else if (option == DITHER_OPTION_SPATIAL10_FRAME_RANDOM ||
option == DITHER_OPTION_SPATIAL10 ||
option == DITHER_OPTION_SPATIAL10_FM8 ||
option == DITHER_OPTION_SPATIAL10_FM6) {
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 2;
fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
fmt_bit_depth->flags.RGB_RANDOM =
(pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
}
if (option == DITHER_OPTION_SPATIAL6 ||
option == DITHER_OPTION_SPATIAL8 ||
option == DITHER_OPTION_SPATIAL10) {
fmt_bit_depth->flags.FRAME_RANDOM = 0;
} else {
fmt_bit_depth->flags.FRAME_RANDOM = 1;
}
//////////////////////
//// temporal dither
//////////////////////
if (option == DITHER_OPTION_FM6 ||
option == DITHER_OPTION_SPATIAL8_FM6 ||
option == DITHER_OPTION_SPATIAL10_FM6 ||
option == DITHER_OPTION_TRUN10_FM6 ||
option == DITHER_OPTION_TRUN8_FM6 ||
option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 0;
} else if (option == DITHER_OPTION_FM8 ||
option == DITHER_OPTION_SPATIAL10_FM8 ||
option == DITHER_OPTION_TRUN10_FM8) {
fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 1;
} else if (option == DITHER_OPTION_FM10) {
fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 2;
}
fmt_bit_depth->pixel_encoding = pixel_encoding;
}
......@@ -122,6 +122,9 @@ struct dc_stream_funcs {
const struct dc_stream **stream,
int num_streams,
const struct dc_static_screen_events *events);
void (*set_dither_option)(const struct dc_stream *stream,
enum dc_dither_option option);
};
struct link_training_settings;
......
......@@ -775,50 +775,6 @@ static void get_pixel_clock_parameters(
}
}
void dce110_resource_build_bit_depth_reduction_params(
const struct core_stream *stream,
struct bit_depth_reduction_params *fmt_bit_depth)
{
memset(fmt_bit_depth, 0, sizeof(*fmt_bit_depth));
/*TODO: Need to un-hardcode, refer to function with same name
* in dal2 hw_sequencer*/
fmt_bit_depth->flags.TRUNCATE_ENABLED = 0;
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 0;
fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 0;
/* Diagnostics need consistent CRC of the image, that means
* dithering should not be enabled for Diagnostics. */
if (IS_DIAG_DC(stream->ctx->dce_environment) == false) {
switch (stream->public.timing.display_color_depth) {
case COLOR_DEPTH_666:
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 0;
break;
case COLOR_DEPTH_888:
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 1;
break;
case COLOR_DEPTH_101010:
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 2;
break;
default:
break;
}
fmt_bit_depth->flags.RGB_RANDOM = 1;
fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 2;
fmt_bit_depth->pixel_encoding =
stream->public.timing.pixel_encoding;
}
return;
}
enum dc_status dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
{
get_pixel_clock_parameters(pipe_ctx, &pipe_ctx->pix_clk_params);
......@@ -826,7 +782,7 @@ enum dc_status dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
pipe_ctx->clock_source,
&pipe_ctx->pix_clk_params,
&pipe_ctx->pll_settings);
dce110_resource_build_bit_depth_reduction_params(pipe_ctx->stream,
resource_build_bit_depth_reduction_params(pipe_ctx->stream,
&pipe_ctx->stream->bit_depth_params);
pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->public.timing.pixel_encoding;
......@@ -1171,8 +1127,6 @@ static const struct resource_funcs dce110_res_pool_funcs = {
.validate_guaranteed = dce110_validate_guaranteed,
.validate_bandwidth = dce110_validate_bandwidth,
.acquire_idle_pipe_for_layer = dce110_acquire_underlay,
.build_bit_depth_reduction_params =
dce110_resource_build_bit_depth_reduction_params
};
static bool underlay_create(struct dc_context *ctx, struct resource_pool *pool)
......
......@@ -40,10 +40,6 @@ struct dce110_resource_pool {
enum dc_status dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx);
void dce110_resource_build_bit_depth_reduction_params(
const struct core_stream *stream,
struct bit_depth_reduction_params *fmt_bit_depth);
struct resource_pool *dce110_create_resource_pool(
uint8_t num_virtual_links,
struct core_dc *dc,
......
......@@ -1062,7 +1062,7 @@ static const struct resource_funcs dce112_res_pool_funcs = {
.link_enc_create = dce112_link_encoder_create,
.validate_with_context = dce112_validate_with_context,
.validate_guaranteed = dce112_validate_guaranteed,
.validate_bandwidth = dce112_validate_bandwidth
.validate_bandwidth = dce112_validate_bandwidth,
};
static void bw_calcs_data_update_from_pplib(struct core_dc *dc)
......
......@@ -214,10 +214,6 @@ struct resource_funcs {
struct validate_context *context,
const struct resource_pool *pool,
struct core_stream *stream);
void (*build_bit_depth_reduction_params)(
const struct core_stream *stream,
struct bit_depth_reduction_params *fmt_bit_depth);
};
struct audio_support{
......
......@@ -160,5 +160,7 @@ bool pipe_need_reprogram(
struct pipe_ctx *pipe_ctx_old,
struct pipe_ctx *pipe_ctx);
void resource_build_bit_depth_reduction_params(const struct core_stream *stream,
struct bit_depth_reduction_params *fmt_bit_depth);
#endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部