Skip to contentSkip to conversation

Subconnector property for DP downstream type

PATCH Superseded Oleg Vasilev 9 participants 28 messages Aug 26, 2019 – Jan 10, 2020 7 messages not in the archive

Subsystems (7)
lore
Share & tools
lore
#1 lore raw

PATCH v3 1/7 drm: move DP_MAX_DOWNSTREAM_PORTS from i915 to drm core

DP_MAX_DOWNSTREAM_PORTS=0x10 is a vendor-independent constant.

---
 drivers/gpu/drm/i915/display/intel_display_types.h | 2 --
 include/drm/drm_dp_helper.h                        | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_display_types.h +0 -2
index 449abaea619f..b53fde16b86f 100644
@@ -1106,8 +1106,6 @@ struct intel_hdmi {
 };
 
 struct intel_dp_mst_encoder;
-#define DP_MAX_DOWNSTREAM_PORTS		0x10
-
 /*
  * enum link_m_n_set:
  *	When platform provides two set of M_N registers for dp, we can
include/drm/drm_dp_helper.h +2 -0
index 8364502f92cf..1aea3e0810db 100644
@@ -349,6 +349,8 @@
 # define DP_DS_12BPC		            2
 # define DP_DS_16BPC		            3
 
+#define DP_MAX_DOWNSTREAM_PORTS		    0x10
+
 /* DP Forward error Correction Registers */
 #define DP_FEC_CAPABILITY		    0x090    /* 1.4 */
 # define DP_FEC_CAPABLE			    (1 << 0)
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH v3 2/7 drm: always determine branch device with drm_dp_is_branch()

In reply to Oleg Vasilev

The helper should always be used.

---
 drivers/gpu/drm/drm_dp_helper.c         | 3 +--
 drivers/gpu/drm/i915/display/intel_dp.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_dp_helper.c +1 -2
index ffc68d305afe..14320930091b 100644
@@ -573,8 +573,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
 	int len;
 	uint8_t rev[2];
 	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
-	bool branch_device = dpcd[DP_DOWNSTREAMPORT_PRESENT] &
-			     DP_DWN_STRM_PORT_PRESENT;
+	bool branch_device = drm_dp_is_branch(dpcd);
 
 	seq_printf(m, "\tDP branch device present: %s\n",
 		   branch_device ? "yes" : "no");
drivers/gpu/drm/i915/display/intel_dp.c +1 -1
index 23908da1cd5d..6da6a4859f06 100644
@@ -2922,7 +2922,7 @@ static bool downstream_hpd_needs_d0(struct intel_dp *intel_dp)
 	 * FIXME should really check all downstream ports...
 	 */
 	return intel_dp->dpcd[DP_DPCD_REV] == 0x11 &&
-		intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT &&
+		drm_dp_is_branch(intel_dp->dpcd) &&
 		intel_dp->downstream_ports[0] & DP_DS_PORT_HPD;
 }
 
Signature · 6 lines
2.23.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH v3 3/7 drm: report dp downstream port type as a subconnector property

In reply to Oleg Vasilev

Currently, downstream port type is only reported in debugfs. This information should be considered important since it reflects the actual physical connector type. Some userspace (e.g. window compositors) may want to show this info to a user.

The 'subconnector' property is already utilized for DVI-I and TV-out for reporting connector subtype.

The initial motivation for this feature came from i2c test [1]. It is supposed to be skipped on VGA connectors, but it cannot detect VGA over DP and fails instead.

v2:
- Ville: utilized drm_dp_is_branch()
- Ville: implement DP 1.0 downstream type info
- Replaced create_dp_properties with add_dp_subconnector_property
- Added dp_set_subconnector_property helper

[1]: https://bugs.freedesktop.org/show_bug.cgi?id=104097

---
 drivers/gpu/drm/drm_connector.c | 49 +++++++++++++++++++++++-
 drivers/gpu/drm/drm_dp_helper.c | 68 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     |  3 ++
 include/drm/drm_dp_helper.h     |  8 ++++
 include/drm/drm_mode_config.h   |  6 +++
 include/uapi/drm/drm_mode.h     | 22 +++++++----
 6 files changed, 146 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_connector.c +47 -2
index 4c766624b20d..47e3466891db 100644
@@ -829,7 +829,7 @@ static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
 
 static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = {
-	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
+	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I, TV-out and DP */
 	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
 	{ DRM_MODE_SUBCONNECTOR_DVIA,      "DVI-A"     }, /* DVI-I  */
 };
@@ -846,7 +846,7 @@ static const struct drm_prop_enum_list drm_tv_select_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
 
 static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
-	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
+	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I, TV-out and DP */
 	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
 	{ DRM_MODE_SUBCONNECTOR_SVIDEO,    "SVIDEO"    }, /* TV-out */
 	{ DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */
@@ -855,6 +855,19 @@ static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
 		 drm_tv_subconnector_enum_list)
 
+static const struct drm_prop_enum_list drm_dp_subconnector_enum_list[] = {
+	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I, TV-out and DP */
+	{ DRM_MODE_SUBCONNECTOR_VGA,	   "VGA"       }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_DVI,	   "DVI"       }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_HDMI,	   "HDMI"      }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_DP,        "DP"        }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_Wireless,  "Wireless"  }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_Native,	   "Native"    }, /* DP */
+};
+
+DRM_ENUM_NAME_FN(drm_get_dp_subconnector_name,
+		 drm_dp_subconnector_enum_list)
+
 static const struct drm_prop_enum_list hdmi_colorspaces[] = {
 	/* For Default case, driver will set the colorspace */
 	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
@@ -1138,6 +1151,14 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] = {
  *	can also expose this property to external outputs, in which case they
  *	must support "None", which should be the default (since external screens
  *	have a built-in scaler).
+ *
+ * subconnector:
+ *	This property is used by DVI-I, TVout and DisplayPort to indicate different
+ *	connector subtypes. Enum values more or less match with those from main
+ *	connector types.
+ *	For DVI-I and TVout there is also a matching property "select subconnector"
+ *	allowing to switch between signal types.
+ *	DP subconnector corresponds to a downstream port.
  */
 
 int drm_connector_create_standard_properties(struct drm_device *dev)
@@ -1226,6 +1247,30 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_dvi_i_properties);
 
+/**
+ * drm_mode_add_dp_subconnector_property - create subconnector property for DP
+ * @connector: drm_connector to attach property
+ *
+ * Called by a driver when DP connector is created.
+ */
+void drm_mode_add_dp_subconnector_property(struct drm_connector *connector)
+{
+	struct drm_mode_config *mode_config = &connector->dev->mode_config;
+
+	if (!mode_config->dp_subconnector_property)
+		mode_config->dp_subconnector_property =
+			drm_property_create_enum(connector->dev,
+				DRM_MODE_PROP_IMMUTABLE,
+				"subconnector",
+				drm_dp_subconnector_enum_list,
+				ARRAY_SIZE(drm_dp_subconnector_enum_list));
+
+	drm_object_attach_property(&connector->base,
+				   mode_config->dp_subconnector_property,
+				   DRM_MODE_SUBCONNECTOR_Unknown);
+}
+EXPORT_SYMBOL(drm_mode_add_dp_subconnector_property);
+
 /**
  * DOC: HDMI connector properties
  *
drivers/gpu/drm/drm_dp_helper.c +68 -0

74 lines not on this page · raw message

include/drm/drm_connector.h +3 -0
index 681cb590f952..119606fcd59f 100644
@@ -1507,10 +1507,13 @@ const char *drm_get_dvi_i_subconnector_name(int val);
 const char *drm_get_dvi_i_select_name(int val);
 const char *drm_get_tv_subconnector_name(int val);
 const char *drm_get_tv_select_name(int val);
+const char *drm_get_dp_subconnector_name(int val);
 const char *drm_get_content_protection_name(int val);
 const char *drm_get_hdcp_content_type_name(int val);
 
 int drm_mode_create_dvi_i_properties(struct drm_device *dev);
+void drm_mode_add_dp_subconnector_property(struct drm_connector *connector);
+
 int drm_mode_create_tv_margin_properties(struct drm_device *dev);
 int drm_mode_create_tv_properties(struct drm_device *dev,
 				  unsigned int num_modes,
include/drm/drm_dp_helper.h +8 -0
index 1aea3e0810db..1fec3c731017 100644
@@ -26,6 +26,7 @@
 #include <linux/types.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <drm/drm_connector.h>
 
 /*
  * Unless otherwise noted, all values are from the DP 1.1a spec.  Note that
@@ -1378,6 +1379,13 @@ int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
 int drm_dp_downstream_id(struct drm_dp_aux *aux, char id[6]);
 void drm_dp_downstream_debug(struct seq_file *m, const u8 dpcd[DP_RECEIVER_CAP_SIZE],
 			     const u8 port_cap[4], struct drm_dp_aux *aux);
+enum drm_mode_subconnector
+drm_dp_subconnector_type(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
+			 const u8 port_cap[4]);
+void drm_dp_set_subconnector_property(struct drm_connector *connector,
+				      enum drm_connector_status status,
+				      const u8 *dpcd,
+				      const u8 port_cap[4]);
 
 void drm_dp_aux_init(struct drm_dp_aux *aux);
 int drm_dp_aux_register(struct drm_dp_aux *aux);
include/drm/drm_mode_config.h +6 -0
index 3bcbe30339f0..732d51951bce 100644
@@ -680,6 +680,12 @@ struct drm_mode_config {
 	 */
 	struct drm_property *dvi_i_select_subconnector_property;
 
+	/**
+	 * @dp_subconnector_property: Optional DP property to differentiate
+	 * between different DP downstream port types.
+	 */
+	struct drm_property *dp_subconnector_property;
+
 	/**
 	 * @tv_subconnector_property: Optional TV property to differentiate
 	 * between different TV connector types.
include/uapi/drm/drm_mode.h +14 -8
index 735c8cfdaaa1..80e3118fee13 100644
@@ -332,14 +332,20 @@ struct drm_mode_get_encoder {
 /* This is for connectors with multiple signal types. */
 /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
 enum drm_mode_subconnector {
-	DRM_MODE_SUBCONNECTOR_Automatic = 0,
-	DRM_MODE_SUBCONNECTOR_Unknown = 0,
-	DRM_MODE_SUBCONNECTOR_DVID = 3,
-	DRM_MODE_SUBCONNECTOR_DVIA = 4,
-	DRM_MODE_SUBCONNECTOR_Composite = 5,
-	DRM_MODE_SUBCONNECTOR_SVIDEO = 6,
-	DRM_MODE_SUBCONNECTOR_Component = 8,
-	DRM_MODE_SUBCONNECTOR_SCART = 9,
+	DRM_MODE_SUBCONNECTOR_Automatic  = 0,  /* DVI-I, TV     */
+	DRM_MODE_SUBCONNECTOR_Unknown    = 0,  /* DVI-I, TV, DP */
+	DRM_MODE_SUBCONNECTOR_VGA	 = 1,  /*            DP */
+	DRM_MODE_SUBCONNECTOR_DVI	 = 2,  /*            DP */
+	DRM_MODE_SUBCONNECTOR_DVID	 = 3,  /* DVI-I         */
+	DRM_MODE_SUBCONNECTOR_DVIA	 = 4,  /* DVI-I         */
+	DRM_MODE_SUBCONNECTOR_Composite  = 5,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_SVIDEO	 = 6,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_Component  = 8,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_SCART	 = 9,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_DP	 = 10, /*            DP */
+	DRM_MODE_SUBCONNECTOR_HDMI       = 11, /*            DP */
+	DRM_MODE_SUBCONNECTOR_Native     = 15, /*            DP */
+	DRM_MODE_SUBCONNECTOR_Wireless   = 19, /*            DP */
 };
 
 #define DRM_MODE_CONNECTOR_Unknown	0
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH v3 3/7] drm: report dp downstream port type as a subconnector property

Quoted 131 lines · Oleg Vasilev

Currently, downstream port type is only reported in debugfs. This information should be considered important since it reflects the actual physical connector type. Some userspace (e.g. window compositors) may want to show this info to a user.

The 'subconnector' property is already utilized for DVI-I and TV-out for reporting connector subtype.

The initial motivation for this feature came from i2c test [1]. It is supposed to be skipped on VGA connectors, but it cannot detect VGA over DP and fails instead.

v2:
- Ville: utilized drm_dp_is_branch()
- Ville: implement DP 1.0 downstream type info
- Replaced create_dp_properties with add_dp_subconnector_property
- Added dp_set_subconnector_property helper

[1]: https://bugs.freedesktop.org/show_bug.cgi?id=104097

---
 drivers/gpu/drm/drm_connector.c | 49 +++++++++++++++++++++++-
 drivers/gpu/drm/drm_dp_helper.c | 68 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     |  3 ++
 include/drm/drm_dp_helper.h     |  8 ++++
 include/drm/drm_mode_config.h   |  6 +++
 include/uapi/drm/drm_mode.h     | 22 +++++++----
 6 files changed, 146 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_connector.c +47 -2
index 4c766624b20d..47e3466891db 100644
@@ -829,7 +829,7 @@ static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
 
 static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = {
-	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
+	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I, TV-out and DP */
 	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
 	{ DRM_MODE_SUBCONNECTOR_DVIA,      "DVI-A"     }, /* DVI-I  */
 };
@@ -846,7 +846,7 @@ static const struct drm_prop_enum_list drm_tv_select_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
 
 static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
-	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
+	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I, TV-out and DP */
 	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
 	{ DRM_MODE_SUBCONNECTOR_SVIDEO,    "SVIDEO"    }, /* TV-out */
 	{ DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */
@@ -855,6 +855,19 @@ static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
 		 drm_tv_subconnector_enum_list)
 
+static const struct drm_prop_enum_list drm_dp_subconnector_enum_list[] = {
+	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I, TV-out and DP */
+	{ DRM_MODE_SUBCONNECTOR_VGA,	   "VGA"       }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_DVI,	   "DVI"       }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_HDMI,	   "HDMI"      }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_DP,        "DP"        }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_Wireless,  "Wireless"  }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_Native,	   "Native"    }, /* DP */
+};
+
+DRM_ENUM_NAME_FN(drm_get_dp_subconnector_name,
+		 drm_dp_subconnector_enum_list)
+
 static const struct drm_prop_enum_list hdmi_colorspaces[] = {
 	/* For Default case, driver will set the colorspace */
 	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
@@ -1138,6 +1151,14 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] = {
  *	can also expose this property to external outputs, in which case they
  *	must support "None", which should be the default (since external screens
  *	have a built-in scaler).
+ *
+ * subconnector:
+ *	This property is used by DVI-I, TVout and DisplayPort to indicate different
+ *	connector subtypes. Enum values more or less match with those from main
+ *	connector types.
+ *	For DVI-I and TVout there is also a matching property "select subconnector"
+ *	allowing to switch between signal types.
+ *	DP subconnector corresponds to a downstream port.
  */
 
 int drm_connector_create_standard_properties(struct drm_device *dev)
@@ -1226,6 +1247,30 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_dvi_i_properties);
 
+/**
+ * drm_mode_add_dp_subconnector_property - create subconnector property for DP
+ * @connector: drm_connector to attach property
+ *
+ * Called by a driver when DP connector is created.
+ */
+void drm_mode_add_dp_subconnector_property(struct drm_connector *connector)
+{
+	struct drm_mode_config *mode_config = &connector->dev->mode_config;
+
+	if (!mode_config->dp_subconnector_property)
+		mode_config->dp_subconnector_property =
+			drm_property_create_enum(connector->dev,
+				DRM_MODE_PROP_IMMUTABLE,
+				"subconnector",
+				drm_dp_subconnector_enum_list,
+				ARRAY_SIZE(drm_dp_subconnector_enum_list));
+
+	drm_object_attach_property(&connector->base,
+				   mode_config->dp_subconnector_property,
+				   DRM_MODE_SUBCONNECTOR_Unknown);
+}
+EXPORT_SYMBOL(drm_mode_add_dp_subconnector_property);
+
 /**
  * DOC: HDMI connector properties
  *
drivers/gpu/drm/drm_dp_helper.c +2 -0
index 14320930091b..bca116cbc58f 100644
@@ -638,6 +638,74 @@ void drm_dp_downstream_debug(struct seq_file *m,
 }
 EXPORT_SYMBOL(drm_dp_downstream_debug);
 
+/**
+ * drm_dp_subconnector_type() - get DP branch device type

drivers/gpu/drm/drm_dp_helper.c void drm_dp_downstream_debug(struct seq_file *m, · line 652

Quoted 10 lines
drivers/gpu/drm/drm_dp_helper.c +10 -0
+ * @dpcd: DisplayPort configuration data
+ * @port_cap: port capabilities
+ *
+ */
+enum drm_mode_subconnector
+drm_dp_subconnector_type(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
+			 const u8 port_cap[4])
+{
+	int type;
+	bool branch_device_present = drm_dp_is_branch(dpcd);

Having a variable for this seems kinda pointless.

drivers/gpu/drm/drm_dp_helper.c void drm_dp_downstream_debug(struct seq_file *m, · line 661

Quoted 9 lines
drivers/gpu/drm/drm_dp_helper.c +9 -0
+
+	if (!branch_device_present)
+		return DRM_MODE_SUBCONNECTOR_Native;
+	/* DP 1.0 approach */
+	if (dpcd[DP_DPCD_REV] == DP_DPCD_REV_10) {
+		type = dpcd[DP_DOWNSTREAMPORT_PRESENT] &
+		       DP_DWN_STRM_PORT_TYPE_MASK;
+		if (type == DP_DWN_STRM_PORT_TYPE_DP)
+			return DRM_MODE_SUBCONNECTOR_DP;

TMDS -> DVI maybe?
analog -> VGA maybe?

Quoted 121 lines
drivers/gpu/drm/drm_dp_helper.c +47 -0
+		return DRM_MODE_SUBCONNECTOR_Unknown;
+	}
+	type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
+
+	switch (type) {
+	case DP_DS_PORT_TYPE_DP:
+	case DP_DS_PORT_TYPE_DP_DUALMODE:
+		return DRM_MODE_SUBCONNECTOR_DP;
+	case DP_DS_PORT_TYPE_VGA:
+		return DRM_MODE_SUBCONNECTOR_VGA;
+	case DP_DS_PORT_TYPE_DVI:
+		return DRM_MODE_SUBCONNECTOR_DVI;
+	case DP_DS_PORT_TYPE_HDMI:
+		return DRM_MODE_SUBCONNECTOR_HDMI;
+	case DP_DS_PORT_TYPE_WIRELESS:
+		return DRM_MODE_SUBCONNECTOR_Wireless;
+	case DP_DS_PORT_TYPE_NON_EDID:
+	default:
+		return DRM_MODE_SUBCONNECTOR_Unknown;
+	}
+}
+EXPORT_SYMBOL(drm_dp_subconnector_type);
+
+/**
+ * drm_mode_set_dp_subconnector_property - set subconnector for DP connector
+ * @connector: dp connector to attach property
+ * @status: connector status which is about to be set
+ * @dpcd: DisplayPort configuration data
+ * @port_cap: port capabilities
+ *
+ * Called by a driver on every detect event.
+ */
+void drm_dp_set_subconnector_property(struct drm_connector *connector,
+				      enum drm_connector_status status,
+				      const u8 *dpcd,
+				      const u8 port_cap[4])
+{
+	enum drm_mode_subconnector subconnector = DRM_MODE_SUBCONNECTOR_Unknown;
+
+	if (status == connector_status_connected)
+		subconnector = drm_dp_subconnector_type(dpcd, port_cap);
+	drm_object_property_set_value(&connector->base,
+			connector->dev->mode_config.dp_subconnector_property,
+			subconnector);
+}
+EXPORT_SYMBOL(drm_dp_set_subconnector_property);
+
 /*
  * I2C-over-AUX implementation
  */
include/drm/drm_connector.h +3 -0
index 681cb590f952..119606fcd59f 100644
@@ -1507,10 +1507,13 @@ const char *drm_get_dvi_i_subconnector_name(int val);
 const char *drm_get_dvi_i_select_name(int val);
 const char *drm_get_tv_subconnector_name(int val);
 const char *drm_get_tv_select_name(int val);
+const char *drm_get_dp_subconnector_name(int val);
 const char *drm_get_content_protection_name(int val);
 const char *drm_get_hdcp_content_type_name(int val);
 
 int drm_mode_create_dvi_i_properties(struct drm_device *dev);
+void drm_mode_add_dp_subconnector_property(struct drm_connector *connector);
+
 int drm_mode_create_tv_margin_properties(struct drm_device *dev);
 int drm_mode_create_tv_properties(struct drm_device *dev,
 				  unsigned int num_modes,
include/drm/drm_dp_helper.h +8 -0
index 1aea3e0810db..1fec3c731017 100644
@@ -26,6 +26,7 @@
 #include <linux/types.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <drm/drm_connector.h>
 
 /*
  * Unless otherwise noted, all values are from the DP 1.1a spec.  Note that
@@ -1378,6 +1379,13 @@ int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
 int drm_dp_downstream_id(struct drm_dp_aux *aux, char id[6]);
 void drm_dp_downstream_debug(struct seq_file *m, const u8 dpcd[DP_RECEIVER_CAP_SIZE],
 			     const u8 port_cap[4], struct drm_dp_aux *aux);
+enum drm_mode_subconnector
+drm_dp_subconnector_type(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
+			 const u8 port_cap[4]);
+void drm_dp_set_subconnector_property(struct drm_connector *connector,
+				      enum drm_connector_status status,
+				      const u8 *dpcd,
+				      const u8 port_cap[4]);
 
 void drm_dp_aux_init(struct drm_dp_aux *aux);
 int drm_dp_aux_register(struct drm_dp_aux *aux);
include/drm/drm_mode_config.h +6 -0
index 3bcbe30339f0..732d51951bce 100644
@@ -680,6 +680,12 @@ struct drm_mode_config {
 	 */
 	struct drm_property *dvi_i_select_subconnector_property;
 
+	/**
+	 * @dp_subconnector_property: Optional DP property to differentiate
+	 * between different DP downstream port types.
+	 */
+	struct drm_property *dp_subconnector_property;
+
 	/**
 	 * @tv_subconnector_property: Optional TV property to differentiate
 	 * between different TV connector types.
include/uapi/drm/drm_mode.h +0 -2
index 735c8cfdaaa1..80e3118fee13 100644
@@ -332,14 +332,20 @@ struct drm_mode_get_encoder {
 /* This is for connectors with multiple signal types. */
 /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
 enum drm_mode_subconnector {
-	DRM_MODE_SUBCONNECTOR_Automatic = 0,
-	DRM_MODE_SUBCONNECTOR_Unknown = 0,

include/uapi/drm/drm_mode.h struct drm_mode_get_encoder { · line 338

Quoted 10 lines
include/uapi/drm/drm_mode.h +4 -6
-	DRM_MODE_SUBCONNECTOR_DVID = 3,
-	DRM_MODE_SUBCONNECTOR_DVIA = 4,
-	DRM_MODE_SUBCONNECTOR_Composite = 5,
-	DRM_MODE_SUBCONNECTOR_SVIDEO = 6,
-	DRM_MODE_SUBCONNECTOR_Component = 8,
-	DRM_MODE_SUBCONNECTOR_SCART = 9,
+	DRM_MODE_SUBCONNECTOR_Automatic  = 0,  /* DVI-I, TV     */
+	DRM_MODE_SUBCONNECTOR_Unknown    = 0,  /* DVI-I, TV, DP */
+	DRM_MODE_SUBCONNECTOR_VGA	 = 1,  /*            DP */
+	DRM_MODE_SUBCONNECTOR_DVI	 = 2,  /*            DP */

I suspect the DP DFP TMDS/DVI stuff is always DVI-D. So maybe we should just reuse that one?

include/uapi/drm/drm_mode.h struct drm_mode_get_encoder { · line 346

Quoted 8 lines
include/uapi/drm/drm_mode.h +8 -0
+	DRM_MODE_SUBCONNECTOR_DVID	 = 3,  /* DVI-I         */
+	DRM_MODE_SUBCONNECTOR_DVIA	 = 4,  /* DVI-I         */
+	DRM_MODE_SUBCONNECTOR_Composite  = 5,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_SVIDEO	 = 6,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_Component  = 8,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_SCART	 = 9,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_DP	 = 10, /*            DP */
+	DRM_MODE_SUBCONNECTOR_HDMI       = 11, /*            DP */

Maybe we want to call it HDMIA just to match the connector counterpart?

include/uapi/drm/drm_mode.h struct drm_mode_get_encoder { · line 348

Quoted 2 lines
include/uapi/drm/drm_mode.h +2 -0
+	DRM_MODE_SUBCONNECTOR_Native     = 15, /*            DP */
+	DRM_MODE_SUBCONNECTOR_Wireless   = 19, /*            DP */

Not sure what numbers we should assign these. The comment says we're trying to match DRM_MODE_CONNECTOR_ here. Not sure why that's needed though.

Reusing the WRITEBACK value for Wireless seems like a safe choice?

Quoted 5 lines
include/uapi/drm/drm_mode.h +0 -0
 };
 
 #define DRM_MODE_CONNECTOR_Unknown	0
Signature · 1 line
2.23.0
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH v3 4/7 drm/i915: utilize subconnector property for DP

In reply to Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

v2: updates to match previous commit changes

---
 drivers/gpu/drm/i915/display/intel_dp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/display/intel_dp.c +6 -0
index 6da6a4859f06..9c97ece803eb 100644
@@ -5434,6 +5434,10 @@ intel_dp_detect(struct drm_connector *connector,
 	if (status != connector_status_connected && !intel_dp->is_mst)
 		intel_dp_unset_edid(intel_dp);
 
+	drm_dp_set_subconnector_property(connector,
+					 status,
+					 intel_dp->dpcd,
+					 intel_dp->downstream_ports);
 	return status;
 }
 
@@ -6332,6 +6336,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	enum port port = dp_to_dig_port(intel_dp)->base.port;
 
+	drm_mode_add_dp_subconnector_property(connector);
+
 	if (!IS_G4X(dev_priv) && port != PORT_A)
 		intel_attach_force_audio_property(connector);
 
Signature · 6 lines
2.23.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH v3 4/7] drm/i915: utilize subconnector property for DP

Quoted 30 lines · Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

v2: updates to match previous commit changes

---
 drivers/gpu/drm/i915/display/intel_dp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/display/intel_dp.c +4 -0
index 6da6a4859f06..9c97ece803eb 100644
@@ -5434,6 +5434,10 @@ intel_dp_detect(struct drm_connector *connector,
 	if (status != connector_status_connected && !intel_dp->is_mst)
 		intel_dp_unset_edid(intel_dp);
 
+	drm_dp_set_subconnector_property(connector,
+					 status,
+					 intel_dp->dpcd,
+					 intel_dp->downstream_ports);
 	return status;
 }
 

drivers/gpu/drm/i915/display/intel_dp.c intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect · line 6339

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_dp.c +1 -0
@@ -6332,6 +6336,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	enum port port = dp_to_dig_port(intel_dp)->base.port;
 
+	drm_mode_add_dp_subconnector_property(connector);

Maybe skip this for eDP?

Quoted 6 lines
drivers/gpu/drm/i915/display/intel_dp.c +1 -0
+
 	if (!IS_G4X(dev_priv) && port != PORT_A)
 		intel_attach_force_audio_property(connector);
 
Signature · 1 line
2.23.0
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

Re: [PATCH v3 4/7] drm/i915: utilize subconnector property for DP

Quoted 31 lines · Ville Syrjälä
Quoted 29 lines · Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

v2: updates to match previous commit changes

---
 drivers/gpu/drm/i915/display/intel_dp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/display/intel_dp.c +4 -0
index 6da6a4859f06..9c97ece803eb 100644
@@ -5434,6 +5434,10 @@ intel_dp_detect(struct drm_connector *connector,
      if (status != connector_status_connected && !intel_dp->is_mst)
              intel_dp_unset_edid(intel_dp);
 
+     drm_dp_set_subconnector_property(connector,
+                                      status,
+                                      intel_dp->dpcd,
+                                      intel_dp->downstream_ports);
      return status;
 }
 
Quoted 7 lines

drivers/gpu/drm/i915/display/intel_dp.c intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect · line 6339

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_dp.c +1 -0
@@ -6332,6 +6336,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
      struct drm_i915_private *dev_priv = to_i915(connector->dev);
      enum port port = dp_to_dig_port(intel_dp)->base.port;
 
+     drm_mode_add_dp_subconnector_property(connector);

Maybe skip this for eDP?

Not sure if you have something similar, but there are AMD platforms that contain eDP to LVDS bridges. Then again, probably not a big deal for the laptop panel.

Alex

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_dp.c +1 -1
+
      if (!IS_G4X(dev_priv) && port != PORT_A)
              intel_attach_force_audio_property(connector);
 
--

2.23.0

Quoted 7 lines

--
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Re: [PATCH v3 4/7] drm/i915: utilize subconnector property for DP

Quoted 37 lines · Alex Deucher
Quoted 35 lines · Ville Syrjälä
Quoted 33 lines · Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

v2: updates to match previous commit changes

---
 drivers/gpu/drm/i915/display/intel_dp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/display/intel_dp.c +4 -0
index 6da6a4859f06..9c97ece803eb 100644
@@ -5434,6 +5434,10 @@ intel_dp_detect(struct drm_connector *connector,
      if (status != connector_status_connected && !intel_dp->is_mst)
              intel_dp_unset_edid(intel_dp);
 
+     drm_dp_set_subconnector_property(connector,
+                                      status,
+                                      intel_dp->dpcd,
+                                      intel_dp->downstream_ports);
      return status;
 }
 
@@ -6332,6 +6336,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
      struct drm_i915_private *dev_priv = to_i915(connector->dev);
      enum port port = dp_to_dig_port(intel_dp)->base.port;
 
Quoted 7 lines
Quoted 3 lines

drivers/gpu/drm/i915/display/intel_dp.c intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect · line 6339

Quoted 1 line
drivers/gpu/drm/i915/display/intel_dp.c +1 -0
+     drm_mode_add_dp_subconnector_property(connector);

Maybe skip this for eDP?

Not sure if you have something similar, but there are AMD platforms that contain eDP to LVDS bridges. Then again, probably not a big deal for the laptop panel.

IIRC those don't generally expose the LVDS side as a DFP anyway. Ie. they just looks like a DP device with a local sink.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): 20190826132216.2823-1-oleg.vasilev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#10 lore raw

PATCH v3 5/7 drm/nouveau: utilize subconnector property for DP

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 13 +++++++++++++
 drivers/gpu/drm/nouveau/nouveau_dp.c        |  9 +++++++++
 drivers/gpu/drm/nouveau/nouveau_encoder.h   |  1 +
 3 files changed, 23 insertions(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +13 -0
index 94dfa2e5a9ab..d9c116cc11b9 100644
@@ -635,6 +635,17 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);
 
+	if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+	    connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+		enum drm_mode_subconnector subconnector = DRM_MODE_SUBCONNECTOR_Unknown;
+
+		if (conn_status == connector_status_connected && nv_encoder)
+			subconnector = nv_encoder->dp.subconnector;
+		drm_object_property_set_value(&connector->base,
+			connector->dev->mode_config.dp_subconnector_property,
+			subconnector);
+	}
+
 	return conn_status;
 }
 
@@ -1359,6 +1370,8 @@ nouveau_connector_create(struct drm_device *dev,
 			kfree(nv_connector);
 			return ERR_PTR(ret);
 		}
+
+		drm_mode_add_dp_subconnector_property(connector);
 		funcs = &nouveau_connector_funcs;
 		break;
 	default:
drivers/gpu/drm/nouveau/nouveau_dp.c +9 -0
index 2674f1587457..85eac853e3f8 100644
@@ -62,6 +62,7 @@ nouveau_dp_detect(struct nouveau_encoder *nv_encoder)
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nvkm_i2c_aux *aux;
 	u8 dpcd[8];
+	u8 port_cap[DP_MAX_DOWNSTREAM_PORTS] = {};
 	int ret;
 
 	aux = nv_encoder->aux;
@@ -72,6 +73,14 @@ nouveau_dp_detect(struct nouveau_encoder *nv_encoder)
 	if (ret)
 		return ret;
 
+	if (dpcd[DP_DPCD_REV] > 0x10) {
+		ret = nvkm_rdaux(aux, DP_DOWNSTREAM_PORT_0,
+				 port_cap, DP_MAX_DOWNSTREAM_PORTS);
+		if (ret)
+			memset(port_cap, 0, DP_MAX_DOWNSTREAM_PORTS);
+	}
+	nv_encoder->dp.subconnector = drm_dp_subconnector_type(dpcd, port_cap);
+
 	nv_encoder->dp.link_bw = 27000 * dpcd[1];
 	nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK;
 
drivers/gpu/drm/nouveau/nouveau_encoder.h +1 -0
index 3517f920bf89..e17971a30221 100644
@@ -63,6 +63,7 @@ struct nouveau_encoder {
 			struct nv50_mstm *mstm;
 			int link_nr;
 			int link_bw;
+			enum drm_mode_subconnector subconnector;
 		} dp;
 	};
 
Signature · 6 lines
2.23.0

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 20190826132216.2823-6-oleg.vasilev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#12 lore raw

Re: [PATCH v3 5/7] drm/nouveau: utilize subconnector property for DP

This should probably be fixed to account for the scenario where an HDMI connector is plugged directly into the DP++ port. I don't think the dp.subconnector property will be valid in that case. (Unfortunately I don't remember how one detects that particular situation.)

Quoted 87 lines · Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 13 +++++++++++++
 drivers/gpu/drm/nouveau/nouveau_dp.c        |  9 +++++++++
 drivers/gpu/drm/nouveau/nouveau_encoder.h   |  1 +
 3 files changed, 23 insertions(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +13 -0
index 94dfa2e5a9ab..d9c116cc11b9 100644
@@ -635,6 +635,17 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
        pm_runtime_mark_last_busy(dev->dev);
        pm_runtime_put_autosuspend(dev->dev);
 
+       if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+           connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+               enum drm_mode_subconnector subconnector = DRM_MODE_SUBCONNECTOR_Unknown;
+
+               if (conn_status == connector_status_connected && nv_encoder)
+                       subconnector = nv_encoder->dp.subconnector;
+               drm_object_property_set_value(&connector->base,
+                       connector->dev->mode_config.dp_subconnector_property,
+                       subconnector);
+       }
+
        return conn_status;
 }
 
@@ -1359,6 +1370,8 @@ nouveau_connector_create(struct drm_device *dev,
                        kfree(nv_connector);
                        return ERR_PTR(ret);
                }
+
+               drm_mode_add_dp_subconnector_property(connector);
                funcs = &nouveau_connector_funcs;
                break;
        default:
drivers/gpu/drm/nouveau/nouveau_dp.c +9 -0
index 2674f1587457..85eac853e3f8 100644
@@ -62,6 +62,7 @@ nouveau_dp_detect(struct nouveau_encoder *nv_encoder)
        struct nouveau_drm *drm = nouveau_drm(dev);
        struct nvkm_i2c_aux *aux;
        u8 dpcd[8];
+       u8 port_cap[DP_MAX_DOWNSTREAM_PORTS] = {};
        int ret;
 
        aux = nv_encoder->aux;
@@ -72,6 +73,14 @@ nouveau_dp_detect(struct nouveau_encoder *nv_encoder)
        if (ret)
                return ret;
 
+       if (dpcd[DP_DPCD_REV] > 0x10) {
+               ret = nvkm_rdaux(aux, DP_DOWNSTREAM_PORT_0,
+                                port_cap, DP_MAX_DOWNSTREAM_PORTS);
+               if (ret)
+                       memset(port_cap, 0, DP_MAX_DOWNSTREAM_PORTS);
+       }
+       nv_encoder->dp.subconnector = drm_dp_subconnector_type(dpcd, port_cap);
+
        nv_encoder->dp.link_bw = 27000 * dpcd[1];
        nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK;
 
drivers/gpu/drm/nouveau/nouveau_encoder.h +1 -1
index 3517f920bf89..e17971a30221 100644
@@ -63,6 +63,7 @@ struct nouveau_encoder {
                        struct nv50_mstm *mstm;
                        int link_nr;
                        int link_bw;
+                       enum drm_mode_subconnector subconnector;
                } dp;
        };
 
--

2.23.0

Quoted 4 lines

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): CAKb7UviahO6HWbxOoLyqN2X6WFw_GyucQuMs7Wj-MrKVNP1n_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#14 lore raw

Re: [PATCH v3 5/7] drm/nouveau: utilize subconnector property for DP

Quoted 5 lines · Ilia Mirkin

This should probably be fixed to account for the scenario where an HDMI connector is plugged directly into the DP++ port. I don't think the dp.subconnector property will be valid in that case. (Unfortunately I don't remember how one detects that particular situation.)

One may or may not be able to detect it very well. I've seen dongles that automagically change the DFP type from DP++ to DP/HDMI depending on what's plugged in, and I've also seen dongles that leave the DFP type to DP++.

I'm actually broiling a series of patches which try to improve how i915 handles various DFP types, and for that I'm thinking of using a combination of the DFP type and the EDID digital input type to differentiate between the two cases like so:

static bool is_edid_digital_input_dp(const struct edid *edid)

{
	return edid && edid->revision >= 4 &&
		edid->input & DRM_EDID_INPUT_DIGITAL &&
		(edid->input & DRM_EDID_DIGITAL_TYPE_MASK) == DRM_EDID_DIGITAL_TYPE_DP;
}
{
	switch (port_cap[0] & DP_DS_PORT_TYPE_MASK) {
	case DP_DS_PORT_TYPE_DP:
		DP_STUFF;
	case DP_DS_PORT_TYPE_DP_DUALMODE:
		if (is_edid_digital_input_dp(edid))
			DP_STUFF;
		/* fall through */
	case DP_DS_PORT_TYPE_HDMI:
	case DP_DS_PORT_TYPE_DVI:
		TMDS_STUFF;
}
Quoted 97 lines · Oleg Vasilev
Quoted 87 lines

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 13 +++++++++++++
 drivers/gpu/drm/nouveau/nouveau_dp.c        |  9 +++++++++
 drivers/gpu/drm/nouveau/nouveau_encoder.h   |  1 +
 3 files changed, 23 insertions(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +13 -0
index 94dfa2e5a9ab..d9c116cc11b9 100644
@@ -635,6 +635,17 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
        pm_runtime_mark_last_busy(dev->dev);
        pm_runtime_put_autosuspend(dev->dev);
 
+       if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+           connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+               enum drm_mode_subconnector subconnector = DRM_MODE_SUBCONNECTOR_Unknown;
+
+               if (conn_status == connector_status_connected && nv_encoder)
+                       subconnector = nv_encoder->dp.subconnector;
+               drm_object_property_set_value(&connector->base,
+                       connector->dev->mode_config.dp_subconnector_property,
+                       subconnector);
+       }
+
        return conn_status;
 }
 
@@ -1359,6 +1370,8 @@ nouveau_connector_create(struct drm_device *dev,
                        kfree(nv_connector);
                        return ERR_PTR(ret);
                }
+
+               drm_mode_add_dp_subconnector_property(connector);
                funcs = &nouveau_connector_funcs;
                break;
        default:
drivers/gpu/drm/nouveau/nouveau_dp.c +9 -0
index 2674f1587457..85eac853e3f8 100644
@@ -62,6 +62,7 @@ nouveau_dp_detect(struct nouveau_encoder *nv_encoder)
        struct nouveau_drm *drm = nouveau_drm(dev);
        struct nvkm_i2c_aux *aux;
        u8 dpcd[8];
+       u8 port_cap[DP_MAX_DOWNSTREAM_PORTS] = {};
        int ret;
 
        aux = nv_encoder->aux;
@@ -72,6 +73,14 @@ nouveau_dp_detect(struct nouveau_encoder *nv_encoder)
        if (ret)
                return ret;
 
+       if (dpcd[DP_DPCD_REV] > 0x10) {
+               ret = nvkm_rdaux(aux, DP_DOWNSTREAM_PORT_0,
+                                port_cap, DP_MAX_DOWNSTREAM_PORTS);
+               if (ret)
+                       memset(port_cap, 0, DP_MAX_DOWNSTREAM_PORTS);
+       }
+       nv_encoder->dp.subconnector = drm_dp_subconnector_type(dpcd, port_cap);
+
        nv_encoder->dp.link_bw = 27000 * dpcd[1];
        nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK;
 
drivers/gpu/drm/nouveau/nouveau_encoder.h +1 -1
index 3517f920bf89..e17971a30221 100644
@@ -63,6 +63,7 @@ struct nouveau_encoder {
                        struct nv50_mstm *mstm;
                        int link_nr;
                        int link_bw;
+                       enum drm_mode_subconnector subconnector;
                } dp;
        };
 
--

2.23.0

Quoted 4 lines

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#15 lore raw

Re: [Nouveau] [PATCH v3 5/7] drm/nouveau: utilize subconnector property for DP

Quoted 8 lines · Ville Syrjälä
Quoted 5 lines · Ilia Mirkin

This should probably be fixed to account for the scenario where an HDMI connector is plugged directly into the DP++ port. I don't think the dp.subconnector property will be valid in that case. (Unfortunately I don't remember how one detects that particular situation.)

Quoted 4 lines

One may or may not be able to detect it very well. I've seen dongles that automagically change the DFP type from DP++ to DP/HDMI depending on what's plugged in, and I've also seen dongles that leave the DFP type to DP++.

Well, our internal logic certainly knows if it's driving DP or TMDS. I just don't remember how it knows this.

-ilia
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): CAKb7Uvg=5BrQmLsq_=Cv1D_-baQ_crWRDePbnXXKy-jCVXtvsA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#17 lore raw

Re: [PATCH v3 5/7] drm/nouveau: utilize subconnector property for DP

Quoted 10 lines · Ilia Mirkin
Quoted 8 lines · Ville Syrjälä
Quoted 5 lines · Ilia Mirkin

This should probably be fixed to account for the scenario where an HDMI connector is plugged directly into the DP++ port. I don't think the dp.subconnector property will be valid in that case. (Unfortunately I don't remember how one detects that particular situation.)

Quoted 7 lines
Quoted 4 lines

One may or may not be able to detect it very well. I've seen dongles that automagically change the DFP type from DP++ to DP/HDMI depending on what's plugged in, and I've also seen dongles that leave the DFP type to DP++.

Well, our internal logic certainly knows if it's driving DP or TMDS. I just don't remember how it knows this.

You'll be driving DP in this case. The DFP will be the one driving DP or TMDS depending on what's plugged in.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#18 lore raw

Re: [Nouveau] [PATCH v3 5/7] drm/nouveau: utilize subconnector property for DP

Quoted 17 lines · Ville Syrjälä
Quoted 15 lines · Ilia Mirkin
Quoted 12 lines · Ville Syrjälä
Quoted 5 lines · Ilia Mirkin

This should probably be fixed to account for the scenario where an HDMI connector is plugged directly into the DP++ port. I don't think the dp.subconnector property will be valid in that case. (Unfortunately I don't remember how one detects that particular situation.)

One may or may not be able to detect it very well. I've seen dongles that automagically change the DFP type from DP++ to DP/HDMI depending on what's plugged in, and I've also seen dongles that leave the DFP type to DP++.

Quoted 5 lines
Quoted 2 lines

Well, our internal logic certainly knows if it's driving DP or TMDS. I just don't remember how it knows this.

You'll be driving DP in this case. The DFP will be the one driving DP or TMDS depending on what's plugged in.

OK. That's not the case I was worried about though :)

I'm worried about the case where you plug a true HDMI thing into the DP port, which will then be driven by HDMI and none of the dp.* things will be set (I don't remember, but they might even be in a union). I think Intel multiplies connectors for this, but nouveau/amd just have a single connector that handles both.

-ilia
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): CAKb7UviDZZkOAQWu+_Lqw3TbhnKq138XM5HXNRUzoc5GCCZGNA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#20 lore raw

Re: [PATCH v3 5/7] drm/nouveau: utilize subconnector property for DP

Quoted 25 lines · Ilia Mirkin
Quoted 17 lines · Ville Syrjälä
Quoted 15 lines · Ilia Mirkin
Quoted 12 lines · Ville Syrjälä
Quoted 5 lines · Ilia Mirkin

This should probably be fixed to account for the scenario where an HDMI connector is plugged directly into the DP++ port. I don't think the dp.subconnector property will be valid in that case. (Unfortunately I don't remember how one detects that particular situation.)

One may or may not be able to detect it very well. I've seen dongles that automagically change the DFP type from DP++ to DP/HDMI depending on what's plugged in, and I've also seen dongles that leave the DFP type to DP++.

Quoted 5 lines
Quoted 2 lines

Well, our internal logic certainly knows if it's driving DP or TMDS. I just don't remember how it knows this.

You'll be driving DP in this case. The DFP will be the one driving DP or TMDS depending on what's plugged in.

Quoted 7 lines

OK. That's not the case I was worried about though :)

I'm worried about the case where you plug a true HDMI thing into the DP port, which will then be driven by HDMI and none of the dp.* things will be set (I don't remember, but they might even be in a union). I think Intel multiplies connectors for this, but nouveau/amd just have a single connector that handles both.

Ah. Yeah, that's a bit more confusing since you kinda now have two levels of subconnectors. Not sure how to deal with that tbh.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#21 lore raw

PATCH v3 6/7 drm/amdgpu: utilize subconnector property for DP through atombios

In reply to a message not in the archive

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 10 ++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/atombios_dp.c       | 18 +++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +10 -0
index ece55c8fa673..348ed9e46bae 100644
@@ -26,6 +26,7 @@
 
 #include <drm/drm_edid.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_dp_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/amdgpu_drm.h>
 #include "amdgpu.h"
@@ -1407,6 +1408,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
 		pm_runtime_put_autosuspend(connector->dev->dev);
 	}
 
+	drm_dp_set_subconnector_property(&amdgpu_connector->base,
+					 ret,
+					 amdgpu_dig_connector->dpcd,
+					 amdgpu_dig_connector->downstream_ports);
 	return ret;
 }
 
@@ -1934,6 +1939,11 @@ amdgpu_connector_add(struct amdgpu_device *adev,
 	if (has_aux)
 		amdgpu_atombios_dp_aux_init(amdgpu_connector);
 
+	if (connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+	    connector_type == DRM_MODE_CONNECTOR_eDP) {
+		drm_mode_add_dp_subconnector_property(&amdgpu_connector->base);
+	}
+
 	return;
 
 failed:
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
index eb9975f4decb..cb360b44371c 100644
@@ -469,6 +469,7 @@ struct amdgpu_encoder {
 struct amdgpu_connector_atom_dig {
 	/* displayport */
 	u8 dpcd[DP_RECEIVER_CAP_SIZE];
+	u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
 	u8 dp_sink_type;
 	int dp_clock;
 	int dp_lane_count;
drivers/gpu/drm/amd/amdgpu/atombios_dp.c +17 -1
index 6858cde9fc5d..b0d414553e71 100644
@@ -334,6 +334,22 @@ static void amdgpu_atombios_dp_probe_oui(struct amdgpu_connector *amdgpu_connect
 			      buf[0], buf[1], buf[2]);
 }
 
+static void amdgpu_atombios_dp_ds_ports(struct amdgpu_connector *amdgpu_connector)
+{
+	struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
+	int ret;
+
+	if (dig_connector->dpcd[DP_DPCD_REV] > 0x10) {
+		ret = drm_dp_dpcd_read(&amdgpu_connector->ddc_bus->aux,
+				       DP_DOWNSTREAM_PORT_0,
+				       dig_connector->downstream_ports,
+				       DP_MAX_DOWNSTREAM_PORTS);
+		if (ret)
+			memset(dig_connector->downstream_ports, 0,
+			       DP_MAX_DOWNSTREAM_PORTS);
+	}
+}
+
 int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
 {
 	struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
@@ -349,7 +365,7 @@ int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
 			      dig_connector->dpcd);
 
 		amdgpu_atombios_dp_probe_oui(amdgpu_connector);
-
+		amdgpu_atombios_dp_ds_ports(amdgpu_connector);
 		return 0;
 	}
 
Signature · 6 lines
2.23.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20190826132216.2823-7-oleg.vasilev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#23 lore raw

Re: [PATCH v3 6/7] drm/amdgpu: utilize subconnector property for DP through atombios

Quoted 10 lines · Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>

Similar to Ilia's sentiments, do these make sense for amd drivers? We expose the physical connectors only. So physical DP ports show up as DP drm connectors and if you connect a passive DP to HDMI/DVI dingle, the driver just does the right thing. We don't expose multiple drm connectors for the same physical connector.

Alex

Quoted 92 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 10 ++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/atombios_dp.c       | 18 +++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +10 -0
index ece55c8fa673..348ed9e46bae 100644
@@ -26,6 +26,7 @@
 
 #include <drm/drm_edid.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_dp_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/amdgpu_drm.h>
 #include "amdgpu.h"
@@ -1407,6 +1408,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
                pm_runtime_put_autosuspend(connector->dev->dev);
        }
 
+       drm_dp_set_subconnector_property(&amdgpu_connector->base,
+                                        ret,
+                                        amdgpu_dig_connector->dpcd,
+                                        amdgpu_dig_connector->downstream_ports);
        return ret;
 }
 
@@ -1934,6 +1939,11 @@ amdgpu_connector_add(struct amdgpu_device *adev,
        if (has_aux)
                amdgpu_atombios_dp_aux_init(amdgpu_connector);
 
+       if (connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+           connector_type == DRM_MODE_CONNECTOR_eDP) {
+               drm_mode_add_dp_subconnector_property(&amdgpu_connector->base);
+       }
+
        return;
 
 failed:
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
index eb9975f4decb..cb360b44371c 100644
@@ -469,6 +469,7 @@ struct amdgpu_encoder {
 struct amdgpu_connector_atom_dig {
        /* displayport */
        u8 dpcd[DP_RECEIVER_CAP_SIZE];
+       u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
        u8 dp_sink_type;
        int dp_clock;
        int dp_lane_count;
drivers/gpu/drm/amd/amdgpu/atombios_dp.c +17 -2
index 6858cde9fc5d..b0d414553e71 100644
@@ -334,6 +334,22 @@ static void amdgpu_atombios_dp_probe_oui(struct amdgpu_connector *amdgpu_connect
                              buf[0], buf[1], buf[2]);
 }
 
+static void amdgpu_atombios_dp_ds_ports(struct amdgpu_connector *amdgpu_connector)
+{
+       struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
+       int ret;
+
+       if (dig_connector->dpcd[DP_DPCD_REV] > 0x10) {
+               ret = drm_dp_dpcd_read(&amdgpu_connector->ddc_bus->aux,
+                                      DP_DOWNSTREAM_PORT_0,
+                                      dig_connector->downstream_ports,
+                                      DP_MAX_DOWNSTREAM_PORTS);
+               if (ret)
+                       memset(dig_connector->downstream_ports, 0,
+                              DP_MAX_DOWNSTREAM_PORTS);
+       }
+}
+
 int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
 {
        struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
@@ -349,7 +365,7 @@ int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
                              dig_connector->dpcd);
 
                amdgpu_atombios_dp_probe_oui(amdgpu_connector);
-
+               amdgpu_atombios_dp_ds_ports(amdgpu_connector);
                return 0;
        }
 
--

2.23.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#24 lore raw

Re: [PATCH v3 6/7] drm/amdgpu: utilize subconnector property for DP through atombios

Quoted 12 lines · Alex Deucher
Quoted 10 lines · Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>
Quoted 5 lines

Similar to Ilia's sentiments, do these make sense for amd drivers? We expose the physical connectors only. So physical DP ports show up as DP drm connectors and if you connect a passive DP to HDMI/DVI dingle, the driver just does the right thing. We don't expose multiple drm connectors for the same physical connector.

After a bit more though I guess you could just

if (detected DP)

	set_subconnector_prop(DFP type);

else if (detected HDMI)
set_subconnector_prop(HDMI)

Quoted 103 lines

Alex

Quoted 92 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 10 ++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/atombios_dp.c       | 18 +++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +10 -0
index ece55c8fa673..348ed9e46bae 100644
@@ -26,6 +26,7 @@
 
 #include <drm/drm_edid.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_dp_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/amdgpu_drm.h>
 #include "amdgpu.h"
@@ -1407,6 +1408,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
                pm_runtime_put_autosuspend(connector->dev->dev);
        }
 
+       drm_dp_set_subconnector_property(&amdgpu_connector->base,
+                                        ret,
+                                        amdgpu_dig_connector->dpcd,
+                                        amdgpu_dig_connector->downstream_ports);
        return ret;
 }
 
@@ -1934,6 +1939,11 @@ amdgpu_connector_add(struct amdgpu_device *adev,
        if (has_aux)
                amdgpu_atombios_dp_aux_init(amdgpu_connector);
 
+       if (connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+           connector_type == DRM_MODE_CONNECTOR_eDP) {
+               drm_mode_add_dp_subconnector_property(&amdgpu_connector->base);
+       }
+
        return;
 
 failed:
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
index eb9975f4decb..cb360b44371c 100644
@@ -469,6 +469,7 @@ struct amdgpu_encoder {
 struct amdgpu_connector_atom_dig {
        /* displayport */
        u8 dpcd[DP_RECEIVER_CAP_SIZE];
+       u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
        u8 dp_sink_type;
        int dp_clock;
        int dp_lane_count;
drivers/gpu/drm/amd/amdgpu/atombios_dp.c +17 -2
index 6858cde9fc5d..b0d414553e71 100644
@@ -334,6 +334,22 @@ static void amdgpu_atombios_dp_probe_oui(struct amdgpu_connector *amdgpu_connect
                              buf[0], buf[1], buf[2]);
 }
 
+static void amdgpu_atombios_dp_ds_ports(struct amdgpu_connector *amdgpu_connector)
+{
+       struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
+       int ret;
+
+       if (dig_connector->dpcd[DP_DPCD_REV] > 0x10) {
+               ret = drm_dp_dpcd_read(&amdgpu_connector->ddc_bus->aux,
+                                      DP_DOWNSTREAM_PORT_0,
+                                      dig_connector->downstream_ports,
+                                      DP_MAX_DOWNSTREAM_PORTS);
+               if (ret)
+                       memset(dig_connector->downstream_ports, 0,
+                              DP_MAX_DOWNSTREAM_PORTS);
+       }
+}
+
 int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
 {
        struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
@@ -349,7 +365,7 @@ int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
                              dig_connector->dpcd);
 
                amdgpu_atombios_dp_probe_oui(amdgpu_connector);
-
+               amdgpu_atombios_dp_ds_ports(amdgpu_connector);
                return 0;
        }
 
--

2.23.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#25 lore raw

PATCH v3 7/7 drm/amdgpu: utilize subconnector property for DP through DisplayManager

In reply to a message not in the archive

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself. Display Core already has the subconnector information, we only need to expose it through DRM property.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 41 ++++++++++++++++++-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |  3 ++
 2 files changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +40 -1
index 028a710c1b46..ce3e243e6343 100644
@@ -143,6 +143,42 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 static void handle_cursor_update(struct drm_plane *plane,
 				 struct drm_plane_state *old_plane_state);
 
+static enum drm_mode_subconnector get_subconnector_type(struct dc_link *link)
+{
+	switch (link->dpcd_caps.dongle_type) {
+	case DISPLAY_DONGLE_NONE:
+		return DRM_MODE_SUBCONNECTOR_Native;
+	case DISPLAY_DONGLE_DP_VGA_CONVERTER:
+		return DRM_MODE_SUBCONNECTOR_VGA;
+	case DISPLAY_DONGLE_DP_DVI_CONVERTER:
+	case DISPLAY_DONGLE_DP_DVI_DONGLE:
+		return DRM_MODE_SUBCONNECTOR_DVI;
+	case DISPLAY_DONGLE_DP_HDMI_CONVERTER:
+	case DISPLAY_DONGLE_DP_HDMI_DONGLE:
+		return DRM_MODE_SUBCONNECTOR_HDMI;
+	case DISPLAY_DONGLE_DP_HDMI_MISMATCHED_DONGLE:
+	default:
+		return DRM_MODE_SUBCONNECTOR_Unknown;
+	}
+}
+
+static void update_subconnector_property(struct amdgpu_dm_connector *aconnector)
+{
+	struct dc_link *link = aconnector->dc_link;
+	struct drm_connector *connector = &aconnector->base;
+	enum drm_mode_subconnector subconnector = DRM_MODE_SUBCONNECTOR_Unknown;
+
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
+		return;
+
+	if (aconnector->dc_sink)
+		subconnector = get_subconnector_type(link);
+
+	drm_object_property_set_value(&connector->base,
+			connector->dev->mode_config.dp_subconnector_property,
+			subconnector);
+}
+
 /*
  * dm_vblank_get_counter
  *
@@ -1322,7 +1358,6 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
 	if (aconnector->mst_mgr.mst_state == true)
 		return;
 
-
 	sink = aconnector->dc_link->local_sink;
 	if (sink)
 		dc_sink_retain(sink);
@@ -1438,6 +1473,8 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
 
 	mutex_unlock(&dev->mode_config.mutex);
 
+	update_subconnector_property(aconnector);
+
 	if (sink)
 		dc_sink_release(sink);
 }
@@ -3774,6 +3811,8 @@ amdgpu_dm_connector_detect(struct drm_connector *connector, bool force)
 	else
 		connected = (aconnector->base.force == DRM_FORCE_ON);
 
+	update_subconnector_property(aconnector);
+
 	return (connected ? connector_status_connected :
 			connector_status_disconnected);
 }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +3 -0
index 16218a202b59..f4088914e34f 100644
@@ -25,6 +25,7 @@
 
 #include <linux/version.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_helper.h>
 #include "dm_services.h"
 #include "amdgpu.h"
 #include "amdgpu_dm.h"
@@ -425,5 +426,7 @@ void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
 		16,
 		4,
 		aconnector->connector_id);
+
+	drm_mode_add_dp_subconnector_property(&aconnector->base);
 }
 
Signature · 6 lines
2.23.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#26 lore raw

PATCH v4 1/7 drm: move DP_MAX_DOWNSTREAM_PORTS from i915 to drm core

In reply to Oleg Vasilev

DP_MAX_DOWNSTREAM_PORTS=0x10 is a vendor-independent constant.

---
 drivers/gpu/drm/i915/display/intel_display_types.h | 2 --
 include/drm/drm_dp_helper.h                        | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_display_types.h +0 -2
index 449abaea619f..b53fde16b86f 100644
@@ -1106,8 +1106,6 @@ struct intel_hdmi {
 };
 
 struct intel_dp_mst_encoder;
-#define DP_MAX_DOWNSTREAM_PORTS		0x10
-
 /*
  * enum link_m_n_set:
  *	When platform provides two set of M_N registers for dp, we can
include/drm/drm_dp_helper.h +2 -0
index 8364502f92cf..1aea3e0810db 100644
@@ -349,6 +349,8 @@
 # define DP_DS_12BPC		            2
 # define DP_DS_16BPC		            3
 
+#define DP_MAX_DOWNSTREAM_PORTS		    0x10
+
 /* DP Forward error Correction Registers */
 #define DP_FEC_CAPABILITY		    0x090    /* 1.4 */
 # define DP_FEC_CAPABLE			    (1 << 0)
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#27 lore raw

PATCH v4 2/7 drm: always determine branch device with drm_dp_is_branch()

The helper should always be used.

---
 drivers/gpu/drm/drm_dp_helper.c         | 3 +--
 drivers/gpu/drm/i915/display/intel_dp.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_dp_helper.c +1 -2
index ffc68d305afe..14320930091b 100644
@@ -573,8 +573,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
 	int len;
 	uint8_t rev[2];
 	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
-	bool branch_device = dpcd[DP_DOWNSTREAMPORT_PRESENT] &
-			     DP_DWN_STRM_PORT_PRESENT;
+	bool branch_device = drm_dp_is_branch(dpcd);
 
 	seq_printf(m, "\tDP branch device present: %s\n",
 		   branch_device ? "yes" : "no");
drivers/gpu/drm/i915/display/intel_dp.c +1 -1
index 23908da1cd5d..6da6a4859f06 100644
@@ -2922,7 +2922,7 @@ static bool downstream_hpd_needs_d0(struct intel_dp *intel_dp)
 	 * FIXME should really check all downstream ports...
 	 */
 	return intel_dp->dpcd[DP_DPCD_REV] == 0x11 &&
-		intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT &&
+		drm_dp_is_branch(intel_dp->dpcd) &&
 		intel_dp->downstream_ports[0] & DP_DS_PORT_HPD;
 }
 
Signature · 6 lines
2.23.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#28 lore raw

Re: [PATCH v4 2/7] drm: always determine branch device with drm_dp_is_branch()

Quoted 6 lines · Oleg Vasilev

The helper should always be used.

Pushed patches 1-2 to drm-misc-next, thanks for the patches and review.

BR,
Jani.

Quoted 31 lines
---
 drivers/gpu/drm/drm_dp_helper.c         | 3 +--
 drivers/gpu/drm/i915/display/intel_dp.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_dp_helper.c +1 -2
index ffc68d305afe..14320930091b 100644
@@ -573,8 +573,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
 	int len;
 	uint8_t rev[2];
 	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
-	bool branch_device = dpcd[DP_DOWNSTREAMPORT_PRESENT] &
-			     DP_DWN_STRM_PORT_PRESENT;
+	bool branch_device = drm_dp_is_branch(dpcd);
 
 	seq_printf(m, "\tDP branch device present: %s\n",
 		   branch_device ? "yes" : "no");
drivers/gpu/drm/i915/display/intel_dp.c +1 -1
index 23908da1cd5d..6da6a4859f06 100644
@@ -2922,7 +2922,7 @@ static bool downstream_hpd_needs_d0(struct intel_dp *intel_dp)
 	 * FIXME should really check all downstream ports...
 	 */
 	return intel_dp->dpcd[DP_DPCD_REV] == 0x11 &&
-		intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT &&
+		drm_dp_is_branch(intel_dp->dpcd) &&
 		intel_dp->downstream_ports[0] & DP_DS_PORT_HPD;
 }
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#29 lore raw

PATCH v4 3/7 drm: report dp downstream port type as a subconnector property

In reply to Oleg Vasilev

Currently, downstream port type is only reported in debugfs. This information should be considered important since it reflects the actual physical connector type. Some userspace (e.g. window compositors) may want to show this info to a user.

The 'subconnector' property is already utilized for DVI-I and TV-out for reporting connector subtype.

The initial motivation for this feature came from i2c test [1]. It is supposed to be skipped on VGA connectors, but it cannot detect VGA over DP and fails instead.

v2:
- Ville: utilized drm_dp_is_branch()
- Ville: implement DP 1.0 downstream type info
- Replaced create_dp_properties with add_dp_subconnector_property
- Added dp_set_subconnector_property helper

v4:
- Ville: add DP1.0 best assumption about subconnector
- Ville: assume DVI is DVI-D
- Ville: reuse Writeback enum value for Virtual subconnector
- Renamed #defines: HDMI -> HDMIA, DP -> DisplayPort

[1]: https://bugs.freedesktop.org/show_bug.cgi?id=104097

---
 drivers/gpu/drm/drm_connector.c | 49 ++++++++++++++++++++-
 drivers/gpu/drm/drm_dp_helper.c | 77 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     |  3 ++
 include/drm/drm_dp_helper.h     |  8 ++++
 include/drm/drm_mode_config.h   |  6 +++
 include/uapi/drm/drm_mode.h     | 21 +++++----
 6 files changed, 154 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_connector.c +47 -2
index 4c766624b20d..5bfb6713d02e 100644
@@ -829,7 +829,7 @@ static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
 
 static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = {
-	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
+	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I, TV-out and DP */
 	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
 	{ DRM_MODE_SUBCONNECTOR_DVIA,      "DVI-A"     }, /* DVI-I  */
 };
@@ -846,7 +846,7 @@ static const struct drm_prop_enum_list drm_tv_select_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
 
 static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
-	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
+	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I, TV-out and DP */
 	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
 	{ DRM_MODE_SUBCONNECTOR_SVIDEO,    "SVIDEO"    }, /* TV-out */
 	{ DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */
@@ -855,6 +855,19 @@ static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
 DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
 		 drm_tv_subconnector_enum_list)
 
+static const struct drm_prop_enum_list drm_dp_subconnector_enum_list[] = {
+	{ DRM_MODE_SUBCONNECTOR_Unknown,     "Unknown"   }, /* DVI-I, TV-out and DP */
+	{ DRM_MODE_SUBCONNECTOR_VGA,	     "VGA"       }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_DVID,	     "DVI-D"     }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_HDMIA,	     "HDMI"      }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_DisplayPort, "DP"        }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_Wireless,    "Wireless"  }, /* DP */
+	{ DRM_MODE_SUBCONNECTOR_Native,	     "Native"    }, /* DP */
+};
+
+DRM_ENUM_NAME_FN(drm_get_dp_subconnector_name,
+		 drm_dp_subconnector_enum_list)
+
 static const struct drm_prop_enum_list hdmi_colorspaces[] = {
 	/* For Default case, driver will set the colorspace */
 	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
@@ -1138,6 +1151,14 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] = {
  *	can also expose this property to external outputs, in which case they
  *	must support "None", which should be the default (since external screens
  *	have a built-in scaler).
+ *
+ * subconnector:
+ *	This property is used by DVI-I, TVout and DisplayPort to indicate different
+ *	connector subtypes. Enum values more or less match with those from main
+ *	connector types.
+ *	For DVI-I and TVout there is also a matching property "select subconnector"
+ *	allowing to switch between signal types.
+ *	DP subconnector corresponds to a downstream port.
  */
 
 int drm_connector_create_standard_properties(struct drm_device *dev)
@@ -1226,6 +1247,30 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_dvi_i_properties);
 
+/**
+ * drm_mode_add_dp_subconnector_property - create subconnector property for DP
+ * @connector: drm_connector to attach property
+ *
+ * Called by a driver when DP connector is created.
+ */
+void drm_mode_add_dp_subconnector_property(struct drm_connector *connector)
+{
+	struct drm_mode_config *mode_config = &connector->dev->mode_config;
+
+	if (!mode_config->dp_subconnector_property)
+		mode_config->dp_subconnector_property =
+			drm_property_create_enum(connector->dev,
+				DRM_MODE_PROP_IMMUTABLE,
+				"subconnector",
+				drm_dp_subconnector_enum_list,
+				ARRAY_SIZE(drm_dp_subconnector_enum_list));
+
+	drm_object_attach_property(&connector->base,
+				   mode_config->dp_subconnector_property,
+				   DRM_MODE_SUBCONNECTOR_Unknown);
+}
+EXPORT_SYMBOL(drm_mode_add_dp_subconnector_property);
+
 /**
  * DOC: HDMI connector properties
  *
drivers/gpu/drm/drm_dp_helper.c +77 -0

83 lines not on this page · raw message

include/drm/drm_connector.h +3 -0
index 681cb590f952..119606fcd59f 100644
@@ -1507,10 +1507,13 @@ const char *drm_get_dvi_i_subconnector_name(int val);
 const char *drm_get_dvi_i_select_name(int val);
 const char *drm_get_tv_subconnector_name(int val);
 const char *drm_get_tv_select_name(int val);
+const char *drm_get_dp_subconnector_name(int val);
 const char *drm_get_content_protection_name(int val);
 const char *drm_get_hdcp_content_type_name(int val);
 
 int drm_mode_create_dvi_i_properties(struct drm_device *dev);
+void drm_mode_add_dp_subconnector_property(struct drm_connector *connector);
+
 int drm_mode_create_tv_margin_properties(struct drm_device *dev);
 int drm_mode_create_tv_properties(struct drm_device *dev,
 				  unsigned int num_modes,
include/drm/drm_dp_helper.h +8 -0
index 1aea3e0810db..1fec3c731017 100644
@@ -26,6 +26,7 @@
 #include <linux/types.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <drm/drm_connector.h>
 
 /*
  * Unless otherwise noted, all values are from the DP 1.1a spec.  Note that
@@ -1378,6 +1379,13 @@ int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
 int drm_dp_downstream_id(struct drm_dp_aux *aux, char id[6]);
 void drm_dp_downstream_debug(struct seq_file *m, const u8 dpcd[DP_RECEIVER_CAP_SIZE],
 			     const u8 port_cap[4], struct drm_dp_aux *aux);
+enum drm_mode_subconnector
+drm_dp_subconnector_type(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
+			 const u8 port_cap[4]);
+void drm_dp_set_subconnector_property(struct drm_connector *connector,
+				      enum drm_connector_status status,
+				      const u8 *dpcd,
+				      const u8 port_cap[4]);
 
 void drm_dp_aux_init(struct drm_dp_aux *aux);
 int drm_dp_aux_register(struct drm_dp_aux *aux);
include/drm/drm_mode_config.h +6 -0
index 3bcbe30339f0..732d51951bce 100644
@@ -680,6 +680,12 @@ struct drm_mode_config {
 	 */
 	struct drm_property *dvi_i_select_subconnector_property;
 
+	/**
+	 * @dp_subconnector_property: Optional DP property to differentiate
+	 * between different DP downstream port types.
+	 */
+	struct drm_property *dp_subconnector_property;
+
 	/**
 	 * @tv_subconnector_property: Optional TV property to differentiate
 	 * between different TV connector types.
include/uapi/drm/drm_mode.h +13 -8
index 735c8cfdaaa1..3358c6b6926e 100644
@@ -332,14 +332,19 @@ struct drm_mode_get_encoder {
 /* This is for connectors with multiple signal types. */
 /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
 enum drm_mode_subconnector {
-	DRM_MODE_SUBCONNECTOR_Automatic = 0,
-	DRM_MODE_SUBCONNECTOR_Unknown = 0,
-	DRM_MODE_SUBCONNECTOR_DVID = 3,
-	DRM_MODE_SUBCONNECTOR_DVIA = 4,
-	DRM_MODE_SUBCONNECTOR_Composite = 5,
-	DRM_MODE_SUBCONNECTOR_SVIDEO = 6,
-	DRM_MODE_SUBCONNECTOR_Component = 8,
-	DRM_MODE_SUBCONNECTOR_SCART = 9,
+	DRM_MODE_SUBCONNECTOR_Automatic   = 0,  /* DVI-I, TV     */
+	DRM_MODE_SUBCONNECTOR_Unknown     = 0,  /* DVI-I, TV, DP */
+	DRM_MODE_SUBCONNECTOR_VGA	  = 1,  /*            DP */
+	DRM_MODE_SUBCONNECTOR_DVID	  = 3,  /* DVI-I      DP */
+	DRM_MODE_SUBCONNECTOR_DVIA	  = 4,  /* DVI-I         */
+	DRM_MODE_SUBCONNECTOR_Composite   = 5,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_SVIDEO	  = 6,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_Component   = 8,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_SCART	  = 9,  /*        TV     */
+	DRM_MODE_SUBCONNECTOR_DisplayPort = 10, /*            DP */
+	DRM_MODE_SUBCONNECTOR_HDMIA       = 11, /*            DP */
+	DRM_MODE_SUBCONNECTOR_Native      = 15, /*            DP */
+	DRM_MODE_SUBCONNECTOR_Wireless    = 18, /*            DP */
 };
 
 #define DRM_MODE_CONNECTOR_Unknown	0
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#30 lore raw

PATCH v4 4/7 drm/i915: utilize subconnector property for DP

In reply to Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

v2: updates to match previous commit changes

---
 drivers/gpu/drm/i915/display/intel_dp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/display/intel_dp.c +8 -0
index 6da6a4859f06..318c7e50cba3 100644
@@ -5434,6 +5434,11 @@ intel_dp_detect(struct drm_connector *connector,
 	if (status != connector_status_connected && !intel_dp->is_mst)
 		intel_dp_unset_edid(intel_dp);
 
+	if (!intel_dp_is_edp(intel_dp))
+		drm_dp_set_subconnector_property(connector,
+						 status,
+						 intel_dp->dpcd,
+						 intel_dp->downstream_ports);
 	return status;
 }
 
@@ -6332,6 +6337,9 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	enum port port = dp_to_dig_port(intel_dp)->base.port;
 
+	if (!intel_dp_is_edp(intel_dp))
+		drm_mode_add_dp_subconnector_property(connector);
+
 	if (!IS_G4X(dev_priv) && port != PORT_A)
 		intel_attach_force_audio_property(connector);
 
Signature · 6 lines
2.23.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): 20190829114854.1539-1-oleg.vasilev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#32 lore raw

PATCH v4 5/7 drm/nouveau: utilize subconnector property for DP

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 13 +++++++++++++
 drivers/gpu/drm/nouveau/nouveau_dp.c        |  9 +++++++++
 drivers/gpu/drm/nouveau/nouveau_encoder.h   |  1 +
 3 files changed, 23 insertions(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +13 -0
index 94dfa2e5a9ab..d9c116cc11b9 100644
@@ -635,6 +635,17 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);
 
+	if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+	    connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+		enum drm_mode_subconnector subconnector = DRM_MODE_SUBCONNECTOR_Unknown;
+
+		if (conn_status == connector_status_connected && nv_encoder)
+			subconnector = nv_encoder->dp.subconnector;
+		drm_object_property_set_value(&connector->base,
+			connector->dev->mode_config.dp_subconnector_property,
+			subconnector);
+	}
+
 	return conn_status;
 }
 
@@ -1359,6 +1370,8 @@ nouveau_connector_create(struct drm_device *dev,
 			kfree(nv_connector);
 			return ERR_PTR(ret);
 		}
+
+		drm_mode_add_dp_subconnector_property(connector);
 		funcs = &nouveau_connector_funcs;
 		break;
 	default:
drivers/gpu/drm/nouveau/nouveau_dp.c +9 -0
index 2674f1587457..85eac853e3f8 100644
@@ -62,6 +62,7 @@ nouveau_dp_detect(struct nouveau_encoder *nv_encoder)
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nvkm_i2c_aux *aux;
 	u8 dpcd[8];
+	u8 port_cap[DP_MAX_DOWNSTREAM_PORTS] = {};
 	int ret;
 
 	aux = nv_encoder->aux;
@@ -72,6 +73,14 @@ nouveau_dp_detect(struct nouveau_encoder *nv_encoder)
 	if (ret)
 		return ret;
 
+	if (dpcd[DP_DPCD_REV] > 0x10) {
+		ret = nvkm_rdaux(aux, DP_DOWNSTREAM_PORT_0,
+				 port_cap, DP_MAX_DOWNSTREAM_PORTS);
+		if (ret)
+			memset(port_cap, 0, DP_MAX_DOWNSTREAM_PORTS);
+	}
+	nv_encoder->dp.subconnector = drm_dp_subconnector_type(dpcd, port_cap);
+
 	nv_encoder->dp.link_bw = 27000 * dpcd[1];
 	nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK;
 
drivers/gpu/drm/nouveau/nouveau_encoder.h +1 -0
index 3517f920bf89..e17971a30221 100644
@@ -63,6 +63,7 @@ struct nouveau_encoder {
 			struct nv50_mstm *mstm;
 			int link_nr;
 			int link_bw;
+			enum drm_mode_subconnector subconnector;
 		} dp;
 	};
 
Signature · 6 lines
2.23.0

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#33 lore raw

PATCH v4 6/7 drm/amdgpu: utilize subconnector property for DP through atombios

In reply to Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 10 ++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/atombios_dp.c       | 18 +++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +10 -0
index ece55c8fa673..348ed9e46bae 100644
@@ -26,6 +26,7 @@
 
 #include <drm/drm_edid.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_dp_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/amdgpu_drm.h>
 #include "amdgpu.h"
@@ -1407,6 +1408,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
 		pm_runtime_put_autosuspend(connector->dev->dev);
 	}
 
+	drm_dp_set_subconnector_property(&amdgpu_connector->base,
+					 ret,
+					 amdgpu_dig_connector->dpcd,
+					 amdgpu_dig_connector->downstream_ports);
 	return ret;
 }
 
@@ -1934,6 +1939,11 @@ amdgpu_connector_add(struct amdgpu_device *adev,
 	if (has_aux)
 		amdgpu_atombios_dp_aux_init(amdgpu_connector);
 
+	if (connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+	    connector_type == DRM_MODE_CONNECTOR_eDP) {
+		drm_mode_add_dp_subconnector_property(&amdgpu_connector->base);
+	}
+
 	return;
 
 failed:
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
index eb9975f4decb..cb360b44371c 100644
@@ -469,6 +469,7 @@ struct amdgpu_encoder {
 struct amdgpu_connector_atom_dig {
 	/* displayport */
 	u8 dpcd[DP_RECEIVER_CAP_SIZE];
+	u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
 	u8 dp_sink_type;
 	int dp_clock;
 	int dp_lane_count;
drivers/gpu/drm/amd/amdgpu/atombios_dp.c +17 -1
index 6858cde9fc5d..b0d414553e71 100644
@@ -334,6 +334,22 @@ static void amdgpu_atombios_dp_probe_oui(struct amdgpu_connector *amdgpu_connect
 			      buf[0], buf[1], buf[2]);
 }
 
+static void amdgpu_atombios_dp_ds_ports(struct amdgpu_connector *amdgpu_connector)
+{
+	struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
+	int ret;
+
+	if (dig_connector->dpcd[DP_DPCD_REV] > 0x10) {
+		ret = drm_dp_dpcd_read(&amdgpu_connector->ddc_bus->aux,
+				       DP_DOWNSTREAM_PORT_0,
+				       dig_connector->downstream_ports,
+				       DP_MAX_DOWNSTREAM_PORTS);
+		if (ret)
+			memset(dig_connector->downstream_ports, 0,
+			       DP_MAX_DOWNSTREAM_PORTS);
+	}
+}
+
 int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
 {
 	struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
@@ -349,7 +365,7 @@ int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
 			      dig_connector->dpcd);
 
 		amdgpu_atombios_dp_probe_oui(amdgpu_connector);
-
+		amdgpu_atombios_dp_ds_ports(amdgpu_connector);
 		return 0;
 	}
 
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#34 lore raw

PATCH v4 7/7 drm/amdgpu: utilize subconnector property for DP through DisplayManager

In reply to Oleg Vasilev

Since DP-specific information is stored in driver's structures, every driver needs to implement subconnector property by itself. Display Core already has the subconnector information, we only need to expose it through DRM property.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 41 ++++++++++++++++++-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |  3 ++
 2 files changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +40 -1
index 028a710c1b46..6c03831f02f2 100644
@@ -143,6 +143,42 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 static void handle_cursor_update(struct drm_plane *plane,
 				 struct drm_plane_state *old_plane_state);
 
+static enum drm_mode_subconnector get_subconnector_type(struct dc_link *link)
+{
+	switch (link->dpcd_caps.dongle_type) {
+	case DISPLAY_DONGLE_NONE:
+		return DRM_MODE_SUBCONNECTOR_Native;
+	case DISPLAY_DONGLE_DP_VGA_CONVERTER:
+		return DRM_MODE_SUBCONNECTOR_VGA;
+	case DISPLAY_DONGLE_DP_DVI_CONVERTER:
+	case DISPLAY_DONGLE_DP_DVI_DONGLE:
+		return DRM_MODE_SUBCONNECTOR_DVID;
+	case DISPLAY_DONGLE_DP_HDMI_CONVERTER:
+	case DISPLAY_DONGLE_DP_HDMI_DONGLE:
+		return DRM_MODE_SUBCONNECTOR_HDMIA;
+	case DISPLAY_DONGLE_DP_HDMI_MISMATCHED_DONGLE:
+	default:
+		return DRM_MODE_SUBCONNECTOR_Unknown;
+	}
+}
+
+static void update_subconnector_property(struct amdgpu_dm_connector *aconnector)
+{
+	struct dc_link *link = aconnector->dc_link;
+	struct drm_connector *connector = &aconnector->base;
+	enum drm_mode_subconnector subconnector = DRM_MODE_SUBCONNECTOR_Unknown;
+
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
+		return;
+
+	if (aconnector->dc_sink)
+		subconnector = get_subconnector_type(link);
+
+	drm_object_property_set_value(&connector->base,
+			connector->dev->mode_config.dp_subconnector_property,
+			subconnector);
+}
+
 /*
  * dm_vblank_get_counter
  *
@@ -1322,7 +1358,6 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
 	if (aconnector->mst_mgr.mst_state == true)
 		return;
 
-
 	sink = aconnector->dc_link->local_sink;
 	if (sink)
 		dc_sink_retain(sink);
@@ -1438,6 +1473,8 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
 
 	mutex_unlock(&dev->mode_config.mutex);
 
+	update_subconnector_property(aconnector);
+
 	if (sink)
 		dc_sink_release(sink);
 }
@@ -3774,6 +3811,8 @@ amdgpu_dm_connector_detect(struct drm_connector *connector, bool force)
 	else
 		connected = (aconnector->base.force == DRM_FORCE_ON);
 
+	update_subconnector_property(aconnector);
+
 	return (connected ? connector_status_connected :
 			connector_status_disconnected);
 }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +3 -0
index 16218a202b59..f4088914e34f 100644
@@ -25,6 +25,7 @@
 
 #include <linux/version.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_helper.h>
 #include "dm_services.h"
 #include "amdgpu.h"
 #include "amdgpu_dm.h"
@@ -425,5 +426,7 @@ void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
 		16,
 		4,
 		aconnector->connector_id);
+
+	drm_mode_add_dp_subconnector_property(&aconnector->base);
 }
 
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel