* [PATCH v2 1/2] drm/connector: Introduce "min bpc" connector property
2026-07-29 12:13 [PATCH v2 0/2] Add a "min bpc" connector property Nicolas Frattaroli
@ 2026-07-29 12:13 ` Nicolas Frattaroli
2026-07-29 12:25 ` sashiko-bot
2026-07-29 12:13 ` [PATCH v2 2/2] drm/connector: hdmi: Implement "min bpc" property Nicolas Frattaroli
1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Frattaroli @ 2026-07-29 12:13 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Xaver Hugl, Michel Dänzer, Harry Wentland,
Mario Kleiner, Pekka Paalanen, Ville Syrjälä,
Daniel Stone, Marius Vlad
Cc: dri-devel, linux-kernel, kernel, wayland-devel,
Nicolas Frattaroli
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.
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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(+)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 285aac3554df..613a674ace87 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 1050dddadb17..0440cb63f786 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -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) {
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 8b4baed060f3..3ecc079404a1 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1739,6 +1739,46 @@ EXPORT_SYMBOL(drm_hdmi_connector_get_output_format_name);
* drm_connector_attach_max_bpc_property() to create and attach the
* property to the connector during initialization.
*
+ * min bpc:
+ * This range property is used by userspace to set a minimum bit depth that
+ * the driver must reach on the connector for a given atomic state. If it
+ * cannot do so, the atomic commit fails.
+ *
+ * The precise definition of minimum bit depth used for the "min bpc"
+ * property must align with the definition a given driver uses for the
+ * "max bpc" property, such that when "min bpc" and "max bpc" are set to
+ * the same value, the allowable range of bit depths is a single set point.
+ *
+ * Drivers should ideally use a definition of bit depth that refers to a
+ * perceptual optical bit depth, meaning it is equivalent to an
+ * uncompressed optical bit depth for a variety of content to the median
+ * human eyeball in a variety of viewing environments. The display link's
+ * actual optical bit depth to represent the data on the wire may be lower
+ * due to compression techniques, or even higher due to padding. In
+ * concrete terms, userspace should not need to know how to implement DSC
+ * compression in order to set a minimum bit depth to the appropriate
+ * value, and should not need to perform display-protocol-specific
+ * calculations to set the right on-the-wire format.
+ *
+ * Userspace may use the "min bpc" property in combination with performing
+ * atomic test commits in order to enumerate the possible output bit depths
+ * for a given configuration. This way, userspace compositors can make
+ * use-case and content-specific tradeoffs to reach a desired output bit
+ * depth, such as by using chroma subsampling, or by choosing a lower
+ * refresh rate mode.
+ *
+ * Userspace may use the "min bpc" property in combination with the
+ * "max bpc" property to know what output bit depth a successful atomic
+ * commit is using. By setting "min bpc" and "max bpc" to the same value,
+ * a successful commit will be using an output bit depth of said value.
+ *
+ * When "min bpc" is set to a non-zero value, any bit depth degradation
+ * logic below "min bpc" must be implemented by userspace (through lowering
+ * "min bpc"), rather than by kernel drivers. For a driver to degrade to an
+ * uncompressed optical output bit depth below "min bpc" is always a bug no
+ * matter how good the intentions are, since it renders the property
+ * useless as an oracle.
+ *
* Connectors also have one standardized atomic property:
*
* CRTC_ID:
@@ -2893,6 +2933,43 @@ int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
}
EXPORT_SYMBOL(drm_connector_attach_max_bpc_property);
+/**
+ * drm_connector_attach_min_bpc_property - attach "min bpc" property
+ * @connector: connector to attach min bpc property on.
+ * @max: The maximum bit depth supported by the connector.
+ *
+ * Create and attach the "min bpc" connector property, which is used by
+ * userspace to require that a certain minimum bit depth is reached by the
+ * connector on atomic commit.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_connector_attach_min_bpc_property(struct drm_connector *connector,
+ unsigned int max)
+{
+ struct drm_device *dev = connector->dev;
+ struct drm_property *prop;
+
+ if (max > U8_MAX)
+ return -ERANGE;
+
+ prop = connector->min_bpc_property;
+ if (!prop) {
+ prop = drm_property_create_range(dev, 0, "min bpc", 0, max);
+ if (!prop)
+ return -ENOMEM;
+
+ connector->min_bpc_property = prop;
+ }
+
+ drm_object_attach_property(&connector->base, prop, 0);
+ connector->state->min_requested_bpc = 0;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_min_bpc_property);
+
/**
* drm_connector_attach_hdr_output_metadata_property - attach "HDR_OUTPUT_METADATA" property
* @connector: connector to attach the property on.
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index a0cf0268de48..35f395d46f6b 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -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(
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 2/2] drm/connector: hdmi: Implement "min bpc" property
2026-07-29 12:13 [PATCH v2 0/2] Add a "min bpc" connector property Nicolas Frattaroli
2026-07-29 12:13 ` [PATCH v2 1/2] drm/connector: Introduce " Nicolas Frattaroli
@ 2026-07-29 12:13 ` Nicolas Frattaroli
2026-07-29 12:23 ` sashiko-bot
1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Frattaroli @ 2026-07-29 12:13 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Xaver Hugl, Michel Dänzer, Harry Wentland,
Mario Kleiner, Pekka Paalanen, Ville Syrjälä,
Daniel Stone, Marius Vlad
Cc: dri-devel, linux-kernel, kernel, wayland-devel,
Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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(-)
diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index ce17eeefc2da..fa015d218b41 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -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;
}
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 3ecc079404a1..f019bd5fef69 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -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;
diff --git a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
index 353a261d42da..8f8f7a528e08 100644
--- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
@@ -1361,6 +1361,150 @@ static void drm_test_check_tmds_char_rate_rgb_12bpc(struct kunit *test)
drm_modeset_acquire_fini(&ctx);
}
+/*
+ * Test that an atomic check with a min bpc of 10 fails on a connector that
+ * maxes out at 8bpc even if the EDID could go higher.
+ */
+static void drm_test_check_min_bpc_10bit_connector_fail(struct kunit *test)
+{
+ struct drm_atomic_helper_connector_hdmi_priv *priv;
+ struct drm_modeset_acquire_ctx ctx;
+ struct drm_connector_state *conn_state;
+ struct drm_display_mode *preferred;
+ struct drm_atomic_commit *state;
+ struct drm_connector *conn;
+ struct drm_device *drm;
+ int ret;
+
+ priv = drm_kunit_helper_connector_hdmi_init_with_edid_funcs(test,
+ BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444) |
+ BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420) |
+ BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422) |
+ BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444),
+ 8,
+ &dummy_connector_hdmi_funcs,
+ test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz);
+ KUNIT_ASSERT_NOT_NULL(test, priv);
+
+ drm = &priv->drm;
+ conn = &priv->connector;
+ preferred = find_preferred_mode(conn);
+ KUNIT_ASSERT_NOT_NULL(test, preferred);
+
+ drm_modeset_acquire_init(&ctx, 0);
+
+retry_conn_enable:
+ ret = drm_kunit_helper_enable_crtc_connector(test, drm, priv->crtc,
+ conn, preferred, &ctx);
+ if (ret == -EDEADLK) {
+ ret = drm_modeset_backoff(&ctx);
+ if (!ret)
+ goto retry_conn_enable;
+ }
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
+
+retry_conn_state:
+ conn_state = drm_atomic_get_connector_state(state, conn);
+ if (PTR_ERR(conn_state) == -EDEADLK) {
+ drm_atomic_commit_clear(state);
+ ret = drm_modeset_backoff(&ctx);
+ if (!ret)
+ goto retry_conn_state;
+ }
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);
+
+ conn_state->min_requested_bpc = 10;
+
+ ret = drm_atomic_check_only(state);
+ if (ret == -EDEADLK) {
+ drm_atomic_commit_clear(state);
+ ret = drm_modeset_backoff(&ctx);
+ if (!ret)
+ goto retry_conn_state;
+ }
+ KUNIT_EXPECT_LT(test, ret, 0);
+
+ drm_modeset_drop_locks(&ctx);
+ drm_modeset_acquire_fini(&ctx);
+}
+
+/*
+ * Test that an atomic check with a min bpc of 10 succeeds on a connector that
+ * can do 10bpc if the EDID can also do 10bpc.
+ */
+static void drm_test_check_min_bpc_10bit_success(struct kunit *test)
+{
+ struct drm_atomic_helper_connector_hdmi_priv *priv;
+ struct drm_modeset_acquire_ctx ctx;
+ struct drm_connector_state *conn_state;
+ struct drm_display_mode *preferred;
+ struct drm_atomic_commit *state;
+ struct drm_connector *conn;
+ struct drm_device *drm;
+ int ret;
+
+ priv = drm_kunit_helper_connector_hdmi_init_with_edid_funcs(test,
+ BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444),
+ 12,
+ &dummy_connector_hdmi_funcs,
+ test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz);
+ KUNIT_ASSERT_NOT_NULL(test, priv);
+
+ drm = &priv->drm;
+ conn = &priv->connector;
+ preferred = find_preferred_mode(conn);
+ KUNIT_ASSERT_NOT_NULL(test, preferred);
+ KUNIT_ASSERT_TRUE(test, conn->display_info.edid_hdmi_rgb444_dc_modes &
+ DRM_EDID_HDMI_DC_30);
+
+ drm_modeset_acquire_init(&ctx, 0);
+
+retry_conn_enable:
+ ret = drm_kunit_helper_enable_crtc_connector(test, drm, priv->crtc,
+ conn, preferred, &ctx);
+ if (ret == -EDEADLK) {
+ ret = drm_modeset_backoff(&ctx);
+ if (!ret)
+ goto retry_conn_enable;
+ }
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
+
+retry_conn_state:
+ conn_state = drm_atomic_get_connector_state(state, conn);
+ if (PTR_ERR(conn_state) == -EDEADLK) {
+ drm_atomic_commit_clear(state);
+ ret = drm_modeset_backoff(&ctx);
+ if (!ret)
+ goto retry_conn_state;
+ }
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);
+
+ conn_state->min_requested_bpc = 10;
+
+ ret = drm_atomic_check_only(state);
+ if (ret == -EDEADLK) {
+ drm_atomic_commit_clear(state);
+ ret = drm_modeset_backoff(&ctx);
+ if (!ret)
+ goto retry_conn_state;
+ }
+ KUNIT_EXPECT_EQ(test, ret, 0);
+
+ conn_state = drm_atomic_get_new_connector_state(state, conn);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);
+ KUNIT_EXPECT_GE(test, conn_state->hdmi.output_bpc, 10);
+ KUNIT_ASSERT_EQ(test, conn_state->hdmi.output_format, DRM_OUTPUT_COLOR_FORMAT_RGB444);
+
+ drm_modeset_drop_locks(&ctx);
+ drm_modeset_acquire_fini(&ctx);
+}
+
/*
* Test that if we filter a rate through our hook, it's indeed rejected
* by the whole atomic_check logic.
@@ -2476,6 +2620,8 @@ static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = {
KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_8bpc),
KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_10bpc),
KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_12bpc),
+ KUNIT_CASE(drm_test_check_min_bpc_10bit_connector_fail),
+ KUNIT_CASE(drm_test_check_min_bpc_10bit_success),
KUNIT_CASE_PARAM(drm_test_check_hdmi_color_format,
check_hdmi_color_format_gen_params),
KUNIT_CASE_PARAM(drm_test_check_hdmi_color_format_420_only,
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread