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. Also remove
subconnector creation from the msm_dp driver to prevent having duplicate
properties on the DP connectors.

Signed-off-by: Dmitry Baryshkov <dmitry.barysh...@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 in v3:
- Rebased on top of linux-next
- Drop subconnector property from msm_dp driver
- Link to v2: 
https://lore.kernel.org/r/20230903214934.2877259-1-dmitry.barysh...@linaro.org

Changes in v2:
- 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)
- Link to v1: 
https://lore.kernel.org/r/20230729004913.215872-1-dmitry.barysh...@linaro.org/
---
 drivers/gpu/drm/display/drm_bridge_connector.c | 28 +++++++++++++++++++++++++-
 drivers/gpu/drm/msm/dp/dp_drm.c                |  3 ---
 include/drm/drm_bridge.h                       |  4 ++++
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c 
b/drivers/gpu/drm/display/drm_bridge_connector.c
index 
0397e62f9cbc93321caeae99982f5e3c66d308c5..4b616dba4dd8c2dc1725a8d7562d0a37e1557dc8
 100644
--- a/drivers/gpu/drm/display/drm_bridge_connector.c
+++ b/drivers/gpu/drm/display/drm_bridge_connector.c
@@ -523,6 +523,7 @@ struct drm_connector *drm_bridge_connector_init(struct 
drm_device *drm,
        struct drm_bridge *bridge, *panel_bridge = NULL;
        unsigned int supported_formats = BIT(HDMI_COLORSPACE_RGB);
        unsigned int max_bpc = 8;
+       enum drm_mode_subconnector subconnector;
        int connector_type;
        int ret;
 
@@ -576,8 +577,10 @@ struct drm_connector *drm_bridge_connector_init(struct 
drm_device *drm,
                                max_bpc = bridge->max_bpc;
                }
 
-               if (!drm_bridge_get_next_bridge(bridge))
+               if (!drm_bridge_get_next_bridge(bridge)) {
                        connector_type = bridge->type;
+                       subconnector = bridge->subtype;
+               }
 
 #ifdef CONFIG_OF
                if (!drm_bridge_get_next_bridge(bridge) &&
@@ -643,6 +646,29 @@ 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) {
+               /*
+                * 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/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
index 
d3e241ea6941615b8e274dd17426c2f8557f09b5..d8e3ec9fd4825916e03ced9011f460c2f32f3912
 100644
--- a/drivers/gpu/drm/msm/dp/dp_drm.c
+++ b/drivers/gpu/drm/msm/dp/dp_drm.c
@@ -361,9 +361,6 @@ struct drm_connector *msm_dp_drm_connector_init(struct 
msm_dp *msm_dp_display,
        if (IS_ERR(connector))
                return connector;
 
-       if (!msm_dp_display->is_edp)
-               drm_connector_attach_dp_subconnector_property(connector);
-
        drm_connector_attach_encoder(connector, encoder);
 
        return connector;
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 
4b84faf14e368310dd20aa964e8178ec80aa6fa7..27a4c9aa3475cefe0137f0a7d01b808651125ac5
 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -850,6 +850,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.

---
base-commit: 8defad9f57376a89914d16757717a27b567de04e
change-id: 20250117-subconnector-246b6fe49488

Best regards,
-- 
Dmitry Baryshkov <dmitry.barysh...@linaro.org>

Reply via email to