loader: Move non-error message to debug level
[mesa.git] / src / loader / loader.c
index fd05f08e64fa685e29cd4c8b13bd93009c7fc1e1..9b4752d31385e2cde2a7319c8f4259c650feefa1 100644 (file)
@@ -33,6 +33,8 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
 #ifdef MAJOR_IN_MKDEV
 #include <sys/mkdev.h>
 #endif
@@ -42,8 +44,6 @@
 #include "loader.h"
 
 #ifdef HAVE_LIBDRM
-#include <stdlib.h>
-#include <unistd.h>
 #include <xf86drm.h>
 #ifdef USE_DRICONF
 #include "xmlconfig.h"
@@ -282,7 +282,7 @@ drm_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
          ret = 1;
       }
       else {
-         log_(_LOADER_WARNING, "MESA-LOADER: device is not located on the PCI bus\n");
+         log_(_LOADER_DEBUG, "MESA-LOADER: device is not located on the PCI bus\n");
          ret = 0;
       }
       drmFreeDevice(&device);
@@ -345,6 +345,17 @@ loader_get_driver_for_fd(int fd)
    int vendor_id, chip_id, i, j;
    char *driver = NULL;
 
+   /* Allow an environment variable to force choosing a different driver
+    * binary.  If that driver binary can't survive on this FD, that's the
+    * user's problem, but this allows vc4 simulator to run on an i965 host,
+    * and may be useful for some touch testing of i915 on an i965 host.
+    */
+   if (geteuid() == getuid()) {
+      driver = getenv("MESA_LOADER_DRIVER_OVERRIDE");
+      if (driver)
+         return strdup(driver);
+   }
+
    if (!loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id)) {
 
 #if HAVE_LIBDRM
@@ -413,5 +424,11 @@ loader_get_extensions_name(const char *driver_name)
    if (asprintf(&name, "%s_%s", __DRI_DRIVER_GET_EXTENSIONS, driver_name) < 0)
       return NULL;
 
+   const size_t len = strlen(name);
+   for (size_t i = 0; i < len; i++) {
+          if (name[i] == '-')
+                  name[i] = '_';
+   }
+
    return name;
 }