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
7 hw/xfree86/common/xf86pciBus.c | 60 ++++++++++++++++++++++++++++++++--------
8 1 files changed, 48 insertions(+), 12 deletions(-)
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)) )
26 * PCI classes that have messages printed always. The others are only
27 @@ -341,6 +337,39 @@ restorePciBusState(BusAccPtr ptr)
31 +/* oh god what have i done */
33 +looks_like_bios_primary(struct pci_device *info)
35 + unsigned char *bios;
36 + unsigned short vendor, device;
40 + bios = xf86MapVidMem(-1, VIDMEM_MMIO, 0xc0000, 0x10000);
44 + if (bios[0] != 0x55 || bios[1] != 0xAA)
47 + offset = (bios[0x19] << 8) + bios[0x18];
49 + if (bios[offset] != 'P' ||
50 + bios[offset+1] != 'C' ||
51 + bios[offset+2] != 'I' ||
52 + bios[offset+3] != 'R')
55 + vendor = (bios[offset+5] << 8) + bios[offset+4];
56 + device = (bios[offset+7] << 8) + bios[offset+6];
58 + ret = (info->vendor_id == vendor) && (info->device_id == device);
61 + xf86UnMapVidMem(-1, bios, 0x10000);
67 @@ -375,24 +404,31 @@ xf86PciProbe(void)
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++) {
77 info = xf86PciVideoInfo[i];
78 + if (!IS_VGA(info->device_class))
81 pci_device_cfg_read_u16(info, & command, 4);
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)) {
88 primaryBus.type = BUS_PCI;
89 primaryBus.id.pci = info;
93 + } else if (looks_like_bios_primary(info)) {
94 + if (primaryBus.type == BUS_NONE) {
95 + primaryBus.type = BUS_PCI;
96 + primaryBus.id.pci = info;
99 "More than one possible primary device found\n");
100 - primaryBus.type ^= (BusType)(-1);
101 + primaryBus.type ^= (BusType)(-1);