diff mbox series

[v3] drm/nouveau: utilize subconnector property for DP

Message ID 1597560705-13897-1-git-send-email-jeevan.b@intel.com (mailing list archive)
State New, archived
Headers show
Series [v3] drm/nouveau: utilize subconnector property for DP | expand

Commit Message

B, Jeevan Aug. 16, 2020, 6:51 a.m. UTC
From: Oleg Vasilev <oleg.vasilev@intel.com>

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

v2: rebase

v3: renamed a function call

Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: nouveau@lists.freedesktop.org
Signed-off-by: Jeevan B <jeevan.b@intel.com>
Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
---
 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(+)

Comments

B, Jeevan Sept. 1, 2020, 7:23 a.m. UTC | #1
Hi Ben Skeggs,

Gentle Reminder, Can you please take a look at the patch and provide your ack.  

Thanks 
Jeevan B 

>-----Original Message-----
>From: B, Jeevan <jeevan.b@intel.com>
>Sent: Sunday, August 16, 2020 12:22 PM
>To: nouveau@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; dri-
>devel@lists.freedesktop.org
>Cc: bskeggs@redhat.com; airlied@redhat.com;
>maarten.lankhorst@linux.intel.com; Nikula, Jani <jani.nikula@intel.com>;
>Shankar, Uma <uma.shankar@intel.com>; Oleg Vasilev
><oleg.vasilev@intel.com>; B, Jeevan <jeevan.b@intel.com>
>Subject: [v3] drm/nouveau: utilize subconnector property for DP
>
>From: Oleg Vasilev <oleg.vasilev@intel.com>
>
>Since DP-specific information is stored in driver's structures, every driver
>needs to implement subconnector property by itself.
>
>v2: rebase
>
>v3: renamed a function call
>
>Cc: Ben Skeggs <bskeggs@redhat.com>
>Cc: nouveau@lists.freedesktop.org
>Signed-off-by: Jeevan B <jeevan.b@intel.com>
>Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
>Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
>---
> 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(+)
>
>diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c
>b/drivers/gpu/drm/nouveau/nouveau_connector.c
>index 7674025..955afed 100644
>--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
>+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
>@@ -654,6 +654,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;
> }
>
>@@ -1390,6 +1401,8 @@ nouveau_connector_create(struct drm_device *dev,
> 			kfree(nv_connector);
> 			return ERR_PTR(ret);
> 		}
>+
>+
>	drm_connector_attach_dp_subconnector_property(connector);
> 		funcs = &nouveau_connector_funcs;
> 		break;
> 	default:
>diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c
>b/drivers/gpu/drm/nouveau/nouveau_dp.c
>index 8a0f799..3eff884 100644
>--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
>+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
>@@ -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;
>
>diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h
>b/drivers/gpu/drm/nouveau/nouveau_encoder.h
>index a72c412..49b5c10 100644
>--- a/drivers/gpu/drm/nouveau/nouveau_encoder.h
>+++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h
>@@ -64,6 +64,7 @@ struct nouveau_encoder {
> 			struct nv50_mstm *mstm;
> 			int link_nr;
> 			int link_bw;
>+			enum drm_mode_subconnector subconnector;
> 		} dp;
> 	};
>
>--
>2.7.4
diff mbox series

Patch

diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 7674025..955afed 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -654,6 +654,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;
 }
 
@@ -1390,6 +1401,8 @@  nouveau_connector_create(struct drm_device *dev,
 			kfree(nv_connector);
 			return ERR_PTR(ret);
 		}
+
+		drm_connector_attach_dp_subconnector_property(connector);
 		funcs = &nouveau_connector_funcs;
 		break;
 	default:
diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c
index 8a0f799..3eff884 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h b/drivers/gpu/drm/nouveau/nouveau_encoder.h
index a72c412..49b5c10 100644
--- a/drivers/gpu/drm/nouveau/nouveau_encoder.h
+++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h
@@ -64,6 +64,7 @@  struct nouveau_encoder {
 			struct nv50_mstm *mstm;
 			int link_nr;
 			int link_bw;
+			enum drm_mode_subconnector subconnector;
 		} dp;
 	};