From patchwork Wed Feb 20 14:53:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 2167661 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id C66EB3FDF1 for ; Wed, 20 Feb 2013 14:56:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC45DE67CF for ; Wed, 20 Feb 2013 06:56:55 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 534EBE67AB for ; Wed, 20 Feb 2013 06:53:21 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 20 Feb 2013 06:53:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,702,1355126400"; d="scan'208";a="265103788" Received: from unknown (HELO dyon.amr.corp.intel.com) ([10.255.12.143]) by orsmga001.jf.intel.com with ESMTP; 20 Feb 2013 06:53:17 -0800 From: Damien Lespiau To: intel-gfx@lists.freedesktop.org Date: Wed, 20 Feb 2013 14:53:14 +0000 Message-Id: <1361371996-28166-2-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 1.7.7.5 In-Reply-To: <1361371996-28166-1-git-send-email-damien.lespiau@intel.com> References: <1361371996-28166-1-git-send-email-damien.lespiau@intel.com> Subject: [Intel-gfx] [PATCH 2/4] lib: Allow to override the device id at run time X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org 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 --- 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; }