Allow non-HDMI bridges to advertise their output bit-depth limit through max_bpc. Attach the max bpc property when the lowest reported limit in the chain exceeds 8, ignoring bridges that do not report a limit. This lets DP drivers expose deep-color support without attaching the property in their connector initialization code.
Use a lower bound of 6 for DP and eDP, which support 6 bpc RGB output, and 8 for other connector types. Keep the existing HDMI registration path. The property can be attached before connector state allocation; the atomic state helper initializes its default when state is created. Assisted-by: LLM Signed-off-by: Xilin Wu <[email protected]> --- drivers/gpu/drm/display/drm_bridge_connector.c | 18 ++++++++++++++++++ include/drm/drm_bridge.h | 11 ++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/drm/display/drm_bridge_connector.c index 8b54069fa53a..be2e08a3694a 100644 --- a/drivers/gpu/drm/display/drm_bridge_connector.c +++ b/drivers/gpu/drm/display/drm_bridge_connector.c @@ -825,6 +825,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, struct drm_bridge *panel_bridge __free(drm_bridge_put) = NULL; unsigned int supported_formats = BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444); unsigned int max_bpc = 8; + unsigned int chain_max_bpc = 0; bool support_hdcp = false; int connector_type; int ret; @@ -985,6 +986,10 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, panel_bridge = drm_bridge_get(bridge); } + if (bridge->max_bpc) + chain_max_bpc = chain_max_bpc ? + min(chain_max_bpc, bridge->max_bpc) : bridge->max_bpc; + if (bridge->support_hdcp) support_hdcp = true; } @@ -1026,6 +1031,19 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, connector_type, ddc); if (ret) return ERR_PTR(ret); + + if (chain_max_bpc > 8) { + unsigned int min_bpc = 8; + + if (connector_type == DRM_MODE_CONNECTOR_DisplayPort || + connector_type == DRM_MODE_CONNECTOR_eDP) + min_bpc = 6; + + ret = drm_connector_attach_max_bpc_property(connector, min_bpc, + chain_max_bpc); + if (ret) + return ERR_PTR(ret); + } } if (bridge_connector->bridge_hdmi_audio || diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 58fff047f43b..01ad1878149e 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1089,9 +1089,14 @@ struct drm_bridge { unsigned int supported_formats; /** - * @max_bpc: Maximum bits per char the HDMI bridge supports. Allowed - * values are 8, 10 and 12. This is only relevant if - * @DRM_BRIDGE_OP_HDMI is set. + * @max_bpc: Maximum bits per color component the bridge supports. + * Zero means that the bridge does not report a limit. For HDMI bridges + * with @DRM_BRIDGE_OP_HDMI set, allowed values are 8, 10 and 12. + * + * For non-HDMI connectors, drm_bridge_connector_init() attaches the + * max bpc property when the lowest nonzero limit in the bridge chain + * exceeds 8. Bridges remain responsible for validating configurations + * against any limits not reported here. */ unsigned int max_bpc; -- 2.56.0
