xf86-video-ati: Branch 'master' - 2 commits

Michel Daenzer daenzer at kemper.freedesktop.org
Sat Oct 13 09:59:24 PDT 2007


 src/radeon_output.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 79 insertions(+), 4 deletions(-)

New commits:
diff-tree fd5bb7bb5e968127b87102320eccc1222f205e5a (from fbf121add5584049627f07345fc502b2aefc88ce)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sat Oct 13 18:56:43 2007 +0200

    radeon: Improve detection of default value for Option "MacModel" on Linux.
    
    * Detect all PowerBooks with dual link DVI (according to developer.apple.com)
      and both Mac Mini G4 models. Other PowerBooks and iBooks should be covered
      by the 'detected as' line in /proc/cpuinfo.
    * Give specific instructions for overriding and reporting incorrect detection.
    * Only perform detection when Option "MacModel" isn't present with a valid
      value.
    * Close /proc/cpuinfo file handle when done with it.
    * Coding style cleanups.

diff --git a/src/radeon_output.c b/src/radeon_output.c
index 0325d84..a5b1393 100644
--- a/src/radeon_output.c
+++ b/src/radeon_output.c
@@ -2832,42 +2832,76 @@ static void RADEONSetupGenericConnectors
 }
 
 #if defined(__powerpc__)
+
 /*
  * Returns RADEONMacModel or 0 based on lines 'detected as' and 'machine'
- * in /proc/cpuinfo file */
-static RADEONMacModel getMacModel (void){
-    RADEONMacModel dviConn = 0;
-    int macmodel = 0;
-    char cpuline[50];  /* 50 should be sufficient for /proc/cpuinfo lines */
+ * in /proc/cpuinfo (on Linux) */
+static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
+{
+    RADEONMacModel ret = 0;
+#ifdef __linux__
+    char cpuline[50];  /* 50 should be sufficient for our purposes */
     FILE *f = fopen ("/proc/cpuinfo", "r");
-    if (f != NULL){
-        while (fgets (cpuline, sizeof cpuline, f)){
-            char *start;
-            if (!strncmp (cpuline, "machine", strlen ("machine"))){
-                if ((start = strstr (cpuline, "PowerBook")) != NULL)
-                    macmodel = *(start + strlen ("PowerBook")) - '0';
-                /* macmodel cannot be used here, because 'machine' line arrives before 'detected as' line */
-            }else if (!strncmp (cpuline, "detected as", strlen ("detected as"))){
-                if (strstr (cpuline, "iBook"))
-                    dviConn = RADEON_MAC_IBOOK;
-                else if (strstr (cpuline, "PowerBook")){
-                    /* database with known DVI connectors:
-                     * dualllink: 5,2
-                     * singlelink: */
-                    if (macmodel >= 5)
-                        dviConn = RADEON_MAC_POWERBOOK_DL;
-                    else
-                        dviConn = RADEON_MAC_POWERBOOK;
+
+    if (f != NULL) {
+	while (fgets(cpuline, sizeof cpuline, f)) {
+	    if (!strncmp(cpuline, "machine", strlen ("machine"))) {
+		if (strstr(cpuline, "PowerBook5,6") ||
+		    strstr(cpuline, "PowerBook5,7") ||
+		    strstr(cpuline, "PowerBook5,8") ||
+		    strstr(cpuline, "PowerBook5,9")) {
+		    ret = RADEON_MAC_POWERBOOK_DL;
+		    break;
+		}
+
+		if (strstr(cpuline, "PowerMac10,1") ||
+		    strstr(cpuline, "PowerMac10,2")) {
+		    ret = RADEON_MAC_MINI;
+		    break;
+		}
+	    } else if (!strncmp(cpuline, "detected as", strlen("detected as"))) {
+                if (strstr(cpuline, "iBook")) {
+                    ret = RADEON_MAC_IBOOK;
+		    break;
+		} else if (strstr(cpuline, "PowerBook")) {
+		    ret = RADEON_MAC_POWERBOOK_DL;
+		    break;
                 }
-                /* else: 'detected as' line not found, we suppose not apple PowerPC computer, so nothing to do */
+
+                /* No known PowerMac model detected */
                 break;
             }
         }
-    }else
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot detect laptop model for DVI connector identification because /proc/cpuinfo not readable.  Please use the MacModel option in xorg.conf to configure it.\n");
-    return dviConn;
-}
+
+	fclose (f);
+    } else
+	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+		   "Cannot detect PowerMac model because /proc/cpuinfo not "
+		   "readable.\n");
+
+#endif /* __linux */
+
+    if (ret) {
+	xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Detected %s.\n",
+		   ret == RADEON_MAC_POWERBOOK_DL ? "PowerBook with dual link DVI" :
+		   ret == RADEON_MAC_POWERBOOK ? "PowerBook with single link DVI" :
+		   ret == RADEON_MAC_IBOOK ? "iBook" :
+		   "Mac Mini");
+	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+		   "If this is not correct, try Option \"MacModel\" and "
+		   "consider reporting to the\n");
+	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+		   "xorg-driver-ati at lists.x.org mailing list"
+#ifdef __linux__
+		   " with the contents of /proc/cpuinfo"
 #endif
+		   ".\n");
+    }
+
+    return ret;
+}
+
+#endif /* __powerpc__ */
 
 /*
  * initialise the static data sos we don't have to re-do at randr change */
@@ -2894,11 +2928,7 @@ Bool RADEONSetupConnectors(ScrnInfoPtr p
     }
 
 #if defined(__powerpc__)
-    info->MacModel = getMacModel ();
-    if (info->MacModel)
-        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detected DVI connector %d.\n", info->MacModel);
-
-    /* overwrite detected data, in case it's falsely detected */
+    info->MacModel = 0;
     optstr = (char *)xf86GetOptValString(info->Options, OPTION_MAC_MODEL);
     if (optstr) {
 	if (!strncmp("ibook", optstr, strlen("ibook")))
@@ -2911,10 +2941,13 @@ Bool RADEONSetupConnectors(ScrnInfoPtr p
 	    info->MacModel = RADEON_MAC_MINI;
 	else {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid Mac Model: %s\n", optstr);
-	    return FALSE;
 	}
     }
 
+    if (!info->MacModel) {
+	info->MacModel = RADEONDetectMacModel(pScrn);
+    }
+
     if (info->MacModel){
 	if (!RADEONSetupAppleConnectors(pScrn))
 	    RADEONSetupGenericConnectors(pScrn);
diff-tree fbf121add5584049627f07345fc502b2aefc88ce (from 5db3afaa1fdb69d382ac769ef40191a4b964d28e)
Author: Eugen Dedu <Eugen.Dedu at pu-pm.univ-fcomte.fr>
Date:   Sat Oct 13 16:51:58 2007 +0200

    radeon: Derive default value of Option "MacModel" from /proc/cpuinfo on Linux.

diff --git a/src/radeon_output.c b/src/radeon_output.c
index 4229eee..0325d84 100644
--- a/src/radeon_output.c
+++ b/src/radeon_output.c
@@ -2831,6 +2831,44 @@ static void RADEONSetupGenericConnectors
 
 }
 
+#if defined(__powerpc__)
+/*
+ * Returns RADEONMacModel or 0 based on lines 'detected as' and 'machine'
+ * in /proc/cpuinfo file */
+static RADEONMacModel getMacModel (void){
+    RADEONMacModel dviConn = 0;
+    int macmodel = 0;
+    char cpuline[50];  /* 50 should be sufficient for /proc/cpuinfo lines */
+    FILE *f = fopen ("/proc/cpuinfo", "r");
+    if (f != NULL){
+        while (fgets (cpuline, sizeof cpuline, f)){
+            char *start;
+            if (!strncmp (cpuline, "machine", strlen ("machine"))){
+                if ((start = strstr (cpuline, "PowerBook")) != NULL)
+                    macmodel = *(start + strlen ("PowerBook")) - '0';
+                /* macmodel cannot be used here, because 'machine' line arrives before 'detected as' line */
+            }else if (!strncmp (cpuline, "detected as", strlen ("detected as"))){
+                if (strstr (cpuline, "iBook"))
+                    dviConn = RADEON_MAC_IBOOK;
+                else if (strstr (cpuline, "PowerBook")){
+                    /* database with known DVI connectors:
+                     * dualllink: 5,2
+                     * singlelink: */
+                    if (macmodel >= 5)
+                        dviConn = RADEON_MAC_POWERBOOK_DL;
+                    else
+                        dviConn = RADEON_MAC_POWERBOOK;
+                }
+                /* else: 'detected as' line not found, we suppose not apple PowerPC computer, so nothing to do */
+                break;
+            }
+        }
+    }else
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot detect laptop model for DVI connector identification because /proc/cpuinfo not readable.  Please use the MacModel option in xorg.conf to configure it.\n");
+    return dviConn;
+}
+#endif
+
 /*
  * initialise the static data sos we don't have to re-do at randr change */
 Bool RADEONSetupConnectors(ScrnInfoPtr pScrn)
@@ -2856,9 +2894,12 @@ Bool RADEONSetupConnectors(ScrnInfoPtr p
     }
 
 #if defined(__powerpc__)
-    optstr = (char *)xf86GetOptValString(info->Options, OPTION_MAC_MODEL);
+    info->MacModel = getMacModel ();
+    if (info->MacModel)
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detected DVI connector %d.\n", info->MacModel);
 
-    info->MacModel = 0;
+    /* overwrite detected data, in case it's falsely detected */
+    optstr = (char *)xf86GetOptValString(info->Options, OPTION_MAC_MODEL);
     if (optstr) {
 	if (!strncmp("ibook", optstr, strlen("ibook")))
 	    info->MacModel = RADEON_MAC_IBOOK;
@@ -2872,10 +2913,11 @@ Bool RADEONSetupConnectors(ScrnInfoPtr p
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid Mac Model: %s\n", optstr);
 	    return FALSE;
 	}
+    }
 
+    if (info->MacModel){
 	if (!RADEONSetupAppleConnectors(pScrn))
 	    RADEONSetupGenericConnectors(pScrn);
-
     } else
 #endif
     if (xf86ReturnOptValBool(info->Options, OPTION_DEFAULT_CONNECTOR_TABLE, FALSE)) {


More information about the xorg-commit mailing list