[PATCH] drm/radeon: Report panel connector status as unknown when lid is closed

Michel Dänzer michel at daenzer.net
Wed Jul 8 01:24:57 PDT 2015


From: Michel Dänzer <michel.daenzer at amd.com>

This makes fbcon and desktop environments such as GNOME automatically
not use the panel when the lid is closed.

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 drivers/gpu/drm/radeon/radeon_connectors.c | 82 ++++++++++++++++--------------
 1 file changed, 44 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index cebb65e..2484438 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -23,6 +23,7 @@
  * Authors: Dave Airlie
  *          Alex Deucher
  */
+#include <acpi/button.h>
 #include <drm/drmP.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_crtc_helper.h>
@@ -890,25 +891,27 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
 	if (r < 0)
 		return connector_status_disconnected;
 
-	if (encoder) {
-		struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-		struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
+	if (acpi_lid_open()) {
+		if (encoder) {
+			struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+			struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
 
-		/* check if panel is valid */
-		if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
-			ret = connector_status_connected;
-		/* don't fetch the edid from the vbios if ddc fails and runpm is
-		 * enabled so we report disconnected.
-		 */
-		if ((rdev->flags & RADEON_IS_PX) && (radeon_runtime_pm != 0))
-			ret = connector_status_disconnected;
-	}
+			/* check if panel is valid */
+			if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
+				ret = connector_status_connected;
+			/* don't fetch the edid from the vbios if ddc fails and runpm is
+			 * enabled so we report disconnected.
+			 */
+			if ((rdev->flags & RADEON_IS_PX) && (radeon_runtime_pm != 0))
+				ret = connector_status_disconnected;
+		}
 
-	/* check for edid as well */
-	radeon_connector_get_edid(connector);
-	if (radeon_connector->edid)
-		ret = connector_status_connected;
-	/* check acpi lid status ??? */
+		/* check for edid as well */
+		radeon_connector_get_edid(connector);
+		if (radeon_connector->edid)
+			ret = connector_status_connected;
+	} else
+		ret = connector_status_unknown;
 
 	radeon_connector_update_scratch_regs(connector, ret);
 	pm_runtime_mark_last_busy(connector->dev->dev);
@@ -1647,29 +1650,32 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
 
 	if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) ||
 	    (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) {
-		if (encoder) {
-			struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-			struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
+		if (acpi_lid_open()) {
+			if (encoder) {
+				struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+				struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
 
-			/* check if panel is valid */
-			if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
+				/* check if panel is valid */
+				if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
+					ret = connector_status_connected;
+				/* don't fetch the edid from the vbios if ddc fails and runpm is
+				 * enabled so we report disconnected.
+				 */
+				if ((rdev->flags & RADEON_IS_PX) && (radeon_runtime_pm != 0))
+					ret = connector_status_disconnected;
+			}
+			/* eDP is always DP */
+			radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT;
+			if (!radeon_dig_connector->edp_on)
+				atombios_set_edp_panel_power(connector,
+							     ATOM_TRANSMITTER_ACTION_POWER_ON);
+			if (radeon_dp_getdpcd(radeon_connector))
 				ret = connector_status_connected;
-			/* don't fetch the edid from the vbios if ddc fails and runpm is
-			 * enabled so we report disconnected.
-			 */
-			if ((rdev->flags & RADEON_IS_PX) && (radeon_runtime_pm != 0))
-				ret = connector_status_disconnected;
-		}
-		/* eDP is always DP */
-		radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT;
-		if (!radeon_dig_connector->edp_on)
-			atombios_set_edp_panel_power(connector,
-						     ATOM_TRANSMITTER_ACTION_POWER_ON);
-		if (radeon_dp_getdpcd(radeon_connector))
-			ret = connector_status_connected;
-		if (!radeon_dig_connector->edp_on)
-			atombios_set_edp_panel_power(connector,
-						     ATOM_TRANSMITTER_ACTION_POWER_OFF);
+			if (!radeon_dig_connector->edp_on)
+				atombios_set_edp_panel_power(connector,
+							     ATOM_TRANSMITTER_ACTION_POWER_OFF);
+		} else
+			ret = connector_status_unknown;
 	} else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) !=
 		   ENCODER_OBJECT_ID_NONE) {
 		/* DP bridges are always DP */
-- 
2.1.4



More information about the dri-devel mailing list