Michel Dänzer wrote:
On Fri, 2007-09-21 at 19:04 +0200, Eugen Dedu wrote:May /proc/cpuinfo be used? snoopy:~$ cat /proc/cpuinfo processor : 0 cpu : 7447/7457, altivec supported clock : 612.000000MHz revision : 0.1 (pvr 8002 0101) bogomips : 36.73 timebase : 18432000 platform : PowerMac machine : PowerBook5,2 motherboard : PowerBook5,2 MacRISC3 Power Macintosh detected as : 287 (PowerBook G4 15") pmac flags : 0000001b L2 cache : 512K unified pmac-generation : NewWorld This makes a difference between ibook and powerbook.Yes, I'm planning to use this for sane default values of Option "MacModel" when I get time, but feel free to beat me to it.
Is this program ok? It looks at the platform line from /proc/cpuinfo file. I am not sure what is the best line to look for.
#include <stdio.h>
#include <string.h>
// or enum instead?
#define UNKNOWN 0
#define IBOOK 1
#define POWERBOOK_SINGLELINK 2
#define POWERBOOK_DUALLINK 3
int main (void){
int param = UNKNOWN;
FILE *f = fopen ("/proc/cpuinfo", "r");
#define MAX 100
char line[MAX];
if (f != NULL){
while (fgets (line, MAX, f)){
if (strncmp (line, "platform", strlen ("platform")) == 0){ //
found the line
if (strstr (line, "Book")) // to check on ibook computers
param = IBOOK;
else if (strstr (line, "Power"))
param = POWERBOOK_SINGLELINK;
// else: not apple computer, nothing to do
break;
}
}
}else
printf ("(WW) Cannot detect laptop DVI because /proc/cpuinfo not
readable. Please use the MacModel option in xorg.conf to configure it.\n");
printf ("%d\n", param);
return 0;
}
Best regards,
--
Eugen Dedu