Skip to contentSkip to conversation

drm: Add colorspace property support to the HDMI helpers

PATCH Superseded Jan Claußen 2 participants 10 messages Nov 21

Subsystems (5)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover drm: Add colorspace property support to the HDMI helpers

HDMI connectors set up through drmm_connector_hdmi_init() don't expose the colorspace property, so userspace can't signal BT.2020 colorimetry for HDR. KWin, for example, doesn't offer HDR without it.

This series lets drivers declare which colorspaces they support and has the HDMI helpers create the property and force a modeset when it changes. dw-hdmi-qp on RK3588 is the first user.

Tested on a Radxa Rock 5B (RK3588) with an LG OLED55B87LC in KDE Plasma 6.7.5. Only BT.2020 RGB is tested.

Changes in v5:
- Convert VOP2 from V4L2 colorspace values to enum drm_colorspace, so the HDMI glue doesn't need a V4L2 translation (Cristian)
- dw_hdmi_qp: Pass conn_state->colorspace directly and set it before the early return, so a colorspace change alone is applied

Changes in v4:
- Set the VOP2 color space from the connector colorspace, so YCbCr output is converted with the matching matrix (Sashiko)

Changes in v3:
- Move colorspace handling into the HDMI helpers (Maxime)
- Let drivers declare supported colorspaces instead of exposing all
- Split into a series

Changes in v2:
- Fix possible null pointer dereferencing requested by the Sashiko bot

v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]
v2: https://lore.kernel.org/all/[email protected]
v1: https://lore.kernel.org/all/[email protected]

Jan Claußen (8):
drm/connector: Fix typo in colorspace error messages drm/display: hdmi-state-helper: Force modeset on colorspace change drm/connector: hdmi: Create the colorspace property drm/bridge-connector: Pass supported colorspaces to the HDMI helpers drm/bridge: dw-hdmi-qp: Forward supported colorspaces from platform
data
drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries

 drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c  |  3 ++
 .../gpu/drm/display/drm_bridge_connector.c    |  4 ++
 .../gpu/drm/display/drm_hdmi_state_helper.c   |  3 +-
 drivers/gpu/drm/drm_connector.c               | 17 +++++++--
 .../gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c  |  3 --
 drivers/gpu/drm/rockchip/dw_dp-rockchip.c     |  2 -
 .../gpu/drm/rockchip/dw_hdmi_qp-rockchip.c    |  6 +++
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c  | 37 +++++++------------
 include/drm/bridge/dw_hdmi_qp.h               |  2 +
 include/drm/drm_bridge.h                      |  7 ++++
 include/drm/drm_connector.h                   |  7 ++++
 12 files changed, 59 insertions(+), 34 deletions(-)
Signature · 1 line
2.56.0
#1 lore raw

PATCH v5 1/8 drm/connector: Fix typo in colorspace error messages

Change provded to provided.

---
 drivers/gpu/drm/drm_connector.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_connector.c +4 -4
index 893716a9e489..66f53e155342 100644
@@ -2768,14 +2768,14 @@ static int drm_mode_create_colorspace_property(struct drm_connector *connector,
 		return 0;
 
 	if (!supported_colorspaces) {
-		drm_err(dev, "No supported colorspaces provded on [CONNECTOR:%d:%s]\n",
-			    connector->base.id, connector->name);
+		drm_err(dev, "No supported colorspaces provided on [CONNECTOR:%d:%s]\n",
+			connector->base.id, connector->name);
 		return -EINVAL;
 	}
 
 	if ((supported_colorspaces & -BIT(DRM_MODE_COLORIMETRY_COUNT)) != 0) {
-		drm_err(dev, "Unknown colorspace provded on [CONNECTOR:%d:%s]\n",
-			    connector->base.id, connector->name);
+		drm_err(dev, "Unknown colorspace provided on [CONNECTOR:%d:%s]\n",
+			connector->base.id, connector->name);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.56.0
#2 lore raw

PATCH v5 2/8 drm/display: hdmi-state-helper: Force modeset on colorspace change

In reply to Jan Claußen

The colorimetry signalled to the sink is part of the AVI infoframe, which is only updated on a modeset. A change of the colorspace property therefore never reaches the sink.

Treat a colorspace change like a change of the Broadcast RGB, output bpc or output format, and force a modeset.

---
 drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/display/drm_hdmi_state_helper.c +2 -1
index 7cdb7ca3dc12..9368e53c5945 100644
@@ -925,7 +925,8 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
 
 	if (old_conn_state->hdmi.broadcast_rgb != new_conn_state->hdmi.broadcast_rgb ||
 	    old_conn_state->hdmi.output_bpc != new_conn_state->hdmi.output_bpc ||
-	    old_conn_state->hdmi.output_format != new_conn_state->hdmi.output_format) {
+	    old_conn_state->hdmi.output_format != new_conn_state->hdmi.output_format ||
+	    old_conn_state->colorspace != new_conn_state->colorspace) {
 		struct drm_crtc *crtc = new_conn_state->crtc;
 		struct drm_crtc_state *crtc_state;
 
Signature · 1 line
2.56.0
#3 lore raw

PATCH v5 3/8 drm/connector: hdmi: Create the colorspace property

In reply to Jan Claußen

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.

---
 drivers/gpu/drm/drm_connector.c | 9 +++++++++
 include/drm/drm_connector.h     | 7 +++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/drm_connector.c +9 -0
index 66f53e155342..eea27bb6557c 100644
@@ -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);
 
include/drm/drm_connector.h +7 -0
index 2ee7c59329aa..9d2d133463ba 100644
@@ -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.
 	 */
Signature · 1 line
2.56.0
#4 lore raw

PATCH v5 4/8 drm/bridge-connector: Pass supported colorspaces to the HDMI helpers

In reply to Jan Claußen

Add a supported_colorspaces field to struct drm_bridge so HDMI bridges can declare the colorimetries they support, and pass it on to drmm_connector_hdmi_init() so the colorspace property gets created.

---
 drivers/gpu/drm/display/drm_bridge_connector.c | 4 ++++
 include/drm/drm_bridge.h                       | 7 +++++++
 2 files changed, 11 insertions(+)
drivers/gpu/drm/display/drm_bridge_connector.c +4 -0
index 81f3e26f6fdf..40f50304c46f 100644
@@ -1042,6 +1042,10 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 			bridge_connector->hdmi_funcs.supported_formats =
 				bridge_connector->bridge_hdmi->supported_formats;
 
+		if (bridge_connector->bridge_hdmi->supported_colorspaces)
+			bridge_connector->hdmi_funcs.supported_colorspaces =
+				bridge_connector->bridge_hdmi->supported_colorspaces;
+
 		if (!connector->ycbcr_420_allowed)
 			bridge_connector->hdmi_funcs.supported_formats &=
 				~BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420);
include/drm/drm_bridge.h +7 -0
index 1981d24a700d..b46d34040024 100644
@@ -1129,6 +1129,13 @@ struct drm_bridge {
 	 */
 	unsigned int supported_formats;
 
+	/**
+	 * @supported_colorspaces: Bitmask of &enum drm_colorspace listing
+	 * supported color spaces. This is only relevant if @DRM_BRIDGE_OP_HDMI
+	 * is set.
+	 */
+	unsigned int supported_colorspaces;
+
 	/**
 	 * @max_tmds_char_rate: Maximum TMDS character rate, in Hz, the HDMI
 	 * bridge supports. A value of 0 means the core should use the default
Signature · 1 line
2.56.0
#5 lore raw

PATCH v5 5/8 drm/bridge: dw-hdmi-qp: Forward supported colorspaces from platform data

In reply to Jan Claußen

Let platform glue drivers declare the supported colorspaces, the same way they already declare supported output formats and max bpc.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c | 3 +++
 include/drm/bridge/dw_hdmi_qp.h              | 2 ++
 2 files changed, 5 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c +3 -0
index b268c9376087..81180e9e8d94 100644
@@ -1170,6 +1170,9 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
 	if (plat_data->supported_formats)
 		hdmi->bridge.supported_formats = plat_data->supported_formats;
 
+	if (plat_data->supported_colorspaces)
+		hdmi->bridge.supported_colorspaces = plat_data->supported_colorspaces;
+
 	if (plat_data->max_bpc)
 		hdmi->bridge.max_bpc = plat_data->max_bpc;
 
include/drm/bridge/dw_hdmi_qp.h +2 -0
index ad33f9cafdeb..c336bd40c9cb 100644
@@ -28,6 +28,8 @@ struct dw_hdmi_qp_plat_data {
 	unsigned long ref_clk_rate;
 	/* Supported output formats: bitmask of @drm_output_color_format */
 	unsigned int supported_formats;
+	/* Supported colorspaces: bitmask of &enum drm_colorspace */
+	unsigned int supported_colorspaces;
 	/* Maximum bits per color channel: 8, 10 or 12 */
 	unsigned int max_bpc;
 };
Signature · 1 line
2.56.0
#6 lore raw

PATCH v5 6/8 drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry

In reply to Jan Claußen

The color_space field in struct rockchip_crtc_state holds V4L2 colorspace values, a leftover from the vendor kernel. The DP and DSI2 encoders only ever set V4L2_COLORSPACE_DEFAULT, so VOP2 always ends up with BT.709. An HDMI encoder that wants to honour the connector colorspace property would have to translate DRM colorimetry into V4L2 values, only for VOP2 to map them back to a CSC matrix.

Store the connector's enum drm_colorspace in the CRTC state instead and pick the CSC matrix from DRM_MODE_COLORIMETRY_* directly. Since DRM_MODE_COLORIMETRY_DEFAULT is 0, the zero-initialised state keeps the current BT.709 behaviour and the encoder assignments can go.

No functional change.

---
 .../gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c  |  3 --
 drivers/gpu/drm/rockchip/dw_dp-rockchip.c     |  2 -
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c  | 37 +++++++------------
 4 files changed, 15 insertions(+), 29 deletions(-)
drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c +0 -3
index 6db88665060d..87bab11d6f8a 100644
@@ -23,8 +23,6 @@
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_of.h>
 
-#include <uapi/linux/videodev2.h>
-
 #include "rockchip_drm_drv.h"
 
 #define PSEC_PER_SEC			1000000000000LL
@@ -268,7 +266,6 @@ dw_mipi_dsi2_encoder_atomic_check(struct drm_encoder *encoder,
 
 	s->output_type = DRM_MODE_CONNECTOR_DSI;
 	s->bus_flags = info->bus_flags;
-	s->color_space = V4L2_COLORSPACE_DEFAULT;
 
 	return 0;
 }
drivers/gpu/drm/rockchip/dw_dp-rockchip.c +0 -2
index b23efb153c9e..412796435af6 100644
@@ -10,7 +10,6 @@
 #include <linux/media-bus-format.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
-#include <linux/videodev2.h>
 
 #include <drm/bridge/dw_dp.h>
 #include <drm/drm_atomic_helper.h>
@@ -62,7 +61,6 @@ static int dw_dp_encoder_atomic_check(struct drm_encoder *encoder,
 	s->output_type = DRM_MODE_CONNECTOR_DisplayPort;
 	s->bus_format = bus_format;
 	s->bus_flags = di->bus_flags;
-	s->color_space = V4L2_COLORSPACE_DEFAULT;
 
 	return 0;
 }
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1 -1
index 4705dc6b8bd7..9c0d744ed95b 100644
@@ -56,7 +56,7 @@ struct rockchip_crtc_state {
 	bool yuv_overlay;
 	u32 bus_format;
 	u32 bus_flags;
-	int color_space;
+	enum drm_colorspace colorspace;
 };
 #define to_rockchip_crtc_state(s) \
 		container_of(s, struct rockchip_crtc_state, base)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +14 -23
index bfb384142568..41035bf27491 100644
@@ -33,8 +33,6 @@
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
 
-#include <uapi/linux/videodev2.h>
-
 #include "rockchip_drm_gem.h"
 #include "rockchip_drm_vop2.h"
 #include "rockchip_rgb.h"
@@ -647,20 +645,13 @@ static void vop2_setup_scale(struct vop2 *vop2, const struct vop2_win *win,
 	}
 }
 
-static int vop2_convert_csc_mode(int csc_mode)
+static enum vop_csc_format
+vop2_convert_csc_mode(enum drm_colorspace colorspace)
 {
-	switch (csc_mode) {
-	case V4L2_COLORSPACE_SMPTE170M:
-	case V4L2_COLORSPACE_470_SYSTEM_M:
-	case V4L2_COLORSPACE_470_SYSTEM_BG:
-		return CSC_BT601L;
-	case V4L2_COLORSPACE_REC709:
-	case V4L2_COLORSPACE_SMPTE240M:
-	case V4L2_COLORSPACE_DEFAULT:
-		return CSC_BT709L;
-	case V4L2_COLORSPACE_JPEG:
-		return CSC_BT601F;
-	case V4L2_COLORSPACE_BT2020:
+	switch (colorspace) {
+	case DRM_MODE_COLORIMETRY_BT2020_RGB:
+	case DRM_MODE_COLORIMETRY_BT2020_YCC:
+	case DRM_MODE_COLORIMETRY_BT2020_CYCC:
 		return CSC_BT2020L;
 	default:
 		return CSC_BT709L;
@@ -707,8 +698,8 @@ static void vop2_setup_csc_mode(struct vop2_video_port *vp,
 	struct rockchip_crtc_state *vcstate = to_rockchip_crtc_state(vp->crtc.state);
 	int is_input_yuv = pstate->fb->format->is_yuv;
 	int is_output_yuv = is_yuv_output(vcstate->bus_format);
-	int input_csc = V4L2_COLORSPACE_DEFAULT;
-	int output_csc = vcstate->color_space;
+	enum drm_colorspace input_csc = DRM_MODE_COLORIMETRY_DEFAULT;
+	enum drm_colorspace output_csc = vcstate->colorspace;
 	bool r2y_en, y2r_en;
 	int csc_mode;
 
@@ -797,10 +788,10 @@ vop2_rgb2yuv_get_matrix(enum vop_csc_format csc)
 }
 
 /* Convert an RGB (16bpc) to YUV444 (16bpc). */
-static void vop2_rgb16_to_yuv16(int v4l2_cs, u16 r, u16 g, u16 b,
-				u16 *y, u16 *cb, u16 *cr)
+static void vop2_rgb16_to_yuv16(enum drm_colorspace colorspace,
+				u16 r, u16 g, u16 b, u16 *y, u16 *cb, u16 *cr)
 {
-	enum vop_csc_format csc = vop2_convert_csc_mode(v4l2_cs);
+	enum vop_csc_format csc = vop2_convert_csc_mode(colorspace);
 	const struct rgb2yuv_matrix *m = vop2_rgb2yuv_get_matrix(csc);
 	s64 rs = r, gs = g, bs = b;
 	s64 ys, cbs, crs;
@@ -1652,7 +1643,7 @@ static void vop2_bgcolor_setup(struct drm_crtc *crtc, bool force,
 	u32 val;
 
 	if (!force && old_crtc_state->background_color == bgcolor &&
-	    old_vcstate->color_space == new_vcstate->color_space)
+	    old_vcstate->colorspace == new_vcstate->colorspace)
 		return;
 
 	/*
@@ -1660,7 +1651,7 @@ static void vop2_bgcolor_setup(struct drm_crtc *crtc, bool force,
 	 * format when operating in YUV overlay mode, and RGB otherwise.
 	 */
 	if (new_vcstate->yuv_overlay) {
-		vop2_rgb16_to_yuv16(new_vcstate->color_space,
+		vop2_rgb16_to_yuv16(new_vcstate->colorspace,
 				    DRM_ARGB64_GETR(bgcolor),
 				    DRM_ARGB64_GETG(bgcolor),
 				    DRM_ARGB64_GETB(bgcolor),
@@ -2140,7 +2131,7 @@ static int vop2_crtc_state_dump(struct drm_crtc *crtc, struct seq_file *s)
 	seq_printf(s, "\tbus_format[%x]: %s\n", vcstate->bus_format,
 		   drm_get_bus_format_name(vcstate->bus_format));
 	seq_printf(s, "\toutput_mode[%x]", vcstate->output_mode);
-	seq_printf(s, " color_space[%d]\n", vcstate->color_space);
+	seq_printf(s, " colorspace[%d]\n", vcstate->colorspace);
 	seq_printf(s, "\tbackground color (10bpc): r=0x%x g=0x%x b=0x%x\n",
 		   DRM_ARGB64_GETR_BPCS(cstate->background_color, 10),
 		   DRM_ARGB64_GETG_BPCS(cstate->background_color, 10),
Signature · 1 line
2.56.0
#7 lore raw

Re: [PATCH v5 6/8] drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] drm/rockchip: vop2: dropped BT.601 mappings in vop2_convert_csc_mode() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] drm/rockchip: vop2: dropped BT.601 mappings in vop2_convert_csc_mode()
--

commit 2d1b69aeefd3a8b09e750140ac04acf448f1e9ea
Author: Jan Claußen <[email protected]>

drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry

This commit replaces the V4L2 colorspace field in struct rockchip_crtc_state with enum drm_colorspace and selects the VOP2 CSC format directly from DRM_MODE_COLORIMETRY_* values.

Quoted 4 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +0 -0
index bfb3841425687..41035bf27491d 100644

[ ... ]

Quoted 17 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +2 -10
@@ -647,20 +645,13 @@ static void vop2_setup_scale(struct vop2 *vop2, const struct vop2_win *win,
 	}
 }
 
-static int vop2_convert_csc_mode(int csc_mode)
+static enum vop_csc_format
+vop2_convert_csc_mode(enum drm_colorspace colorspace)
 {
-	switch (csc_mode) {
-	case V4L2_COLORSPACE_SMPTE170M:
-	case V4L2_COLORSPACE_470_SYSTEM_M:
-	case V4L2_COLORSPACE_470_SYSTEM_BG:
-		return CSC_BT601L;
-	case V4L2_COLORSPACE_REC709:
-	case V4L2_COLORSPACE_SMPTE240M:
-	case V4L2_COLORSPACE_DEFAULT:
-		return CSC_BT709L;

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c static void vop2_setup_scale(struct vop2 *vop2, const struct vop2_win *win, · line 657

Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +4 -3
-	case V4L2_COLORSPACE_JPEG:
-		return CSC_BT601F;
-	case V4L2_COLORSPACE_BT2020:
+	switch (colorspace) {
+	case DRM_MODE_COLORIMETRY_BT2020_RGB:
+	case DRM_MODE_COLORIMETRY_BT2020_YCC:
+	case DRM_MODE_COLORIMETRY_BT2020_CYCC:
 		return CSC_BT2020L;
 	default:
 		return CSC_BT709L;

[Severity: Low]
Should vop2_convert_csc_mode() keep mappings for BT.601 colorimetries (such as DRM_MODE_COLORIMETRY_SMPTE_170M_YCC and DRM_MODE_COLORIMETRY_BT601_YCC), or should the unused BT.601 matrix tables be dropped if BT.601 is not needed?

Dropping CSC_BT601L and CSC_BT601F here causes any BT.601 colorspace to fall back to CSC_BT709L and leaves the CSC_BT601L and CSC_BT601F cases (and rgb2yuv_bt601l / rgb2yuv_bt601f) in vop2_rgb2yuv_get_matrix() unreachable.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#8 lore raw

PATCH v5 7/8 drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector

In reply to Jan Claußen

VOP2 converts RGB to YCbCr using the matrix selected by the CRTC state's colorspace, but the HDMI encoder never sets it, so VOP2 always converts with BT.709. Once the colorspace property can signal BT.2020 colorimetry to the sink, a YCbCr output would be encoded with BT.709 and decoded with BT.2020.

Pass the connector colorspace on to VOP2, and do so before the early return so that a colorspace change alone is applied.

---
 drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c +2 -0
index f2a1ea8dfefa..24a28b5f4576 100644
@@ -205,6 +205,8 @@ dw_hdmi_qp_rockchip_encoder_atomic_check(struct drm_encoder *encoder,
 	if (ingest_fmt < 0)
 		return -EINVAL;
 
+	s->colorspace = conn_state->colorspace;
+
 	if (hdmi->tmds_char_rate == conn_state->hdmi.tmds_char_rate &&
 	    s->output_bpc == conn_state->hdmi.output_bpc &&
 	    s->bus_format == ingest_fmt)
Signature · 1 line
2.56.0
#9 lore raw

PATCH v5 8/8 drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries

In reply to Jan Claußen

Expose BT.2020 RGB and YCC colorimetry so userspace can enable HDR output. Also explicitly expose BT.709 YCC as it is listed in the Rockchip RK3588 TRM V1.0-Part2 20220309 data sheet.

Tested on a Radxa Rock 5B (RK3588) with an LG OLED55B87LC in KDE Plasma 6.7.5: enabling HDR switches the colorspace to BT.2020, and disabling it restores the default.

---
 drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c +4 -0
index 24a28b5f4576..890791c5277d 100644
@@ -644,6 +644,10 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,
 				      BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444) |
 				      BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422);
 
+	plat_data.supported_colorspaces = BIT(DRM_MODE_COLORIMETRY_BT709_YCC) |
+				      BIT(DRM_MODE_COLORIMETRY_BT2020_RGB) |
+				      BIT(DRM_MODE_COLORIMETRY_BT2020_YCC);
+
 	encoder = &hdmi->encoder.encoder;
 	encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
 
Signature · 1 line
2.56.0