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>
This commit is contained in:
Daniel Vetter
2012-01-10 14:59:58 +01:00
parent 1be3fd7eee
commit aa67b22e42
10 changed files with 39 additions and 149 deletions
+25 -1
View File
@@ -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);
}
+3
View File
@@ -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);