From bfda78cd33b6562306c8c42e83047149f2ff6984 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Thu, 18 Sep 2014 18:25:37 +0300 Subject: tests/pm_rpm: factor out drm_open_any_master Signed-off-by: Imre Deak --- lib/drmtest.c | 19 +++++++++++++++++++ lib/drmtest.h | 1 + 2 files changed, 20 insertions(+) (limited to 'lib') diff --git a/lib/drmtest.c b/lib/drmtest.c index b0b97310..3d828e12 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -324,6 +324,25 @@ int drm_open_any(void) return fd; } +/** + * 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: * 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); -- cgit v1.2.3