From dca0703dac7364a3e3cbec8944a69d56ea3d798f Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 13 Feb 2025 16:23:00 +0000 Subject: [PATCH] backend/drm: Add color_range/encoding properties Add the following optional DRM properties, for use by the color-representation-v1 protocol: - COLOR_ENCODING - COLOR_RANGE --- backend/drm/properties.c | 2 ++ include/backend/drm/properties.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/backend/drm/properties.c b/backend/drm/properties.c index 314023954..4c6bdcb36 100644 --- a/backend/drm/properties.c +++ b/backend/drm/properties.c @@ -50,6 +50,8 @@ static const struct prop_info crtc_info[] = { static const struct prop_info plane_info[] = { #define INDEX(name) (offsetof(struct wlr_drm_plane_props, name) / sizeof(uint32_t)) + { "COLOR_ENCODING", INDEX(color_encoding) }, + { "COLOR_RANGE", INDEX(color_range) }, { "CRTC_H", INDEX(crtc_h) }, { "CRTC_ID", INDEX(crtc_id) }, { "CRTC_W", INDEX(crtc_w) }, diff --git a/include/backend/drm/properties.h b/include/backend/drm/properties.h index c02d655ba..20e0a5bff 100644 --- a/include/backend/drm/properties.h +++ b/include/backend/drm/properties.h @@ -65,6 +65,22 @@ struct wlr_drm_plane_props { uint32_t hotspot_x; uint32_t hotspot_y; uint32_t in_fence_fd; + + uint32_t color_encoding; // Not guaranteed to exist + uint32_t color_range; // Not guaranteed to exist +}; + +// Equivalent to wlr_drm_color_encoding defined in the kernel (but not exported) +enum wlr_drm_color_encoding { + WLR_DRM_COLOR_YCBCR_BT601, + WLR_DRM_COLOR_YCBCR_BT709, + WLR_DRM_COLOR_YCBCR_BT2020, +}; + +// Equivalent to wlr_drm_color_range defined in the kernel (but not exported) +enum wlr_drm_color_range { + WLR_DRM_COLOR_YCBCR_FULL_RANGE, + WLR_DRM_COLOR_YCBCR_LIMITED_RANGE, }; bool get_drm_connector_props(int fd, uint32_t id,