xf86-video-ati: Branch 'master'

Alex Deucher agd5f at kemper.freedesktop.org
Wed Dec 12 16:40:20 PST 2007


 src/radeon_output.c |   54 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 41 insertions(+), 13 deletions(-)

New commits:
commit 1668f2056f56370f1b5681c13f1e14904e301216
Author: Alex Deucher <alex at t41p.hsd1.va.comcast.net>
Date:   Wed Dec 12 19:39:08 2007 -0500

    RADEON: use /proc/acpi to determine lid status
    
    Linux only

diff --git a/src/radeon_output.c b/src/radeon_output.c
index d041d54..12c83aa 100644
--- a/src/radeon_output.c
+++ b/src/radeon_output.c
@@ -684,6 +684,45 @@ void RADEONConnectorFindMonitor(ScrnInfoPtr pScrn, xf86OutputPtr output)
     }
 }
 
+static RADEONMonitorType
+RADEONDetectLidStatus(ScrnInfoPtr pScrn)
+{
+    RADEONInfoPtr info = RADEONPTR(pScrn);
+    RADEONMonitorType MonType = MT_NONE;
+#ifdef __linux__
+    char lidline[50];  /* 50 should be sufficient for our purposes */
+    FILE *f = fopen ("/proc/acpi/button/lid/LID/state", "r");
+
+    if (f != NULL) {
+	while (fgets(lidline, sizeof lidline, f)) {
+	    if (!strncmp(lidline, "state:", strlen ("state:"))) {
+		if (strstr(lidline, "open")) {
+		    ErrorF("proc lid open\n");
+		    return MT_LCD;
+		}
+		else if (strstr(lidline, "closed")) {
+		    ErrorF("proc lid closed\n");
+		    return MT_NONE;
+		}
+	    }
+	}
+    }
+#endif
+
+    if (!info->IsAtomBios) {
+	unsigned char *RADEONMMIO = info->MMIO;
+
+	/* see if the lid is closed -- only works at boot */
+	if (INREG(RADEON_BIOS_6_SCRATCH) & 0x10)
+	    MonType = MT_NONE;
+	else
+	    MonType = MT_LCD;
+    } else
+	MonType = MT_LCD;
+
+    return MonType;
+}
+
 static RADEONMonitorType RADEONPortCheckNonDDC(ScrnInfoPtr pScrn, xf86OutputPtr output)
 {
     RADEONOutputPrivatePtr radeon_output = output->driver_private;
@@ -691,21 +730,10 @@ static RADEONMonitorType RADEONPortCheckNonDDC(ScrnInfoPtr pScrn, xf86OutputPtr
 
     if (radeon_output->type == OUTPUT_LVDS) {
 #if defined(__powerpc__)
-	/* not sure on ppc, OF? */
+	MonType = MT_LCD;
 #else
-	RADEONInfoPtr info       = RADEONPTR(pScrn);
-
-	if (!info->IsAtomBios) {
-	    unsigned char *RADEONMMIO = info->MMIO;
-
-	    /* see if the lid is closed -- only works at boot */
-	    if (INREG(RADEON_BIOS_6_SCRATCH) & 0x10)
-		MonType = MT_NONE;
-	    else
-		MonType = MT_LCD;
-	} else
+	MonType = RADEONDetectLidStatus(pScrn);
 #endif
-	    MonType = MT_LCD;
     } /*else if (radeon_output->type == OUTPUT_DVI) {
 	if (radeon_output->TMDSType == TMDS_INT) {
 	    if (INREG(RADEON_FP_GEN_CNTL) & RADEON_FP_DETECT_SENSE)


More information about the xorg-commit mailing list