Skip to content

Commit 1e826ac

Browse files
Ilya Bakoulingregkh
authored andcommitted
drm/amd/display: Fix BT2020 YCbCr limited/full range input
[ Upstream commit 07bc2dc ] [Why] BT2020 YCbCr input is not handled properly when full range quantization is used and limited range is not supported at all. [How] - Add enums for BT2020 YCbCr limited/full range - Add limited range CSC matrix Reviewed-by: Krunoslav Kovac <krunoslav.kovac@amd.com> Signed-off-by: Ilya Bakoulin <Ilya.Bakoulin@amd.com> Signed-off-by: Roman Li <roman.li@amd.com> Tested-by: Robert Mader <robert.mader@collabora.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2bba67f commit 1e826ac

File tree

12 files changed

+29
-17
lines changed

12 files changed

+29
-17
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5552,9 +5552,9 @@ fill_plane_color_attributes(const struct drm_plane_state *plane_state,
55525552

55535553
case DRM_COLOR_YCBCR_BT2020:
55545554
if (full_range)
5555-
*color_space = COLOR_SPACE_2020_YCBCR;
5555+
*color_space = COLOR_SPACE_2020_YCBCR_FULL;
55565556
else
5557-
return -EINVAL;
5557+
*color_space = COLOR_SPACE_2020_YCBCR_LIMITED;
55585558
break;
55595559

55605560
default:
@@ -6050,7 +6050,7 @@ get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
60506050
if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB)
60516051
color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
60526052
else
6053-
color_space = COLOR_SPACE_2020_YCBCR;
6053+
color_space = COLOR_SPACE_2020_YCBCR_LIMITED;
60546054
break;
60556055
case DRM_MODE_COLORIMETRY_DEFAULT: // ITU601
60566056
default:

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ static int amdgpu_current_colorspace_show(struct seq_file *m, void *data)
11451145
case COLOR_SPACE_2020_RGB_FULLRANGE:
11461146
seq_puts(m, "BT2020_RGB");
11471147
break;
1148-
case COLOR_SPACE_2020_YCBCR:
1148+
case COLOR_SPACE_2020_YCBCR_LIMITED:
11491149
seq_puts(m, "BT2020_YCC");
11501150
break;
11511151
default:

drivers/gpu/drm/amd/display/dc/basics/dc_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ bool is_rgb_cspace(enum dc_color_space output_color_space)
4040
case COLOR_SPACE_YCBCR709:
4141
case COLOR_SPACE_YCBCR601_LIMITED:
4242
case COLOR_SPACE_YCBCR709_LIMITED:
43-
case COLOR_SPACE_2020_YCBCR:
43+
case COLOR_SPACE_2020_YCBCR_LIMITED:
44+
case COLOR_SPACE_2020_YCBCR_FULL:
4445
return false;
4546
default:
4647
/* Add a case to switch */

drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static bool is_ycbcr2020_type(
176176
{
177177
bool ret = false;
178178

179-
if (color_space == COLOR_SPACE_2020_YCBCR)
179+
if (color_space == COLOR_SPACE_2020_YCBCR_LIMITED || color_space == COLOR_SPACE_2020_YCBCR_FULL)
180180
ret = true;
181181
return ret;
182182
}
@@ -247,7 +247,8 @@ void color_space_to_black_color(
247247
case COLOR_SPACE_YCBCR709_BLACK:
248248
case COLOR_SPACE_YCBCR601_LIMITED:
249249
case COLOR_SPACE_YCBCR709_LIMITED:
250-
case COLOR_SPACE_2020_YCBCR:
250+
case COLOR_SPACE_2020_YCBCR_LIMITED:
251+
case COLOR_SPACE_2020_YCBCR_FULL:
251252
*black_color = black_color_format[BLACK_COLOR_FORMAT_YUV_CV];
252253
break;
253254

drivers/gpu/drm/amd/display/dc/core/dc_resource.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,7 +4215,7 @@ static void set_avi_info_frame(
42154215
break;
42164216
case COLOR_SPACE_2020_RGB_FULLRANGE:
42174217
case COLOR_SPACE_2020_RGB_LIMITEDRANGE:
4218-
case COLOR_SPACE_2020_YCBCR:
4218+
case COLOR_SPACE_2020_YCBCR_LIMITED:
42194219
hdmi_info.bits.EC0_EC2 = COLORIMETRYEX_BT2020RGBYCBCR;
42204220
hdmi_info.bits.C0_C1 = COLORIMETRY_EXTENDED;
42214221
break;
@@ -4229,7 +4229,7 @@ static void set_avi_info_frame(
42294229
break;
42304230
}
42314231

4232-
if (pixel_encoding && color_space == COLOR_SPACE_2020_YCBCR &&
4232+
if (pixel_encoding && color_space == COLOR_SPACE_2020_YCBCR_LIMITED &&
42334233
stream->out_transfer_func.tf == TRANSFER_FUNCTION_GAMMA22) {
42344234
hdmi_info.bits.EC0_EC2 = 0;
42354235
hdmi_info.bits.C0_C1 = COLORIMETRY_ITU709;

drivers/gpu/drm/amd/display/dc/dc_hw_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,16 @@ enum dc_color_space {
641641
COLOR_SPACE_YCBCR709_LIMITED,
642642
COLOR_SPACE_2020_RGB_FULLRANGE,
643643
COLOR_SPACE_2020_RGB_LIMITEDRANGE,
644-
COLOR_SPACE_2020_YCBCR,
644+
COLOR_SPACE_2020_YCBCR_LIMITED,
645+
COLOR_SPACE_2020_YCBCR_FULL,
645646
COLOR_SPACE_ADOBERGB,
646647
COLOR_SPACE_DCIP3,
647648
COLOR_SPACE_DISPLAYNATIVE,
648649
COLOR_SPACE_DOLBYVISION,
649650
COLOR_SPACE_APPCTRL,
650651
COLOR_SPACE_CUSTOMPOINTS,
651652
COLOR_SPACE_YCBCR709_BLACK,
653+
COLOR_SPACE_2020_YCBCR = COLOR_SPACE_2020_YCBCR_LIMITED,
652654
};
653655

654656
enum dc_dither_option {

drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ static void dce110_stream_encoder_dp_set_stream_attribute(
420420
dynamic_range_rgb = 1; /*limited range*/
421421
break;
422422
case COLOR_SPACE_2020_RGB_FULLRANGE:
423-
case COLOR_SPACE_2020_YCBCR:
423+
case COLOR_SPACE_2020_YCBCR_LIMITED:
424424
case COLOR_SPACE_XR_RGB:
425425
case COLOR_SPACE_MSREF_SCRGB:
426426
case COLOR_SPACE_ADOBERGB:
@@ -432,6 +432,7 @@ static void dce110_stream_encoder_dp_set_stream_attribute(
432432
case COLOR_SPACE_APPCTRL:
433433
case COLOR_SPACE_CUSTOMPOINTS:
434434
case COLOR_SPACE_UNKNOWN:
435+
default:
435436
/* do nothing */
436437
break;
437438
}

drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_stream_encoder.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void enc1_stream_encoder_dp_set_stream_attribute(
393393
break;
394394
case COLOR_SPACE_2020_RGB_LIMITEDRANGE:
395395
case COLOR_SPACE_2020_RGB_FULLRANGE:
396-
case COLOR_SPACE_2020_YCBCR:
396+
case COLOR_SPACE_2020_YCBCR_LIMITED:
397397
case COLOR_SPACE_XR_RGB:
398398
case COLOR_SPACE_MSREF_SCRGB:
399399
case COLOR_SPACE_ADOBERGB:
@@ -406,6 +406,7 @@ void enc1_stream_encoder_dp_set_stream_attribute(
406406
case COLOR_SPACE_CUSTOMPOINTS:
407407
case COLOR_SPACE_UNKNOWN:
408408
case COLOR_SPACE_YCBCR709_BLACK:
409+
default:
409410
/* do nothing */
410411
break;
411412
}

drivers/gpu/drm/amd/display/dc/dio/dcn401/dcn401_dio_stream_encoder.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ void enc401_stream_encoder_dp_set_stream_attribute(
634634
break;
635635
case COLOR_SPACE_2020_RGB_LIMITEDRANGE:
636636
case COLOR_SPACE_2020_RGB_FULLRANGE:
637-
case COLOR_SPACE_2020_YCBCR:
637+
case COLOR_SPACE_2020_YCBCR_LIMITED:
638638
case COLOR_SPACE_XR_RGB:
639639
case COLOR_SPACE_MSREF_SCRGB:
640640
case COLOR_SPACE_ADOBERGB:
@@ -647,6 +647,7 @@ void enc401_stream_encoder_dp_set_stream_attribute(
647647
case COLOR_SPACE_CUSTOMPOINTS:
648648
case COLOR_SPACE_UNKNOWN:
649649
case COLOR_SPACE_YCBCR709_BLACK:
650+
default:
650651
/* do nothing */
651652
break;
652653
}

drivers/gpu/drm/amd/display/dc/hpo/dcn31/dcn31_hpo_dp_stream_encoder.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static void dcn31_hpo_dp_stream_enc_set_stream_attribute(
323323
break;
324324
case COLOR_SPACE_2020_RGB_LIMITEDRANGE:
325325
case COLOR_SPACE_2020_RGB_FULLRANGE:
326-
case COLOR_SPACE_2020_YCBCR:
326+
case COLOR_SPACE_2020_YCBCR_LIMITED:
327327
case COLOR_SPACE_XR_RGB:
328328
case COLOR_SPACE_MSREF_SCRGB:
329329
case COLOR_SPACE_ADOBERGB:
@@ -336,6 +336,7 @@ static void dcn31_hpo_dp_stream_enc_set_stream_attribute(
336336
case COLOR_SPACE_CUSTOMPOINTS:
337337
case COLOR_SPACE_UNKNOWN:
338338
case COLOR_SPACE_YCBCR709_BLACK:
339+
default:
339340
/* do nothing */
340341
break;
341342
}

0 commit comments

Comments
 (0)