1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include <pciaccess.h>
#include "radeondemo.h"
#include "radeon.h"
static char *family_strings[] = {"Unknown", "legacy", "radeon",
"rv100", "rs100", "rv200", "rs200",
"r200", "rv250", "rv280", "rs300",
"r300", "r350",
"rv350", "rv380", "r420", "rv410", "rs400",
"rs480", "rv515", "r520", "rv530", "r580",
"rv560", "rv570", "rs600", "rs690", "rs740",
"r600", "r630", "rv610", "rv630", "rv670",
"rv620", "rv635", "rs780", "rs880",
"rv770", "rv730", "rv710", "rv740",
"cedar", "redwood", "juniper",
"cypress", "hemlock",
"palm",
"barts", "turks", "caicos" };
int radeon_detect(struct radeon *radeon)
{
struct pci_slot_match match;
struct pci_device_iterator *iter;
struct pci_device *device;
int i = 0;
RADEONCardInfo *card_info = NULL;
if (pci_system_init() != 0)
return -1;
match.domain = PCI_MATCH_ANY;
match.bus = PCI_MATCH_ANY;
match.dev = PCI_MATCH_ANY;
match.func = 0;
match.match_data = 0;
iter = pci_slot_match_iterator_create(&match);
while ((device = pci_device_next(iter))) {
pci_device_probe(device);
if (device->vendor_id == 0x1002 &&
(((device->device_class & 0x00ffff00) == 0x00030000) ||
((device->device_class & 0x00ffff00) == 0x00038000))) {
for (i = 0; i < sizeof(RADEONCards) / sizeof(RADEONCardInfo); i++) {
if (RADEONCards[i].pci_device_id == device->device_id) {
card_info = &RADEONCards[i];
}
}
}
if (card_info)
break;
}
if (!card_info)
return -1;
radeon->cardinfo = card_info;
radeon->pci_device = device;
return 0;
}
|