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; }
17AXP;
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
52
53axpDevice
54lnxGetAXP(void)
55{
56  FILE *file;
57  int count = 0;
58  char res[256];
59  char cpu[255];
60  char systype[255];
61  char sysvari[255];
62  if (!(file = fopen("/proc/cpuinfo","r")))
63    return SYS_NONE;
64  do {
65    if (!fgets(res,0xff,file)) return SYS_NONE;
66    switch (count) {
67    case 1:
68      sscanf(res, "cpu model : %s",cpu);
69      DebugF("CPU %s\n",cpu);
70      break;
71    case 5:
72      sscanf(res, "system type : %s",systype);
73      DebugF("system type : %s\n",systype);
74      break;
75    case 6:
76      sscanf(res, "system variation : %s",sysvari);
77      DebugF("system variation: %s\n",sysvari);
78      break;
79    }
80    count++;
81  } while (count < 8);
82
83  fclose(file);
84
85  count = 0;
86
87  do {
88    if (!axpList[count].sysName || !strcmp(axpList[count].sysName,systype)) {
89      if (axpList[count].sysVari && strcmp(axpList[count].sysVari,sysvari)) {
90	count++;
91	continue;
92      };
93      if (axpList[count].cpu && strcmp(axpList[count].cpu,cpu)) {
94	count++;
95	continue;
96      }
97      return axpList[count].sys;
98    }
99	count++;
100  } while (1);
101}
102