]> git.hungrycats.org Git - linux/commitdiff
drm/amd/display: Honor Broadcast RGB for BT.2020 RGB output
authorSatyajit Roy <sroy14@alum.utk.edu>
Sun, 30 Aug 2026 03:52:06 +0000 (03:52 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 10 Sep 2026 16:55:28 +0000 (12:55 -0400)
amdgpu_dm_get_output_color_space() applies the Broadcast RGB connector
property to default RGB output, but always selects full-range output for
BT.2020 RGB. Consequently, explicitly selecting Limited has no effect on
the output CSC or AVI InfoFrame when HDR uses BT.2020 RGB.

Select COLOR_SPACE_2020_RGB_LIMITEDRANGE when the output encoding is RGB
and Broadcast RGB is Limited. Keep Automatic and Full at full range, and
leave YCbCr output unchanged.

Add KUnit coverage for limited-range RGB output through both BT.2020
connector colorspace values.

Fixes: 6eb4c13a3845 ("drm/amd/display: Support "Broadcast RGB" drm property")
Signed-off-by: Satyajit Roy <sroy14@alum.utk.edu>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 022236eaa63bbf65761aa8aec43f661451a94654)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c

index d037738872147a9c9673204cce9aeba5a7f6d560..154e1f35dcb190d2a564443483a543293111939a 100644 (file)
@@ -756,10 +756,14 @@ amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
                break;
        case DRM_MODE_COLORIMETRY_BT2020_RGB:
        case DRM_MODE_COLORIMETRY_BT2020_YCC:
-               if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB)
-                       color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
-               else
+               if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) {
+                       if (connector_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED)
+                               color_space = COLOR_SPACE_2020_RGB_LIMITEDRANGE;
+                       else
+                               color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
+               } else {
                        color_space = COLOR_SPACE_2020_YCBCR_LIMITED;
+               }
                break;
        case DRM_MODE_COLORIMETRY_DEFAULT: /* ITU601 */
        default:
index 0d2f9dbce0a9ffbc5b377dfdcdcb826f0ff0c505..212a7536e65b7fde69d77b20a48273c96f1a26a2 100644 (file)
@@ -567,6 +567,23 @@ static void dm_test_output_color_space_bt2020_rgb(struct kunit *test)
                        (int)COLOR_SPACE_2020_RGB_FULLRANGE);
 }
 
+/**
+ * dm_test_output_color_space_bt2020_rgb_limited - Test limited BT.2020 RGB
+ * @test: The KUnit test context
+ */
+static void dm_test_output_color_space_bt2020_rgb_limited(struct kunit *test)
+{
+       struct dc_crtc_timing timing = {};
+       struct drm_connector_state state = {};
+
+       timing.pixel_encoding = PIXEL_ENCODING_RGB;
+       state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB;
+       state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED;
+
+       KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+                       (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE);
+}
+
 /**
  * dm_test_output_color_space_bt2020_ycc - Test Output color space bt2020 ycc
  * @test: The KUnit test context
@@ -638,6 +655,24 @@ static void dm_test_output_color_space_bt2020_ycc_rgb_encoding(struct kunit *tes
                        (int)COLOR_SPACE_2020_RGB_FULLRANGE);
 }
 
+/**
+ * dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited - Test limited
+ * BT.2020 RGB output selected through the BT.2020 YCC connector colorspace
+ * @test: The KUnit test context
+ */
+static void dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited(struct kunit *test)
+{
+       struct dc_crtc_timing timing = {};
+       struct drm_connector_state state = {};
+
+       timing.pixel_encoding = PIXEL_ENCODING_RGB;
+       state.colorspace = DRM_MODE_COLORIMETRY_BT2020_YCC;
+       state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED;
+
+       KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+                       (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE);
+}
+
 /**
  * dm_test_output_color_space_bt2020_rgb_ycc_encoding - Test Output color space
  * bt2020 rgb with non-rgb pixel encoding falls back to limited ycbcr
@@ -5422,10 +5457,12 @@ static struct kunit_case amdgpu_dm_connector_tests[] = {
        KUNIT_CASE(dm_test_output_color_space_bt709_y_only),
        KUNIT_CASE(dm_test_output_color_space_oprgb),
        KUNIT_CASE(dm_test_output_color_space_bt2020_rgb),
+       KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_limited),
        KUNIT_CASE(dm_test_output_color_space_bt2020_ycc),
        KUNIT_CASE(dm_test_output_color_space_default_ycbcr709_y_only),
        KUNIT_CASE(dm_test_output_color_space_default_ycbcr601),
        KUNIT_CASE(dm_test_output_color_space_bt2020_ycc_rgb_encoding),
+       KUNIT_CASE(dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited),
        KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_ycc_encoding),
        /* Tests for amdgpu_dm_convert_dc_color_depth_into_bpc */
        KUNIT_CASE(dm_test_convert_color_depth_bpc_mappings),