From 50fdf32e46bcfd01e83b813d6a1fd0dc5b686692 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 6 Dec 2012 12:16:12 +0000 Subject: [PATCH] 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 --- lib/intel_pci.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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"); -- 2.7.4