|
|
8b7db15 |
From 69e53f2493c142ef5569af01ce52565be5b2976e Mon Sep 17 00:00:00 2001
|
|
|
ab13247 |
From: Adam Jackson <ajax@redhat.com>
|
|
|
ab13247 |
Date: Tue, 3 Mar 2009 10:58:33 -0500
|
|
|
ab13247 |
Subject: [PATCH] Primary video device hack
|
|
|
ab13247 |
|
|
|
ab13247 |
---
|
|
|
8b7db15 |
hw/xfree86/common/xf86pciBus.c | 60 ++++++++++++++++++++++++++++++++--------
|
|
|
8b7db15 |
1 files changed, 48 insertions(+), 12 deletions(-)
|
|
|
ab13247 |
|
|
|
ab13247 |
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
|
|
|
8b7db15 |
index 467a0c3..0d2d01c 100644
|
|
|
ab13247 |
--- a/hw/xfree86/common/xf86pciBus.c
|
|
|
ab13247 |
+++ b/hw/xfree86/common/xf86pciBus.c
|
|
|
8b7db15 |
@@ -60,11 +60,7 @@ static struct pci_device ** xf86PciVideoInfo = NULL; /* PCI probe for video hw *
|
|
|
8b7db15 |
/* PCI classes that get included in xf86PciVideoInfo */
|
|
|
8b7db15 |
#define PCIINFOCLASSES(c) \
|
|
|
8b7db15 |
( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
|
|
|
8b7db15 |
- || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
|
|
|
8b7db15 |
- || ((((c) & 0x00ffff00) \
|
|
|
8b7db15 |
- == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \
|
|
|
8b7db15 |
- || ((((c) & 0x00ffff00) \
|
|
|
8b7db15 |
- == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) )
|
|
|
f80ad20 |
+ || (((c) & 0x00ffff00) == (PCI_CLASS_DISPLAY << 16)) )
|
|
|
8b7db15 |
|
|
|
8b7db15 |
/*
|
|
|
8b7db15 |
* PCI classes that have messages printed always. The others are only
|
|
|
8b7db15 |
@@ -341,6 +337,39 @@ restorePciBusState(BusAccPtr ptr)
|
|
|
ab13247 |
}
|
|
|
ab13247 |
#undef MASKBITS
|
|
|
ab13247 |
|
|
|
ab13247 |
+/* oh god what have i done */
|
|
|
ab13247 |
+static Bool
|
|
|
ab13247 |
+looks_like_bios_primary(struct pci_device *info)
|
|
|
ab13247 |
+{
|
|
|
ab13247 |
+ unsigned char *bios;
|
|
|
ab13247 |
+ unsigned short vendor, device;
|
|
|
ab13247 |
+ int offset;
|
|
|
ab13247 |
+ Bool ret = FALSE;
|
|
|
ab13247 |
+
|
|
|
ab13247 |
+ bios = xf86MapVidMem(-1, VIDMEM_MMIO, 0xc0000, 0x10000);
|
|
|
ab13247 |
+ if (!bios)
|
|
|
ab13247 |
+ return FALSE;
|
|
|
ab13247 |
+
|
|
|
ab13247 |
+ if (bios[0] != 0x55 || bios[1] != 0xAA)
|
|
|
ab13247 |
+ goto out;
|
|
|
ab13247 |
+
|
|
|
ab13247 |
+ offset = (bios[0x19] << 8) + bios[0x18];
|
|
|
ab13247 |
+
|
|
|
ab13247 |
+ if (bios[offset] != 'P' ||
|
|
|
ab13247 |
+ bios[offset+1] != 'C' ||
|
|
|
ab13247 |
+ bios[offset+2] != 'I' ||
|
|
|
ab13247 |
+ bios[offset+3] != 'R')
|
|
|
ab13247 |
+ goto out;
|
|
|
ab13247 |
+
|
|
|
ab13247 |
+ vendor = (bios[offset+5] << 8) + bios[offset+4];
|
|
|
ab13247 |
+ device = (bios[offset+7] << 8) + bios[offset+6];
|
|
|
ab13247 |
+
|
|
|
ab13247 |
+ ret = (info->vendor_id == vendor) && (info->device_id == device);
|
|
|
ab13247 |
+
|
|
|
ab13247 |
+out:
|
|
|
ab13247 |
+ xf86UnMapVidMem(-1, bios, 0x10000);
|
|
|
ab13247 |
+ return ret;
|
|
|
ab13247 |
+}
|
|
|
ab13247 |
|
|
|
ab13247 |
/*
|
|
|
ab13247 |
* xf86Bus.c interface
|
|
|
8b7db15 |
@@ -375,24 +404,31 @@ xf86PciProbe(void)
|
|
|
ab13247 |
}
|
|
|
ab13247 |
}
|
|
|
ab13247 |
|
|
|
ab13247 |
-
|
|
|
ab13247 |
/* If we haven't found a primary device try a different heuristic */
|
|
|
ab13247 |
if (primaryBus.type == BUS_NONE && num) {
|
|
|
ab13247 |
for (i = 0; i < num; i++) {
|
|
|
ab13247 |
uint16_t command;
|
|
|
ab13247 |
|
|
|
ab13247 |
info = xf86PciVideoInfo[i];
|
|
|
ab13247 |
+ if (!IS_VGA(info->device_class))
|
|
|
ab13247 |
+ continue;
|
|
|
ab13247 |
+
|
|
|
ab13247 |
pci_device_cfg_read_u16(info, & command, 4);
|
|
|
ab13247 |
|
|
|
ab13247 |
- if ((command & PCI_CMD_MEM_ENABLE)
|
|
|
ab13247 |
- && ((num == 1) || IS_VGA(info->device_class))) {
|
|
|
ab13247 |
- if (primaryBus.type == BUS_NONE) {
|
|
|
ab13247 |
+ if ((command & PCI_CMD_MEM_ENABLE)) {
|
|
|
ab13247 |
+ if (num == 1) {
|
|
|
ab13247 |
primaryBus.type = BUS_PCI;
|
|
|
ab13247 |
primaryBus.id.pci = info;
|
|
|
ab13247 |
- } else {
|
|
|
ab13247 |
- xf86Msg(X_NOTICE,
|
|
|
ab13247 |
+ break;
|
|
|
ab13247 |
+ } else if (looks_like_bios_primary(info)) {
|
|
|
ab13247 |
+ if (primaryBus.type == BUS_NONE) {
|
|
|
ab13247 |
+ primaryBus.type = BUS_PCI;
|
|
|
ab13247 |
+ primaryBus.id.pci = info;
|
|
|
ab13247 |
+ } else {
|
|
|
ab13247 |
+ xf86Msg(X_NOTICE,
|
|
|
ab13247 |
"More than one possible primary device found\n");
|
|
|
ab13247 |
- primaryBus.type ^= (BusType)(-1);
|
|
|
ab13247 |
+ primaryBus.type ^= (BusType)(-1);
|
|
|
ab13247 |
+ }
|
|
|
ab13247 |
}
|
|
|
ab13247 |
}
|
|
|
ab13247 |
}
|
|
|
ab13247 |
--
|
|
|
ab13247 |
1.6.1.3
|
|
|
ab13247 |
|