Skip to contentSkip to conversation

Add a "min bpc" connector property

PATCH Superseded Nicolas Frattaroli 2 participants 4 messages Jun 12 – Jun 24

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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 no draft userspace implementation this time around. Something that would adequately make the case for all the uses of "min bpc" would take a lot of effort to add to weston, and anything less than a full implementation will then be used as ammo to argue against the property.

[1]: https://lore.kernel.org/dri-devel/[email protected]/T/

---
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: 8372c3177e62bca48fdca142601d3d3804ff3129
change-id: 20260605-min-bpc-dbbf3b3a2521

Best regards,

Signature · 1 line
Nicolas Frattaroli <[email protected]>
#1 lore raw

PATCH 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
index 285aac3554df..613a674ace87 100644
@@ -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
index 1050dddadb17..0440cb63f786 100644
@@ -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
index 4317166562cf..63d6ac85b3ec 100644
@@ -1261,6 +1261,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.
@@ -2291,6 +2296,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;
 
@@ -2697,6 +2708,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.54.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] drm/connector: Introduce "min bpc" connector property

Quoted 7 lines · 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.

Despite your statement in the cover letter, this does still need a userspace implementation before merging, as well as an IGT test.

But I like this definition and your documentation and think we have something quite workable, even long-term.

Harry

Quoted 178 lines
---
 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
index 285aac3554df..613a674ace87 100644
@@ -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
index 1050dddadb17..0440cb63f786 100644
@@ -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
index cbb067d02cb9..dcf53cc113b0 100644
@@ -1738,6 +1738,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:
@@ -2892,6 +2932,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.
include/drm/drm_connector.h +13 -0
index 4317166562cf..63d6ac85b3ec 100644
@@ -1261,6 +1261,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.
@@ -2291,6 +2296,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;
 
@@ -2697,6 +2708,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(
#3 lore raw

PATCH 2/2 drm/connector: hdmi: Implement "min bpc" property

In reply to 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.

---
 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
index ce17eeefc2da..fa015d218b41 100644
@@ -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
index dcf53cc113b0..5cf512add4ef 100644
@@ -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.54.0