diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-06 12:16:12 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-06 12:18:58 +0000 |
commit | 50fdf32e46bcfd01e83b813d6a1fd0dc5b686692 (patch) | |
tree | b32f16912fd524031c93659c945e281fe91fc504 | |
parent | 51f08301ab5702db673fd4c2543ead7251641939 (diff) |
pci: Search for the first Intel GPU, rather than assume a fixed slot
Everywhere else we search for a match based on an Intel display
device, so if the quick check of the fixed slot fails, fallback to
walking the PCI bus looking for a match.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | lib/intel_pci.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/intel_pci.c b/lib/intel_pci.c index 7228dae..704c87a 100644 --- a/lib/intel_pci.c +++ b/lib/intel_pci.c @@ -54,8 +54,27 @@ intel_get_pci_device(void) exit(1); } - /* Grab the graphics card */ + /* Grab the graphics card. Try the canonical slot first, then + * walk the entire PCI bus for a matching device. */ pci_dev = pci_device_find_by_slot(0, 0, 2, 0); + if (pci_dev == NULL || pci_dev->vendor_id != 0x8086) { + struct pci_device_iterator *iter; + struct pci_id_match match; + + match.vendor_id = 0x8086; /* Intel */ + match.device_id = PCI_MATCH_ANY; + match.subvendor_id = PCI_MATCH_ANY; + match.subdevice_id = PCI_MATCH_ANY; + + match.device_class = 0x3 << 16; + match.device_class_mask = 0xff << 16; + + match.match_data = 0; + + iter = pci_id_match_iterator_create(&match); + pci_dev = pci_device_next(iter); + pci_iterator_destroy(iter); + } if (pci_dev == NULL) errx(1, "Couldn't find graphics card"); |