[PATCH 2/4] lib: Allow to override the device id at run time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using the same environment variable as libdrm so one doesn't have to
remember two different things. This is helpful to run a test under a
fake identity, to, say, dump an aub file.

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 lib/intel_drm.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/intel_drm.c b/lib/intel_drm.c
index 8d89d24..eaf9895 100644
--- a/lib/intel_drm.c
+++ b/lib/intel_drm.c
@@ -54,12 +54,18 @@ intel_get_drm_devid(int fd)
 	int ret;
 	struct drm_i915_getparam gp;
 	uint32_t devid;
+	char *override;
 
-	gp.param = I915_PARAM_CHIPSET_ID;
-	gp.value = (int *)&devid;
+	override = getenv("INTEL_DEVID_OVERRIDE");
+	if (override) {
+		devid = strtod(override, NULL);
+	} else {
+		gp.param = I915_PARAM_CHIPSET_ID;
+		gp.value = (int *)&devid;
 
-	ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
-	assert(ret == 0);
+		ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		assert(ret == 0);
+	}
 
 	return devid;
 }
-- 
1.7.7.5



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux