Merge branches 'x86-build-for-linus', 'x86-cleanups-for-linus' and 'x86-debug-for...
[cascardo/linux.git] / arch / ia64 / pci / fixup.c
index 1fe9aa5..ec73b2c 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/vgaarb.h>
+#include <linux/screen_info.h>
 
 #include <asm/machvec.h>
 
@@ -37,6 +38,27 @@ static void pci_fixup_video(struct pci_dev *pdev)
                return;
        /* Maybe, this machine supports legacy memory map. */
 
+       if (!vga_default_device()) {
+               resource_size_t start, end;
+               int i;
+
+               /* Does firmware framebuffer belong to us? */
+               for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+                       if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM))
+                               continue;
+
+                       start = pci_resource_start(pdev, i);
+                       end  = pci_resource_end(pdev, i);
+
+                       if (!start || !end)
+                               continue;
+
+                       if (screen_info.lfb_base >= start &&
+                           (screen_info.lfb_base + screen_info.lfb_size) < end)
+                               vga_set_default_device(pdev);
+               }
+       }
+
        /* Is VGA routed to us? */
        bus = pdev->bus;
        while (bus) {