HDMI connectors initialised through drmm_connector_hdmi_init() do not
expose the colorspace property, so userspace cannot signal colorimetry
such as BT.2020 for HDR output. KWin, for instance, does not offer HDR
without it.

Add a supported_colorspaces bitmask to struct drm_connector_hdmi_funcs.
If a driver sets it, create and attach the colorspace property with
the colorspaces it lists, next to the other HDMI properties.

Signed-off-by: Jan Claußen <[email protected]>
---
 drivers/gpu/drm/drm_connector.c | 9 +++++++++
 include/drm/drm_connector.h     | 7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 66f53e155342..eea27bb6557c 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -672,6 +672,15 @@ int drmm_connector_hdmi_init(struct drm_device *dev,
        /* TODO: remove after conversion to new drmm_connector_hdmi_init() */
        connector->max_bpc = hdmi_funcs->max_bpc;
 
+       if (hdmi_funcs->supported_colorspaces) {
+               ret = drm_mode_create_hdmi_colorspace_property(connector,
+                                                              
hdmi_funcs->supported_colorspaces);
+               if (ret)
+                       return ret;
+
+               drm_connector_attach_colorspace_property(connector);
+       }
+
        if (hdmi_funcs->max_bpc > 8)
                drm_connector_attach_hdr_output_metadata_property(connector);
 
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 2ee7c59329aa..9d2d133463ba 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1521,6 +1521,13 @@ struct drm_connector_hdmi_funcs {
         */
        unsigned long supported_formats;
 
+       /**
+        * @supported_colorspaces:
+        *
+        * Bitmask of &enum drm_colorspace listing supported color spaces.
+        */
+       unsigned long supported_colorspaces;
+
        /**
         * @max_bpc: Maximum bits per char the HDMI connector supports.
         */
-- 
2.56.0

Reply via email to