]>
Commit | Line | Data |
---|---|---|
ae2945da AM |
1 | From 69e53f2493c142ef5569af01ce52565be5b2976e Mon Sep 17 00:00:00 2001 |
2 | From: Adam Jackson <ajax@redhat.com> | |
3 | Date: Tue, 3 Mar 2009 10:58:33 -0500 | |
4 | Subject: [PATCH] Primary video device hack | |
5 | ||
6 | --- | |
7 | hw/xfree86/common/xf86pciBus.c | 60 ++++++++++++++++++++++++++++++++-------- | |
8 | 1 files changed, 48 insertions(+), 12 deletions(-) | |
9 | ||
10 | diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c | |
11 | index 467a0c3..0d2d01c 100644 | |
12 | --- a/hw/xfree86/common/xf86pciBus.c | |
13 | +++ b/hw/xfree86/common/xf86pciBus.c | |
14 | @@ -60,11 +60,7 @@ static struct pci_device ** xf86PciVideoInfo = NULL; /* PCI probe for video hw * | |
15 | /* PCI classes that get included in xf86PciVideoInfo */ | |
16 | #define PCIINFOCLASSES(c) \ | |
17 | ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \ | |
18 | - || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \ | |
19 | - || ((((c) & 0x00ffff00) \ | |
20 | - == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \ | |
21 | - || ((((c) & 0x00ffff00) \ | |
22 | - == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) ) | |
23 | + || (((c) & 0x00ffff00) == (PCI_CLASS_DISPLAY << 16)) ) | |
24 | ||
25 | /* | |
26 | * PCI classes that have messages printed always. The others are only | |
27 | @@ -341,6 +337,39 @@ restorePciBusState(BusAccPtr ptr) | |
28 | } | |
29 | #undef MASKBITS | |
30 | ||
31 | +/* oh god what have i done */ | |
32 | +static Bool | |
33 | +looks_like_bios_primary(struct pci_device *info) | |
34 | +{ | |
35 | + unsigned char *bios; | |
36 | + unsigned short vendor, device; | |
37 | + int offset; | |
38 | + Bool ret = FALSE; | |
39 | + | |
40 | + bios = xf86MapVidMem(-1, VIDMEM_MMIO, 0xc0000, 0x10000); | |
41 | + if (!bios) | |
42 | + return FALSE; | |
43 | + | |
44 | + if (bios[0] != 0x55 || bios[1] != 0xAA) | |
45 | + goto out; | |
46 | + | |
47 | + offset = (bios[0x19] << 8) + bios[0x18]; | |
48 | + | |
49 | + if (bios[offset] != 'P' || | |
50 | + bios[offset+1] != 'C' || | |
51 | + bios[offset+2] != 'I' || | |
52 | + bios[offset+3] != 'R') | |
53 | + goto out; | |
54 | + | |
55 | + vendor = (bios[offset+5] << 8) + bios[offset+4]; | |
56 | + device = (bios[offset+7] << 8) + bios[offset+6]; | |
57 | + | |
58 | + ret = (info->vendor_id == vendor) && (info->device_id == device); | |
59 | + | |
60 | +out: | |
61 | + xf86UnMapVidMem(-1, bios, 0x10000); | |
62 | + return ret; | |
63 | +} | |
64 | ||
65 | /* | |
66 | * xf86Bus.c interface | |
67 | @@ -375,24 +404,31 @@ xf86PciProbe(void) | |
68 | } | |
69 | } | |
70 | ||
71 | - | |
72 | /* If we haven't found a primary device try a different heuristic */ | |
73 | if (primaryBus.type == BUS_NONE && num) { | |
74 | for (i = 0; i < num; i++) { | |
75 | uint16_t command; | |
76 | ||
77 | info = xf86PciVideoInfo[i]; | |
78 | + if (!IS_VGA(info->device_class)) | |
79 | + continue; | |
80 | + | |
81 | pci_device_cfg_read_u16(info, & command, 4); | |
82 | ||
83 | - if ((command & PCI_CMD_MEM_ENABLE) | |
84 | - && ((num == 1) || IS_VGA(info->device_class))) { | |
85 | - if (primaryBus.type == BUS_NONE) { | |
86 | + if ((command & PCI_CMD_MEM_ENABLE)) { | |
87 | + if (num == 1) { | |
88 | primaryBus.type = BUS_PCI; | |
89 | primaryBus.id.pci = info; | |
90 | - } else { | |
91 | - xf86Msg(X_NOTICE, | |
92 | + break; | |
93 | + } else if (looks_like_bios_primary(info)) { | |
94 | + if (primaryBus.type == BUS_NONE) { | |
95 | + primaryBus.type = BUS_PCI; | |
96 | + primaryBus.id.pci = info; | |
97 | + } else { | |
98 | + xf86Msg(X_NOTICE, | |
99 | "More than one possible primary device found\n"); | |
100 | - primaryBus.type ^= (BusType)(-1); | |
101 | + primaryBus.type ^= (BusType)(-1); | |
102 | + } | |
103 | } | |
104 | } | |
105 | } | |
106 | -- | |
107 | 1.6.1.3 | |
108 |