i915g: use drm ioctl to get pci devid
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 28 Mar 2011 19:16:12 +0000 (21:16 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 28 Mar 2011 19:23:31 +0000 (21:23 +0200)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
src/gallium/winsys/i915/drm/i915_drm_winsys.c

index 2c3b508d0567fe6b813e2f61362b8bb80224f54b..a2b61cde2c256a56e50c8b8de24cc9f7fdd7fa71 100644 (file)
 static void
 i915_drm_get_device_id(unsigned int *device_id)
 {
-   char path[512];
-   FILE *file;
-   void *shutup_gcc;
-
-   /*
-    * FIXME: Fix this up to use a drm ioctl or whatever.
-    */
-
-   snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
-   file = fopen(path, "r");
-   if (!file) {
-      return;
-   }
-
-   shutup_gcc = fgets(path, sizeof(path), file);
-   (void) shutup_gcc;
-   sscanf(path, "%x", device_id);
-   fclose(file);
+   int ret;
+   struct drm_i915_getparam gp;
+
+   gp.param = I915_PARAM_CHIPSET_ID;
+   gp.value = (int *)devid;
+
+   ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+   assert(ret == 0);
 }
 
 static void