]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/connector: hdmi: Add support for YUV420 format verification
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Tue, 27 May 2025 12:11:10 +0000 (15:11 +0300)
committerMaxime Ripard <mripard@kernel.org>
Mon, 2 Jun 2025 09:02:31 +0000 (11:02 +0200)
Provide the necessary constraints verification in
sink_supports_format_bpc() in order to support handling of YUV420
output format.

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Link: https://lore.kernel.org/r/20250527-hdmi-conn-yuv-v5-2-74c9c4a8ac0c@collabora.com
Signed-off-by: Maxime Ripard <mripard@kernel.org>
drivers/gpu/drm/display/drm_hdmi_state_helper.c

index 97cb4f29c4b5d88f4b6288bd93c6abb33bb7c17a..e026f1ca82848f3be874245c06093d3be8355c5c 100644 (file)
@@ -3,6 +3,7 @@
 #include <drm/drm_atomic.h>
 #include <drm/drm_connector.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_modes.h>
 #include <drm/drm_print.h>
 
 #include <drm/display/drm_hdmi_audio_helper.h>
@@ -408,6 +409,11 @@ sink_supports_format_bpc(const struct drm_connector *connector,
                return false;
        }
 
+       if (drm_mode_is_420_only(info, mode) && format != HDMI_COLORSPACE_YUV420) {
+               drm_dbg_kms(dev, "Mode can be only supported in YUV420 format.\n");
+               return false;
+       }
+
        switch (format) {
        case HDMI_COLORSPACE_RGB:
                drm_dbg_kms(dev, "RGB Format, checking the constraints.\n");
@@ -438,9 +444,36 @@ sink_supports_format_bpc(const struct drm_connector *connector,
                return true;
 
        case HDMI_COLORSPACE_YUV420:
-               /* TODO: YUV420 is unsupported at the moment. */
-               drm_dbg_kms(dev, "YUV420 format isn't supported yet.\n");
-               return false;
+               drm_dbg_kms(dev, "YUV420 format, checking the constraints.\n");
+
+               if (!(info->color_formats & DRM_COLOR_FORMAT_YCBCR420)) {
+                       drm_dbg_kms(dev, "Sink doesn't support YUV420.\n");
+                       return false;
+               }
+
+               if (!drm_mode_is_420(info, mode)) {
+                       drm_dbg_kms(dev, "Mode cannot be supported in YUV420 format.\n");
+                       return false;
+               }
+
+               if (bpc == 10 && !(info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_30)) {
+                       drm_dbg_kms(dev, "10 BPC but sink doesn't support Deep Color 30.\n");
+                       return false;
+               }
+
+               if (bpc == 12 && !(info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_36)) {
+                       drm_dbg_kms(dev, "12 BPC but sink doesn't support Deep Color 36.\n");
+                       return false;
+               }
+
+               if (bpc == 16 && !(info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_48)) {
+                       drm_dbg_kms(dev, "16 BPC but sink doesn't support Deep Color 48.\n");
+                       return false;
+               }
+
+               drm_dbg_kms(dev, "YUV420 format supported in that configuration.\n");
+
+               return true;
 
        case HDMI_COLORSPACE_YUV422:
                drm_dbg_kms(dev, "YUV422 format, checking the constraints.\n");