From aa67b22e426f26f8a8d7fe35221fe2a6ceb5d3db Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Tue, 10 Jan 2012 14:59:58 +0100 Subject: lib/drmtest: extract gem_set_tiling Way too much copy-pasting going on here. Also fix a compiler warnings in gem_stress while fixup things up. Signed-off-by: Daniel Vetter --- lib/drmtest.c | 26 +++++++++++++++++++++++++- lib/drmtest.h | 3 +++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/drmtest.c b/lib/drmtest.c index fc40ad12..dc655c47 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -1,5 +1,5 @@ /* - * Copyright © 2007 Intel Corporation + * Copyright © 2007, 2011 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,16 +22,21 @@ * * Authors: * Eric Anholt + * Daniel Vetter * */ #include #include #include +#include #include "drmtest.h" #include "i915_drm.h" #include "intel_chipset.h" +/* This file contains a bunch of wrapper functions to directly use gem ioctls. + * Mostly useful to write kernel tests. */ + static int is_intel(int fd) { @@ -110,3 +115,22 @@ int drm_open_any_master(void) fprintf(stderr, "Couldn't find an un-controlled DRM device\n"); abort(); } + +void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride) +{ + struct drm_i915_gem_set_tiling st; + int ret; + + memset(&st, 0, sizeof(st)); + do { + st.handle = handle; + st.tiling_mode = tiling; + st.stride = tiling ? stride : 0; + + ret = ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &st); + } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); + assert(ret == 0); + assert(st.tiling_mode == tiling); +} + + diff --git a/lib/drmtest.h b/lib/drmtest.h index afa0df4a..02138dca 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -35,3 +35,6 @@ int drm_open_any(void); int drm_open_any_master(void); + + +void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride); -- cgit v1.2.3