[Mesa-dev] [PATCH] loader: add special logic to distinguish nouveau from nouveau_vieux

Ilia Mirkin imirkin at alum.mit.edu
Mon Mar 17 07:22:57 PDT 2014


Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 include/pci_ids/pci_id_driver_map.h |  1 -
 src/loader/loader.c                 | 25 +++++++++++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/include/pci_ids/pci_id_driver_map.h b/include/pci_ids/pci_id_driver_map.h
index db9e07f..064e8d4 100644
--- a/include/pci_ids/pci_id_driver_map.h
+++ b/include/pci_ids/pci_id_driver_map.h
@@ -73,7 +73,6 @@ static const struct {
    { 0x1002, "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids), _LOADER_GALLIUM },
    { 0x1002, "r600", r600_chip_ids, ARRAY_SIZE(r600_chip_ids), _LOADER_GALLIUM },
    { 0x1002, "radeonsi", radeonsi_chip_ids, ARRAY_SIZE(radeonsi_chip_ids), _LOADER_GALLIUM},
-   { 0x10de, "nouveau", NULL, -1,  _LOADER_GALLIUM  },
    { 0x15ad, "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids), _LOADER_GALLIUM },
    { 0x0000, NULL, NULL, 0 },
 };
diff --git a/src/loader/loader.c b/src/loader/loader.c
index 811f8a2..fe41b39 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -258,9 +258,19 @@ loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
       }
    }
    else if (strcmp(version->name, "nouveau") == 0) {
+      struct drm_nouveau_getparam gp;
+      int ret;
+
       *vendor_id = 0x10de;
-      /* not used */
-      *chip_id = 0;
+
+      memset(&gp, 0, sizeof(gp));
+      gp.param = NOUVEAU_GETPARAM_CHIPSET_ID;
+      gp.value = chip_id;
+      ret = drmCommandWriteRead(fd, DRM_NOUVEAU_GETPARAM, &gp, sizeof(gp));
+      if (ret) {
+         log_(_LOADER_WARNING, "MESA-LOADER: failed to get param for nouveau\n");
+         *chip_id = -1;
+      }
    }
    else if (strcmp(version->name, "vmwgfx") == 0) {
       *vendor_id = 0x15ad;
@@ -345,6 +355,17 @@ loader_get_driver_for_fd(int fd, unsigned driver_types)
       return driver;
    }
 
+   /* Special handling for nouveau, we don't want to list out all of the pci,
+    * or even chipset ids
+    */
+   if (vendor_id == 0x10de) {
+      if (driver_types & _LOADER_GALLIUM && chip_id >= 0x30)
+         driver = strdup("nouveau");
+      else if (driver_types & _LOADER_DRI && chip_id < 0x30)
+         driver = strdup("nouveau_vieux");
+      goto out;
+   }
+
    for (i = 0; driver_map[i].driver; i++) {
       if (vendor_id != driver_map[i].vendor_id)
          continue;
-- 
1.8.3.2



More information about the mesa-dev mailing list