aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorDing Wang <Ding.Wang@amd.com>2017-04-25 10:03:27 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-09-26 18:06:43 -0400
commit529cad0f945c9e60569e902062d2f2741e4fd71a (patch)
treefc714e767f05e069defb5317d0e588fc65560f67 /drivers/gpu/drm/amd
parent7cc9e7a68abef8d1303700bac6f58ab76bc9db7b (diff)
drm/amd/display: Add function to set dither option
Signed-off-by: Ding Wang <Ding.Wang@amd.com> Acked-by: Harry Wentland <Harry.Wentland@amd.com> Reviewed-by: Tony Cheng <Tony.Cheng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc.c41
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c4
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_resource.c110
-rw-r--r--drivers/gpu/drm/amd/display/dc/dc.h3
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c48
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.h4
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c2
-rw-r--r--drivers/gpu/drm/amd/display/dc/inc/core_types.h4
-rw-r--r--drivers/gpu/drm/amd/display/dc/inc/resource.h2
9 files changed, 160 insertions, 58 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 37986632f025..738acf0cc7db 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -363,6 +363,44 @@ static void set_test_pattern(
363 cust_pattern_size); 363 cust_pattern_size);
364} 364}
365 365
366void set_dither_option(const struct dc_stream *dc_stream,
367 enum dc_dither_option option)
368{
369 struct core_stream *stream = DC_STREAM_TO_CORE(dc_stream);
370 struct bit_depth_reduction_params params;
371 struct core_link *core_link = DC_LINK_TO_CORE(stream->status.link);
372 struct pipe_ctx *pipes =
373 core_link->dc->current_context->res_ctx.pipe_ctx;
374
375 memset(&params, 0, sizeof(params));
376 if (!stream)
377 return;
378 if (option > DITHER_OPTION_MAX)
379 return;
380 if (option == DITHER_OPTION_DEFAULT) {
381 switch (stream->public.timing.display_color_depth) {
382 case COLOR_DEPTH_666:
383 stream->public.dither_option = DITHER_OPTION_SPATIAL6;
384 break;
385 case COLOR_DEPTH_888:
386 stream->public.dither_option = DITHER_OPTION_SPATIAL8;
387 break;
388 case COLOR_DEPTH_101010:
389 stream->public.dither_option = DITHER_OPTION_SPATIAL10;
390 break;
391 default:
392 option = DITHER_OPTION_DISABLE;
393 }
394 } else {
395 stream->public.dither_option = option;
396 }
397 resource_build_bit_depth_reduction_params(stream,
398 &params);
399 stream->bit_depth_params = params;
400 pipes->opp->funcs->
401 opp_program_bit_depth_reduction(pipes->opp, &params);
402}
403
366static void allocate_dc_stream_funcs(struct core_dc *core_dc) 404static void allocate_dc_stream_funcs(struct core_dc *core_dc)
367{ 405{
368 core_dc->public.stream_funcs.stream_update_scaling = stream_update_scaling; 406 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)
380 core_dc->public.stream_funcs.set_gamut_remap = 418 core_dc->public.stream_funcs.set_gamut_remap =
381 set_gamut_remap; 419 set_gamut_remap;
382 420
421 core_dc->public.stream_funcs.set_dither_option =
422 set_dither_option;
423
383 core_dc->public.link_funcs.set_drive_settings = 424 core_dc->public.link_funcs.set_drive_settings =
384 set_drive_settings; 425 set_drive_settings;
385 426
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 4b9d3f12406f..a0d192774a22 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -11,6 +11,7 @@
11#include "dpcd_defs.h" 11#include "dpcd_defs.h"
12 12
13#include "core_dc.h" 13#include "core_dc.h"
14#include "resource.h"
14 15
15/* maximum pre emphasis level allowed for each voltage swing level*/ 16/* maximum pre emphasis level allowed for each voltage swing level*/
16static const enum dc_pre_emphasis voltage_swing_to_pre_emphasis[] = { 17static const enum dc_pre_emphasis voltage_swing_to_pre_emphasis[] = {
@@ -2245,8 +2246,7 @@ static void set_crtc_test_pattern(struct core_link *link,
2245 case DP_TEST_PATTERN_VIDEO_MODE: 2246 case DP_TEST_PATTERN_VIDEO_MODE:
2246 { 2247 {
2247 /* restore bitdepth reduction */ 2248 /* restore bitdepth reduction */
2248 link->dc->res_pool->funcs-> 2249 resource_build_bit_depth_reduction_params(pipe_ctx->stream,
2249 build_bit_depth_reduction_params(pipe_ctx->stream,
2250 &params); 2250 &params);
2251 pipe_ctx->stream->bit_depth_params = params; 2251 pipe_ctx->stream->bit_depth_params = params;
2252 pipe_ctx->opp->funcs-> 2252 pipe_ctx->opp->funcs->
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index 43e5758719ca..2de86f8364a3 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -2246,3 +2246,113 @@ bool pipe_need_reprogram(
2246 2246
2247 return false; 2247 return false;
2248} 2248}
2249
2250void resource_build_bit_depth_reduction_params(const struct core_stream *stream,
2251 struct bit_depth_reduction_params *fmt_bit_depth)
2252{
2253 enum dc_dither_option option = stream->public.dither_option;
2254 enum dc_pixel_encoding pixel_encoding =
2255 stream->public.timing.pixel_encoding;
2256
2257 memset(fmt_bit_depth, 0, sizeof(*fmt_bit_depth));
2258
2259 if (option == DITHER_OPTION_DISABLE)
2260 return;
2261
2262 if (option == DITHER_OPTION_TRUN6) {
2263 fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
2264 fmt_bit_depth->flags.TRUNCATE_DEPTH = 0;
2265 } else if (option == DITHER_OPTION_TRUN8 ||
2266 option == DITHER_OPTION_TRUN8_SPATIAL6 ||
2267 option == DITHER_OPTION_TRUN8_FM6) {
2268 fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
2269 fmt_bit_depth->flags.TRUNCATE_DEPTH = 1;
2270 } else if (option == DITHER_OPTION_TRUN10 ||
2271 option == DITHER_OPTION_TRUN10_SPATIAL6 ||
2272 option == DITHER_OPTION_TRUN10_SPATIAL8 ||
2273 option == DITHER_OPTION_TRUN10_FM8 ||
2274 option == DITHER_OPTION_TRUN10_FM6 ||
2275 option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
2276 fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
2277 fmt_bit_depth->flags.TRUNCATE_DEPTH = 2;
2278 }
2279
2280 /* special case - Formatter can only reduce by 4 bits at most.
2281 * When reducing from 12 to 6 bits,
2282 * HW recommends we use trunc with round mode
2283 * (if we did nothing, trunc to 10 bits would be used)
2284 * note that any 12->10 bit reduction is ignored prior to DCE8,
2285 * as the input was 10 bits.
2286 */
2287 if (option == DITHER_OPTION_SPATIAL6_FRAME_RANDOM ||
2288 option == DITHER_OPTION_SPATIAL6 ||
2289 option == DITHER_OPTION_FM6) {
2290 fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
2291 fmt_bit_depth->flags.TRUNCATE_DEPTH = 2;
2292 fmt_bit_depth->flags.TRUNCATE_MODE = 1;
2293 }
2294
2295 /* spatial dither
2296 * note that spatial modes 1-3 are never used
2297 */
2298 if (option == DITHER_OPTION_SPATIAL6_FRAME_RANDOM ||
2299 option == DITHER_OPTION_SPATIAL6 ||
2300 option == DITHER_OPTION_TRUN10_SPATIAL6 ||
2301 option == DITHER_OPTION_TRUN8_SPATIAL6) {
2302 fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
2303 fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 0;
2304 fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
2305 fmt_bit_depth->flags.RGB_RANDOM =
2306 (pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
2307 } else if (option == DITHER_OPTION_SPATIAL8_FRAME_RANDOM ||
2308 option == DITHER_OPTION_SPATIAL8 ||
2309 option == DITHER_OPTION_SPATIAL8_FM6 ||
2310 option == DITHER_OPTION_TRUN10_SPATIAL8 ||
2311 option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
2312 fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
2313 fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 1;
2314 fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
2315 fmt_bit_depth->flags.RGB_RANDOM =
2316 (pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
2317 } else if (option == DITHER_OPTION_SPATIAL10_FRAME_RANDOM ||
2318 option == DITHER_OPTION_SPATIAL10 ||
2319 option == DITHER_OPTION_SPATIAL10_FM8 ||
2320 option == DITHER_OPTION_SPATIAL10_FM6) {
2321 fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
2322 fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 2;
2323 fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
2324 fmt_bit_depth->flags.RGB_RANDOM =
2325 (pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
2326 }
2327
2328 if (option == DITHER_OPTION_SPATIAL6 ||
2329 option == DITHER_OPTION_SPATIAL8 ||
2330 option == DITHER_OPTION_SPATIAL10) {
2331 fmt_bit_depth->flags.FRAME_RANDOM = 0;
2332 } else {
2333 fmt_bit_depth->flags.FRAME_RANDOM = 1;
2334 }
2335
2336 //////////////////////
2337 //// temporal dither
2338 //////////////////////
2339 if (option == DITHER_OPTION_FM6 ||
2340 option == DITHER_OPTION_SPATIAL8_FM6 ||
2341 option == DITHER_OPTION_SPATIAL10_FM6 ||
2342 option == DITHER_OPTION_TRUN10_FM6 ||
2343 option == DITHER_OPTION_TRUN8_FM6 ||
2344 option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
2345 fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
2346 fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 0;
2347 } else if (option == DITHER_OPTION_FM8 ||
2348 option == DITHER_OPTION_SPATIAL10_FM8 ||
2349 option == DITHER_OPTION_TRUN10_FM8) {
2350 fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
2351 fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 1;
2352 } else if (option == DITHER_OPTION_FM10) {
2353 fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
2354 fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 2;
2355 }
2356
2357 fmt_bit_depth->pixel_encoding = pixel_encoding;
2358}
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index dd8902d28ee1..87675f032949 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -122,6 +122,9 @@ struct dc_stream_funcs {
122 const struct dc_stream **stream, 122 const struct dc_stream **stream,
123 int num_streams, 123 int num_streams,
124 const struct dc_static_screen_events *events); 124 const struct dc_static_screen_events *events);
125
126 void (*set_dither_option)(const struct dc_stream *stream,
127 enum dc_dither_option option);
125}; 128};
126 129
127struct link_training_settings; 130struct link_training_settings;
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
index 122f2d03afc0..5b2b41efa5f0 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
@@ -775,50 +775,6 @@ static void get_pixel_clock_parameters(
775 } 775 }
776} 776}
777 777
778void dce110_resource_build_bit_depth_reduction_params(
779 const struct core_stream *stream,
780 struct bit_depth_reduction_params *fmt_bit_depth)
781{
782 memset(fmt_bit_depth, 0, sizeof(*fmt_bit_depth));
783
784 /*TODO: Need to un-hardcode, refer to function with same name
785 * in dal2 hw_sequencer*/
786
787 fmt_bit_depth->flags.TRUNCATE_ENABLED = 0;
788 fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 0;
789 fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 0;
790
791 /* Diagnostics need consistent CRC of the image, that means
792 * dithering should not be enabled for Diagnostics. */
793 if (IS_DIAG_DC(stream->ctx->dce_environment) == false) {
794 switch (stream->public.timing.display_color_depth) {
795 case COLOR_DEPTH_666:
796 fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
797 fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 0;
798 break;
799 case COLOR_DEPTH_888:
800 fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
801 fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 1;
802 break;
803 case COLOR_DEPTH_101010:
804 fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
805 fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 2;
806 break;
807 default:
808 break;
809 }
810 fmt_bit_depth->flags.RGB_RANDOM = 1;
811 fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
812 fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
813 fmt_bit_depth->flags.TRUNCATE_DEPTH = 2;
814
815 fmt_bit_depth->pixel_encoding =
816 stream->public.timing.pixel_encoding;
817 }
818
819 return;
820}
821
822enum dc_status dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx) 778enum dc_status dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
823{ 779{
824 get_pixel_clock_parameters(pipe_ctx, &pipe_ctx->pix_clk_params); 780 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)
826 pipe_ctx->clock_source, 782 pipe_ctx->clock_source,
827 &pipe_ctx->pix_clk_params, 783 &pipe_ctx->pix_clk_params,
828 &pipe_ctx->pll_settings); 784 &pipe_ctx->pll_settings);
829 dce110_resource_build_bit_depth_reduction_params(pipe_ctx->stream, 785 resource_build_bit_depth_reduction_params(pipe_ctx->stream,
830 &pipe_ctx->stream->bit_depth_params); 786 &pipe_ctx->stream->bit_depth_params);
831 pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->public.timing.pixel_encoding; 787 pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->public.timing.pixel_encoding;
832 788
@@ -1171,8 +1127,6 @@ static const struct resource_funcs dce110_res_pool_funcs = {
1171 .validate_guaranteed = dce110_validate_guaranteed, 1127 .validate_guaranteed = dce110_validate_guaranteed,
1172 .validate_bandwidth = dce110_validate_bandwidth, 1128 .validate_bandwidth = dce110_validate_bandwidth,
1173 .acquire_idle_pipe_for_layer = dce110_acquire_underlay, 1129 .acquire_idle_pipe_for_layer = dce110_acquire_underlay,
1174 .build_bit_depth_reduction_params =
1175 dce110_resource_build_bit_depth_reduction_params
1176}; 1130};
1177 1131
1178static bool underlay_create(struct dc_context *ctx, struct resource_pool *pool) 1132static bool underlay_create(struct dc_context *ctx, struct resource_pool *pool)
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.h b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.h
index 0c357fdfa8bc..8e2e85dd30b9 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.h
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.h
@@ -40,10 +40,6 @@ struct dce110_resource_pool {
40 40
41enum dc_status dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx); 41enum dc_status dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx);
42 42
43void dce110_resource_build_bit_depth_reduction_params(
44 const struct core_stream *stream,
45 struct bit_depth_reduction_params *fmt_bit_depth);
46
47struct resource_pool *dce110_create_resource_pool( 43struct resource_pool *dce110_create_resource_pool(
48 uint8_t num_virtual_links, 44 uint8_t num_virtual_links,
49 struct core_dc *dc, 45 struct core_dc *dc,
diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
index 4de51a86c9ea..18c1b89a52be 100644
--- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
@@ -1062,7 +1062,7 @@ static const struct resource_funcs dce112_res_pool_funcs = {
1062 .link_enc_create = dce112_link_encoder_create, 1062 .link_enc_create = dce112_link_encoder_create,
1063 .validate_with_context = dce112_validate_with_context, 1063 .validate_with_context = dce112_validate_with_context,
1064 .validate_guaranteed = dce112_validate_guaranteed, 1064 .validate_guaranteed = dce112_validate_guaranteed,
1065 .validate_bandwidth = dce112_validate_bandwidth 1065 .validate_bandwidth = dce112_validate_bandwidth,
1066}; 1066};
1067 1067
1068static void bw_calcs_data_update_from_pplib(struct core_dc *dc) 1068static void bw_calcs_data_update_from_pplib(struct core_dc *dc)
diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
index f3fe850ffa13..9e5e0ba5b10b 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
@@ -214,10 +214,6 @@ struct resource_funcs {
214 struct validate_context *context, 214 struct validate_context *context,
215 const struct resource_pool *pool, 215 const struct resource_pool *pool,
216 struct core_stream *stream); 216 struct core_stream *stream);
217
218 void (*build_bit_depth_reduction_params)(
219 const struct core_stream *stream,
220 struct bit_depth_reduction_params *fmt_bit_depth);
221}; 217};
222 218
223struct audio_support{ 219struct audio_support{
diff --git a/drivers/gpu/drm/amd/display/dc/inc/resource.h b/drivers/gpu/drm/amd/display/dc/inc/resource.h
index 89d34bed131b..4e07b9fea669 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/resource.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/resource.h
@@ -160,5 +160,7 @@ bool pipe_need_reprogram(
160 struct pipe_ctx *pipe_ctx_old, 160 struct pipe_ctx *pipe_ctx_old,
161 struct pipe_ctx *pipe_ctx); 161 struct pipe_ctx *pipe_ctx);
162 162
163void resource_build_bit_depth_reduction_params(const struct core_stream *stream,
164 struct bit_depth_reduction_params *fmt_bit_depth);
163 165
164#endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */ 166#endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */