[PATCH v8 05/20] drm/display: hdmi-state-helper: Act on color format DRM property

Nicolas Frattaroli nicolas.frattaroli at collabora.com
Mon Feb 16 05:01:19 PST 2026


With the introduction of the "color format" DRM property, which allows
userspace to request a specific color format, the HDMI state helper
should implement this.

Implement it by translating the requested drm_color_format_enum to an
hdmi_colorspace enum value. Auto is translated to RGB, and a fallback to
YUV420 is only performed if the original color format was auto.

Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli at collabora.com>
---
 drivers/gpu/drm/display/drm_hdmi_state_helper.c | 28 +++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index a1d16762ac7a..3ba752200984 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -649,10 +649,34 @@ hdmi_compute_config(const struct drm_connector *connector,
 	unsigned int max_bpc = clamp_t(unsigned int,
 				       conn_state->max_bpc,
 				       8, connector->max_bpc);
+	enum hdmi_colorspace fmt;
 	int ret;
 
-	ret = hdmi_compute_format_bpc(connector, conn_state, mode, max_bpc,
-				      HDMI_COLORSPACE_RGB);
+	switch (conn_state->color_format) {
+	case DRM_COLOR_FORMAT_ENUM_AUTO:
+	case DRM_COLOR_FORMAT_ENUM_RGB444:
+		fmt = HDMI_COLORSPACE_RGB;
+		break;
+	case DRM_COLOR_FORMAT_ENUM_YCBCR444:
+		fmt = HDMI_COLORSPACE_YUV444;
+		break;
+	case DRM_COLOR_FORMAT_ENUM_YCBCR422:
+		fmt = HDMI_COLORSPACE_YUV422;
+		break;
+	case DRM_COLOR_FORMAT_ENUM_YCBCR420:
+		fmt = HDMI_COLORSPACE_YUV420;
+		break;
+	default:
+		drm_dbg_kms(connector->dev, "HDMI does not support color format '%s'.\n",
+			    drm_get_color_format_name(conn_state->color_format));
+		return -EINVAL;
+	}
+
+	ret = hdmi_compute_format_bpc(connector, conn_state, mode, max_bpc, fmt);
+
+	if (conn_state->color_format != DRM_COLOR_FORMAT_ENUM_AUTO)
+		return ret;
+
 	if (ret) {
 		if (connector->ycbcr_420_allowed) {
 			ret = hdmi_compute_format_bpc(connector, conn_state,

-- 
2.53.0




More information about the Linux-rockchip mailing list