gallium/targets/d3dadapter9: Fix device detection for render-nodes
authorAxel Davy <axel.davy@ens.fr>
Sat, 10 Jan 2015 17:49:16 +0000 (18:49 +0100)
committerAxel Davy <axel.davy@ens.fr>
Thu, 5 Feb 2015 23:07:19 +0000 (00:07 +0100)
When on a render node the unique ioctl doesn't work.

This patch drops the code to detect the device, which relied
on an ioctl, and replaces it by the mesa loader function.
The mesa loader function is more complete and won't fail for render-nodes.

Alternatively we could also have used the pipe cap to
determine the vendor and device id from the driver.

Reviewed-by: Tiziano Bacocco <tizbac2@gmail.com>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/targets/d3dadapter9/drm.c

index dd916f1ea7307ff87ef89a96aa88377fde5e1a88..bdc402fea24eed2edcae5d1c57a07cfebec7025f 100644 (file)
@@ -135,53 +135,22 @@ get_bus_info( int fd,
               DWORD *subsysid,
               DWORD *revision )
 {
-    drm_unique_t u;
-
-    u.unique_len = 0;
-    u.unique = NULL;
-
-    if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) { return; }
-    u.unique = CALLOC(u.unique_len+1, 1);
-
-    if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) { return; }
-    u.unique[u.unique_len] = '\0';
-
-    DBG("DRM Device BusID: %s\n", u.unique);
-    if (strncmp("pci:", u.unique, 4) == 0) {
-        char fname[512]; /* this ought to be enough */
-        int l = snprintf(fname, 512, "/sys/bus/pci/devices/%s/", u.unique+4);
-
-        /* VendorId */
-        snprintf(fname+l, 512-l, "vendor");
-        *vendorid = read_file_dword(fname);
-        /* DeviceId */
-        snprintf(fname+l, 512-l, "device");
-        *deviceid = read_file_dword(fname);
-        /* SubSysId */
-        snprintf(fname+l, 512-l, "subsystem_device");
-        *subsysid = (read_file_dword(fname) << 16) & 0xFFFF0000;
-        snprintf(fname+l, 512-l, "subsystem_vendor");
-        *subsysid |= read_file_dword(fname) & 0x0000FFFF;
-        /* Revision */
-        {
-            int cfgfd;
-
-            snprintf(fname+l, 512-l, "config");
-            cfgfd = open(fname, O_RDONLY);
-            if (cfgfd >= 0) {
-                *revision = read_config_dword(cfgfd, 0x8) & 0x000000FF;
-                close(cfgfd);
-            } else {
-                DBG("Unable to get raw PCI information from `%s'\n", fname);
-            }
-        }
-        DBG("PCI info: vendor=0x%04x, device=0x%04x, subsys=0x%08x, rev=%d\n",
-            *vendorid, *deviceid, *subsysid, *revision);
+    int vid, did;
+
+    if (loader_get_pci_id_for_fd(fd, &vid, &did)) {
+        DBG("PCI info: vendor=0x%04x, device=0x%04x\n",
+            vid, did);
+        *vendorid = vid;
+        *deviceid = did;
+        *subsysid = 0;
+        *revision = 0;
     } else {
-        DBG("Unsupported BusID type.\n");
+        DBG("Unable to detect card. Fake GTX 680.\n");
+        *vendorid = 0x10de; /* NV GTX 680 */
+        *deviceid = 0x1180;
+        *subsysid = 0;
+        *revision = 0;
     }
-
-    FREE(u.unique);
 }
 
 static INLINE void