summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2012-01-10 14:59:58 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-01-10 14:59:58 +0100
commitaa67b22e426f26f8a8d7fe35221fe2a6ceb5d3db (patch)
treea975475aedd8eef629dd922ed764c3e141422de9 /lib
parent1be3fd7eeed3adf1fba56edc37110d346b03b88b (diff)
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 <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/drmtest.c26
-rw-r--r--lib/drmtest.h3
2 files changed, 28 insertions, 1 deletions
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 <eric@anholt.net>
+ * Daniel Vetter <daniel.vetter@ffwll.ch>
*
*/
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
+#include <string.h>
#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);