[PATCH 2/2] xfree86: Support autoloading of non-PCI drivers

Thierry Reding thierry.reding at gmail.com
Wed Feb 12 08:11:01 PST 2014


Drivers for non-PCI devices cannot be autoloaded because there is no
mechanism in place to correlate the device to the driver name.

This patch adds a simple table that maps the name of the Linux kernel
driver name to a list of DDX module names. Matching modules will be
added to the list of drivers that X tries to load for a given device.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 hw/xfree86/common/xf86platformBus.c | 41 +++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 5875a91363cc..16c9bb6c1dbc 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -176,6 +176,41 @@ xf86_check_platform_slot(const struct xf86_platform_device *pd)
     return TRUE;
 }
 
+#ifdef __linux__
+static const struct xf86platformDriver {
+    const char *name;
+    const char **modules;
+} xf86platformDrivers[] = {
+    {
+        .name = "tegra",
+        .modules = (const char *[]) {
+            "opentegra",
+            NULL
+        },
+    },
+    { },
+};
+
+static int xf86platformDriverList(char *name, char *matches[], int nmatches)
+{
+    const struct xf86platformDriver *driver = xf86platformDrivers;
+    int i = 0;
+
+    while (driver->name) {
+        if (strcmp(driver->name, name) == 0) {
+            for (i = 0; driver->modules[i] && (i < nmatches); i++)
+                matches[i] = xstrdup(driver->modules[i]);
+
+            break;
+        }
+
+        driver++;
+    }
+
+    return i;
+}
+#endif
+
 /**
  *  @return The numbers of found devices that match with the current system
  *  drivers.
@@ -208,6 +243,12 @@ xf86PlatformMatchDriver(char *matches[], int nmatches)
             if ((info != NULL) && (j < nmatches)) {
                 j += xf86VideoPtrToDriverList(info, &(matches[j]), nmatches - j);
             }
+#ifdef __linux__
+            else if (j < nmatches) {
+                char *name = xf86_get_platform_attrib(i, ODEV_ATTRIB_DRIVER);
+                j += xf86platformDriverList(name, &matches[j], nmatches - j);
+            }
+#endif
         }
     }
     return j;
-- 
1.8.4.2



More information about the xorg-devel mailing list