Skip to contentSkip to conversation

drm/radeon: hotplug of passive dp to dvi|hdmi|vga adaptor

PATCH In review [email protected] 2 participants 3 messages Jul 19, 2012 – Jul 20, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon: hotplug of passive dp to dvi|hdmi|vga adaptor

From: Jerome Glisse <[email protected]>

We should not turn off the connector neither try to retrain DP link if a passive DP adaptor is connected to a DP port.

---
 drivers/gpu/drm/radeon/radeon_connectors.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_connectors.c +20 -2
index 2914c57..890cf1d 100644
@@ -49,6 +49,7 @@ void radeon_connector_hotplug(struct drm_connector *connector)
 	struct drm_device *dev = connector->dev;
 	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_connector *radeon_connector = to_radeon_connector(connector);
+	struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
 
 	/* bail if the connector does not have hpd pin, e.g.,
 	 * VGA, TV, etc.
@@ -62,15 +63,32 @@ void radeon_connector_hotplug(struct drm_connector *connector)
 	if (connector->dpms != DRM_MODE_DPMS_ON)
 		return;
 
+	/* don't do anything is sink is not display port
+	 * (passive dp->(dvi|hdmi|vga) adaptor
+	 */
+	if (radeon_dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT) {
+		return;
+	}
+
 	/* just deal with DP (not eDP) here. */
 	if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
 		int saved_dpms = connector->dpms;
 
 		/* Only turn off the display it it's physically disconnected */
-		if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
+		if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
 			drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-		else if (radeon_dp_needs_link_train(radeon_connector))
+		} else if (radeon_dp_needs_link_train(radeon_connector)) {
+
+			/* first get sink type as it's reset after unplug */
+			radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector);
+			/* don't do anything is sink is not display port
+			 * (passive dp->(dvi|hdmi|vga) adaptor
+			 */
+			if (radeon_dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT) {
+				return;
+			}
 			drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
+		}
 		connector->dpms = saved_dpms;
 	}
 }
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 7 lines · On Thu, Jul 19, 2012 at 5:12 PM, <[email protected]> wrote:

From: Jerome Glisse <[email protected]>

We should not turn off the connector neither try to retrain DP link if a passive DP adaptor is connected to a DP port.

Looks good although we should probably wait to assign radeon_connector_atom_dig until we know we have a digital connector. How about the attached patches (also a follow up on your patch from yesterday)?

Alex

Quoted 54 lines
---
 drivers/gpu/drm/radeon/radeon_connectors.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_connectors.c +20 -3
index 2914c57..890cf1d 100644
@@ -49,6 +49,7 @@ void radeon_connector_hotplug(struct drm_connector *connector)
        struct drm_device *dev = connector->dev;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_connector *radeon_connector = to_radeon_connector(connector);
+       struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
 
        /* bail if the connector does not have hpd pin, e.g.,
         * VGA, TV, etc.
@@ -62,15 +63,32 @@ void radeon_connector_hotplug(struct drm_connector *connector)
        if (connector->dpms != DRM_MODE_DPMS_ON)
                return;
 
+       /* don't do anything is sink is not display port
+        * (passive dp->(dvi|hdmi|vga) adaptor
+        */
+       if (radeon_dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT) {
+               return;
+       }
+
        /* just deal with DP (not eDP) here. */
        if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
                int saved_dpms = connector->dpms;
 
                /* Only turn off the display it it's physically disconnected */
-               if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
+               if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
                        drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-               else if (radeon_dp_needs_link_train(radeon_connector))
+               } else if (radeon_dp_needs_link_train(radeon_connector)) {
+
+                       /* first get sink type as it's reset after unplug */
+                       radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector);
+                       /* don't do anything is sink is not display port
+                        * (passive dp->(dvi|hdmi|vga) adaptor
+                        */
+                       if (radeon_dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT) {
+                               return;
+                       }
                        drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
+               }
                connector->dpms = saved_dpms;
        }
 }
--

1.7.10.4

Quoted 4 lines

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

From 1d5f2cb85fba0aafbd403a8a26787d4bf074fed6 Mon Sep 17 00:00:00 2001
From: Jerome Glisse <[email protected]>
Date: Thu, 19 Jul 2012 17:15:56 -0400
Subject: [PATCH 1/2] drm/radeon: fix hotplug of DP to DVI|HDMI passive
adapters (v2)

No need to retrain the link for passive adapters.

v2: agd5f
- no passive DP to VGA adapters, update comments
- assign radeon_connector_atom_dig after we are sure we have a digital connector as analog connectors have different private data.
- get new sink type before checking for retrain. No need to check if it's no longer a DP connection.

---
 drivers/gpu/drm/radeon/radeon_connectors.c |   29 ++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 8 deletions(-)
drivers/gpu/drm/radeon/radeon_connectors.c +21 -8
index 2914c57..3524f17 100644
@@ -64,14 +64,27 @@ void radeon_connector_hotplug(struct drm_connector *connector)
 
 	/* just deal with DP (not eDP) here. */
 	if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
-		int saved_dpms = connector->dpms;
-
-		/* Only turn off the display it it's physically disconnected */
-		if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
-			drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-		else if (radeon_dp_needs_link_train(radeon_connector))
-			drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
-		connector->dpms = saved_dpms;
+		struct radeon_connector_atom_dig *dig_connector =
+			radeon_connector->con_priv;
+
+		/* if existing sink type was not DP no need to retrain */
+		if (dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT)
+			return;
+
+		/* first get sink type as it may be reset after (un)plug */
+		dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector);
+		/* don't do anything if sink is not display port, i.e.,
+		 * passive dp->(dvi|hdmi) adaptor
+		 */
+		if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) {
+			int saved_dpms = connector->dpms;
+			/* Only turn off the display if it's physically disconnected */
+			if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
+				drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+			else if (radeon_dp_needs_link_train(radeon_connector))
+				drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
+			connector->dpms = saved_dpms;
+		}
 	}
 }
 
Signature · 1 line
1.7.7.5

From 9de839f3907cf04febdeed0e92528c729f4e735c Mon Sep 17 00:00:00 2001
From: Jerome Glisse <[email protected]>
Date: Thu, 19 Jul 2012 17:25:55 -0400
Subject: [PATCH 2/2] drm/radeon: on hotplug force link training to happen
(v2)

To have DP behave like VGA/DVI we need to retrain the link on hotplug. For this to happen we need to force link training to happen by setting connector dpms to off before asking it turning it on again.

v2: agd5f
- drop the dp_get_link_status() change in atombios_dp.c for now. We still need the dpms OFF change.

---
 drivers/gpu/drm/radeon/radeon_connectors.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_connectors.c +8 -2
index 3524f17..895e628 100644
@@ -79,10 +79,16 @@ void radeon_connector_hotplug(struct drm_connector *connector)
 		if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) {
 			int saved_dpms = connector->dpms;
 			/* Only turn off the display if it's physically disconnected */
-			if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
+			if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
 				drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-			else if (radeon_dp_needs_link_train(radeon_connector))
+			} else if (radeon_dp_needs_link_train(radeon_connector)) {
+				/* set it to OFF so that drm_helper_connector_dpms()
+				 * won't return immediately since the current state
+				 * is ON at this point.
+				 */
+				connector->dpms = DRM_MODE_DPMS_OFF;
 				drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
+			}
 			connector->dpms = saved_dpms;
 		}
 	}
Signature · 1 line
1.7.7.5

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

#2 lore raw
Quoted 9 lines · Alex Deucher
Quoted 7 lines · On Thu, Jul 19, 2012 at 5:12 PM, <[email protected]> wrote:

From: Jerome Glisse <[email protected]>

We should not turn off the connector neither try to retrain DP link if a passive DP adaptor is connected to a DP port.

Quoted 6 lines

Looks good although we should probably wait to assign radeon_connector_atom_dig until we know we have a digital connector. How about the attached patches (also a follow up on your patch from yesterday)?

Alex

Yes looks better.

Cheers,
Jerome

Quoted 58 lines
Quoted 58 lines
---
 drivers/gpu/drm/radeon/radeon_connectors.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_connectors.c +20 -3
index 2914c57..890cf1d 100644
@@ -49,6 +49,7 @@ void radeon_connector_hotplug(struct drm_connector *connector)
        struct drm_device *dev = connector->dev;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_connector *radeon_connector = to_radeon_connector(connector);
+       struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
 
        /* bail if the connector does not have hpd pin, e.g.,
         * VGA, TV, etc.
@@ -62,15 +63,32 @@ void radeon_connector_hotplug(struct drm_connector *connector)
        if (connector->dpms != DRM_MODE_DPMS_ON)
                return;
 
+       /* don't do anything is sink is not display port
+        * (passive dp->(dvi|hdmi|vga) adaptor
+        */
+       if (radeon_dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT) {
+               return;
+       }
+
        /* just deal with DP (not eDP) here. */
        if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
                int saved_dpms = connector->dpms;
 
                /* Only turn off the display it it's physically disconnected */
-               if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
+               if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
                        drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-               else if (radeon_dp_needs_link_train(radeon_connector))
+               } else if (radeon_dp_needs_link_train(radeon_connector)) {
+
+                       /* first get sink type as it's reset after unplug */
+                       radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector);
+                       /* don't do anything is sink is not display port
+                        * (passive dp->(dvi|hdmi|vga) adaptor
+                        */
+                       if (radeon_dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT) {
+                               return;
+                       }
                        drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
+               }
                connector->dpms = saved_dpms;
        }
 }
--

1.7.10.4

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