summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Dedu <Eugen.Dedu@pu-pm.univ-fcomte.fr>2007-10-13 16:51:58 +0200
committerMichel Dänzer <michel@tungstengraphics.com>2007-10-13 16:51:58 +0200
commitfbf121add5584049627f07345fc502b2aefc88ce (patch)
tree4bdb5ab49d7939b20826e8fb437cd678c7598293
parent5db3afaa1fdb69d382ac769ef40191a4b964d28e (diff)
radeon: Derive default value of Option "MacModel" from /proc/cpuinfo on Linux.
-rw-r--r--src/radeon_output.c48
1 files changed, 45 insertions, 3 deletions
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(ScrnInfoPtr pScrn)
}
+#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 pScrn)
}
#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 pScrn)
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)) {