lib: unnecessary header removal for drmtest.h, part 1

Brought a few missing headers to light in ioctl_wrappers.h, too.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
diff --git a/benchmarks/intel_upload_blit_large.c b/benchmarks/intel_upload_blit_large.c
index 4d1b66f..b44433f 100644
--- a/benchmarks/intel_upload_blit_large.c
+++ b/benchmarks/intel_upload_blit_large.c
@@ -59,6 +59,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define OBJECT_WIDTH	1280
 #define OBJECT_HEIGHT	720
diff --git a/benchmarks/intel_upload_blit_large_gtt.c b/benchmarks/intel_upload_blit_large_gtt.c
index 6f864cb..4910710 100644
--- a/benchmarks/intel_upload_blit_large_gtt.c
+++ b/benchmarks/intel_upload_blit_large_gtt.c
@@ -59,6 +59,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define OBJECT_WIDTH	1280
 #define OBJECT_HEIGHT	720
diff --git a/benchmarks/intel_upload_blit_large_map.c b/benchmarks/intel_upload_blit_large_map.c
index 97b825d..93433fc 100644
--- a/benchmarks/intel_upload_blit_large_map.c
+++ b/benchmarks/intel_upload_blit_large_map.c
@@ -62,6 +62,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define OBJECT_WIDTH	1280
 #define OBJECT_HEIGHT	720
diff --git a/benchmarks/intel_upload_blit_small.c b/benchmarks/intel_upload_blit_small.c
index 3fd095f..e2f804b 100644
--- a/benchmarks/intel_upload_blit_small.c
+++ b/benchmarks/intel_upload_blit_small.c
@@ -55,6 +55,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 /* Happens to be 128k, the size of the VBOs used by i965's Mesa driver. */
 #define OBJECT_WIDTH	256
diff --git a/demos/intel_sprite_on.c b/demos/intel_sprite_on.c
index 98c0af9..fb375f4 100644
--- a/demos/intel_sprite_on.c
+++ b/demos/intel_sprite_on.c
@@ -47,10 +47,9 @@
 #include "drmtest.h"
 #include "igt_kms.h"
 
-#if defined(DRM_IOCTL_MODE_ADDFB2) && defined(DRM_I915_SET_SPRITE_COLORKEY)
-#define TEST_PLANES 1
-#include "drm_fourcc.h"
-#endif
+#include <drm_fourcc.h>
+
+#include "ioctl_wrappers.h"
 
 /*
  * Mode setting with the kernel interfaces is a bit of a chore.
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 112f049..c6f7bde 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -56,6 +56,7 @@
 #include "../version.h"
 #include "config.h"
 #include "intel_reg.h"
+#include "ioctl_wrappers.h"
 
 /* This file contains a bunch of wrapper functions to directly use gem ioctls.
  * Mostly useful to write kernel tests. */
diff --git a/lib/drmtest.h b/lib/drmtest.h
index d048ee0..4c55068 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -33,18 +33,11 @@
 #include <unistd.h>
 #include <errno.h>
 #include <stdbool.h>
-#include <setjmp.h>
 #include <sys/mman.h>
 
 #include "xf86drm.h"
 #include "xf86drmMode.h"
-#include "i915_drm.h"
 #include "intel_batchbuffer.h"
-#include "intel_chipset.h"
-#include "intel_gpu_tools.h"
-
-#include "ioctl_wrappers.h"
-#include "igt_core.h"
 
 #ifdef ANDROID
 #ifndef HAVE_MMAP64
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 05036fc..f467ce0 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -22,6 +22,7 @@
  *
  */
 
+#include <inttypes.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
 #include <errno.h>
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index ac27d7a..88ee83b 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -34,6 +34,7 @@
 
 #include "drmtest.h"
 #include "igt_kms.h"
+#include "ioctl_wrappers.h"
 
 /* helpers to create nice-looking framebuffers */
 static int create_bo_for_fb(int fd, int width, int height, int bpp,
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 6e3eb0f..8ca2181 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -30,6 +30,11 @@
 #ifndef IOCTL_WRAPPERS_H
 #define IOCTL_WRAPPERS_H
 
+#include <stdint.h>
+#include <stdbool.h>
+#include <intel_bufmgr.h>
+#include <i915_drm.h>
+
 /* libdrm interfacing */
 drm_intel_bo * gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd,
 				       const char *name, uint32_t handle);
diff --git a/lib/rendercopy_gen7.c b/lib/rendercopy_gen7.c
index 05e6829..75e0571 100644
--- a/lib/rendercopy_gen7.c
+++ b/lib/rendercopy_gen7.c
@@ -16,6 +16,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 #include "rendercopy.h"
 #include "gen7_render.h"
 #include "intel_reg.h"
diff --git a/tests/core_get_client_auth.c b/tests/core_get_client_auth.c
index 566a658..eef97e0 100644
--- a/tests/core_get_client_auth.c
+++ b/tests/core_get_client_auth.c
@@ -40,7 +40,7 @@
 # include <sys/syscall.h>
 
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 /* Checks whether the thread id is the current thread */
diff --git a/tests/drm_vma_limiter.c b/tests/drm_vma_limiter.c
index b38037a..f14ced8 100644
--- a/tests/drm_vma_limiter.c
+++ b/tests/drm_vma_limiter.c
@@ -33,11 +33,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/drm_vma_limiter_cached.c b/tests/drm_vma_limiter_cached.c
index 3a78436..7c40541 100644
--- a/tests/drm_vma_limiter_cached.c
+++ b/tests/drm_vma_limiter_cached.c
@@ -33,11 +33,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/drm_vma_limiter_cpu.c b/tests/drm_vma_limiter_cpu.c
index 77a50b1..4da4673 100644
--- a/tests/drm_vma_limiter_cpu.c
+++ b/tests/drm_vma_limiter_cpu.c
@@ -33,11 +33,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/drm_vma_limiter_gtt.c b/tests/drm_vma_limiter_gtt.c
index 5104b0d..283bf6b 100644
--- a/tests/drm_vma_limiter_gtt.c
+++ b/tests/drm_vma_limiter_gtt.c
@@ -33,11 +33,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c
index ff8a348..ed393af 100644
--- a/tests/drv_suspend.c
+++ b/tests/drv_suspend.c
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "igt_debugfs.h"
 
diff --git a/tests/gem_bad_address.c b/tests/gem_bad_address.c
index 6e5f025..5881935 100644
--- a/tests/gem_bad_address.c
+++ b/tests/gem_bad_address.c
@@ -35,9 +35,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_bad_batch.c b/tests/gem_bad_batch.c
index abeda88..5bb08b4 100644
--- a/tests/gem_bad_batch.c
+++ b/tests/gem_bad_batch.c
@@ -35,10 +35,11 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_bad_blit.c b/tests/gem_bad_blit.c
index c518b4f..ec414ea 100644
--- a/tests/gem_bad_blit.c
+++ b/tests/gem_bad_blit.c
@@ -50,10 +50,11 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_bad_length.c b/tests/gem_bad_length.c
index ae48d55..4b93cde 100644
--- a/tests/gem_bad_length.c
+++ b/tests/gem_bad_length.c
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 /*
diff --git a/tests/gem_basic.c b/tests/gem_basic.c
index 5d8f840..71d29ae 100644
--- a/tests/gem_basic.c
+++ b/tests/gem_basic.c
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 static void
diff --git a/tests/gem_caching.c b/tests/gem_caching.c
index d788891..da6f2d8 100644
--- a/tests/gem_caching.c
+++ b/tests/gem_caching.c
@@ -35,11 +35,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 /*
  * Testcase: snoop consistency when touching partial cachelines
diff --git a/tests/gem_close_race.c b/tests/gem_close_race.c
index 2087fed..e46e2c1 100644
--- a/tests/gem_close_race.c
+++ b/tests/gem_close_race.c
@@ -38,8 +38,9 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 
 #define OBJECT_SIZE 1024*1024*4
 
diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index 254bc4c..29f42c7 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -45,11 +45,12 @@
 #include <sys/time.h>
 #include <sys/wait.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void
 prw_set_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
index 6e1f888..77d9109 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -54,11 +54,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static uint32_t use_blt;
 
diff --git a/tests/gem_cs_prefetch.c b/tests/gem_cs_prefetch.c
index 9ff6573..842e427 100644
--- a/tests/gem_cs_prefetch.c
+++ b/tests/gem_cs_prefetch.c
@@ -44,11 +44,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_cs_tlb.c b/tests/gem_cs_tlb.c
index 6f1fd5b..7d5c99d 100644
--- a/tests/gem_cs_tlb.c
+++ b/tests/gem_cs_tlb.c
@@ -47,7 +47,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c
index 3fcc946..092f342 100644
--- a/tests/gem_ctx_bad_destroy.c
+++ b/tests/gem_ctx_bad_destroy.c
@@ -31,7 +31,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 struct local_drm_i915_context_destroy {
diff --git a/tests/gem_ctx_bad_exec.c b/tests/gem_ctx_bad_exec.c
index 834b5fe..f0bb0fc 100644
--- a/tests/gem_ctx_bad_exec.c
+++ b/tests/gem_ctx_bad_exec.c
@@ -42,7 +42,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 /* Copied from gem_exec_nop.c */
diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c
index 4340000..3dbef2b 100644
--- a/tests/gem_ctx_basic.c
+++ b/tests/gem_ctx_basic.c
@@ -41,11 +41,12 @@
 #include <sys/time.h>
 #include <getopt.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 /* options */
 int num_contexts = 10;
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index d7a4538..f32c228 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -27,7 +27,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 struct local_drm_i915_gem_context_create {
diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c
index 8a20181..3afa765 100644
--- a/tests/gem_ctx_exec.c
+++ b/tests/gem_ctx_exec.c
@@ -41,7 +41,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 struct local_drm_i915_gem_context_destroy {
diff --git a/tests/gem_double_irq_loop.c b/tests/gem_double_irq_loop.c
index 47784ad..f5c7629 100644
--- a/tests/gem_double_irq_loop.c
+++ b/tests/gem_double_irq_loop.c
@@ -34,12 +34,13 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 #include "i830_reg.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_dummy_reloc_loop.c b/tests/gem_dummy_reloc_loop.c
index 955de96..7c9da63 100644
--- a/tests/gem_dummy_reloc_loop.c
+++ b/tests/gem_dummy_reloc_loop.c
@@ -34,12 +34,13 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 #include "i830_reg.h"
+#include "intel_chipset.h"
 
 #define LOCAL_I915_EXEC_VEBOX (4<<0)
 
diff --git a/tests/gem_evict_alignment.c b/tests/gem_evict_alignment.c
index c478f18..46da5ba 100644
--- a/tests/gem_evict_alignment.c
+++ b/tests/gem_evict_alignment.c
@@ -42,8 +42,9 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 
 #define HEIGHT 256
 #define WIDTH 1024
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index ad33c0a..c595302 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -42,8 +42,9 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 
 #include "eviction_common.c"
 
diff --git a/tests/gem_exec_bad_domains.c b/tests/gem_exec_bad_domains.c
index e0e13de..0000e9e 100644
--- a/tests/gem_exec_bad_domains.c
+++ b/tests/gem_exec_bad_domains.c
@@ -34,11 +34,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 /* Testcase: Test whether the kernel rejects relocations with non-gpu domains
  *
diff --git a/tests/gem_exec_big.c b/tests/gem_exec_big.c
index 4be8559..7075316 100644
--- a/tests/gem_exec_big.c
+++ b/tests/gem_exec_big.c
@@ -44,7 +44,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define BATCH_SIZE		(1024*1024)
diff --git a/tests/gem_exec_blt.c b/tests/gem_exec_blt.c
index bac11f1..6c3ea37 100644
--- a/tests/gem_exec_blt.c
+++ b/tests/gem_exec_blt.c
@@ -37,7 +37,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c
index d5ca18c..51e5b6e 100644
--- a/tests/gem_exec_faulting_reloc.c
+++ b/tests/gem_exec_faulting_reloc.c
@@ -37,7 +37,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
diff --git a/tests/gem_exec_lut_handle.c b/tests/gem_exec_lut_handle.c
index c27e4d5..d0e2126 100644
--- a/tests/gem_exec_lut_handle.c
+++ b/tests/gem_exec_lut_handle.c
@@ -36,7 +36,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define BATCH_SIZE		(1024*1024)
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 868f010..28ec66b 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -37,7 +37,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_fd_exhaustion.c b/tests/gem_fd_exhaustion.c
index afaa100..7d865d4 100644
--- a/tests/gem_fd_exhaustion.c
+++ b/tests/gem_fd_exhaustion.c
@@ -32,6 +32,7 @@
 #include <fcntl.h>
 #include <limits.h>
 #include "drmtest.h"
+#include "ioctl_wrappers.h"
 
 
 #define FD_ARR_SZ 100
diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 86ee5be..9c1ff1c 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -41,7 +41,7 @@
 #include <sys/ioctl.h>
 #include <pthread.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define OBJECT_SIZE (128*1024) /* restricted to 1MiB alignment on i915 fences */
diff --git a/tests/gem_fenced_exec_thrash.c b/tests/gem_fenced_exec_thrash.c
index 6b3608e..cd53caf 100644
--- a/tests/gem_fenced_exec_thrash.c
+++ b/tests/gem_fenced_exec_thrash.c
@@ -34,9 +34,10 @@
 #include <fcntl.h>
 #include <inttypes.h>
 #include <drm.h>
-#include <i915_drm.h>
+#include "ioctl_wrappers.h"
 
 #include "drmtest.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 
 #define WIDTH 1024
diff --git a/tests/gem_flink.c b/tests/gem_flink.c
index 4b3b7c2..339f7f1 100644
--- a/tests/gem_flink.c
+++ b/tests/gem_flink.c
@@ -34,7 +34,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 static void
diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c
index 195ec15..26c71ce 100644
--- a/tests/gem_flink_race.c
+++ b/tests/gem_flink_race.c
@@ -33,7 +33,7 @@
 #include <pthread.h>
 
 #include "drmtest.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
 #include "igt_debugfs.h"
 
diff --git a/tests/gem_gtt_cpu_tlb.c b/tests/gem_gtt_cpu_tlb.c
index d664025..c087a37 100644
--- a/tests/gem_gtt_cpu_tlb.c
+++ b/tests/gem_gtt_cpu_tlb.c
@@ -40,7 +40,7 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_gtt_hog.c b/tests/gem_gtt_hog.c
index c7206dc..7fd22bd 100644
--- a/tests/gem_gtt_hog.c
+++ b/tests/gem_gtt_hog.c
@@ -39,8 +39,9 @@
 #include <sys/wait.h>
 
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 
 static const uint32_t canary = 0xdeadbeef;
 
diff --git a/tests/gem_gtt_speed.c b/tests/gem_gtt_speed.c
index 2f70276..6ebe275 100644
--- a/tests/gem_gtt_speed.c
+++ b/tests/gem_gtt_speed.c
@@ -38,7 +38,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define OBJECT_SIZE 16384
diff --git a/tests/gem_hang.c b/tests/gem_hang.c
index a675eae..5b1f5dc 100644
--- a/tests/gem_hang.c
+++ b/tests/gem_hang.c
@@ -35,9 +35,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_hangcheck_forcewake.c b/tests/gem_hangcheck_forcewake.c
index cd51d6c..d1bf000 100644
--- a/tests/gem_hangcheck_forcewake.c
+++ b/tests/gem_hangcheck_forcewake.c
@@ -34,11 +34,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 /*
  * Testcase: Provoke the hangcheck timer on an otherwise idle system
diff --git a/tests/gem_largeobject.c b/tests/gem_largeobject.c
index 5f0bb55..c01045e 100644
--- a/tests/gem_largeobject.c
+++ b/tests/gem_largeobject.c
@@ -34,7 +34,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 /* Should take 64 pages to store the page pointers on 64 bit */
diff --git a/tests/gem_linear_blits.c b/tests/gem_linear_blits.c
index e76de02..a7e398f 100644
--- a/tests/gem_linear_blits.c
+++ b/tests/gem_linear_blits.c
@@ -42,7 +42,8 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
+#include "intel_chipset.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
diff --git a/tests/gem_lut_handle.c b/tests/gem_lut_handle.c
index 10fa22b..e682ccf 100644
--- a/tests/gem_lut_handle.c
+++ b/tests/gem_lut_handle.c
@@ -36,7 +36,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define BATCH_SIZE		(1024*1024)
diff --git a/tests/gem_madvise.c b/tests/gem_madvise.c
index 17e5975..04a82aa 100644
--- a/tests/gem_madvise.c
+++ b/tests/gem_madvise.c
@@ -36,7 +36,7 @@
 #include <signal.h>
 
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define OBJECT_SIZE (1024*1024)
diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c
index 220f862..68bbdf2 100644
--- a/tests/gem_media_fill.c
+++ b/tests/gem_media_fill.c
@@ -43,11 +43,12 @@
 #include <sys/time.h>
 #include <getopt.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define WIDTH 64
 #define STRIDE (WIDTH)
diff --git a/tests/gem_mmap.c b/tests/gem_mmap.c
index 4c5be8f..a1b00fa 100644
--- a/tests/gem_mmap.c
+++ b/tests/gem_mmap.c
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define OBJECT_SIZE 16384
diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index 5f9e638..7ba5e39 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -36,7 +36,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "igt_debugfs.h"
 
diff --git a/tests/gem_mmap_offset_exhaustion.c b/tests/gem_mmap_offset_exhaustion.c
index 670ca46..d5939ec 100644
--- a/tests/gem_mmap_offset_exhaustion.c
+++ b/tests/gem_mmap_offset_exhaustion.c
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define OBJECT_SIZE (1024*1024)
diff --git a/tests/gem_non_secure_batch.c b/tests/gem_non_secure_batch.c
index 101b9dc..1d96222 100644
--- a/tests/gem_non_secure_batch.c
+++ b/tests/gem_non_secure_batch.c
@@ -34,10 +34,11 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 #include "i830_reg.h"
 
diff --git a/tests/gem_partial_pwrite_pread.c b/tests/gem_partial_pwrite_pread.c
index 0f4c9ae..c246537 100644
--- a/tests/gem_partial_pwrite_pread.c
+++ b/tests/gem_partial_pwrite_pread.c
@@ -34,8 +34,9 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
diff --git a/tests/gem_persistent_relocs.c b/tests/gem_persistent_relocs.c
index 50d8e0e..1a705fa 100644
--- a/tests/gem_persistent_relocs.c
+++ b/tests/gem_persistent_relocs.c
@@ -37,9 +37,10 @@
 #include <signal.h>
 #include <sys/wait.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 #include "igt_debugfs.h"
diff --git a/tests/gem_pin.c b/tests/gem_pin.c
index 860e565..e57ddcc 100644
--- a/tests/gem_pin.c
+++ b/tests/gem_pin.c
@@ -36,7 +36,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
diff --git a/tests/gem_pipe_control_store_loop.c b/tests/gem_pipe_control_store_loop.c
index f4c03ba..41bfc1b 100644
--- a/tests/gem_pipe_control_store_loop.c
+++ b/tests/gem_pipe_control_store_loop.c
@@ -40,10 +40,11 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_pread.c b/tests/gem_pread.c
index d1baf54..5f8246b 100644
--- a/tests/gem_pread.c
+++ b/tests/gem_pread.c
@@ -37,7 +37,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define OBJECT_SIZE 16384
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index eb8fd3a..f263286 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -43,8 +43,9 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c
index d04535b..4d47f6f 100644
--- a/tests/gem_pwrite.c
+++ b/tests/gem_pwrite.c
@@ -37,7 +37,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define OBJECT_SIZE 16384
diff --git a/tests/gem_pwrite_pread.c b/tests/gem_pwrite_pread.c
index db939b6..c3314e4 100644
--- a/tests/gem_pwrite_pread.c
+++ b/tests/gem_pwrite_pread.c
@@ -37,8 +37,9 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
diff --git a/tests/gem_readwrite.c b/tests/gem_readwrite.c
index 149254a..5260fb9 100644
--- a/tests/gem_readwrite.c
+++ b/tests/gem_readwrite.c
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 #define OBJECT_SIZE 16384
diff --git a/tests/gem_reg_read.c b/tests/gem_reg_read.c
index a88c6a4..19f1351 100644
--- a/tests/gem_reg_read.c
+++ b/tests/gem_reg_read.c
@@ -27,7 +27,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 
 struct local_drm_i915_reg_read {
diff --git a/tests/gem_reloc_overflow.c b/tests/gem_reloc_overflow.c
index fa7baab..98b7dd4 100644
--- a/tests/gem_reloc_overflow.c
+++ b/tests/gem_reloc_overflow.c
@@ -43,7 +43,8 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
+#include "intel_chipset.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_reloc_vs_gpu.c b/tests/gem_reloc_vs_gpu.c
index 34e81a2..07c79b3 100644
--- a/tests/gem_reloc_vs_gpu.c
+++ b/tests/gem_reloc_vs_gpu.c
@@ -37,10 +37,11 @@
 #include <signal.h>
 #include <sys/wait.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 #include "igt_debugfs.h"
 
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index ad48bfc..54f971d 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -43,11 +43,12 @@
 #include <sys/time.h>
 #include <getopt.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index 92c5bf6..ac2b29b 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -48,11 +48,13 @@
 #include <sys/time.h>
 #include <getopt.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
 #define HEIGHT 512
diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c
index 5233b23..8481e51 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -44,11 +44,12 @@
 #include <sys/time.h>
 #include <getopt.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 8ac93a8..90befd7 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -40,10 +40,11 @@
 #include <time.h>
 #include <signal.h>
 
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "igt_debugfs.h"
 #include "intel_bufmgr.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_ring_sync_copy.c b/tests/gem_ring_sync_copy.c
index b8b1454..768d02d 100644
--- a/tests/gem_ring_sync_copy.c
+++ b/tests/gem_ring_sync_copy.c
@@ -50,9 +50,10 @@
 #include <stdlib.h>
 #include <stdbool.h>
 
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 
 #define WIDTH	512
 #define HEIGHT	512
diff --git a/tests/gem_ring_sync_loop.c b/tests/gem_ring_sync_loop.c
index 95fcd30..5010d35 100644
--- a/tests/gem_ring_sync_loop.c
+++ b/tests/gem_ring_sync_loop.c
@@ -34,12 +34,13 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 #include "i830_reg.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index ef98701..716ff56 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -42,9 +42,10 @@
 #include <sys/time.h>
 
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index f974032..19c0201 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -42,12 +42,13 @@
 #include <getopt.h>
 #include <signal.h>
 
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "igt_core.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static int devid;
 static int card_index = 0;
diff --git a/tests/gem_set_tiling_vs_blt.c b/tests/gem_set_tiling_vs_blt.c
index 7335da8..1ad0e5c 100644
--- a/tests/gem_set_tiling_vs_blt.c
+++ b/tests/gem_set_tiling_vs_blt.c
@@ -54,10 +54,11 @@
 #include <sys/time.h>
 #include <stdbool.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_set_tiling_vs_gtt.c b/tests/gem_set_tiling_vs_gtt.c
index 5dc90ae..abe0963 100644
--- a/tests/gem_set_tiling_vs_gtt.c
+++ b/tests/gem_set_tiling_vs_gtt.c
@@ -35,9 +35,10 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define OBJECT_SIZE (1024*1024)
 #define TEST_STRIDE (1024*4)
diff --git a/tests/gem_set_tiling_vs_pwrite.c b/tests/gem_set_tiling_vs_pwrite.c
index 4ef3720..d07ebaf 100644
--- a/tests/gem_set_tiling_vs_pwrite.c
+++ b/tests/gem_set_tiling_vs_pwrite.c
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_storedw_batches_loop.c b/tests/gem_storedw_batches_loop.c
index 85d6f6c..f07085c 100644
--- a/tests/gem_storedw_batches_loop.c
+++ b/tests/gem_storedw_batches_loop.c
@@ -35,9 +35,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_storedw_loop_blt.c b/tests/gem_storedw_loop_blt.c
index d08f5b0..b242b29 100644
--- a/tests/gem_storedw_loop_blt.c
+++ b/tests/gem_storedw_loop_blt.c
@@ -35,11 +35,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_storedw_loop_bsd.c b/tests/gem_storedw_loop_bsd.c
index 079b139..482e276 100644
--- a/tests/gem_storedw_loop_bsd.c
+++ b/tests/gem_storedw_loop_bsd.c
@@ -35,11 +35,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_storedw_loop_render.c b/tests/gem_storedw_loop_render.c
index 2dc16b1..7cbc0a8 100644
--- a/tests/gem_storedw_loop_render.c
+++ b/tests/gem_storedw_loop_render.c
@@ -35,11 +35,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_storedw_loop_vebox.c b/tests/gem_storedw_loop_vebox.c
index aa1987a..872d4b2 100644
--- a/tests/gem_storedw_loop_vebox.c
+++ b/tests/gem_storedw_loop_vebox.c
@@ -34,11 +34,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define LOCAL_I915_EXEC_VEBOX (4<<0)
 
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index 3a94fb1..d6434bc 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -60,11 +60,12 @@
 #include <sys/time.h>
 #include <getopt.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define CMD_POLY_STIPPLE_OFFSET       0x7906
 
diff --git a/tests/gem_threaded_access_tiled.c b/tests/gem_threaded_access_tiled.c
index cf07daf..3752a1f 100644
--- a/tests/gem_threaded_access_tiled.c
+++ b/tests/gem_threaded_access_tiled.c
@@ -31,7 +31,7 @@
 #include <pthread.h>
 
 #include "drmtest.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
 
 /* Testcase: check parallel access to tiled memory
diff --git a/tests/gem_tiled_blits.c b/tests/gem_tiled_blits.c
index e21fc78..00b6955 100644
--- a/tests/gem_tiled_blits.c
+++ b/tests/gem_tiled_blits.c
@@ -50,10 +50,11 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_tiled_fence_blits.c b/tests/gem_tiled_fence_blits.c
index b33be58..3dfcf00 100644
--- a/tests/gem_tiled_fence_blits.c
+++ b/tests/gem_tiled_fence_blits.c
@@ -50,11 +50,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_tiled_partial_pwrite_pread.c b/tests/gem_tiled_partial_pwrite_pread.c
index bcae6e9..322cca9 100644
--- a/tests/gem_tiled_partial_pwrite_pread.c
+++ b/tests/gem_tiled_partial_pwrite_pread.c
@@ -34,9 +34,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_tiled_pread.c b/tests/gem_tiled_pread.c
index 0592b8c..6f104a6 100644
--- a/tests/gem_tiled_pread.c
+++ b/tests/gem_tiled_pread.c
@@ -45,9 +45,10 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/gem_tiled_pread_pwrite.c b/tests/gem_tiled_pread_pwrite.c
index 09d3ea4..06c32fc 100644
--- a/tests/gem_tiled_pread_pwrite.c
+++ b/tests/gem_tiled_pread_pwrite.c
@@ -54,7 +54,7 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c
index e8fcc7e..28d21d4 100644
--- a/tests/gem_tiled_swapping.c
+++ b/tests/gem_tiled_swapping.c
@@ -54,7 +54,7 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
 
diff --git a/tests/gem_tiling_max_stride.c b/tests/gem_tiling_max_stride.c
index e4b58dc..ded965a 100644
--- a/tests/gem_tiling_max_stride.c
+++ b/tests/gem_tiling_max_stride.c
@@ -36,9 +36,10 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void do_test_invalid_tiling(int fd, uint32_t handle, int tiling, int stride)
 {
diff --git a/tests/gem_unfence_active_buffers.c b/tests/gem_unfence_active_buffers.c
index b79b124..9ccabe9 100644
--- a/tests/gem_unfence_active_buffers.c
+++ b/tests/gem_unfence_active_buffers.c
@@ -48,11 +48,12 @@
 #include <sys/time.h>
 #include <stdbool.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_unref_active_buffers.c b/tests/gem_unref_active_buffers.c
index 1e9e214..8906705 100644
--- a/tests/gem_unref_active_buffers.c
+++ b/tests/gem_unref_active_buffers.c
@@ -41,11 +41,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_vmap_blits.c b/tests/gem_vmap_blits.c
index 48297af..4fb2a21 100644
--- a/tests/gem_vmap_blits.c
+++ b/tests/gem_vmap_blits.c
@@ -44,7 +44,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
diff --git a/tests/gem_wait_render_timeout.c b/tests/gem_wait_render_timeout.c
index 0748104..d4c12fe 100644
--- a/tests/gem_wait_render_timeout.c
+++ b/tests/gem_wait_render_timeout.c
@@ -38,11 +38,12 @@
 #include <sys/time.h>
 #include <getopt.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define MSEC_PER_SEC	1000L
 #define USEC_PER_MSEC	1000L
diff --git a/tests/gem_write_read_ring_switch.c b/tests/gem_write_read_ring_switch.c
index 524d6fb..cd235c9 100644
--- a/tests/gem_write_read_ring_switch.c
+++ b/tests/gem_write_read_ring_switch.c
@@ -34,10 +34,11 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 #include "i830_reg.h"
 
diff --git a/tests/gen3_mixed_blits.c b/tests/gen3_mixed_blits.c
index 17ccf20..64041a0 100644
--- a/tests/gen3_mixed_blits.c
+++ b/tests/gen3_mixed_blits.c
@@ -43,9 +43,10 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #include "i915_reg.h"
 #include "i915_3d.h"
diff --git a/tests/gen3_render_linear_blits.c b/tests/gen3_render_linear_blits.c
index 129b506..eed3ba5 100644
--- a/tests/gen3_render_linear_blits.c
+++ b/tests/gen3_render_linear_blits.c
@@ -42,9 +42,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #include "i915_reg.h"
 #include "i915_3d.h"
diff --git a/tests/gen3_render_mixed_blits.c b/tests/gen3_render_mixed_blits.c
index d60e726..ac5452a 100644
--- a/tests/gen3_render_mixed_blits.c
+++ b/tests/gen3_render_mixed_blits.c
@@ -43,9 +43,10 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #include "i915_reg.h"
 #include "i915_3d.h"
diff --git a/tests/gen3_render_tiledx_blits.c b/tests/gen3_render_tiledx_blits.c
index 427a5c7..1b2a00c 100644
--- a/tests/gen3_render_tiledx_blits.c
+++ b/tests/gen3_render_tiledx_blits.c
@@ -43,9 +43,10 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #include "i915_reg.h"
 #include "i915_3d.h"
diff --git a/tests/gen3_render_tiledy_blits.c b/tests/gen3_render_tiledy_blits.c
index a82f994..8030541 100644
--- a/tests/gen3_render_tiledy_blits.c
+++ b/tests/gen3_render_tiledy_blits.c
@@ -43,9 +43,10 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #include "i915_reg.h"
 #include "i915_3d.h"
diff --git a/tests/gen7_forcewake_mt.c b/tests/gen7_forcewake_mt.c
index db5dd3e..03eb6e9 100644
--- a/tests/gen7_forcewake_mt.c
+++ b/tests/gen7_forcewake_mt.c
@@ -35,10 +35,11 @@
 #include <string.h>
 
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "i915_pciids.h"
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define FORCEWAKE_MT 0xa188
 
diff --git a/tests/kms_addfb.c b/tests/kms_addfb.c
index 3f727cc..349e7fb 100644
--- a/tests/kms_addfb.c
+++ b/tests/kms_addfb.c
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "drm_fourcc.h"
 
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index 07a572d..db595c7 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -27,12 +27,14 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "drm_fourcc.h"
+#include <drm_fourcc.h>
 
 #include "drmtest.h"
 #include "igt_debugfs.h"
 #include "igt_kms.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
+#include "ioctl_wrappers.h"
 
 enum test_mode {
 	TEST_PAGE_FLIP,
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 70d67e5..d5292e8 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -35,10 +35,12 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include <linux/kd.h>
+#include <time.h>
+#include <pthread.h>
 
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "testdisplay.h"
+#include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "igt_kms.h"
 
diff --git a/tests/kms_render.c b/tests/kms_render.c
index e661753..7bff958 100644
--- a/tests/kms_render.c
+++ b/tests/kms_render.c
@@ -30,13 +30,16 @@
 #include <unistd.h>
 #include <sys/time.h>
 
-#include "drm_fourcc.h"
+#include <drm_fourcc.h>
+
 #include "drmtest.h"
 #include "testdisplay.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 #include "igt_kms.h"
+#include "ioctl_wrappers.h"
 
 drmModeRes *resources;
 int drm_fd;
diff --git a/tests/pm_lpsp.c b/tests/pm_lpsp.c
index ede9149..1dc7a73 100644
--- a/tests/pm_lpsp.c
+++ b/tests/pm_lpsp.c
@@ -31,6 +31,8 @@
 
 #include "drmtest.h"
 #include "igt_kms.h"
+#include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 /* We know that if we don't enable audio runtime PM, snd_hda_intel will never
  * release its power well refcount, and we'll never reach the LPSP sate. OTOH
diff --git a/tests/pm_pc8.c b/tests/pm_pc8.c
index c672e80..5a1e747 100644
--- a/tests/pm_pc8.c
+++ b/tests/pm_pc8.c
@@ -44,7 +44,8 @@
 #include "drmtest.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
-#include "i915_drm.h"
+#include "intel_chipset.h"
+#include "ioctl_wrappers.h"
 #include "igt_kms.h"
 #include "igt_debugfs.h"
 
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index 038987c..e6ab379 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -34,11 +34,14 @@
 #include <getopt.h>
 #include <fcntl.h>
 #include <signal.h>
+
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "igt_debugfs.h"
+#include "ioctl_wrappers.h"
 
 static int drm_fd;
 
diff --git a/tests/prime_nv_api.c b/tests/prime_nv_api.c
index e2448be..c510c1c 100644
--- a/tests/prime_nv_api.c
+++ b/tests/prime_nv_api.c
@@ -19,6 +19,7 @@
 #include "intel_gpu_tools.h"
 #include "intel_batchbuffer.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 
 #define BO_SIZE (256*1024)
 
diff --git a/tests/prime_nv_pcopy.c b/tests/prime_nv_pcopy.c
index fd2018b..3f3814a 100644
--- a/tests/prime_nv_pcopy.c
+++ b/tests/prime_nv_pcopy.c
@@ -23,11 +23,12 @@
 #include <sys/ioctl.h>
 #include <errno.h>
 
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
 #include "nouveau.h"
 #include "intel_gpu_tools.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "drmtest.h"
 
 static int intel_fd = -1, nouveau_fd = -1;
diff --git a/tests/prime_nv_test.c b/tests/prime_nv_test.c
index 640515b..ee54e7a 100644
--- a/tests/prime_nv_test.c
+++ b/tests/prime_nv_test.c
@@ -22,11 +22,12 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
 #include "nouveau.h"
 #include "intel_gpu_tools.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 #include "drmtest.h"
 
 int intel_fd = -1, nouveau_fd = -1;
diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c
index 2566af9..efdd24f 100644
--- a/tests/prime_self_import.c
+++ b/tests/prime_self_import.c
@@ -44,7 +44,7 @@
 #include <pthread.h>
 
 #include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "igt_debugfs.h"
 
diff --git a/tests/prime_udl.c b/tests/prime_udl.c
index d853085..892a952 100644
--- a/tests/prime_udl.c
+++ b/tests/prime_udl.c
@@ -25,11 +25,12 @@
 
 #include "xf86drm.h"
 #include "xf86drmMode.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
 #include "intel_gpu_tools.h"
 #include "intel_batchbuffer.h"
 #include "drmtest.h"
+#include "intel_chipset.h"
 
 int intel_fd = -1, udl_fd = -1;
 drm_intel_bufmgr *bufmgr;
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index d0cd512..b70287e 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -62,7 +62,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "testdisplay.h"
 #include "igt_kms.h"
diff --git a/tools/intel_perf_counters.c b/tools/intel_perf_counters.c
index 23d9ed3..c31111e 100644
--- a/tools/intel_perf_counters.c
+++ b/tools/intel_perf_counters.c
@@ -48,6 +48,7 @@
 #include "intel_gpu_tools.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
+#include "intel_chipset.h"
 
 #define GEN5_COUNTER_COUNT 29