Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / xfree86 / os-support / linux / lnx_axp.c
CommitLineData
a09e091a
JB
1
2#ifdef HAVE_XORG_CONFIG_H
3#include <xorg-config.h>
4#endif
5
6#include <stdio.h>
7#include "xf86.h"
8#include "shared/xf86Axp.h"
9
10axpDevice lnxGetAXP(void);
11
12typedef struct {
13 char *sysName;
14 char *sysVari;
15 char *cpu;
16 axpDevice sys;
17} AXP;
18
19static AXP axpList[] = {
20 {"Tsunami", NULL, NULL, TSUNAMI},
21 {"Eiger", NULL, NULL, TSUNAMI},
22 {"Noname", NULL, NULL, LCA},
23 {"AlphaBook1", NULL, NULL, LCA},
24 {"EB66", NULL, NULL, LCA},
25 {"EB64+", NULL, NULL, APECS},
26 {"Noritake", NULL, "EV5", CIA},
27 {"Noritake", NULL, "EV56", CIA},
28 {"Noritake", NULL, NULL, APECS},
29 {"XL", NULL, NULL, APECS},
30 {"Avanti", NULL, NULL, APECS},
31 {"Mikasa", NULL, "EV5", CIA},
32 {"Mikasa", NULL, "EV56", CIA},
33 {"Mikasa", NULL, NULL, APECS},
34 {"EB164", "EB164", NULL, CIA},
35 {"EB164", "PC164", NULL, CIA},
36 {"EB164", "LX164", NULL, PYXIS},
37 {"EB164", "SX164", NULL, PYXIS},
38 {"EB164", "RX164", NULL, POLARIS},
39 {"Alcor", NULL, NULL, CIA},
40 {"Takara", NULL, NULL, CIA},
41 {"Sable", NULL, "EV5", T2_GAMMA},
42 {"Sable", NULL, "EV56", T2_GAMMA},
43 {"Sable", NULL, NULL, T2},
44 {"Rawhide", NULL, NULL, MCPCIA},
45 {"Jensen", NULL, NULL, JENSEN},
46 {"Miata", NULL, NULL, PYXIS_CIA},
47 {"Ruffian", NULL, NULL, PYXIS_CIA},
48 {"Nautilus", NULL, NULL, IRONGATE},
49 {NULL, NULL, NULL, SYS_NONE}
50};
51
52axpDevice
53lnxGetAXP(void)
54{
55 FILE *file;
56 int count = 0;
57 char res[256];
58 char cpu[255];
59 char systype[255];
60 char sysvari[255];
61
62 if (!(file = fopen("/proc/cpuinfo", "r")))
63 return SYS_NONE;
64 do {
65 if (!fgets(res, 0xff, file))
66 return SYS_NONE;
67 switch (count) {
68 case 1:
69 sscanf(res, "cpu model : %s", cpu);
70 DebugF("CPU %s\n", cpu);
71 break;
72 case 5:
73 sscanf(res, "system type : %s", systype);
74 DebugF("system type : %s\n", systype);
75 break;
76 case 6:
77 sscanf(res, "system variation : %s", sysvari);
78 DebugF("system variation: %s\n", sysvari);
79 break;
80 }
81 count++;
82 } while (count < 8);
83
84 fclose(file);
85
86 count = 0;
87
88 do {
89 if (!axpList[count].sysName || !strcmp(axpList[count].sysName, systype)) {
90 if (axpList[count].sysVari &&
91 strcmp(axpList[count].sysVari, sysvari)) {
92 count++;
93 continue;
94 };
95 if (axpList[count].cpu && strcmp(axpList[count].cpu, cpu)) {
96 count++;
97 continue;
98 }
99 return axpList[count].sys;
100 }
101 count++;
102 } while (1);
103}