Add a "min bpc" connector property
Subsystems (2)
v2 cover Add a "min bpc" connector property
This series is an alternative to the link-bpc[1] series, which implemented an immutable property to determine the output's bit depth. The link bpc property wasn't very liked as it'd only be updated after an atomic commit went through. For a userspace that's trying to evaluate all available bit depths at a certain configuration, this was untenable.
After some discussion at Display Next Hackfest 2026, the general consensus seemed to be that a "min bpc" property would be a better way forward. By setting it and "max bpc" to the same value, userspace can probe for supported BPCs of a configuration with repeated atomic test commits, without actually doing a modeset.
At the same time, it satisfies a common userspace use case: often times, userspace just wants to ensure that its deep color plane it's submitting is not being degraded by the driver to 8bpc for bandwidth reasons. By setting "min bpc" accordingly, userspace will get definitive feedback (an atomic commit failure) and can then make content-specific trade-off decisions that the kernel wouldn't be able to do, such as by lowering the framerate, or once "color format" is in, by subsampling the chroma. Alternatively, userspace can of course also accept that there's really nothing better it can do, and lower "min bpc" to accept the degradation.
This series adds the property (including documentation) and implements it in the common HDMI state helpers (including new KUnit tests). Drivers that don't use the common HDMI state helpers will need to register the property and implement the (fairly simple) logic themselves.
There is a draft minimal userspace implementation in weston at [2] which doesn't do any fancy atomic test commit probing with dynamic userspace-side fallbacks.
[1]: https://lore.kernel.org/dri-devel/[email protected]/T/
[2]: https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/1850
---
Changes in v2:
- Add link to weston draft MR in cover letter
- Apply trailers
- Link to v1: https://patch.msgid.link/[email protected]
---
Nicolas Frattaroli (2):
drm/connector: Introduce "min bpc" connector property drm/connector: hdmi: Implement "min bpc" property
drivers/gpu/drm/display/drm_hdmi_state_helper.c | 10 +- drivers/gpu/drm/drm_atomic_helper.c | 4 + drivers/gpu/drm/drm_atomic_uapi.c | 4 + drivers/gpu/drm/drm_connector.c | 81 ++++++++++++ drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 146 +++++++++++++++++++++ include/drm/drm_connector.h | 13 ++ 6 files changed, 254 insertions(+), 4 deletions(-)
---
base-commit: 5df28e621a86e501b09902fdf816f8c02a162794
change-id: 20260605-min-bpc-dbbf3b3a2521
Best regards,
Signature · 1 line
Nicolas Frattaroli <[email protected]>
PATCH v2 1/2 drm/connector: Introduce "min bpc" connector property
Add a new KMS connector property called "min bpc". Its purpose is to allow userspace to mandate that the output bit depth ends up greater than or equal to a specified depth, or else have the commit fail. This is useful for checking for output depth degradation in combination with atomic test commits.
--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++ drivers/gpu/drm/drm_atomic_uapi.c | 4 ++ drivers/gpu/drm/drm_connector.c | 77 +++++++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 13 +++++++ 4 files changed, 98 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
@@ -739,6 +739,10 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, new_connector_state->max_requested_bpc) new_crtc_state->connectors_changed = true; +if (old_connector_state->min_requested_bpc != + new_connector_state->min_requested_bpc) + new_crtc_state->connectors_changed = true; +if (old_connector_state->color_format != new_connector_state->color_format) new_crtc_state->connectors_changed = true;
drivers/gpu/drm/drm_atomic_uapi.c +4 -0
@@ -956,6 +956,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, fence_ptr); }else if (property == connector->max_bpc_property) { state->max_requested_bpc = val; + }else if (property == connector->min_bpc_property) { + state->min_requested_bpc = val; }else if (property == connector->privacy_screen_sw_state_property) { state->privacy_screen_sw_state = val; }else if (property == connector->broadcast_rgb_property) {
@@ -1043,6 +1045,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val =0 ; }else if (property == connector->max_bpc_property) { *val = state->max_requested_bpc; + }else if (property == connector->min_bpc_property) { + *val = state->min_requested_bpc; }else if (property == connector->privacy_screen_sw_state_property) { *val = state->privacy_screen_sw_state; }else if (property == connector->broadcast_rgb_property) {
drivers/gpu/drm/drm_connector.c +77 -0
89 lines not on this page · raw message
include/drm/drm_connector.h +13 -0
@@ -1267,6 +1267,11 @@ struct drm_connector_state {*/ u8 max_requested_bpc; +/** +* @min_requested_bpc: Minimum output bit depth requested by userspace +*/ +u8 min_requested_bpc; +/** * @max_bpc: Connector max_bpc based on the requested max_bpc property * and the connector bpc limitations obtained from edid.
@@ -2297,6 +2302,12 @@ struct drm_connector {*/ struct drm_property *max_bpc_property; +/** +* @min_bpc_property: Default connector property for the minimum bit +* depth for the output to reach, or the commit to fail otherwise. +*/ +struct drm_property *min_bpc_property; +/** @privacy_screen: drm_privacy_screen for this connector, or NULL. */ struct drm_privacy_screen *privacy_screen;
@@ -2706,6 +2717,8 @@ int drm_connector_set_orientation_from_panel( struct drm_panel *panel);int drm_connector_attach_max_bpc_property (struct drm_connector *connector,int min,int max); +int drm_connector_attach_min_bpc_property (struct drm_connector *connector, +unsigned int max);void drm_connector_create_privacy_screen_properties (struct drm_connector *conn);void drm_connector_attach_privacy_screen_properties (struct drm_connector *conn); void drm_connector_attach_privacy_screen_provider(
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 1/2] drm/connector: Introduce "min bpc" connector property
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Missing generic bounds validation for `min_requested_bpc` against `max_bpc` in core DRM atomic…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Missing generic bounds validation for min_requested_bpc against max_bpc in core DRM atomic check.
- [Low] The newly introduced 'min_requested_bpc' field is not printed in debugfs atomic state dumps. --
--- Patch [1]: [PATCH v2 1/2] drm/connector: Introduce "min bpc" connector property --- commit c6fed32ee27d744d2ae9e2fb7635ec916f3ea61f
Author: Nicolas Frattaroli <[email protected]>
drm/connector: Introduce "min bpc" connector property
Add a new KMS connector property called "min bpc". Its purpose is to allow userspace to mandate that the output bit depth ends up greater than or equal to a specified depth, or else have the commit fail. This is useful for checking for output depth degradation in combination with atomic test commits.
include/drm/drm_connector.h struct drm_connector_state { · line 1274
Quoted 13 lines
include/drm/drm_connector.h +5
-0@@ -1267,6 +1267,11 @@ struct drm_connector_state {*/ u8 max_requested_bpc; +/** +* @min_requested_bpc: Minimum output bit depth requested by userspace +*/ +u8 min_requested_bpc; +
[Severity: Low]
Does this omit printing the newly added min_requested_bpc?
When a developer or user reads /sys/kernel/debug/dri/*/state to inspect the atomic KMS configuration, drm_atomic_connector_print_state() in drivers/gpu/drm/drm_atomic.c prints max_requested_bpc but doesn't seem to print min_requested_bpc, which could lead to incomplete state dumps.
[Severity: Medium]
Does the DRM core need to validate that min_requested_bpc <= max_bpc?
The core drm_atomic_connector_check() function in drivers/gpu/drm/drm_atomic.c calculates state->max_bpc but doesn't verify that state->min_requested_bpc <= state->max_bpc.
If userspace sets the "min bpc" property to a value higher than max_bpc and issues an atomic commit, this impossible constraint isn't rejected by the DRM core.
This forces every driver implementing this property to manually check for this contradiction. If a driver fails to do so, it may silently configure a bit depth lower than min_requested_bpc, violating the explicit uAPI contract that the commit must fail if the minimum bit depth cannot be met.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v2 2/2 drm/connector: hdmi: Implement "min bpc" property
In reply to Nicolas FrattaroliAct on the "min bpc" property's min_requested_bpc state in the common HDMI state helpers, and register the property on HDMI connectors.
Also add two KUnit tests to verify that the property behaves as expected.
--- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 10 +- drivers/gpu/drm/drm_connector.c | 4 + drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 146 +++++++++++++++++++++ 3 files changed, 156 insertions(+), 4 deletions(-)
drivers/gpu/drm/display/drm_hdmi_state_helper.c +6 -4
@@ -636,10 +636,12 @@ hdmi_compute_format_bpc(const struct drm_connector *connector, unsigned int max_bpc, enum drm_output_color_format fmt) {struct drm_device *dev = connector->dev; -unsigned int bpc; +unsigned int bpc, min_bpc;int ret; -for (bpc = max_bpc; bpc >=8 ; bpc -=2 ) { + min_bpc =max (conn_state->min_requested_bpc,8 ); + +for (bpc = max_bpc; bpc >= min_bpc; bpc -=2 ) { ret =hdmi_try_format_bpc (connector, conn_state, mode, bpc, fmt);if (!ret)continue ;
@@ -657,8 +659,8 @@ hdmi_compute_format_bpc(const struct drm_connector *connector,return 0 ; } -drm_dbg_kms (dev,"Failed. %s output format not supported for any bpc count.\n" , -drm_hdmi_connector_get_output_format_name (fmt)); +drm_dbg_kms (dev,"Failed. %s output format not supported for any bpc <= %u and >= %u.\n" , +drm_hdmi_connector_get_output_format_name (fmt), max_bpc, min_bpc);return -EINVAL ; }
drivers/gpu/drm/drm_connector.c +4 -0
@@ -640,6 +640,10 @@ int drmm_connector_hdmi_init(struct drm_device *dev,if (ret)return ret; + ret =drm_connector_attach_min_bpc_property (connector, max_bpc); +if (ret) +return ret; + connector->hdmi.funcs = hdmi_funcs;return 0 ;
drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c +146 -0
158 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 2/2] drm/connector: hdmi: Implement "min bpc" property
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The new `min_requested_bpc` property is not printed in `drm_atomic_connector_print_state()`. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The new min_requested_bpc property is not printed in drm_atomic_connector_print_state(). --
--- Patch [2]: [PATCH v2 2/2] drm/connector: hdmi: Implement "min bpc" property --- commit 1bb247d1cac675bb602431e3c391ddd31f8fed8d
Author: Nicolas Frattaroli <[email protected]>
drm/connector: hdmi: Implement "min bpc" property
Act on the "min bpc" property's min_requested_bpc state in the common HDMI state helpers, and register the property on HDMI connectors. Also add two KUnit tests to verify that the property behaves as expected.
drivers/gpu/drm/drm_connector.c int drmm_connector_hdmi_init(struct drm_device *dev, · line 646
Quoted 12 lines
drivers/gpu/drm/drm_connector.c +4
-0@@ -640,6 +640,10 @@ int drmm_connector_hdmi_init(struct drm_device *dev,if (ret)return ret; + ret =drm_connector_attach_min_bpc_property (connector, max_bpc); +if (ret) +return ret; +
[Severity: Low]
Since we are adding support for the min bpc property and using min_requested_bpc in the connector state, should this also be printed in drm_atomic_connector_print_state() alongside max_requested_bpc?
For example, looking at drivers/gpu/drm/drm_atomic.c in drm_atomic_connector_print_state():
drm_printf_indent(p, 1, "max_requested_bpc=%d\n", state->max_requested_bpc); drm_printf_indent(p, 1, "colorspace=%s\n", drm_get_colorspace_name(state->colorspace));
Without printing it here, the debugfs atomic state dump will not display the min_requested_bpc field, which might make debugging atomic commits incomplete.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2