drm/rockchip: dw_hdmi_qp: attach the HDMI Colorspace connector property
Subsystems (4)
PATCH v2 1/1 drm/rockchip: dw_hdmi_qp: attach the HDMI Colorspace connector property
The RK3588 HDMI QP output never exposes the "Colorspace" connector property, so userspace has no way to request BT.2020 colorimetry.
Everything needed to signal it is already in place. The connector comes from drm_bridge_connector_init(), which calls drmm_connector_hdmi_init() and attaches "max bpc", "HDR_OUTPUT_METADATA" and the output color format, and the HDMI state helper feeds conn_state->colorspace into the AVI infoframe colorimetry bits via hdmi_generate_avi_infoframe() and drm_hdmi_avi_infoframe_colorimetry(). dw-hdmi-qp then emits the infoframe through its hdmi_write_avi_infoframe hook. Only the property itself is missing, so conn_state->colorspace stays at its default and the AVI infoframe always reports "no colorimetry data".
The user-visible effect is that HDR is unavailable on every RK3588 HDMI output. KWin (Plasma 6.x) requires "Colorspace" alongside "HDR_OUTPUT_METADATA" and "max bpc" before it treats an output as wide-gamut capable, so it never offers the HDR toggle.
Create and attach the property right after the bridge connector is initialised, as vc4_hdmi already does. Passing 0 to drm_mode_create_hdmi_colorspace_property() selects the full HDMI colorspace set defined by the core.
Tested on an Orange Pi 5 Plus driving a Samsung Odyssey G70B: KWin now offers the HDR toggle, the connector property switches to BT2020_RGB once HDR is enabled, and the output runs 4K@144 at 10 bpc.
---
Changes in v2:
- Regenerated with git format-patch. v1 was a hand-assembled diff: it carried no "diff --git" header, no diffstat, and no function context on the @@ hunk header. That is the most likely reason it never showed up in patchwork and got no review in three weeks.
- Rebased onto drm-misc-next (97c03b32b28a), the right tree for this change. The hunk is unchanged apart from its new offset and the function context that format-patch adds.
- Reworded the commit message to lead with the user-visible effect and to name the exact core path that consumes conn_state->colorspace.
- Trimmed the in-code comment to a single line; the reasoning now lives in the commit message instead. No functional change from v1: the two API calls and their placement are the same.
- An automated review of v1 flagged that returning an error from dw_hdmi_qp_rockchip_bind() leaves hdmi->hpd_work queued. That gap pre-dates this patch and is shared by every existing error path in bind() (drmm_encoder_init(), dw_hdmi_qp_bind(), drm_bridge_connector_init()), since cancel_delayed_work_sync() runs only in dw_hdmi_qp_rockchip_unbind(), which the component framework does not call for a failed bind(). It is already being addressed in the HDMI 2.0 series below ("Cancel pending HPD work on suspend", 30/69, and "Control the HPD IRQ line via the bridge HPD ops", 37/69), so this patch adds nothing for it.
v1: https://lore.kernel.org/all/[email protected]/
HDMI 2.0 series: https://lore.kernel.org/all/[email protected]/
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c +7 -0
@@ -695,6 +695,13 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,return dev_err_probe (hdmi->dev,PTR_ERR (connector),"Failed to init bridge connector\n" ); +/* Passing 0 selects the full HDMI colorspace set defined by the core. */ + ret =drm_mode_create_hdmi_colorspace_property (connector,0 ); +if (ret) +return ret; + +drm_connector_attach_colorspace_property (connector); +return 0 ; }
base-commit: 97c03b32b28a9f7f13f768f2b06e1eaafe850e66
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-After-Free in HPD interrupt handler and workqueue due to mismatched devm and drmm lifecycles on bind error paths. --
--- Patch [1]: [PATCH v2] drm/rockchip: dw_hdmi_qp: attach the HDMI Colorspace connector property --- commit 2bdde0ebdaa05708637a2fd7def9b7106821d2d5
Author: Igor Paunovic <[email protected]>
drm/rockchip: dw_hdmi_qp: attach the HDMI Colorspace connector property
This commit attaches the HDMI Colorspace connector property to the RK3588 HDMI QP output, which allows userspace to request BT.2020 colorimetry. This enables HDR support for every RK3588 HDMI output.
Quoted 4 lines
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c +0
-0
[ ... ]
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master, · line 701
Quoted 8 lines
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c +4
-0@@ -695,6 +695,13 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,return dev_err_probe (hdmi->dev,PTR_ERR (connector),"Failed to init bridge connector\n" ); +/* Passing 0 selects the full HDMI colorspace set defined by the core. */ + ret =drm_mode_create_hdmi_colorspace_property (connector,0 ); +if (ret) +return ret;
[Severity: High]
This is a pre-existing issue, but does adding this new error return path introduce a use-after-free risk with the HPD interrupt handler?
As noted in the commit message, the uncancelled hpd_work queue is a known issue on bind error paths, but the same problem applies to the IRQ handler.
In dw_hdmi_qp_rockchip_bind(), the hdmi struct is allocated via drmm_kzalloc(), tying its lifetime to the DRM device:
hdmi = drmm_kzalloc(drm, sizeof(*hdmi), GFP_KERNEL);
However, the interrupt is registered using devm_request_threaded_irq() against the component's platform device (pdev->dev):
ret = devm_request_threaded_irq(hdmi->dev, irq, cfg->ctrl_ops->hardirq_callback, cfg->ctrl_ops->irq_callback, IRQF_SHARED, "dw-hdmi-qp-hpd", hdmi);
If drm_mode_create_hdmi_colorspace_property() fails, the component bind returns an error. This causes the master bind to fail and destroy the DRM device, which frees the hdmi struct.
Because the component device itself remains successfully probed, its devm resources (including the IRQ handler) are not rolled back. If the shared IRQ line fires after this bind failure, will the kernel invoke the handler with the freed hdmi pointer?
Quoted 5 lines
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c +2
-0+ +drm_connector_attach_colorspace_property (connector);return 0 ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hi,
Thank you for the review.
The lifetime mismatch is real and worth spelling out precisely: hdmi is allocated with drmm_kzalloc() against the DRM device, while the HPD interrupt is registered with devm_request_threaded_irq() against the component's platform device, with hdmi as the cookie and IRQF_SHARED set. The bind error paths that follow the IRQ registration predate this
patch: encoder init, dw_hdmi_qp_bind() and drm_bridge_connector_init() can all return with the handler still registered. This patch adds one more such return, which can only trigger if the property allocation fails under memory pressure.
So the issue is pre-existing, correctly flagged as such, and this change does not alter the exposure in any practical way. The clean fix looks orthogonal to this patch: register the IRQ with plain request_threaded_irq() and tie its release to the DRM device with drmm_add_action_or_reset(), so the handler cannot outlive the structure it dereferences. Happy to send that as a separate follow-up if the maintainers think it is worth doing.
Thanks,
Igor
Quoted 53 lines · Igor Paunovic
The RK3588 HDMI QP output never exposes the "Colorspace" connector property, so userspace has no way to request BT.2020 colorimetry.
Everything needed to signal it is already in place. The connector comes from
drm_bridge_connector_init(), which callsdrmm_connector_hdmi_init()and attaches "max bpc", "HDR_OUTPUT_METADATA" and the output color format, and the HDMI state helper feedsconn_state->colorspaceinto the AVI infoframe colorimetry bits viahdmi_generate_avi_infoframe()anddrm_hdmi_avi_infoframe_colorimetry(). dw-hdmi-qp then emits the infoframe through itshdmi_write_avi_infoframehook. Only the property itself is missing, soconn_state->colorspacestays at its default and the AVI infoframe always reports "no colorimetry data".The user-visible effect is that HDR is unavailable on every RK3588 HDMI output. KWin (Plasma 6.x) requires "Colorspace" alongside "
HDR_OUTPUT_METADATA" and "max bpc" before it treats an output as wide-gamut capable, so it never offers the HDR toggle.Create and attach the property right after the bridge connector is initialised, as
vc4_hdmialready does. Passing 0 todrm_mode_create_hdmi_colorspace_property()selects the full HDMI colorspace set defined by the core.Tested on an Orange Pi 5 Plus driving a Samsung Odyssey G70B: KWin now offers the HDR toggle, the connector property switches to
BT2020_RGBonce HDR is enabled, and the output runs 4K@144 at 10 bpc.Signed-off-by Igor Paunovic <[email protected]>---
Changes in v2:
- Regenerated with git format-patch. v1 was a hand-assembled diff: it carried no "diff --git" header, no diffstat, and no function context on the @@ hunk header. That is the most likely reason it never showed up in patchwork and got no review in three weeks.
- Rebased onto drm-misc-next (97c03b32b28a), the right tree for this change. The hunk is unchanged apart from its new offset and the function context that format-patch adds.
- Reworded the commit message to lead with the user-visible effect and to name the exact core path that consumesconn_state->colorspace.
- Trimmed the in-code comment to a single line; the reasoning now lives in the commit message instead. No functional change from v1: the two API calls and their placement are the same.
- An automated review of v1 flagged that returning an error fromdw_hdmi_qp_rockchip_bind()leaveshdmi->hpd_workqueued. That gap pre-dates this patch and is shared by every existing error path inbind()(drmm_encoder_init(),dw_hdmi_qp_bind(),drm_bridge_connector_init()), sincecancel_delayed_work_sync()runs only indw_hdmi_qp_rockchip_unbind(), which the component framework does not call for a failedbind(). It is already being addressed in the HDMI 2.0 series below ("Cancel pending HPD work on suspend", 30/69, and "Control the HPD IRQ line via the bridge HPD ops", 37/69), so this patch adds nothing for it.
Quoted 2 lines
v1: https://lore.kernel.org/all/[email protected]/
HDMI 2.0 series: https://lore.kernel.org/all/[email protected]/
Explicitly adding the author of that patch set into the loop.
Cheers,
Diederik
Quoted 23 lines
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c +7
-0@@ -695,6 +695,13 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,return dev_err_probe (hdmi->dev,PTR_ERR (connector),"Failed to init bridge connector\n" ); +/* Passing 0 selects the full HDMI colorspace set defined by the core. */ + ret =drm_mode_create_hdmi_colorspace_property (connector,0 ); +if (ret) +return ret; + +drm_connector_attach_colorspace_property (connector); +return 0 ; }base-commit:
97c03b32b28a9f7f13f768f2b06e1eaafe850e66
Hi Heiko,
Gentle ping on this one - it has been a month without review.
I re-checked it today rather than assuming: it still applies cleanly on drm-misc-next (8ce26b09f652), with no offset and no fuzz, and nothing merged since attaches the Colorspace property for this connector. So the gap is still there: without it KWin reports the outputs as "HDR:
incapable" on RK3588 even though the sinks and the rest of the kernel side are ready.
The patch is independent of Cristian's dw-hdmi-qp HDMI 2.0 series; that series is not in drm-misc-next yet, and when it lands its patch 34 will touch the first context line of my hunk, so I will rebase and resend as v3 at that point. The change itself does not overlap with it.
Happy to respin if you would rather have it on top of that series.
Thanks,
Igor
Heiko Stübner
maintainerHey Igor,
Am Mittwoch, 9. September 2026, 13:25:40 Mitteleuropäische Sommerzeit schrieb Igor Paunovic:
Quoted 9 lines
Gentle ping on this one - it has been a month without review.
I re-checked it today rather than assuming: it still applies cleanly on drm-misc-next (
8ce26b09f652), with no offset and no fuzz, and nothing merged since attaches the Colorspace property for this connector. So the gap is still there: without it KWin reports the outputs as "HDR:
incapable" on RK3588 even though the sinks and the rest of the kernel side are ready.
Quoted 6 lines
The patch is independent of Cristian's dw-hdmi-qp HDMI 2.0 series; that series is not in drm-misc-next yet, and when it lands its patch 34 will touch the first context line of my hunk, so I will rebase and resend as v3 at that point. The change itself does not overlap with it.
Happy to respin if you would rather have it on top of that series.
yes, the hdmi2.0 series landed meanwhile.
But there is also
https://lore.kernel.org/dri-devel/[email protected]/
which does way more to that colorspace thing, especially doing something into the direction of HDR support it seems.
So really no clue how that all is supposed to work ;-)
Heiko
Heiko Stübner
maintainerAm Dienstag, 20. Oktober 2026, 15:59:18 Mitteleuropäische Sommerzeit schrieb Heiko Stübner:
Quoted 21 lines
Hey Igor,
Am Mittwoch, 9. September 2026, 13:25:40 Mitteleuropäische Sommerzeit schrieb Igor Paunovic:
Quoted 9 lines
Gentle ping on this one - it has been a month without review.
I re-checked it today rather than assuming: it still applies cleanly on drm-misc-next (
8ce26b09f652), with no offset and no fuzz, and nothing merged since attaches the Colorspace property for this connector. So the gap is still there: without it KWin reports the outputs as "HDR:
incapable" on RK3588 even though the sinks and the rest of the kernel side are ready.Quoted 6 lines
The patch is independent of Cristian's dw-hdmi-qp HDMI 2.0 series; that series is not in drm-misc-next yet, and when it lands its patch 34 will touch the first context line of my hunk, so I will rebase and resend as v3 at that point. The change itself does not overlap with it.
Happy to respin if you would rather have it on top of that series.
yes, the hdmi2.0 series landed meanwhile.
Quoted 7 lines
But there is also
https://lore.kernel.org/dri-devel/[email protected]/which does way more to that colorspace thing, especially doing something into the direction of HDR support it seems.
So really no clue how that all is supposed to work ;-)
and of course there is also your HDR'ish-series in
https://lore.kernel.org/dri-devel/[email protected]/
way confusing.