summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorImre Deak <imre.deak@intel.com>2014-09-18 18:25:37 +0300
committerImre Deak <imre.deak@intel.com>2014-09-30 16:44:50 +0300
commitbfda78cd33b6562306c8c42e83047149f2ff6984 (patch)
treec5f539bebe4567dd90622e6eb65893726f596645 /lib
parent781a0485aca871d6b0278afacea724b97f6f59c1 (diff)
tests/pm_rpm: factor out drm_open_any_master
Signed-off-by: Imre Deak <imre.deak@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/drmtest.c19
-rw-r--r--lib/drmtest.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index b0b97310..3d828e12 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -325,6 +325,25 @@ int drm_open_any(void)
}
/**
+ * drm_open_any_master:
+ *
+ * Open an i915 drm legacy device node and ensure that it is drm master.
+ *
+ * Returns:
+ * The i915 drm file descriptor or -1 on error
+ */
+int drm_open_any_master(void)
+{
+ int fd = drm_open_any();
+
+ igt_require(fd >= 0);
+ igt_require_f(drmSetMaster(fd) == 0, "Can't become DRM master, "
+ "please check if no other DRM client is running.\n");
+
+ return fd;
+}
+
+/**
* drm_open_any:
*
* Open an i915 drm render device node.
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 40ac1461..b39b45af 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -72,6 +72,7 @@ static inline void *igt_mmap64(void *addr, size_t length, int prot, int flags,
int drm_get_card(void);
int drm_open_any(void);
+int drm_open_any_master(void);
int drm_open_any_render(void);
void gem_quiescent_gpu(int fd);