[SeaBIOS] [PATCH 1/6] pci, optionrom: enable non-vga display devices

Gerd Hoffmann kraxel at redhat.com
Thu May 31 08:33:48 CEST 2018


In case no VGA device was found look for other display devices,
in both pci initialization and in vgabios rom scan.

Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
 src/fw/pciinit.c | 15 +++++++++++----
 src/optionroms.c | 29 ++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
index 3a2f747984..e9518741b5 100644
--- a/src/fw/pciinit.c
+++ b/src/fw/pciinit.c
@@ -431,6 +431,7 @@ static void pci_bios_init_devices(void)
 static void pci_enable_default_vga(void)
 {
     struct pci_device *pci;
+    int is_vga = 1;
 
     foreachpci(pci) {
         if (is_pci_vga(pci)) {
@@ -441,16 +442,22 @@ static void pci_enable_default_vga(void)
 
     pci = pci_find_class(PCI_CLASS_DISPLAY_VGA);
     if (!pci) {
-        dprintf(1, "PCI: No VGA devices found\n");
-        return;
+        dprintf(1, "PCI: No VGA devices found, trying other display devices\n");
+        pci = pci_find_class(PCI_CLASS_DISPLAY_OTHER);
+        if (!pci) {
+            dprintf(1, "PCI: No other display devices found\n");
+            return;
+        }
+        is_vga = 0;
     }
 
-    dprintf(1, "PCI: Enabling %pP for primary VGA\n", pci);
+    dprintf(1, "PCI: Enabling %pP for primary %s\n", pci
+            , is_vga ? "VGA" : "display");
 
     pci_config_maskw(pci->bdf, PCI_COMMAND, 0,
                      PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
 
-    while (pci->parent) {
+    while (is_vga && pci->parent) {
         pci = pci->parent;
 
         dprintf(1, "PCI: Setting VGA enable on bridge %pP\n", pci);
diff --git a/src/optionroms.c b/src/optionroms.c
index 092393a56c..7febd7fcf8 100644
--- a/src/optionroms.c
+++ b/src/optionroms.c
@@ -224,6 +224,17 @@ is_pci_vga(struct pci_device *pci)
     return 1;
 }
 
+int
+is_pci_display_other(struct pci_device *pci)
+{
+    if (pci->class != PCI_CLASS_DISPLAY_OTHER)
+        return 0;
+    u16 cmd = pci_config_readw(pci->bdf, PCI_COMMAND);
+    if (!(cmd & PCI_COMMAND_IO && cmd & PCI_COMMAND_MEMORY))
+        return 0;
+    return 1;
+}
+
 // Copy a rom to its permanent location below 1MiB
 static struct rom_header *
 copy_rom(struct rom_header *rom)
@@ -350,7 +361,9 @@ optionrom_setup(void)
     // Find and deploy PCI roms.
     struct pci_device *pci;
     foreachpci(pci) {
-        if (pci->class == PCI_CLASS_DISPLAY_VGA || pci->have_driver)
+        if (pci->class == PCI_CLASS_DISPLAY_VGA ||
+            pci->class == PCI_CLASS_DISPLAY_OTHER ||
+            pci->have_driver)
             continue;
         init_pcirom(pci, 0, sources);
     }
@@ -404,6 +417,8 @@ struct rom_header *VgaROM;
 void
 vgarom_setup(void)
 {
+    int have_vga = 0;
+
     if (! CONFIG_OPTIONROMS)
         return;
 
@@ -425,8 +440,20 @@ vgarom_setup(void)
             continue;
         vgahook_setup(pci);
         init_pcirom(pci, 1, NULL);
+        have_vga = 1;
         break;
     }
+    if (!have_vga) {
+        // no VGA, try fallback to display
+        dprintf(1, "no vga, try display\n");
+        foreachpci(pci) {
+            if (!is_pci_display_other(pci))
+                continue;
+            vgahook_setup(pci);
+            init_pcirom(pci, 1, NULL);
+            break;
+        }
+    }
 
     // Find and deploy CBFS vga-style roms not associated with a device.
     run_file_roms("vgaroms/", 1, NULL);
-- 
2.9.3




More information about the SeaBIOS mailing list