From a37b496737f062e9881f7e6784ab341ae9a40a68 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Tue, 21 Oct 2025 12:40:45 +0000 Subject: [PATCH 1/2] backend-drm: Add 'link bpc' connector property The 'link bpc' DRM connector property can be used to retrieve the physical bpc value. This property can be used to find out the physical link value as drivers will try to lower the bpc value when creaing an optimal output. If we detect change we would notify the user if the value set with 'max bpc' would be different than that of 'link bpc'. Signed-off-by: Marius Vlad --- libweston/backend-drm/drm-kms-enums.h | 1 + libweston/backend-drm/drm.c | 23 +++++++++++++++++++++++ libweston/backend-drm/kms.c | 1 + 3 files changed, 25 insertions(+) diff --git a/libweston/backend-drm/drm-kms-enums.h b/libweston/backend-drm/drm-kms-enums.h index 955a3ae15..436d28d82 100644 --- a/libweston/backend-drm/drm-kms-enums.h +++ b/libweston/backend-drm/drm-kms-enums.h @@ -124,6 +124,7 @@ enum wdrm_connector_property { WDRM_CONNECTOR_CONTENT_TYPE, WDRM_CONNECTOR_COLORSPACE, WDRM_CONNECTOR_VRR_CAPABLE, + WDRM_CONNECTOR_LINK_BPC, WDRM_CONNECTOR__COUNT }; diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 17013edfb..2348be691 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -3891,6 +3891,26 @@ drm_connector_find_property_by_id(struct drm_connector *connector, return prop; } +static void +weston_head_verify_bpc_status(struct drm_head *head) +{ + unsigned int link_bpc; + unsigned int current_max_bpc; + + link_bpc = drm_property_get_value(&head->connector.props[WDRM_CONNECTOR_LINK_BPC], + head->connector.props_drm, 0); + + /* inherited_max_bpc is used only at head creation or if max_bpc + * is not set by the user. Further more user might supply a different + * max_bpc than one in the range. */ + current_max_bpc = drm_property_get_value(&head->connector.props[WDRM_CONNECTOR_MAX_BPC], + head->connector.props_drm, 0); + + if (current_max_bpc != link_bpc) + weston_log("WARNING: max bpc was set to %u but current link bpc " + "set to %u\n", current_max_bpc, link_bpc); +} + static void drm_backend_update_conn_props(struct drm_backend *b, struct drm_device *device, @@ -3918,6 +3938,9 @@ drm_backend_update_conn_props(struct drm_backend *b, weston_head_set_content_protection_status(&head->base, drm_head_get_current_protection(head)); } + + if (conn_prop == WDRM_CONNECTOR_LINK_BPC) + weston_head_verify_bpc_status(head); } static int diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c index accd3743a..b011ba981 100644 --- a/libweston/backend-drm/kms.c +++ b/libweston/backend-drm/kms.c @@ -252,6 +252,7 @@ const struct drm_property_info connector_props[] = { [WDRM_CONNECTOR_VRR_CAPABLE] = { .name = "vrr_capable", }, + [WDRM_CONNECTOR_LINK_BPC] = { .name = "link bpc", }, }; const struct drm_property_info crtc_props[] = { From cca2859fed9babaa13ef139bfc6f45da9e3e1b1e Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Thu, 12 Mar 2026 10:26:09 +0200 Subject: [PATCH 2/2] backend-drm: Inform user that we might be outside max_bpc range This informs users that the max_bpc set in the ini file might be outside of allowed/permited range. Signed-off-by: Marius Vlad --- libweston/backend-drm/kms.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c index b011ba981..5b48bd827 100644 --- a/libweston/backend-drm/kms.c +++ b/libweston/backend-drm/kms.c @@ -1194,6 +1194,11 @@ drm_connector_set_max_bpc(struct drm_connector *connector, assert(a <= b); max_bpc = MAX(a, MIN(output->max_bpc, b)); + if (max_bpc != output->max_bpc) + weston_log("Warning: user-specified 'max_bpc' %u, " + "outside of range: [%"PRIu64", %"PRIu64"]. " + "Using 'max_bpc': %"PRIu64"\n", output->max_bpc, + a, b, max_bpc); } return connector_add_prop(req, connector,