Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Lespiau <damien.lespiau@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/4] lib: Allow to override the device id at run time
Date: Wed, 20 Feb 2013 14:53:14 +0000	[thread overview]
Message-ID: <1361371996-28166-2-git-send-email-damien.lespiau@intel.com> (raw)
In-Reply-To: <1361371996-28166-1-git-send-email-damien.lespiau@intel.com>

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@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

  reply	other threads:[~2013-02-20 14:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-20 14:53 [PATCH 1/4] lib: Factor out a function to check if an environment variable is set Damien Lespiau
2013-02-20 14:53 ` Damien Lespiau [this message]
2013-02-20 14:53 ` [PATCH 3/4] rendercopy: Add a way to dump an .aub file with the rendercopy bos Damien Lespiau
2013-02-20 14:53 ` [PATCH 4/4] build: Guard the inclusions of config.h with HAVE_CONFIG_H Damien Lespiau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361371996-28166-2-git-send-email-damien.lespiau@intel.com \
    --to=damien.lespiau@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox