Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] drm: Add colorspace property support to the HDMI helpers
@ 2026-10-18 14:31 Jan Claußen
  2026-10-18 14:31 ` [PATCH v4 6/7] drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector Jan Claußen
  2026-10-18 14:31 ` [PATCH v4 7/7] drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries Jan Claußen
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Claußen @ 2026-10-18 14:31 UTC (permalink / raw)
  To: Sandy Huang, Heiko Stübner, Andy Yan, Andrzej Hajda,
	Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Dmitry Baryshkov,
	Daniel Stone, Cristian Ciocaltea, Nicolas Frattaroli,
	Jan Claußen
  Cc: dri-devel, linux-rockchip, linux-kernel, linux-arm-kernel

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 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

v3: https://lore.kernel.org/all/20261018123037.19560-1-jan.claussen10@web.de
v2: https://lore.kernel.org/all/20261011142733.7806-1-jan.claussen10@web.de
v1: https://lore.kernel.org/all/20261011132024.2833-1-jan.claussen10@web.de

Jan Claußen (7):
  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: 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_hdmi_qp-rockchip.c    | 20 +++++++++++++++++++
 include/drm/bridge/dw_hdmi_qp.h               |  2 ++
 include/drm/drm_bridge.h                      |  7 +++++++
 include/drm/drm_connector.h                   |  7 +++++++
 8 files changed, 58 insertions(+), 5 deletions(-)

-- 
2.56.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v4 6/7] drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector
  2026-10-18 14:31 [PATCH v4 0/7] drm: Add colorspace property support to the HDMI helpers Jan Claußen
@ 2026-10-18 14:31 ` Jan Claußen
  2026-10-18 14:31 ` [PATCH v4 7/7] drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries Jan Claußen
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Claußen @ 2026-10-18 14:31 UTC (permalink / raw)
  To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Jan Claußen, dri-devel, linux-rockchip, linux-arm-kernel,
	linux-kernel

VOP2 converts RGB to YCbCr using the matrix selected by the CRTC
state's color_space, 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.

Derive color_space from the connector colorspace before the early
return, so that a colorspace change alone is applied.

Signed-off-by: Jan Claußen <jan.claussen10@web.de>
---
 drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
index 9c4cf68d79d5..10c5b6d6406e 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
@@ -17,6 +17,7 @@
 #include <linux/phy/phy.h>
 #include <linux/phy/phy-hdmi.h>
 #include <linux/regmap.h>
+#include <linux/videodev2.h>
 #include <linux/workqueue.h>
 
 #include <drm/bridge/dw_hdmi_qp.h>
@@ -187,6 +188,19 @@ static int dw_hdmi_qp_rockchip_get_vop_format(struct drm_encoder *encoder,
 	return bstate->output_bus_cfg.format;
 }
 
+static u32
+dw_hdmi_qp_rockchip_color_space(const struct drm_connector_state *conn_state)
+{
+	switch (conn_state->colorspace) {
+	case DRM_MODE_COLORIMETRY_BT2020_RGB:
+	case DRM_MODE_COLORIMETRY_BT2020_YCC:
+	case DRM_MODE_COLORIMETRY_BT2020_CYCC:
+		return V4L2_COLORSPACE_BT2020;
+	default:
+		return V4L2_COLORSPACE_DEFAULT;
+	}
+}
+
 static int
 dw_hdmi_qp_rockchip_encoder_atomic_check(struct drm_encoder *encoder,
 					 struct drm_crtc_state *crtc_state,
@@ -202,6 +216,8 @@ dw_hdmi_qp_rockchip_encoder_atomic_check(struct drm_encoder *encoder,
 	if (ingest_fmt < 0)
 		return -EINVAL;
 
+	s->color_space = dw_hdmi_qp_rockchip_color_space(conn_state);
+
 	if (hdmi->tmds_char_rate == conn_state->hdmi.tmds_char_rate &&
 	    s->output_bpc == conn_state->hdmi.output_bpc &&
 	    s->bus_format == ingest_fmt)
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v4 7/7] drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries
  2026-10-18 14:31 [PATCH v4 0/7] drm: Add colorspace property support to the HDMI helpers Jan Claußen
  2026-10-18 14:31 ` [PATCH v4 6/7] drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector Jan Claußen
@ 2026-10-18 14:31 ` Jan Claußen
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Claußen @ 2026-10-18 14:31 UTC (permalink / raw)
  To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Jan Claußen, dri-devel, linux-rockchip, linux-arm-kernel,
	linux-kernel

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.

Signed-off-by: Jan Claußen <jan.claussen10@web.de>
---
 drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
index 10c5b6d6406e..e677aacf5a33 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
@@ -621,6 +621,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);
 
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-18 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-18 14:31 [PATCH v4 0/7] drm: Add colorspace property support to the HDMI helpers Jan Claußen
2026-10-18 14:31 ` [PATCH v4 6/7] drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector Jan Claußen
2026-10-18 14:31 ` [PATCH v4 7/7] drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries Jan Claußen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox