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