* [PATCH v5 0/8] drm: Add colorspace property support to the HDMI helpers
@ 2026-11-21 13:10 Jan Claußen
2026-11-21 13:11 ` [PATCH v5 6/8] drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry Jan Claußen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jan Claußen @ 2026-11-21 13:10 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 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/20261018143135.5745-1-jan.claussen10@web.de/
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 (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(-)
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v5 6/8] drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry
2026-11-21 13:10 [PATCH v5 0/8] drm: Add colorspace property support to the HDMI helpers Jan Claußen
@ 2026-11-21 13:11 ` Jan Claußen
2026-11-21 13:11 ` [PATCH v5 7/8] drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector Jan Claußen
2026-11-21 13:11 ` [PATCH v5 8/8] drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries Jan Claußen
2 siblings, 0 replies; 4+ messages in thread
From: Jan Claußen @ 2026-11-21 13:11 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
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.
Signed-off-by: Jan Claußen <jan.claussen10@web.de>
---
.../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(-)
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c
index 6db88665060d..87bab11d6f8a 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c
@@ -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;
}
diff --git a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
index b23efb153c9e..412796435af6 100644
--- a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
@@ -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;
}
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index 4705dc6b8bd7..9c0d744ed95b 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -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)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index bfb384142568..41035bf27491 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -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),
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v5 7/8] drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector
2026-11-21 13:10 [PATCH v5 0/8] drm: Add colorspace property support to the HDMI helpers Jan Claußen
2026-11-21 13:11 ` [PATCH v5 6/8] drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry Jan Claußen
@ 2026-11-21 13:11 ` Jan Claußen
2026-11-21 13:11 ` [PATCH v5 8/8] drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries Jan Claußen
2 siblings, 0 replies; 4+ messages in thread
From: Jan Claußen @ 2026-11-21 13:11 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 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.
Signed-off-by: Jan Claußen <jan.claussen10@web.de>
---
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
index f2a1ea8dfefa..24a28b5f4576 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
@@ -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)
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v5 8/8] drm/rockchip: dw_hdmi_qp: Advertise BT.709 and BT.2020 colorimetries
2026-11-21 13:10 [PATCH v5 0/8] drm: Add colorspace property support to the HDMI helpers Jan Claußen
2026-11-21 13:11 ` [PATCH v5 6/8] drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry Jan Claußen
2026-11-21 13:11 ` [PATCH v5 7/8] drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector Jan Claußen
@ 2026-11-21 13:11 ` Jan Claußen
2 siblings, 0 replies; 4+ messages in thread
From: Jan Claußen @ 2026-11-21 13:11 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 24a28b5f4576..890791c5277d 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
@@ -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);
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-21 13:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21 13:10 [PATCH v5 0/8] drm: Add colorspace property support to the HDMI helpers Jan Claußen
2026-11-21 13:11 ` [PATCH v5 6/8] drm/rockchip: vop2: Select the CSC matrix from the DRM colorimetry Jan Claußen
2026-11-21 13:11 ` [PATCH v5 7/8] drm/rockchip: dw_hdmi_qp: Set the VOP2 color space from the connector Jan Claußen
2026-11-21 13:11 ` [PATCH v5 8/8] 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