diff mbox series

[v2] drm/bridge-connector: handle subconnector types

Message ID 20230903214934.2877259-1-dmitry.baryshkov@linaro.org
State New
Headers show
Series [v2] drm/bridge-connector: handle subconnector types | expand

Commit Message

Dmitry Baryshkov Sept. 3, 2023, 9:49 p.m. UTC
If the created connector type supports subconnector type property,
create and attach corresponding it. The default subtype value is 0,
which maps to the DRM_MODE_SUBCONNECTOR_Unknown type.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---

This is a leftover of my previous attempt to implement USB-C DisplayPort
uABI. The idea was dropped, but I consider this part still to be useful,
as it allows one to register corresponding subconnector properties and
also to export the subconnector type.

Changes since v1:
 - Dropped all DP and USB-related patches
 - Dropped the patch adding default subtype to
   drm_connector_attach_dp_subconnector_property()
 - Replaced creation of TV subconnector property with the check that it
   was created beforehand (Neil, Laurent)

---
 drivers/gpu/drm/drm_bridge_connector.c | 29 +++++++++++++++++++++++++-
 include/drm/drm_bridge.h               |  4 ++++
 2 files changed, 32 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c
index ca255609fb08..74a3164825dd 100644
--- a/drivers/gpu/drm/drm_bridge_connector.c
+++ b/drivers/gpu/drm/drm_bridge_connector.c
@@ -332,6 +332,7 @@  struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 	struct i2c_adapter *ddc = NULL;
 	struct drm_bridge *bridge, *panel_bridge = NULL;
 	const char *path = NULL;
+	enum drm_mode_subconnector subconnector;
 	int connector_type;
 	int ret;
 
@@ -369,8 +370,10 @@  struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 		if (bridge->ops & DRM_BRIDGE_OP_MODES)
 			bridge_connector->bridge_modes = bridge;
 
-		if (!drm_bridge_get_next_bridge(bridge))
+		if (!drm_bridge_get_next_bridge(bridge)) {
 			connector_type = bridge->type;
+			subconnector = bridge->subtype;
+		}
 
 		if (!drm_bridge_get_next_bridge(bridge) &&
 		    bridge->of_node)
@@ -418,6 +421,30 @@  struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 	if (panel_bridge)
 		drm_panel_bridge_set_orientation(connector, panel_bridge);
 
+	if (connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
+		drm_connector_attach_dp_subconnector_property(connector);
+	} else if (connector_type == DRM_MODE_CONNECTOR_DVII) {
+		ret = drm_mode_create_dvi_i_properties(drm);
+		if (ret)
+			return ERR_PTR(ret);
+
+		drm_object_attach_property(&connector->base,
+					   drm->mode_config.dvi_i_subconnector_property,
+					   subconnector);
+	} else if (connector_type == DRM_MODE_CONNECTOR_TV &&
+		   subconnector) {
+		/*
+		 * We do not know which modes are supported by the HW, so the
+		 * property should be created in advance.
+		 */
+		if (!drm->mode_config.tv_subconnector_property)
+			return ERR_PTR(-EINVAL);
+
+		drm_object_attach_property(&connector->base,
+					   drm->mode_config.tv_subconnector_property,
+					   subconnector);
+	}
+
 	return connector;
 }
 EXPORT_SYMBOL_GPL(drm_bridge_connector_init);
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index afa1de791075..440a8aa91e65 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -738,6 +738,10 @@  struct drm_bridge {
 	 * identifies the type of connected display.
 	 */
 	int type;
+	/**
+	 * @subtype: the subtype of the connector for the DP/TV/DVI-I cases.
+	 */
+	enum drm_mode_subconnector subtype;
 	/**
 	 * @interlace_allowed: Indicate that the bridge can handle interlaced
 	 * modes.