All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/28] more i-g-t docs and api polish
@ 2014-03-23 14:18 Daniel Vetter
  2014-03-23 14:18 ` [PATCH 01/28] lib: rename intel_pci.c to intel_chipset.c Daniel Vetter
                   ` (28 more replies)
  0 siblings, 29 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Hi all,

So this thing turned out to be fairly ugly overall, and I don't think it's worth
the effort to polish the series through some giant rebasing. make distcheck
still works so I don't think I've fumbled this too badly and will hence just
push the patches as-is.

I'm still very much interested in feedback, I'll simply apply that as follow-up
patches.

For those who want a peak at what the i-g-t docs look like now:

http://people.freedesktop.org/~danvet/igt/

Everything but the modeset helpers is now neatly documented, with some intro
texts where useful. I think for the igt_display/kms libraries we first need to
give the apis a bit more polish before documentation makes sense. There's still
an awful lot of boilerplate going on in kms tests ...

Cheers, Daniel

Daniel Vetter (28):
  lib: rename intel_pci.c to intel_chipset.c
  lib: consolidate chipset helpers in intel_chipset.[hc]
  lib/intel_chipset: intel_ prefix for pch global
  lib/intel_chipset: api docs
  lib: make rendercopy.h an internal header
  lib: make media_fill.h an internal header
  lib/intel_batchbuffer: un-inline buf_height/width
  lib/intel_batchbuffer: igt_ namespace for the buffer structure
  lib/intel_batchbuffer: igt_ prefix for rendercopy/mediafill funcs
  lib/intel_batchbuffer: drop cpu_mapping from igt_buf
  lib/intel_batchbuffer: api documentation for render copy/media fill
  lib: Move non-register things out of intel-gpu-tools.h
  tests|lib: remove assert.h includes
  lib: add #include "foo.h" lines like in manpages
  lib: remove uncessary #includes from headers
  lib: more unecessary header removal
  lib: unnecessary header removal for drmtest.h, part 1
  lib: unnecessary header removal for drmtest.h, part 2
  lib: rename intel_gpu_tools.h to intel_io.h
  lib/intel_io: rename mmio setup functions
  lib/intel_io: api documentation
  lib: s/drmtest_dumb_aub/igt_aub_dump_enabled/
  lib: extract igt_aux.[hc]
  lib/igt_aux: api documentation
  lib: s/igt_env_set/igt_check_boolean_env_var
  lib: Use @include tag for include files
  lib/drmtest: api documentation
  lib/intel_batchbuffer: document header dependencies

 benchmarks/intel_upload_blit_large.c               |   9 +-
 benchmarks/intel_upload_blit_large_gtt.c           |   3 +-
 benchmarks/intel_upload_blit_large_map.c           |   3 +-
 benchmarks/intel_upload_blit_small.c               |   3 +-
 debugger/debug_rdata.c                             |   3 +-
 debugger/eudb.c                                    |   2 +-
 demos/intel_sprite_on.c                            |   7 +-
 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   5 +-
 lib/Makefile.sources                               |   9 +-
 lib/drmtest.c                                      | 243 +++-----------
 lib/drmtest.h                                      |  80 +++--
 lib/gen6_render.h                                  |   8 -
 lib/gen7_media.h                                   |   2 +
 lib/gen8_media.h                                   |   2 +
 lib/igt_aux.c                                      | 373 +++++++++++++++++++++
 lib/igt_aux.h                                      |  67 ++++
 lib/igt_core.c                                     |   9 +-
 lib/igt_core.h                                     |   7 +
 lib/igt_debugfs.c                                  |   3 +
 lib/igt_debugfs.h                                  |   3 +-
 lib/igt_kms.c                                      |  14 +-
 lib/igt_kms.h                                      |  10 +-
 lib/intel_batchbuffer.c                            |  93 ++++-
 lib/intel_batchbuffer.h                            |  96 +++++-
 lib/intel_chipset.c                                | 215 ++++++++++++
 lib/intel_chipset.h                                |  26 ++
 lib/intel_drm.c                                    | 200 -----------
 lib/intel_gpu_tools.h                              | 126 -------
 lib/intel_io.h                                     |  81 +++++
 lib/intel_iosf.c                                   |  61 +++-
 lib/intel_mmio.c                                   | 133 +++++++-
 lib/intel_os.c                                     | 171 ++++++++++
 lib/intel_pci.c                                    | 123 -------
 lib/intel_reg_map.c                                |   3 +-
 lib/ioctl_wrappers.c                               |   6 +-
 lib/ioctl_wrappers.h                               |   5 +
 lib/media_fill.c                                   |  14 -
 lib/media_fill.h                                   |  49 +--
 lib/media_fill_gen7.c                              |  16 +-
 lib/media_fill_gen8.c                              |  16 +-
 lib/rendercopy.h                                   |  71 +---
 lib/rendercopy_gen6.c                              |  51 ++-
 lib/rendercopy_gen7.c                              |  44 ++-
 lib/rendercopy_gen8.c                              |  58 ++--
 lib/rendercopy_i830.c                              |  64 ++--
 lib/rendercopy_i915.c                              |  30 +-
 tests/core_get_client_auth.c                       |   2 +-
 tests/core_getclient.c                             |   3 +
 tests/core_getstats.c                              |   5 +
 tests/ddi_compute_wrpll.c                          |   3 +-
 tests/drm_vma_limiter.c                            |   5 +-
 tests/drm_vma_limiter_cached.c                     |   5 +-
 tests/drm_vma_limiter_cpu.c                        |   5 +-
 tests/drm_vma_limiter_gtt.c                        |   5 +-
 tests/drv_suspend.c                                |  11 +-
 tests/eviction_common.c                            |   1 +
 tests/gem_bad_address.c                            |   5 +-
 tests/gem_bad_batch.c                              |   5 +-
 tests/gem_bad_blit.c                               |   5 +-
 tests/gem_bad_length.c                             |   2 +-
 tests/gem_basic.c                                  |   2 +-
 tests/gem_caching.c                                |  10 +-
 tests/gem_close_race.c                             |   3 +-
 tests/gem_concurrent_blit.c                        |  10 +-
 tests/gem_cpu_reloc.c                              |  10 +-
 tests/gem_cs_prefetch.c                            |  10 +-
 tests/gem_cs_tlb.c                                 |   9 +-
 tests/gem_ctx_bad_destroy.c                        |   4 +-
 tests/gem_ctx_bad_exec.c                           |   2 +-
 tests/gem_ctx_basic.c                              |  24 +-
 tests/gem_ctx_create.c                             |   4 +-
 tests/gem_ctx_exec.c                               |   8 +-
 tests/gem_double_irq_loop.c                        |   5 +-
 tests/gem_dummy_reloc_loop.c                       |   5 +-
 tests/gem_evict_alignment.c                        |   8 +-
 tests/gem_evict_everything.c                       |   3 +-
 tests/gem_exec_bad_domains.c                       |   5 +-
 tests/gem_exec_big.c                               |   2 +-
 tests/gem_exec_blt.c                               |   4 +-
 tests/gem_exec_faulting_reloc.c                    |   4 +-
 tests/gem_exec_lut_handle.c                        |   2 +-
 tests/gem_exec_nop.c                               |   4 +-
 tests/gem_fd_exhaustion.c                          |   3 +
 tests/gem_fence_thrash.c                           |  34 +-
 tests/gem_fenced_exec_thrash.c                     |   8 +-
 tests/gem_flink.c                                  |   2 +-
 tests/gem_flink_race.c                             |   3 +-
 tests/gem_gtt_cpu_tlb.c                            |   4 +-
 tests/gem_gtt_hog.c                                |   3 +-
 tests/gem_gtt_speed.c                              |   2 +-
 tests/gem_hang.c                                   |   5 +-
 tests/gem_hangcheck_forcewake.c                    |   5 +-
 tests/gem_largeobject.c                            |   2 +-
 tests/gem_linear_blits.c                           |  12 +-
 tests/gem_lut_handle.c                             |   2 +-
 tests/gem_madvise.c                                |   2 +-
 tests/gem_media_fill.c                             |  29 +-
 tests/gem_mmap.c                                   |   2 +-
 tests/gem_mmap_gtt.c                               |   2 +-
 tests/gem_mmap_offset_exhaustion.c                 |   2 +-
 tests/gem_non_secure_batch.c                       |   5 +-
 tests/gem_partial_pwrite_pread.c                   |  12 +-
 tests/gem_persistent_relocs.c                      |  12 +-
 tests/gem_pin.c                                    |   9 +-
 tests/gem_pipe_control_store_loop.c                |   5 +-
 tests/gem_pread.c                                  |   2 +-
 tests/gem_pread_after_blit.c                       |  12 +-
 tests/gem_pwrite.c                                 |   2 +-
 tests/gem_pwrite_pread.c                           |   5 +-
 tests/gem_readwrite.c                              |   2 +-
 tests/gem_reg_read.c                               |   4 +-
 tests/gem_reloc_overflow.c                         |   5 +-
 tests/gem_reloc_vs_gpu.c                           |  12 +-
 tests/gem_render_copy.c                            |  40 ++-
 tests/gem_render_linear_blits.c                    |  31 +-
 tests/gem_render_tiled_blits.c                     |  27 +-
 tests/gem_reset_stats.c                            |  11 +-
 tests/gem_ring_sync_copy.c                         |  21 +-
 tests/gem_ring_sync_loop.c                         |   5 +-
 tests/gem_ringfill.c                               |  26 +-
 tests/gem_seqno_wrap.c                             |  22 +-
 tests/gem_set_tiling_vs_blt.c                      |   5 +-
 tests/gem_set_tiling_vs_gtt.c                      |   5 +-
 tests/gem_set_tiling_vs_pwrite.c                   |   4 +-
 tests/gem_storedw_batches_loop.c                   |   7 +-
 tests/gem_storedw_loop_blt.c                       |   5 +-
 tests/gem_storedw_loop_bsd.c                       |   5 +-
 tests/gem_storedw_loop_render.c                    |   5 +-
 tests/gem_storedw_loop_vebox.c                     |   5 +-
 tests/gem_stress.c                                 |  87 +++--
 tests/gem_threaded_access_tiled.c                  |   2 +-
 tests/gem_tiled_blits.c                            |  12 +-
 tests/gem_tiled_fence_blits.c                      |  10 +-
 tests/gem_tiled_partial_pwrite_pread.c             |  12 +-
 tests/gem_tiled_pread.c                            |   5 +-
 tests/gem_tiled_pread_pwrite.c                     |   9 +-
 tests/gem_tiled_swapping.c                         |   9 +-
 tests/gem_tiling_max_stride.c                      |   5 +-
 tests/gem_unfence_active_buffers.c                 |   5 +-
 tests/gem_unref_active_buffers.c                   |   5 +-
 tests/gem_vmap_blits.c                             |   5 +-
 tests/gem_wait_render_timeout.c                    |  22 +-
 tests/gem_write_read_ring_switch.c                 |  12 +-
 tests/gen3_mixed_blits.c                           |   5 +-
 tests/gen3_render_linear_blits.c                   |   5 +-
 tests/gen3_render_mixed_blits.c                    |   5 +-
 tests/gen3_render_tiledx_blits.c                   |   5 +-
 tests/gen3_render_tiledy_blits.c                   |   5 +-
 tests/gen7_forcewake_mt.c                          |   5 +-
 tests/igt_fork_helper.c                            |   1 +
 tests/igt_simulation.c                             |   2 +
 tests/kms_addfb.c                                  |   2 +-
 tests/kms_cursor_crc.c                             |   1 +
 tests/kms_fbc_crc.c                                |  12 +-
 tests/kms_flip.c                                   |  17 +-
 tests/kms_pipe_crc_basic.c                         |   1 +
 tests/kms_plane.c                                  |   1 +
 tests/kms_render.c                                 |   7 +-
 tests/kms_setmode.c                                |  27 +-
 tests/pm_lpsp.c                                    |   2 +
 tests/pm_pc8.c                                     |   5 +-
 tests/pm_psr.c                                     |   2 +
 tests/pm_rc6_residency.c                           |   2 +
 tests/pm_rps.c                                     |   8 +-
 tests/prime_nv_api.c                               |   3 +-
 tests/prime_nv_pcopy.c                             |   5 +-
 tests/prime_nv_test.c                              |   5 +-
 tests/prime_self_import.c                          |   2 +-
 tests/prime_udl.c                                  |   8 +-
 tests/testdisplay.c                                |   6 +-
 tools/intel_audio_dump.c                           |   9 +-
 tools/intel_backlight.c                            |   6 +-
 tools/intel_bios_reader.c                          |   4 +-
 tools/intel_dpio_read.c                            |   3 +-
 tools/intel_dpio_write.c                           |   3 +-
 tools/intel_error_decode.c                         |   3 +-
 tools/intel_forcewaked.c                           |   3 +-
 tools/intel_framebuffer_dump.c                     |   2 +-
 tools/intel_gpu_time.c                             |   6 +-
 tools/intel_gpu_top.c                              |   6 +-
 tools/intel_gtt.c                                  |   3 +-
 tools/intel_infoframes.c                           |   8 +-
 tools/intel_l3_parity.c                            |   3 +-
 tools/intel_lid.c                                  |   5 +-
 tools/intel_nc_read.c                              |   3 +-
 tools/intel_nc_write.c                             |   3 +-
 tools/intel_opregion_decode.c                      |   3 +-
 tools/intel_panel_fitter.c                         |   4 +-
 tools/intel_perf_counters.c                        |   3 +-
 tools/intel_punit_read.c                           |   3 +-
 tools/intel_punit_write.c                          |   3 +-
 tools/intel_reg_checker.c                          |   5 +-
 tools/intel_reg_dumper.c                           |  17 +-
 tools/intel_reg_read.c                             |   3 +-
 tools/intel_reg_snapshot.c                         |   5 +-
 tools/intel_reg_write.c                            |   3 +-
 tools/intel_stepping.c                             |   3 +-
 tools/intel_vga_read.c                             |   3 +-
 tools/intel_vga_write.c                            |   3 +-
 tools/quick_dump/Makefile.am                       |   6 +-
 tools/quick_dump/chipset_macro_wrap.c              |  33 ++
 tools/quick_dump/intel_chipset.c                   |  33 --
 202 files changed, 2401 insertions(+), 1398 deletions(-)
 create mode 100644 lib/igt_aux.c
 create mode 100644 lib/igt_aux.h
 create mode 100644 lib/intel_chipset.c
 delete mode 100644 lib/intel_drm.c
 delete mode 100644 lib/intel_gpu_tools.h
 create mode 100644 lib/intel_io.h
 create mode 100644 lib/intel_os.c
 delete mode 100644 lib/intel_pci.c
 delete mode 100644 lib/media_fill.c
 create mode 100644 tools/quick_dump/chipset_macro_wrap.c
 delete mode 100644 tools/quick_dump/intel_chipset.c

-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 01/28] lib: rename intel_pci.c to intel_chipset.c
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 02/28] lib: consolidate chipset helpers in intel_chipset.[hc] Daniel Vetter
                   ` (27 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

This is to consolidate all the chipset related functions to
intel_chipset.[hc].

Unfortunately we need to rename a wrapper lib file in quick_dump, too.
And quick_dump makes automake a bit unhappy apparently.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/Makefile.sources                  |   2 +-
 lib/intel_chipset.c                   | 123 ++++++++++++++++++++++++++++++++++
 lib/intel_pci.c                       | 123 ----------------------------------
 tools/quick_dump/Makefile.am          |   4 +-
 tools/quick_dump/chipset_macro_wrap.c |  33 +++++++++
 tools/quick_dump/intel_chipset.c      |  33 ---------
 6 files changed, 159 insertions(+), 159 deletions(-)
 create mode 100644 lib/intel_chipset.c
 delete mode 100644 lib/intel_pci.c
 create mode 100644 tools/quick_dump/chipset_macro_wrap.c
 delete mode 100644 tools/quick_dump/intel_chipset.c

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index a3a679c1c41e..2b700c6c2726 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -18,7 +18,7 @@ libintel_tools_la_SOURCES = 	\
 	intel_drm.c		\
 	intel_gpu_tools.h	\
 	intel_mmio.c		\
-	intel_pci.c		\
+	intel_chipset.c		\
 	intel_reg.h		\
 	ioctl_wrappers.c	\
 	ioctl_wrappers.h	\
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
new file mode 100644
index 000000000000..e60e0d324da8
--- /dev/null
+++ b/lib/intel_chipset.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <err.h>
+#include <assert.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+#include "intel_gpu_tools.h"
+
+enum pch_type pch;
+
+struct pci_device *
+intel_get_pci_device(void)
+{
+	struct pci_device *pci_dev;
+	int error;
+
+	error = pci_system_init();
+	if (error != 0) {
+		fprintf(stderr, "Couldn't initialize PCI system: %s\n",
+			strerror(error));
+		exit(1);
+	}
+
+	/* Grab the graphics card. Try the canonical slot first, then
+	 * walk the entire PCI bus for a matching device. */
+	pci_dev = pci_device_find_by_slot(0, 0, 2, 0);
+	if (pci_dev == NULL || pci_dev->vendor_id != 0x8086) {
+		struct pci_device_iterator *iter;
+		struct pci_id_match match;
+
+		match.vendor_id = 0x8086; /* Intel */
+		match.device_id = PCI_MATCH_ANY;
+		match.subvendor_id = PCI_MATCH_ANY;
+		match.subdevice_id = PCI_MATCH_ANY;
+
+		match.device_class = 0x3 << 16;
+		match.device_class_mask = 0xff << 16;
+
+		match.match_data = 0;
+
+		iter = pci_id_match_iterator_create(&match);
+		pci_dev = pci_device_next(iter);
+		pci_iterator_destroy(iter);
+	}
+	if (pci_dev == NULL)
+		errx(1, "Couldn't find graphics card");
+
+	error = pci_device_probe(pci_dev);
+	if (error != 0) {
+		fprintf(stderr, "Couldn't probe graphics card: %s\n",
+			strerror(error));
+		exit(1);
+	}
+
+	if (pci_dev->vendor_id != 0x8086)
+		errx(1, "Graphics card is non-intel");
+
+	return pci_dev;
+}
+
+void
+intel_check_pch(void)
+{
+	struct pci_device *pch_dev;
+
+	pch_dev = pci_device_find_by_slot(0, 0, 31, 0);
+	if (pch_dev == NULL)
+		return;
+
+	if (pch_dev->vendor_id != 0x8086)
+		return;
+
+	switch (pch_dev->device_id & 0xff00) {
+	case 0x3b00:
+		pch = PCH_IBX;
+		break;
+	case 0x1c00:
+	case 0x1e00:
+		pch = PCH_CPT;
+		break;
+	case 0x8c00:
+	case 0x9c00:
+		pch = PCH_LPT;
+		break;
+	default:
+		pch = PCH_NONE;
+		return;
+	}
+}
+
diff --git a/lib/intel_pci.c b/lib/intel_pci.c
deleted file mode 100644
index e60e0d324da8..000000000000
--- a/lib/intel_pci.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright © 2008 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Eric Anholt <eric@anholt.net>
- *
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <err.h>
-#include <assert.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-
-#include "intel_gpu_tools.h"
-
-enum pch_type pch;
-
-struct pci_device *
-intel_get_pci_device(void)
-{
-	struct pci_device *pci_dev;
-	int error;
-
-	error = pci_system_init();
-	if (error != 0) {
-		fprintf(stderr, "Couldn't initialize PCI system: %s\n",
-			strerror(error));
-		exit(1);
-	}
-
-	/* Grab the graphics card. Try the canonical slot first, then
-	 * walk the entire PCI bus for a matching device. */
-	pci_dev = pci_device_find_by_slot(0, 0, 2, 0);
-	if (pci_dev == NULL || pci_dev->vendor_id != 0x8086) {
-		struct pci_device_iterator *iter;
-		struct pci_id_match match;
-
-		match.vendor_id = 0x8086; /* Intel */
-		match.device_id = PCI_MATCH_ANY;
-		match.subvendor_id = PCI_MATCH_ANY;
-		match.subdevice_id = PCI_MATCH_ANY;
-
-		match.device_class = 0x3 << 16;
-		match.device_class_mask = 0xff << 16;
-
-		match.match_data = 0;
-
-		iter = pci_id_match_iterator_create(&match);
-		pci_dev = pci_device_next(iter);
-		pci_iterator_destroy(iter);
-	}
-	if (pci_dev == NULL)
-		errx(1, "Couldn't find graphics card");
-
-	error = pci_device_probe(pci_dev);
-	if (error != 0) {
-		fprintf(stderr, "Couldn't probe graphics card: %s\n",
-			strerror(error));
-		exit(1);
-	}
-
-	if (pci_dev->vendor_id != 0x8086)
-		errx(1, "Graphics card is non-intel");
-
-	return pci_dev;
-}
-
-void
-intel_check_pch(void)
-{
-	struct pci_device *pch_dev;
-
-	pch_dev = pci_device_find_by_slot(0, 0, 31, 0);
-	if (pch_dev == NULL)
-		return;
-
-	if (pch_dev->vendor_id != 0x8086)
-		return;
-
-	switch (pch_dev->device_id & 0xff00) {
-	case 0x3b00:
-		pch = PCH_IBX;
-		break;
-	case 0x1c00:
-	case 0x1e00:
-		pch = PCH_CPT;
-		break;
-	case 0x8c00:
-	case 0x9c00:
-		pch = PCH_LPT;
-		break;
-	default:
-		pch = PCH_NONE;
-		return;
-	}
-}
-
diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
index 1814315e0cb5..e6329c9c2980 100644
--- a/tools/quick_dump/Makefile.am
+++ b/tools/quick_dump/Makefile.am
@@ -7,9 +7,9 @@ bin_SCRIPTS = chipset.py
 
 lib_LTLIBRARIES = I915ChipsetPython.la
 I915ChipsetPython_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) $(PCIACCESS_LIBS)
-I915ChipsetPython_la_SOURCES = chipset_wrap_python.c intel_chipset.c \
+I915ChipsetPython_la_SOURCES = chipset_wrap_python.c chipset_macro_wrap.c \
 			       $(top_srcdir)/lib/intel_drm.c  \
-			       $(top_srcdir)/lib/intel_pci.c  \
+			       $(top_srcdir)/lib/intel_chipset.c  \
 			       $(top_srcdir)/lib/intel_reg_map.c  \
 			       $(top_srcdir)/lib/intel_mmio.c  \
 			       $(top_srcdir)/lib/intel_iosf.c
diff --git a/tools/quick_dump/chipset_macro_wrap.c b/tools/quick_dump/chipset_macro_wrap.c
new file mode 100644
index 000000000000..392b85eca2e4
--- /dev/null
+++ b/tools/quick_dump/chipset_macro_wrap.c
@@ -0,0 +1,33 @@
+#include <pciaccess.h>
+#include "intel_chipset.h"
+
+int is_sandybridge(unsigned short pciid)
+{
+	return IS_GEN6(pciid);
+}
+
+int is_ivybridge(unsigned short pciid)
+{
+	return IS_IVYBRIDGE(pciid);
+}
+
+int is_valleyview(unsigned short pciid)
+{
+	return IS_VALLEYVIEW(pciid);
+}
+
+int is_haswell(unsigned short pciid)
+{
+	return IS_HASWELL(pciid);
+}
+
+int is_broadwell(unsigned short pciid)
+{
+	return IS_BROADWELL(pciid);
+}
+
+/* Simple helper because I couldn't make this work in the script */
+unsigned short pcidev_to_devid(struct pci_device *pdev)
+{
+	return pdev->device_id;
+}
diff --git a/tools/quick_dump/intel_chipset.c b/tools/quick_dump/intel_chipset.c
deleted file mode 100644
index 392b85eca2e4..000000000000
--- a/tools/quick_dump/intel_chipset.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <pciaccess.h>
-#include "intel_chipset.h"
-
-int is_sandybridge(unsigned short pciid)
-{
-	return IS_GEN6(pciid);
-}
-
-int is_ivybridge(unsigned short pciid)
-{
-	return IS_IVYBRIDGE(pciid);
-}
-
-int is_valleyview(unsigned short pciid)
-{
-	return IS_VALLEYVIEW(pciid);
-}
-
-int is_haswell(unsigned short pciid)
-{
-	return IS_HASWELL(pciid);
-}
-
-int is_broadwell(unsigned short pciid)
-{
-	return IS_BROADWELL(pciid);
-}
-
-/* Simple helper because I couldn't make this work in the script */
-unsigned short pcidev_to_devid(struct pci_device *pdev)
-{
-	return pdev->device_id;
-}
-- 
1.8.5.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 02/28] lib: consolidate chipset helpers in intel_chipset.[hc]
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
  2014-03-23 14:18 ` [PATCH 01/28] lib: rename intel_pci.c to intel_chipset.c Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 03/28] lib/intel_chipset: intel_ prefix for pch global Daniel Vetter
                   ` (26 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_chipset.c   | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 lib/intel_chipset.h   | 21 +++++++++++++++++++++
 lib/intel_drm.c       | 42 ------------------------------------------
 lib/intel_gpu_tools.h | 18 ------------------
 4 files changed, 65 insertions(+), 61 deletions(-)

diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index e60e0d324da8..e5d2b5bd78d7 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -36,8 +36,9 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include "i915_drm.h"
 
-#include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 enum pch_type pch;
 
@@ -91,6 +92,48 @@ intel_get_pci_device(void)
 	return pci_dev;
 }
 
+uint32_t
+intel_get_drm_devid(int fd)
+{
+	int ret;
+	struct drm_i915_getparam gp;
+	uint32_t devid;
+	char *override;
+
+	override = getenv("INTEL_DEVID_OVERRIDE");
+	if (override) {
+		devid = strtod(override, NULL);
+	} else {
+		gp.param = I915_PARAM_CHIPSET_ID;
+		gp.value = (int *)&devid;
+
+		ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		assert(ret == 0);
+	}
+
+	return devid;
+}
+
+int intel_gen(uint32_t devid)
+{
+	if (IS_GEN2(devid))
+		return 2;
+	if (IS_GEN3(devid))
+		return 3;
+	if (IS_GEN4(devid))
+		return 4;
+	if (IS_GEN5(devid))
+		return 5;
+	if (IS_GEN6(devid))
+		return 6;
+	if (IS_GEN7(devid))
+		return 7;
+	if (IS_GEN8(devid))
+		return 8;
+
+	return -1;
+}
+
 void
 intel_check_pch(void)
 {
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index 7ce090088b40..f50056f29171 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -28,6 +28,27 @@
 #ifndef _INTEL_CHIPSET_H
 #define _INTEL_CHIPSET_H
 
+#include <sys/types.h>
+#include <pciaccess.h>
+
+struct pci_device *intel_get_pci_device(void);
+uint32_t intel_get_drm_devid(int fd);
+int intel_gen(uint32_t devid);
+
+extern enum pch_type pch;
+enum pch_type {
+	PCH_NONE,
+	PCH_IBX,
+	PCH_CPT,
+	PCH_LPT,
+};
+
+void intel_check_pch(void);
+
+#define HAS_IBX (pch == PCH_IBX)
+#define HAS_CPT (pch == PCH_CPT)
+#define HAS_LPT (pch == PCH_LPT)
+
 #define PCI_CHIP_I810			0x7121
 #define PCI_CHIP_I810_DC100		0x7123
 #define PCI_CHIP_I810_E			0x7125
diff --git a/lib/intel_drm.c b/lib/intel_drm.c
index f16e5784c2d9..ce4dcbcad5b2 100644
--- a/lib/intel_drm.c
+++ b/lib/intel_drm.c
@@ -50,48 +50,6 @@
 #include "intel_gpu_tools.h"
 #include "i915_drm.h"
 
-uint32_t
-intel_get_drm_devid(int fd)
-{
-	int ret;
-	struct drm_i915_getparam gp;
-	uint32_t devid;
-	char *override;
-
-	override = getenv("INTEL_DEVID_OVERRIDE");
-	if (override) {
-		devid = strtod(override, NULL);
-	} else {
-		gp.param = I915_PARAM_CHIPSET_ID;
-		gp.value = (int *)&devid;
-
-		ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
-		assert(ret == 0);
-	}
-
-	return devid;
-}
-
-int intel_gen(uint32_t devid)
-{
-	if (IS_GEN2(devid))
-		return 2;
-	if (IS_GEN3(devid))
-		return 3;
-	if (IS_GEN4(devid))
-		return 4;
-	if (IS_GEN5(devid))
-		return 5;
-	if (IS_GEN6(devid))
-		return 6;
-	if (IS_GEN7(devid))
-		return 7;
-	if (IS_GEN8(devid))
-		return 8;
-
-	return -1;
-}
-
 uint64_t
 intel_get_total_ram_mb(void)
 {
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
index 1ae1bab016d7..37cbcb19bb4c 100644
--- a/lib/intel_gpu_tools.h
+++ b/lib/intel_gpu_tools.h
@@ -100,27 +100,9 @@ OUTREG(uint32_t reg, uint32_t val)
 	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
 }
 
-struct pci_device *intel_get_pci_device(void);
-
-uint32_t intel_get_drm_devid(int fd);
-int intel_gen(uint32_t devid);
 uint64_t intel_get_total_ram_mb(void);
 uint64_t intel_get_total_swap_mb(void);
 
 void intel_map_file(char *);
 
-enum pch_type {
-	PCH_NONE,
-	PCH_IBX,
-	PCH_CPT,
-	PCH_LPT,
-};
-
-extern enum pch_type pch;
-void intel_check_pch(void);
-
-#define HAS_IBX (pch == PCH_IBX)
-#define HAS_CPT (pch == PCH_CPT)
-#define HAS_LPT (pch == PCH_LPT)
-
 #endif /* INTEL_GPU_TOOLS_H */
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 03/28] lib/intel_chipset: intel_ prefix for pch global
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
  2014-03-23 14:18 ` [PATCH 01/28] lib: rename intel_pci.c to intel_chipset.c Daniel Vetter
  2014-03-23 14:18 ` [PATCH 02/28] lib: consolidate chipset helpers in intel_chipset.[hc] Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 04/28] lib/intel_chipset: api docs Daniel Vetter
                   ` (25 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Just a bit better namespacing.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_chipset.c      | 10 +++++-----
 lib/intel_chipset.h      |  8 ++++----
 tools/intel_infoframes.c |  4 ++--
 tools/intel_reg_dumper.c | 10 +++++-----
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index e5d2b5bd78d7..8c440cc9c8ba 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -40,7 +40,7 @@
 
 #include "intel_chipset.h"
 
-enum pch_type pch;
+enum pch_type intel_pch;
 
 struct pci_device *
 intel_get_pci_device(void)
@@ -148,18 +148,18 @@ intel_check_pch(void)
 
 	switch (pch_dev->device_id & 0xff00) {
 	case 0x3b00:
-		pch = PCH_IBX;
+		intel_pch = PCH_IBX;
 		break;
 	case 0x1c00:
 	case 0x1e00:
-		pch = PCH_CPT;
+		intel_pch = PCH_CPT;
 		break;
 	case 0x8c00:
 	case 0x9c00:
-		pch = PCH_LPT;
+		intel_pch = PCH_LPT;
 		break;
 	default:
-		pch = PCH_NONE;
+		intel_pch = PCH_NONE;
 		return;
 	}
 }
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index f50056f29171..24dfe9455663 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -35,7 +35,7 @@ struct pci_device *intel_get_pci_device(void);
 uint32_t intel_get_drm_devid(int fd);
 int intel_gen(uint32_t devid);
 
-extern enum pch_type pch;
+extern enum pch_type intel_pch;
 enum pch_type {
 	PCH_NONE,
 	PCH_IBX,
@@ -45,9 +45,9 @@ enum pch_type {
 
 void intel_check_pch(void);
 
-#define HAS_IBX (pch == PCH_IBX)
-#define HAS_CPT (pch == PCH_CPT)
-#define HAS_LPT (pch == PCH_LPT)
+#define HAS_IBX (intel_pch == PCH_IBX)
+#define HAS_CPT (intel_pch == PCH_CPT)
+#define HAS_LPT (intel_pch == PCH_LPT)
 
 #define PCI_CHIP_I810			0x7121
 #define PCI_CHIP_I810_DC100		0x7123
diff --git a/tools/intel_infoframes.c b/tools/intel_infoframes.c
index c60a87e6f680..81e034337277 100644
--- a/tools/intel_infoframes.c
+++ b/tools/intel_infoframes.c
@@ -367,7 +367,7 @@ static void dump_port_info(int hdmi_port_index)
 
 	if (gen == 4)
 		transcoder = (val & HDMI_PORT_TRANSCODER_GEN4) >> 30;
-	else if (pch >= PCH_CPT)
+	else if (intel_pch >= PCH_CPT)
 		transcoder = (val & HDMI_PORT_TRANSCODER_CPT) >> 29;
 	else
 		transcoder = (val & HDMI_PORT_TRANSCODER_IBX) >> 30;
@@ -1187,7 +1187,7 @@ int main(int argc, char *argv[])
 				transcoder = TRANSC_A;
 			else if (!strcmp(optarg, "B"))
 				transcoder = TRANSC_B;
-			else if (pch >= PCH_CPT && !strcmp(optarg, "C")) {
+			else if (intel_pch >= PCH_CPT && !strcmp(optarg, "C")) {
 				transcoder = TRANSC_C;
 			} else {
 				printf("Invalid transcoder.\n");
diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index 805b665c46c7..65fe41ebf610 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -2931,18 +2931,18 @@ int main(int argc, char** argv)
 		intel_map_file(file);
 		if (devid) {
 			if (IS_GEN5(devid))
-				pch = PCH_IBX;
+				intel_pch = PCH_IBX;
 			else if (IS_GEN6(devid) || IS_IVYBRIDGE(devid))
-				pch = PCH_CPT;
+				intel_pch = PCH_CPT;
 			else if (IS_HASWELL(devid))
-				pch = PCH_LPT;
+				intel_pch = PCH_LPT;
 			else
-				pch = PCH_NONE;
+				intel_pch = PCH_NONE;
 		} else {
 			printf("Dumping from file without -d argument. "
 			       "Assuming Ironlake machine.\n");
 			devid = 0x0042;
-			pch = PCH_IBX;
+			intel_pch = PCH_IBX;
 		}
 	} else {
 		pci_dev = intel_get_pci_device();
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 04/28] lib/intel_chipset: api docs
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (2 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 03/28] lib/intel_chipset: intel_ prefix for pch global Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 05/28] lib: make rendercopy.h an internal header Daniel Vetter
                   ` (24 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Unfortunately gtkdoc doesn't pick up the intel_pch enum.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_chipset.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 lib/intel_chipset.h |  5 +++++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index 8c440cc9c8ba..5ac90d1b8ed2 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -40,8 +40,32 @@
 
 #include "intel_chipset.h"
 
+/**
+ * SECTION:intel_chipset
+ * @short_description: Feature macros and chipset helpers
+ * @title: intel chipset
+ *
+ * This library mostly provides feature macros which use raw pci device ids. It
+ * also provides a few more helper functions to handle pci devices, chipset
+ * detection and related issues.
+ */
+
+/**
+ * intel_pch:
+ *
+ * Global variable to keep track of the pch type. Can either be set manually or
+ * detected at runtime with intel_check_pch().
+ */
 enum pch_type intel_pch;
 
+/**
+ * intel_get_pci_device:
+ *
+ * Looks up the main graphics pci device using libpciaccess.
+ *
+ * Returns:
+ * The pci_device, exits the program on any failures.
+ */
 struct pci_device *
 intel_get_pci_device(void)
 {
@@ -92,6 +116,16 @@ intel_get_pci_device(void)
 	return pci_dev;
 }
 
+/**
+ * intel_get_drm_devid:
+ * @fd: open i915 drm file descriptor
+ *
+ * Queries the kernel for the pci device id corresponding to the drm file
+ * descriptor.
+ *
+ * Returns:
+ * The devid, exits the program on any failures.
+ */
 uint32_t
 intel_get_drm_devid(int fd)
 {
@@ -114,6 +148,15 @@ intel_get_drm_devid(int fd)
 	return devid;
 }
 
+/**
+ * intel_gen:
+ * @devid: pci device id
+ *
+ * Computes the Intel GFX generation for the give device id.
+ *
+ * Returns:
+ * The GFX generation on successful lookup, -1 on failure.
+ */
 int intel_gen(uint32_t devid)
 {
 	if (IS_GEN2(devid))
@@ -134,6 +177,12 @@ int intel_gen(uint32_t devid)
 	return -1;
 }
 
+/**
+ * intel_check_pch:
+ *
+ * Detects the PCH chipset type of the running systems and fills in the results
+ * into the global #intel_pch varaible.
+ */
 void
 intel_check_pch(void)
 {
@@ -163,4 +212,3 @@ intel_check_pch(void)
 		return;
 	}
 }
-
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index 24dfe9455663..2f3077881dd4 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -49,6 +49,9 @@ void intel_check_pch(void);
 #define HAS_CPT (intel_pch == PCH_CPT)
 #define HAS_LPT (intel_pch == PCH_LPT)
 
+/* Exclude chipset #defines, they just add noise */
+#ifndef __GTK_DOC_IGNORE__
+
 #define PCI_CHIP_I810			0x7121
 #define PCI_CHIP_I810_DC100		0x7123
 #define PCI_CHIP_I810_E			0x7125
@@ -181,6 +184,8 @@ void intel_check_pch(void);
 #define PCI_CHIP_VALLEYVIEW_2		0x0f32
 #define PCI_CHIP_VALLEYVIEW_3		0x0f33
 
+#endif /* __GTK_DOC_IGNORE__ */
+
 #define IS_MOBILE(devid)	((devid) == PCI_CHIP_I855_GM || \
 				 (devid) == PCI_CHIP_I915_GM || \
 				 (devid) == PCI_CHIP_I945_GM || \
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 05/28] lib: make rendercopy.h an internal header
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (3 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 04/28] lib/intel_chipset: api docs Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 06/28] lib: make media_fill.h " Daniel Vetter
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

And move the public interfaces into intel_batchbuffer.[hc].

A bit messy since we are fairly inconsistent with our header #include
handling.

Also exclude rendercopy.h from the documentation.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |  1 -
 lib/intel_batchbuffer.c                            | 19 ++++++++
 lib/intel_batchbuffer.h                            | 29 ++++++++++++
 lib/media_fill.h                                   | 20 ---------
 lib/rendercopy.h                                   | 51 ----------------------
 lib/rendercopy_gen6.c                              | 20 ++++++++-
 lib/rendercopy_gen7.c                              | 20 ++++++++-
 lib/rendercopy_gen8.c                              | 20 ++++++++-
 lib/rendercopy_i830.c                              | 36 +++++++--------
 lib/rendercopy_i915.c                              | 18 ++++++++
 tests/gem_ctx_basic.c                              | 19 +++++++-
 tests/gem_render_copy.c                            | 20 ++++++++-
 tests/gem_render_linear_blits.c                    | 20 ++++++++-
 tests/gem_render_tiled_blits.c                     | 19 +++++++-
 tests/gem_reset_stats.c                            |  5 ++-
 tests/gem_ring_sync_copy.c                         |  2 +-
 tests/gem_ringfill.c                               |  2 +-
 tests/gem_seqno_wrap.c                             |  4 +-
 tests/gem_stress.c                                 | 19 +++++++-
 tests/gem_wait_render_timeout.c                    | 18 +++++++-
 tests/kms_fbc_crc.c                                |  2 +-
 tests/kms_flip.c                                   |  2 +-
 22 files changed, 255 insertions(+), 111 deletions(-)

diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index 9f8eebedd0aa..468844ec6bd1 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -25,7 +25,6 @@
     <xi:include href="xml/intel_chipset.xml"/>
     <xi:include href="xml/intel_gpu_tools.xml"/>
     <xi:include href="xml/media_fill.xml"/>
-    <xi:include href="xml/rendercopy.xml"/>
 
   </chapter>
   <index id="api-index-full">
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 195f1b29925d..df036013792d 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -37,6 +37,7 @@
 #include "intel_bufmgr.h"
 #include "intel_chipset.h"
 #include "intel_reg.h"
+#include "rendercopy.h"
 #include <i915_drm.h>
 
 /**
@@ -384,3 +385,21 @@ intel_copy_bo(struct intel_batchbuffer *batch,
 		       dst_bo, 0, 0, 4096,
 		       4096/4, size/4096, 32);
 }
+
+render_copyfunc_t get_render_copyfunc(int devid)
+{
+	render_copyfunc_t copy = NULL;
+
+	if (IS_GEN2(devid))
+		copy = gen2_render_copyfunc;
+	else if (IS_GEN3(devid))
+		copy = gen3_render_copyfunc;
+	else if (IS_GEN6(devid))
+		copy = gen6_render_copyfunc;
+	else if (IS_GEN7(devid))
+		copy = gen7_render_copyfunc;
+	else if (IS_GEN8(devid))
+		copy = gen8_render_copyfunc;
+
+	return copy;
+}
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 10088c2ecc3c..5e02269c24ca 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -2,6 +2,7 @@
 #define INTEL_BATCHBUFFER_H
 
 #include <assert.h>
+#include <stdint.h>
 #include "intel_bufmgr.h"
 
 #define BATCH_SZ 4096
@@ -195,4 +196,32 @@ void intel_copy_bo(struct intel_batchbuffer *batch,
 		   drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
 		   long int size);
 
+struct scratch_buf {
+    drm_intel_bo *bo;
+    uint32_t stride;
+    uint32_t tiling;
+    uint32_t *data;
+    uint32_t *cpu_mapping;
+    uint32_t size;
+    unsigned num_tiles;
+};
+
+static inline unsigned buf_width(struct scratch_buf *buf)
+{
+	return buf->stride/sizeof(uint32_t);
+}
+
+static inline unsigned buf_height(struct scratch_buf *buf)
+{
+	return buf->size/buf->stride;
+}
+
+typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch,
+				  drm_intel_context *context,
+				  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+				  unsigned width, unsigned height,
+				  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
+
+render_copyfunc_t get_render_copyfunc(int devid);
+
 #endif
diff --git a/lib/media_fill.h b/lib/media_fill.h
index 719eb54aa8fd..9115776a93d4 100644
--- a/lib/media_fill.h
+++ b/lib/media_fill.h
@@ -19,26 +19,6 @@
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 
-struct scratch_buf {
-    drm_intel_bo *bo;
-    uint32_t stride;
-    uint32_t tiling;
-    uint32_t *data;
-    uint32_t *cpu_mapping;
-    uint32_t size;
-    unsigned num_tiles;
-};
-
-static inline unsigned buf_width(struct scratch_buf *buf)
-{
-	return buf->stride/sizeof(uint8_t);
-}
-
-static inline unsigned buf_height(struct scratch_buf *buf)
-{
-	return buf->size/buf->stride;
-}
-
 typedef void (*media_fillfunc_t)(struct intel_batchbuffer *batch,
 				struct scratch_buf *dst,
 				unsigned x, unsigned y,
diff --git a/lib/rendercopy.h b/lib/rendercopy.h
index 6312cc327e17..92691fcf7abf 100644
--- a/lib/rendercopy.h
+++ b/lib/rendercopy.h
@@ -1,34 +1,3 @@
-#ifndef RENDERCOPY_H
-#define RENDERCOPY_H
-
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <getopt.h>
-#include "drm.h"
-#include "i915_drm.h"
-#include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
-
-struct scratch_buf {
-    drm_intel_bo *bo;
-    uint32_t stride;
-    uint32_t tiling;
-    uint32_t *data;
-    uint32_t *cpu_mapping;
-    uint32_t size;
-    unsigned num_tiles;
-};
-
 static inline void emit_vertex_2s(struct intel_batchbuffer *batch,
 				  int16_t x, int16_t y)
 {
@@ -51,24 +20,6 @@ static inline void emit_vertex_normalized(struct intel_batchbuffer *batch,
 	OUT_BATCH(u.ui);
 }
 
-static inline unsigned buf_width(struct scratch_buf *buf)
-{
-	return buf->stride/sizeof(uint32_t);
-}
-
-static inline unsigned buf_height(struct scratch_buf *buf)
-{
-	return buf->size/buf->stride;
-}
-
-typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch,
-				  drm_intel_context *context,
-				  struct scratch_buf *src, unsigned src_x, unsigned src_y,
-				  unsigned width, unsigned height,
-				  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
-
-render_copyfunc_t get_render_copyfunc(int devid);
-
 void gen8_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
 			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
@@ -94,5 +45,3 @@ void gen2_render_copyfunc(struct intel_batchbuffer *batch,
 			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
 			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
-
-#endif /* RENDERCOPY_H */
diff --git a/lib/rendercopy_gen6.c b/lib/rendercopy_gen6.c
index 457cb354932e..092a312b6c2e 100644
--- a/lib/rendercopy_gen6.c
+++ b/lib/rendercopy_gen6.c
@@ -1,8 +1,24 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen6_render.h"
 
-#include <assert.h>
-
 #define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
 #define VERTEX_SIZE (3*4)
 
diff --git a/lib/rendercopy_gen7.c b/lib/rendercopy_gen7.c
index f6981c7db1fa..04bc69062916 100644
--- a/lib/rendercopy_gen7.c
+++ b/lib/rendercopy_gen7.c
@@ -1,8 +1,24 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen7_render.h"
 
-#include <assert.h>
-
 #define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
 
 static const uint32_t ps_kernel[][4] = {
diff --git a/lib/rendercopy_gen8.c b/lib/rendercopy_gen8.c
index 45a134c37dc9..09d9fe4eb172 100644
--- a/lib/rendercopy_gen8.c
+++ b/lib/rendercopy_gen8.c
@@ -1,8 +1,24 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen8_render.h"
 
-#include <assert.h>
-
 #include <intel_aub.h>
 
 #define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
diff --git a/lib/rendercopy_i830.c b/lib/rendercopy_i830.c
index 73edcfa5974e..cb9088e2030f 100644
--- a/lib/rendercopy_i830.c
+++ b/lib/rendercopy_i830.c
@@ -1,3 +1,21 @@
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
+
 #include "i830_reg.h"
 #include "rendercopy.h"
 
@@ -228,21 +246,3 @@ void gen2_render_copyfunc(struct intel_batchbuffer *batch,
 
 	intel_batchbuffer_flush(batch);
 }
-
-render_copyfunc_t get_render_copyfunc(int devid)
-{
-	render_copyfunc_t copy = NULL;
-
-	if (IS_GEN2(devid))
-		copy = gen2_render_copyfunc;
-	else if (IS_GEN3(devid))
-		copy = gen3_render_copyfunc;
-	else if (IS_GEN6(devid))
-		copy = gen6_render_copyfunc;
-	else if (IS_GEN7(devid))
-		copy = gen7_render_copyfunc;
-	else if (IS_GEN8(devid))
-		copy = gen8_render_copyfunc;
-
-	return copy;
-}
diff --git a/lib/rendercopy_i915.c b/lib/rendercopy_i915.c
index 33e027e0f670..f7de2662b22b 100644
--- a/lib/rendercopy_i915.c
+++ b/lib/rendercopy_i915.c
@@ -1,3 +1,21 @@
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
+
 #include "i915_reg.h"
 #include "i915_3d.h"
 #include "rendercopy.h"
diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c
index e1eeaa1664b4..345425119f21 100644
--- a/tests/gem_ctx_basic.c
+++ b/tests/gem_ctx_basic.c
@@ -30,7 +30,24 @@
  */
 
 #include <pthread.h>
-#include "rendercopy.h"
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
 
 /* options */
 int num_contexts = 10;
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index 5e2433c9a722..65323a940c4e 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -32,8 +32,24 @@
 #include <stdbool.h>
 #include <unistd.h>
 #include <cairo.h>
-
-#include "rendercopy.h"
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.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 5ba7c98fcb6b..5efcc210d4ef 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -37,8 +37,24 @@
 #include "config.h"
 #endif
 
-#include "rendercopy.h"
-
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.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 9b6e92041530..71dfdd64fcee 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -33,7 +33,24 @@
  * The goal is to simply ensure the basics work.
  */
 
-#include "rendercopy.h"
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
 
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 3719f4070403..8ac93a898243 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -26,6 +26,7 @@
  */
 
 #define _GNU_SOURCE
+#include <stdbool.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -40,11 +41,11 @@
 #include <signal.h>
 
 #include "i915_drm.h"
+#include "drmtest.h"
+#include "igt_debugfs.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
-#include "rendercopy.h"
-#include "igt_debugfs.h"
 
 #define RS_NO_ERROR      0
 #define RS_BATCH_ACTIVE  (1 << 0)
diff --git a/tests/gem_ring_sync_copy.c b/tests/gem_ring_sync_copy.c
index 2cd78a32d8c2..b7dcf9dfdd4c 100644
--- a/tests/gem_ring_sync_copy.c
+++ b/tests/gem_ring_sync_copy.c
@@ -52,7 +52,7 @@
 
 #include "i915_drm.h"
 #include "drmtest.h"
-#include "rendercopy.h"
+#include "intel_batchbuffer.h"
 
 #define WIDTH	512
 #define HEIGHT	512
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index 31a21cbbc042..8e0ca91b98aa 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -43,10 +43,10 @@
 
 #include "drm.h"
 #include "i915_drm.h"
+#include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
-#include "rendercopy.h"
 
 struct bo {
 	const char *ring;
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index 79562693d250..cc133a9acc9b 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -39,13 +39,15 @@
 #include <sys/wait.h>
 #include <limits.h>
 #include <wordexp.h>
+#include <getopt.h>
 #include <signal.h>
 
 #include "i915_drm.h"
+#include "drmtest.h"
+#include "igt_core.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
-#include "rendercopy.h"
 
 static int devid;
 static int card_index = 0;
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index c01e92eb004e..527f7de823a3 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -49,7 +49,24 @@
  * In short: designed for maximum evilness.
  */
 
-#include "rendercopy.h"
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
 
 #define CMD_POLY_STIPPLE_OFFSET       0x7906
 
diff --git a/tests/gem_wait_render_timeout.c b/tests/gem_wait_render_timeout.c
index e16d623828ce..1c6aa7d1da18 100644
--- a/tests/gem_wait_render_timeout.c
+++ b/tests/gem_wait_render_timeout.c
@@ -27,8 +27,24 @@
 
 #include <stdio.h>
 #include <time.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
 #include "drm.h"
-#include "rendercopy.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
 
 #define MSEC_PER_SEC	1000L
 #define USEC_PER_MSEC	1000L
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index 2f1b90d28e18..bb06bc491812 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -32,7 +32,7 @@
 #include "drmtest.h"
 #include "igt_debugfs.h"
 #include "igt_kms.h"
-#include "rendercopy.h"
+#include "intel_batchbuffer.h"
 
 enum test_mode {
 	TEST_PAGE_FLIP,
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 09dc20bdc777..5ef5afa2c211 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -39,7 +39,7 @@
 #include "i915_drm.h"
 #include "drmtest.h"
 #include "testdisplay.h"
-#include "rendercopy.h"
+#include "intel_batchbuffer.h"
 #include "igt_kms.h"
 
 #define TEST_DPMS		(1 << 0)
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 06/28] lib: make media_fill.h an internal header
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (4 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 05/28] lib: make rendercopy.h an internal header Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 07/28] lib/intel_batchbuffer: un-inline buf_height/width Daniel Vetter
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Same deal as with rendercopy.h.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 .../intel-gpu-tools/intel-gpu-tools-docs.xml         |  1 -
 lib/Makefile.sources                                 |  1 -
 lib/intel_batchbuffer.c                              | 13 +++++++++++++
 lib/intel_batchbuffer.h                              |  8 ++++++++
 lib/media_fill.c                                     | 14 --------------
 lib/media_fill.h                                     |  8 --------
 tests/gem_media_fill.c                               | 20 ++++++++++++++++++--
 7 files changed, 39 insertions(+), 26 deletions(-)
 delete mode 100644 lib/media_fill.c

diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index 468844ec6bd1..0f117f71c9f9 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -24,7 +24,6 @@
     <xi:include href="xml/intel_batchbuffer.xml"/>
     <xi:include href="xml/intel_chipset.xml"/>
     <xi:include href="xml/intel_gpu_tools.xml"/>
-    <xi:include href="xml/media_fill.xml"/>
 
   </chapter>
   <index id="api-index-full">
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 2b700c6c2726..e6ada3c900b4 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -22,7 +22,6 @@ libintel_tools_la_SOURCES = 	\
 	intel_reg.h		\
 	ioctl_wrappers.c	\
 	ioctl_wrappers.h	\
-	media_fill.c            \
 	media_fill.h            \
 	media_fill_gen7.c       \
 	media_fill_gen8.c       \
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index df036013792d..29740bd93bd3 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -38,6 +38,7 @@
 #include "intel_chipset.h"
 #include "intel_reg.h"
 #include "rendercopy.h"
+#include "media_fill.h"
 #include <i915_drm.h>
 
 /**
@@ -403,3 +404,15 @@ render_copyfunc_t get_render_copyfunc(int devid)
 
 	return copy;
 }
+
+media_fillfunc_t get_media_fillfunc(int devid)
+{
+	media_fillfunc_t fill = NULL;
+
+	if (IS_GEN8(devid))
+		fill = gen8_media_fillfunc;
+	else if (IS_GEN7(devid))
+		fill = gen7_media_fillfunc;
+
+	return fill;
+}
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 5e02269c24ca..4b183122f6c0 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -224,4 +224,12 @@ typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch,
 
 render_copyfunc_t get_render_copyfunc(int devid);
 
+typedef void (*media_fillfunc_t)(struct intel_batchbuffer *batch,
+				struct scratch_buf *dst,
+				unsigned x, unsigned y,
+				unsigned width, unsigned height,
+				uint8_t color);
+
+media_fillfunc_t get_media_fillfunc(int devid);
+
 #endif
diff --git a/lib/media_fill.c b/lib/media_fill.c
deleted file mode 100644
index 084237f7a982..000000000000
--- a/lib/media_fill.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "i830_reg.h"
-#include "media_fill.h"
-
-media_fillfunc_t get_media_fillfunc(int devid)
-{
-	media_fillfunc_t fill = NULL;
-
-	if (IS_GEN8(devid))
-		fill = gen8_media_fillfunc;
-	else if (IS_GEN7(devid))
-		fill = gen7_media_fillfunc;
-
-	return fill;
-}
diff --git a/lib/media_fill.h b/lib/media_fill.h
index 9115776a93d4..4b2fd3a4fb30 100644
--- a/lib/media_fill.h
+++ b/lib/media_fill.h
@@ -19,14 +19,6 @@
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 
-typedef void (*media_fillfunc_t)(struct intel_batchbuffer *batch,
-				struct scratch_buf *dst,
-				unsigned x, unsigned y,
-				unsigned width, unsigned height,
-				uint8_t color);
-
-media_fillfunc_t get_media_fillfunc(int devid);
-
 void
 gen8_media_fillfunc(struct intel_batchbuffer *batch,
 		struct scratch_buf *dst,
diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c
index 1c3fe609f5e2..df891290c11c 100644
--- a/tests/gem_media_fill.c
+++ b/tests/gem_media_fill.c
@@ -32,8 +32,24 @@
 
 #include <stdbool.h>
 #include <unistd.h>
-
-#include "media_fill.h"
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
 
 #define WIDTH 64
 #define STRIDE (WIDTH)
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 07/28] lib/intel_batchbuffer: un-inline buf_height/width
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (5 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 06/28] lib: make media_fill.h " Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 08/28] lib/intel_batchbuffer: igt_ namespace for the buffer structure Daniel Vetter
                   ` (21 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

gtkdoc won't pick them up otherwise.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_batchbuffer.c | 10 ++++++++++
 lib/intel_batchbuffer.h | 11 ++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 29740bd93bd3..235c1d1d8310 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -387,6 +387,16 @@ intel_copy_bo(struct intel_batchbuffer *batch,
 		       4096/4, size/4096, 32);
 }
 
+unsigned buf_width(struct scratch_buf *buf)
+{
+	return buf->stride/sizeof(uint32_t);
+}
+
+unsigned buf_height(struct scratch_buf *buf)
+{
+	return buf->size/buf->stride;
+}
+
 render_copyfunc_t get_render_copyfunc(int devid)
 {
 	render_copyfunc_t copy = NULL;
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 4b183122f6c0..26c5e6c34c89 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -206,15 +206,8 @@ struct scratch_buf {
     unsigned num_tiles;
 };
 
-static inline unsigned buf_width(struct scratch_buf *buf)
-{
-	return buf->stride/sizeof(uint32_t);
-}
-
-static inline unsigned buf_height(struct scratch_buf *buf)
-{
-	return buf->size/buf->stride;
-}
+unsigned buf_width(struct scratch_buf *buf);
+unsigned buf_height(struct scratch_buf *buf);
 
 typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch,
 				  drm_intel_context *context,
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 08/28] lib/intel_batchbuffer: igt_ namespace for the buffer structure
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (6 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 07/28] lib/intel_batchbuffer: un-inline buf_height/width Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 09/28] lib/intel_batchbuffer: igt_ prefix for rendercopy/mediafill funcs Daniel Vetter
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Step one to properly namespace the rendercpy/mediafill functions. Als
give the buf_height/width helpers a proper igt_ prefix.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_batchbuffer.c         |  4 +--
 lib/intel_batchbuffer.h         | 12 ++++----
 lib/media_fill.h                |  4 +--
 lib/media_fill_gen7.c           | 12 ++++----
 lib/media_fill_gen8.c           | 12 ++++----
 lib/rendercopy.h                | 20 ++++++-------
 lib/rendercopy_gen6.c           | 30 +++++++++----------
 lib/rendercopy_gen7.c           | 22 +++++++-------
 lib/rendercopy_gen8.c           | 32 ++++++++++-----------
 lib/rendercopy_i830.c           | 28 +++++++++---------
 lib/rendercopy_i915.c           | 12 ++++----
 tests/gem_ctx_basic.c           |  4 +--
 tests/gem_media_fill.c          |  6 ++--
 tests/gem_render_copy.c         | 12 ++++----
 tests/gem_render_linear_blits.c |  6 ++--
 tests/gem_render_tiled_blits.c  |  2 +-
 tests/gem_ring_sync_copy.c      | 12 ++++----
 tests/gem_ringfill.c            |  6 ++--
 tests/gem_seqno_wrap.c          |  8 +++---
 tests/gem_stress.c              | 64 ++++++++++++++++++++---------------------
 tests/kms_fbc_crc.c             |  4 +--
 tests/kms_flip.c                |  4 +--
 22 files changed, 158 insertions(+), 158 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 235c1d1d8310..0da0043c0f50 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -387,12 +387,12 @@ intel_copy_bo(struct intel_batchbuffer *batch,
 		       4096/4, size/4096, 32);
 }
 
-unsigned buf_width(struct scratch_buf *buf)
+unsigned igt_buf_width(struct igt_buf *buf)
 {
 	return buf->stride/sizeof(uint32_t);
 }
 
-unsigned buf_height(struct scratch_buf *buf)
+unsigned igt_buf_height(struct igt_buf *buf)
 {
 	return buf->size/buf->stride;
 }
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 26c5e6c34c89..333b08946789 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -196,7 +196,7 @@ void intel_copy_bo(struct intel_batchbuffer *batch,
 		   drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
 		   long int size);
 
-struct scratch_buf {
+struct igt_buf {
     drm_intel_bo *bo;
     uint32_t stride;
     uint32_t tiling;
@@ -206,19 +206,19 @@ struct scratch_buf {
     unsigned num_tiles;
 };
 
-unsigned buf_width(struct scratch_buf *buf);
-unsigned buf_height(struct scratch_buf *buf);
+unsigned igt_buf_width(struct igt_buf *buf);
+unsigned igt_buf_height(struct igt_buf *buf);
 
 typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch,
 				  drm_intel_context *context,
-				  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+				  struct igt_buf *src, unsigned src_x, unsigned src_y,
 				  unsigned width, unsigned height,
-				  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
+				  struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
 
 render_copyfunc_t get_render_copyfunc(int devid);
 
 typedef void (*media_fillfunc_t)(struct intel_batchbuffer *batch,
-				struct scratch_buf *dst,
+				struct igt_buf *dst,
 				unsigned x, unsigned y,
 				unsigned width, unsigned height,
 				uint8_t color);
diff --git a/lib/media_fill.h b/lib/media_fill.h
index 4b2fd3a4fb30..2e1af325cac6 100644
--- a/lib/media_fill.h
+++ b/lib/media_fill.h
@@ -21,14 +21,14 @@
 
 void
 gen8_media_fillfunc(struct intel_batchbuffer *batch,
-		struct scratch_buf *dst,
+		struct igt_buf *dst,
 		unsigned x, unsigned y,
 		unsigned width, unsigned height,
 		uint8_t color);
 
 void
 gen7_media_fillfunc(struct intel_batchbuffer *batch,
-                struct scratch_buf *dst,
+                struct igt_buf *dst,
                 unsigned x, unsigned y,
                 unsigned width, unsigned height,
                 uint8_t color);
diff --git a/lib/media_fill_gen7.c b/lib/media_fill_gen7.c
index 8f43de7a2ec7..520c4a22ca75 100644
--- a/lib/media_fill_gen7.c
+++ b/lib/media_fill_gen7.c
@@ -82,7 +82,7 @@ gen7_fill_curbe_buffer_data(struct intel_batchbuffer *batch,
 
 static uint32_t
 gen7_fill_surface_state(struct intel_batchbuffer *batch,
-			struct scratch_buf *buf,
+			struct igt_buf *buf,
 			uint32_t format,
 			int is_dst)
 {
@@ -116,8 +116,8 @@ gen7_fill_surface_state(struct intel_batchbuffer *batch,
 				read_domain, write_domain);
 	assert(ret == 0);
 
-	ss->ss2.height = buf_height(buf) - 1;
-	ss->ss2.width  = buf_width(buf) - 1;
+	ss->ss2.height = igt_buf_height(buf) - 1;
+	ss->ss2.width  = igt_buf_width(buf) - 1;
 
 	ss->ss3.pitch  = buf->stride - 1;
 
@@ -131,7 +131,7 @@ gen7_fill_surface_state(struct intel_batchbuffer *batch,
 
 static uint32_t
 gen7_fill_binding_table(struct intel_batchbuffer *batch,
-			struct scratch_buf *dst)
+			struct igt_buf *dst)
 {
 	uint32_t *binding_table, offset;
 
@@ -156,7 +156,7 @@ gen7_fill_media_kernel(struct intel_batchbuffer *batch,
 }
 
 static uint32_t
-gen7_fill_interface_descriptor(struct intel_batchbuffer *batch, struct scratch_buf *dst)
+gen7_fill_interface_descriptor(struct intel_batchbuffer *batch, struct igt_buf *dst)
 {
 	struct gen7_interface_descriptor_data *idd;
 	uint32_t offset;
@@ -311,7 +311,7 @@ gen7_emit_media_objects(struct intel_batchbuffer *batch,
 
 void
 gen7_media_fillfunc(struct intel_batchbuffer *batch,
-		struct scratch_buf *dst,
+		struct igt_buf *dst,
 		unsigned x, unsigned y,
 		unsigned width, unsigned height,
 		uint8_t color)
diff --git a/lib/media_fill_gen8.c b/lib/media_fill_gen8.c
index 1af3b3d658fb..7e0a5677762b 100644
--- a/lib/media_fill_gen8.c
+++ b/lib/media_fill_gen8.c
@@ -82,7 +82,7 @@ gen8_fill_curbe_buffer_data(struct intel_batchbuffer *batch,
 
 static uint32_t
 gen8_fill_surface_state(struct intel_batchbuffer *batch,
-			struct scratch_buf *buf,
+			struct igt_buf *buf,
 			uint32_t format,
 			int is_dst)
 {
@@ -119,8 +119,8 @@ gen8_fill_surface_state(struct intel_batchbuffer *batch,
 				read_domain, write_domain);
 	assert(ret == 0);
 
-	ss->ss2.height = buf_height(buf) - 1;
-	ss->ss2.width  = buf_width(buf) - 1;
+	ss->ss2.height = igt_buf_height(buf) - 1;
+	ss->ss2.width  = igt_buf_width(buf) - 1;
 	ss->ss3.pitch  = buf->stride - 1;
 
 	ss->ss7.shader_chanel_select_r = 4;
@@ -133,7 +133,7 @@ gen8_fill_surface_state(struct intel_batchbuffer *batch,
 
 static uint32_t
 gen8_fill_binding_table(struct intel_batchbuffer *batch,
-			struct scratch_buf *dst)
+			struct igt_buf *dst)
 {
 	uint32_t *binding_table, offset;
 
@@ -158,7 +158,7 @@ gen8_fill_media_kernel(struct intel_batchbuffer *batch,
 }
 
 static uint32_t
-gen8_fill_interface_descriptor(struct intel_batchbuffer *batch, struct scratch_buf *dst)
+gen8_fill_interface_descriptor(struct intel_batchbuffer *batch, struct igt_buf *dst)
 {
 	struct gen8_interface_descriptor_data *idd;
 	uint32_t offset;
@@ -334,7 +334,7 @@ gen8_emit_media_objects(struct intel_batchbuffer *batch,
 
 void
 gen8_media_fillfunc(struct intel_batchbuffer *batch,
-		struct scratch_buf *dst,
+		struct igt_buf *dst,
 		unsigned x, unsigned y,
 		unsigned width, unsigned height,
 		uint8_t color)
diff --git a/lib/rendercopy.h b/lib/rendercopy.h
index 92691fcf7abf..bb9051e7e976 100644
--- a/lib/rendercopy.h
+++ b/lib/rendercopy.h
@@ -22,26 +22,26 @@ static inline void emit_vertex_normalized(struct intel_batchbuffer *batch,
 
 void gen8_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
 void gen7_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
 void gen6_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
 void gen3_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
 void gen2_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
diff --git a/lib/rendercopy_gen6.c b/lib/rendercopy_gen6.c
index 092a312b6c2e..4f5b57904d4a 100644
--- a/lib/rendercopy_gen6.c
+++ b/lib/rendercopy_gen6.c
@@ -107,7 +107,7 @@ gen6_render_flush(struct intel_batchbuffer *batch,
 }
 
 static uint32_t
-gen6_bind_buf(struct intel_batchbuffer *batch, struct scratch_buf *buf,
+gen6_bind_buf(struct intel_batchbuffer *batch, struct igt_buf *buf,
 	      uint32_t format, int is_dst)
 {
 	struct gen6_surface_state *ss;
@@ -135,8 +135,8 @@ gen6_bind_buf(struct intel_batchbuffer *batch, struct scratch_buf *buf,
 				      read_domain, write_domain);
 	assert(ret == 0);
 
-	ss->ss2.height = buf_height(buf) - 1;
-	ss->ss2.width  = buf_width(buf) - 1;
+	ss->ss2.height = igt_buf_height(buf) - 1;
+	ss->ss2.width  = igt_buf_width(buf) - 1;
 	ss->ss3.pitch  = buf->stride - 1;
 	ss->ss3.tiled_surface = buf->tiling != I915_TILING_NONE;
 	ss->ss3.tile_walk     = buf->tiling == I915_TILING_Y;
@@ -146,8 +146,8 @@ gen6_bind_buf(struct intel_batchbuffer *batch, struct scratch_buf *buf,
 
 static uint32_t
 gen6_bind_surfaces(struct intel_batchbuffer *batch,
-		   struct scratch_buf *src,
-		   struct scratch_buf *dst)
+		   struct igt_buf *src,
+		   struct igt_buf *dst)
 {
 	uint32_t *binding_table;
 
@@ -376,11 +376,11 @@ gen6_emit_binding_table(struct intel_batchbuffer *batch, uint32_t wm_table)
 }
 
 static void
-gen6_emit_drawing_rectangle(struct intel_batchbuffer *batch, struct scratch_buf *dst)
+gen6_emit_drawing_rectangle(struct intel_batchbuffer *batch, struct igt_buf *dst)
 {
 	OUT_BATCH(GEN6_3DSTATE_DRAWING_RECTANGLE | (4 - 2));
 	OUT_BATCH(0);
-	OUT_BATCH((buf_height(dst) - 1) << 16 | (buf_width(dst) - 1));
+	OUT_BATCH((igt_buf_height(dst) - 1) << 16 | (igt_buf_width(dst) - 1));
 	OUT_BATCH(0);
 }
 
@@ -547,9 +547,9 @@ static uint32_t gen6_emit_primitive(struct intel_batchbuffer *batch)
 
 void gen6_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
 {
 	uint32_t wm_state, wm_kernel, wm_table;
 	uint32_t cc_vp, cc_blend, offset;
@@ -601,16 +601,16 @@ void gen6_render_copyfunc(struct intel_batchbuffer *batch,
 		batch_round_upto(batch, VERTEX_SIZE)/VERTEX_SIZE;
 
 	emit_vertex_2s(batch, dst_x + width, dst_y + height);
-	emit_vertex_normalized(batch, src_x + width, buf_width(src));
-	emit_vertex_normalized(batch, src_y + height, buf_height(src));
+	emit_vertex_normalized(batch, src_x + width, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y + height, igt_buf_height(src));
 
 	emit_vertex_2s(batch, dst_x, dst_y + height);
-	emit_vertex_normalized(batch, src_x, buf_width(src));
-	emit_vertex_normalized(batch, src_y + height, buf_height(src));
+	emit_vertex_normalized(batch, src_x, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y + height, igt_buf_height(src));
 
 	emit_vertex_2s(batch, dst_x, dst_y);
-	emit_vertex_normalized(batch, src_x, buf_width(src));
-	emit_vertex_normalized(batch, src_y, buf_height(src));
+	emit_vertex_normalized(batch, src_x, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y, igt_buf_height(src));
 
 	gen6_render_flush(batch, context, batch_end);
 	intel_batchbuffer_reset(batch);
diff --git a/lib/rendercopy_gen7.c b/lib/rendercopy_gen7.c
index 04bc69062916..ddd6b97c7619 100644
--- a/lib/rendercopy_gen7.c
+++ b/lib/rendercopy_gen7.c
@@ -93,7 +93,7 @@ gen7_tiling_bits(uint32_t tiling)
 
 static uint32_t
 gen7_bind_buf(struct intel_batchbuffer *batch,
-	      struct scratch_buf *buf,
+	      struct igt_buf *buf,
 	      uint32_t format,
 	      int is_dst)
 {
@@ -114,8 +114,8 @@ gen7_bind_buf(struct intel_batchbuffer *batch,
 		 gen7_tiling_bits(buf->tiling) |
 		format << GEN7_SURFACE_FORMAT_SHIFT);
 	ss[1] = buf->bo->offset;
-	ss[2] = ((buf_width(buf) - 1)  << GEN7_SURFACE_WIDTH_SHIFT |
-		 (buf_height(buf) - 1) << GEN7_SURFACE_HEIGHT_SHIFT);
+	ss[2] = ((igt_buf_width(buf) - 1)  << GEN7_SURFACE_WIDTH_SHIFT |
+		 (igt_buf_height(buf) - 1) << GEN7_SURFACE_HEIGHT_SHIFT);
 	ss[3] = (buf->stride - 1) << GEN7_SURFACE_PITCH_SHIFT;
 	ss[4] = 0;
 	ss[5] = 0;
@@ -220,8 +220,8 @@ static void gen7_emit_vertex_buffer(struct intel_batchbuffer *batch,
 
 static uint32_t
 gen7_bind_surfaces(struct intel_batchbuffer *batch,
-		   struct scratch_buf *src,
-		   struct scratch_buf *dst)
+		   struct igt_buf *src,
+		   struct igt_buf *dst)
 {
 	uint32_t *binding_table;
 
@@ -237,19 +237,19 @@ gen7_bind_surfaces(struct intel_batchbuffer *batch,
 
 static void
 gen7_emit_binding_table(struct intel_batchbuffer *batch,
-			struct scratch_buf *src,
-			struct scratch_buf *dst)
+			struct igt_buf *src,
+			struct igt_buf *dst)
 {
 	OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS | (2 - 2));
 	OUT_BATCH(gen7_bind_surfaces(batch, src, dst));
 }
 
 static void
-gen7_emit_drawing_rectangle(struct intel_batchbuffer *batch, struct scratch_buf *dst)
+gen7_emit_drawing_rectangle(struct intel_batchbuffer *batch, struct igt_buf *dst)
 {
 	OUT_BATCH(GEN7_3DSTATE_DRAWING_RECTANGLE | (4 - 2));
 	OUT_BATCH(0);
-	OUT_BATCH((buf_height(dst) - 1) << 16 | (buf_width(dst) - 1));
+	OUT_BATCH((igt_buf_height(dst) - 1) << 16 | (igt_buf_width(dst) - 1));
 	OUT_BATCH(0);
 }
 
@@ -531,9 +531,9 @@ gen7_emit_null_depth_buffer(struct intel_batchbuffer *batch)
 #define BATCH_STATE_SPLIT 2048
 void gen7_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
 {
 	uint32_t batch_end;
 
diff --git a/lib/rendercopy_gen8.c b/lib/rendercopy_gen8.c
index 09d9fe4eb172..f6dd2b5b0445 100644
--- a/lib/rendercopy_gen8.c
+++ b/lib/rendercopy_gen8.c
@@ -177,7 +177,7 @@ gen6_render_flush(struct intel_batchbuffer *batch,
 
 /* Mostly copy+paste from gen6, except height, width, pitch moved */
 static uint32_t
-gen8_bind_buf(struct intel_batchbuffer *batch, struct scratch_buf *buf,
+gen8_bind_buf(struct intel_batchbuffer *batch, struct igt_buf *buf,
 	      uint32_t format, int is_dst) {
 	struct gen8_surface_state *ss;
 	uint32_t write_domain, read_domain, offset;
@@ -213,8 +213,8 @@ gen8_bind_buf(struct intel_batchbuffer *batch, struct scratch_buf *buf,
 				      read_domain, write_domain);
 	assert(ret == 0);
 
-	ss->ss2.height = buf_height(buf) - 1;
-	ss->ss2.width  = buf_width(buf) - 1;
+	ss->ss2.height = igt_buf_height(buf) - 1;
+	ss->ss2.width  = igt_buf_width(buf) - 1;
 	ss->ss3.pitch  = buf->stride - 1;
 
 	ss->ss7.shader_chanel_select_r = 4;
@@ -227,8 +227,8 @@ gen8_bind_buf(struct intel_batchbuffer *batch, struct scratch_buf *buf,
 
 static uint32_t
 gen8_bind_surfaces(struct intel_batchbuffer *batch,
-		   struct scratch_buf *src,
-		   struct scratch_buf *dst)
+		   struct igt_buf *src,
+		   struct igt_buf *dst)
 {
 	uint32_t *binding_table, offset;
 
@@ -295,7 +295,7 @@ gen8_fill_ps(struct intel_batchbuffer *batch,
  */
 static uint32_t
 gen7_fill_vertex_buffer_data(struct intel_batchbuffer *batch,
-			     struct scratch_buf *src,
+			     struct igt_buf *src,
 			     uint32_t src_x, uint32_t src_y,
 			     uint32_t dst_x, uint32_t dst_y,
 			     uint32_t width, uint32_t height)
@@ -307,16 +307,16 @@ gen7_fill_vertex_buffer_data(struct intel_batchbuffer *batch,
 	start = batch->ptr;
 
 	emit_vertex_2s(batch, dst_x + width, dst_y + height);
-	emit_vertex_normalized(batch, src_x + width, buf_width(src));
-	emit_vertex_normalized(batch, src_y + height, buf_height(src));
+	emit_vertex_normalized(batch, src_x + width, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y + height, igt_buf_height(src));
 
 	emit_vertex_2s(batch, dst_x, dst_y + height);
-	emit_vertex_normalized(batch, src_x, buf_width(src));
-	emit_vertex_normalized(batch, src_y + height, buf_height(src));
+	emit_vertex_normalized(batch, src_x, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y + height, igt_buf_height(src));
 
 	emit_vertex_2s(batch, dst_x, dst_y);
-	emit_vertex_normalized(batch, src_x, buf_width(src));
-	emit_vertex_normalized(batch, src_y, buf_height(src));
+	emit_vertex_normalized(batch, src_x, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y, igt_buf_height(src));
 
 	offset = batch_offset(batch, start);
 	annotation_add_state(&aub_annotations, AUB_TRACE_VERTEX_BUFFER,
@@ -843,11 +843,11 @@ gen7_emit_clear(struct intel_batchbuffer *batch) {
 }
 
 static void
-gen6_emit_drawing_rectangle(struct intel_batchbuffer *batch, struct scratch_buf *dst)
+gen6_emit_drawing_rectangle(struct intel_batchbuffer *batch, struct igt_buf *dst)
 {
 	OUT_BATCH(GEN6_3DSTATE_DRAWING_RECTANGLE | (4 - 2));
 	OUT_BATCH(0);
-	OUT_BATCH((buf_height(dst) - 1) << 16 | (buf_width(dst) - 1));
+	OUT_BATCH((igt_buf_height(dst) - 1) << 16 | (igt_buf_width(dst) - 1));
 	OUT_BATCH(0);
 }
 
@@ -907,9 +907,9 @@ static void gen8_emit_primitive(struct intel_batchbuffer *batch, uint32_t offset
 
 void gen8_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
 {
 	uint32_t ps_sampler_state, ps_kernel_off, ps_binding_table;
 	uint32_t scissor_state;
diff --git a/lib/rendercopy_i830.c b/lib/rendercopy_i830.c
index cb9088e2030f..5ebd31a4677a 100644
--- a/lib/rendercopy_i830.c
+++ b/lib/rendercopy_i830.c
@@ -134,7 +134,7 @@ static void gen2_emit_invariant(struct intel_batchbuffer *batch)
 }
 
 static void gen2_emit_target(struct intel_batchbuffer *batch,
-			     struct scratch_buf *dst)
+			     struct igt_buf *dst)
 {
 	uint32_t tiling;
 
@@ -156,13 +156,13 @@ static void gen2_emit_target(struct intel_batchbuffer *batch,
 	OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);
 	OUT_BATCH(0);
 	OUT_BATCH(0);		/* ymin, xmin */
-	OUT_BATCH(DRAW_YMAX(buf_height(dst) - 1) |
-		  DRAW_XMAX(buf_width(dst) - 1));
+	OUT_BATCH(DRAW_YMAX(igt_buf_height(dst) - 1) |
+		  DRAW_XMAX(igt_buf_width(dst) - 1));
 	OUT_BATCH(0);		/* yorig, xorig */
 }
 
 static void gen2_emit_texture(struct intel_batchbuffer *batch,
-			      struct scratch_buf *src,
+			      struct igt_buf *src,
 			      int unit)
 {
 	uint32_t tiling;
@@ -175,8 +175,8 @@ static void gen2_emit_texture(struct intel_batchbuffer *batch,
 
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_MAP(unit) | 4);
 	OUT_RELOC(src->bo, I915_GEM_DOMAIN_SAMPLER, 0, 0);
-	OUT_BATCH((buf_height(src) - 1) << TM0S1_HEIGHT_SHIFT |
-		  (buf_width(src) - 1) << TM0S1_WIDTH_SHIFT |
+	OUT_BATCH((igt_buf_height(src) - 1) << TM0S1_HEIGHT_SHIFT |
+		  (igt_buf_width(src) - 1) << TM0S1_WIDTH_SHIFT |
 		  MAPSURF_32BIT | MT_32BIT_ARGB8888 | tiling);
 	OUT_BATCH((src->stride / 4 - 1) << TM0S2_PITCH_SHIFT | TM0S2_MAP_2D);
 	OUT_BATCH(FILTER_NEAREST << TM0S3_MAG_FILTER_SHIFT |
@@ -210,9 +210,9 @@ static void gen2_emit_copy_pipeline(struct intel_batchbuffer *batch)
 
 void gen2_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
 {
 	gen2_emit_invariant(batch);
 	gen2_emit_copy_pipeline(batch);
@@ -231,18 +231,18 @@ void gen2_render_copyfunc(struct intel_batchbuffer *batch,
 	OUT_BATCH(PRIM3D_INLINE | PRIM3D_RECTLIST | (3*4 -1));
 	emit_vertex(batch, dst_x + width);
 	emit_vertex(batch, dst_y + height);
-	emit_vertex_normalized(batch, src_x + width, buf_width(src));
-	emit_vertex_normalized(batch, src_y + height, buf_height(src));
+	emit_vertex_normalized(batch, src_x + width, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y + height, igt_buf_height(src));
 
 	emit_vertex(batch, dst_x);
 	emit_vertex(batch, dst_y + height);
-	emit_vertex_normalized(batch, src_x, buf_width(src));
-	emit_vertex_normalized(batch, src_y + height, buf_height(src));
+	emit_vertex_normalized(batch, src_x, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y + height, igt_buf_height(src));
 
 	emit_vertex(batch, dst_x);
 	emit_vertex(batch, dst_y);
-	emit_vertex_normalized(batch, src_x, buf_width(src));
-	emit_vertex_normalized(batch, src_y, buf_height(src));
+	emit_vertex_normalized(batch, src_x, igt_buf_width(src));
+	emit_vertex_normalized(batch, src_y, igt_buf_height(src));
 
 	intel_batchbuffer_flush(batch);
 }
diff --git a/lib/rendercopy_i915.c b/lib/rendercopy_i915.c
index f7de2662b22b..b63c5cc4f03d 100644
--- a/lib/rendercopy_i915.c
+++ b/lib/rendercopy_i915.c
@@ -22,9 +22,9 @@
 
 void gen3_render_copyfunc(struct intel_batchbuffer *batch,
 			  drm_intel_context *context,
-			  struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
+			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
 {
 	/* invariant state */
 	{
@@ -96,8 +96,8 @@ void gen3_render_copyfunc(struct intel_batchbuffer *batch,
 		OUT_RELOC(src->bo, I915_GEM_DOMAIN_SAMPLER, 0, 0);
 		OUT_BATCH(MAPSURF_32BIT | MT_32BIT_ARGB8888 |
 			  tiling_bits |
-			  (buf_height(src) - 1) << MS3_HEIGHT_SHIFT |
-			  (buf_width(src) - 1) << MS3_WIDTH_SHIFT);
+			  (igt_buf_height(src) - 1) << MS3_HEIGHT_SHIFT |
+			  (igt_buf_width(src) - 1) << MS3_WIDTH_SHIFT);
 		OUT_BATCH((src->stride/4-1) << MS4_PITCH_SHIFT);
 
 		OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3 * TEX_COUNT));
@@ -133,8 +133,8 @@ void gen3_render_copyfunc(struct intel_batchbuffer *batch,
 		OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);
 		OUT_BATCH(0x00000000);
 		OUT_BATCH(0x00000000);	/* ymin, xmin */
-		OUT_BATCH(DRAW_YMAX(buf_height(dst) - 1) |
-			  DRAW_XMAX(buf_width(dst) - 1));
+		OUT_BATCH(DRAW_YMAX(igt_buf_height(dst) - 1) |
+			  DRAW_XMAX(igt_buf_width(dst) - 1));
 		/* yorig, xorig (relate to color buffer?) */
 		OUT_BATCH(0x00000000);
 	}
diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c
index 345425119f21..67d6191e529c 100644
--- a/tests/gem_ctx_basic.c
+++ b/tests/gem_ctx_basic.c
@@ -61,7 +61,7 @@ int devid;
 int fd;
 
 static void init_buffer(drm_intel_bufmgr *bufmgr,
-			struct scratch_buf *buf,
+			struct igt_buf *buf,
 			uint32_t size)
 {
 	buf->bo = drm_intel_bo_alloc(bufmgr, "", size, 4096);
@@ -93,7 +93,7 @@ static void *work(void *arg)
 	igt_require(context);
 
 	for (i = 0; i < iter; i++) {
-		struct scratch_buf src, dst;
+		struct igt_buf src, dst;
 
 		init_buffer(bufmgr, &src, 4096);
 		init_buffer(bufmgr, &dst, 4096);
diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c
index df891290c11c..7fc567612f97 100644
--- a/tests/gem_media_fill.c
+++ b/tests/gem_media_fill.c
@@ -66,7 +66,7 @@ typedef struct {
 	uint8_t linear[WIDTH * HEIGHT];
 } data_t;
 
-static void scratch_buf_init(data_t *data, struct scratch_buf *buf,
+static void scratch_buf_init(data_t *data, struct igt_buf *buf,
 			int width, int height, int stride, uint8_t color)
 {
 	drm_intel_bo *bo;
@@ -85,7 +85,7 @@ static void scratch_buf_init(data_t *data, struct scratch_buf *buf,
 }
 
 static void
-scratch_buf_check(data_t *data, struct scratch_buf *buf, int x, int y,
+scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
 		uint8_t color)
 {
 	uint8_t val;
@@ -104,7 +104,7 @@ igt_simple_main
 {
 	data_t data = {0, };
 	struct intel_batchbuffer *batch = NULL;
-	struct scratch_buf dst;
+	struct igt_buf dst;
 	media_fillfunc_t media_fill = NULL;
 	int i, j;
 
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index 65323a940c4e..7196a51a0198 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -66,7 +66,7 @@ typedef struct {
 	uint32_t linear[WIDTH * HEIGHT];
 } data_t;
 
-static void scratch_buf_write_to_png(struct scratch_buf *buf, const char *filename)
+static void scratch_buf_write_to_png(struct igt_buf *buf, const char *filename)
 {
 	cairo_surface_t *surface;
 	cairo_status_t ret;
@@ -74,8 +74,8 @@ static void scratch_buf_write_to_png(struct scratch_buf *buf, const char *filena
 	drm_intel_bo_map(buf->bo, 0);
 	surface = cairo_image_surface_create_for_data(buf->bo->virtual,
 						      CAIRO_FORMAT_RGB24,
-						      buf_width(buf),
-						      buf_height(buf),
+						      igt_buf_width(buf),
+						      igt_buf_height(buf),
 						      buf->stride);
 	ret = cairo_surface_write_to_png(surface, filename);
 	if (ret != CAIRO_STATUS_SUCCESS) {
@@ -86,7 +86,7 @@ static void scratch_buf_write_to_png(struct scratch_buf *buf, const char *filena
 	drm_intel_bo_unmap(buf->bo);
 }
 
-static void scratch_buf_init(data_t *data, struct scratch_buf *buf,
+static void scratch_buf_init(data_t *data, struct igt_buf *buf,
 			     int width, int height, int stride, uint32_t color)
 {
 	drm_intel_bo *bo;
@@ -105,7 +105,7 @@ static void scratch_buf_init(data_t *data, struct scratch_buf *buf,
 }
 
 static void
-scratch_buf_check(data_t *data, struct scratch_buf *buf, int x, int y,
+scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
 		  uint32_t color)
 {
 	uint32_t val;
@@ -124,7 +124,7 @@ int main(int argc, char **argv)
 {
 	data_t data = {0, };
 	struct intel_batchbuffer *batch = NULL;
-	struct scratch_buf src, dst;
+	struct igt_buf src, dst;
 	render_copyfunc_t render_copy = NULL;
 	int opt;
 	int opt_dump_png = false;
diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index 5efcc210d4ef..9d5d4ccf8cd0 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -137,7 +137,7 @@ int main(int argc, char **argv)
 
 	printf("Cyclic blits, forward...\n");
 	for (i = 0; i < count * 4; i++) {
-		struct scratch_buf src, dst;
+		struct igt_buf src, dst;
 
 		src.bo = bo[i % count];
 		src.stride = STRIDE;
@@ -160,7 +160,7 @@ int main(int argc, char **argv)
 
 	printf("Cyclic blits, backward...\n");
 	for (i = 0; i < count * 4; i++) {
-		struct scratch_buf src, dst;
+		struct igt_buf src, dst;
 
 		src.bo = bo[(i + 1) % count];
 		src.stride = STRIDE;
@@ -180,7 +180,7 @@ int main(int argc, char **argv)
 
 	printf("Random blits...\n");
 	for (i = 0; i < count * 4; i++) {
-		struct scratch_buf src, dst;
+		struct igt_buf src, dst;
 		int s = random() % count;
 		int d = random() % count;
 
diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c
index 71dfdd64fcee..0552af1fff80 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -84,7 +84,7 @@ int main(int argc, char **argv)
 	drm_intel_bufmgr *bufmgr;
 	struct intel_batchbuffer *batch;
 	uint32_t *start_val;
-	struct scratch_buf *buf;
+	struct igt_buf *buf;
 	uint32_t start = 0;
 	int i, j, fd, count;
 
diff --git a/tests/gem_ring_sync_copy.c b/tests/gem_ring_sync_copy.c
index b7dcf9dfdd4c..1ab9b0ce1224 100644
--- a/tests/gem_ring_sync_copy.c
+++ b/tests/gem_ring_sync_copy.c
@@ -70,8 +70,8 @@ typedef struct {
 
 	struct {
 		render_copyfunc_t copy;
-		struct scratch_buf *srcs;
-		struct scratch_buf *dsts;
+		struct igt_buf *srcs;
+		struct igt_buf *dsts;
 	} render;
 
 	struct {
@@ -128,7 +128,7 @@ static void bo_check(data_t *data, drm_intel_bo *bo, uint32_t val)
 		igt_assert_cmpint(data->linear[i], ==, val);
 }
 
-static void scratch_buf_init_from_bo(struct scratch_buf *buf, drm_intel_bo *bo)
+static void scratch_buf_init_from_bo(struct igt_buf *buf, drm_intel_bo *bo)
 {
 	buf->bo = bo;
 	buf->stride = 4 * WIDTH;
@@ -136,7 +136,7 @@ static void scratch_buf_init_from_bo(struct scratch_buf *buf, drm_intel_bo *bo)
 	buf->size = 4 * WIDTH * HEIGHT;
 }
 
-static void scratch_buf_init(data_t *data, struct scratch_buf *buf,
+static void scratch_buf_init(data_t *data, struct igt_buf *buf,
 			     int width, int height, uint32_t color)
 {
 	drm_intel_bo *bo;
@@ -162,7 +162,7 @@ static void render_busy(data_t *data)
 	size_t array_size;
 	int i;
 
-	array_size = data->n_buffers_load * sizeof(struct scratch_buf);
+	array_size = data->n_buffers_load * sizeof(struct igt_buf);
 	data->render.srcs = malloc(array_size);
 	data->render.dsts = malloc(array_size);
 
@@ -201,7 +201,7 @@ static void render_busy_fini(data_t *data)
 
 static void render_copy(data_t *data, drm_intel_bo *src, drm_intel_bo *dst)
 {
-	struct scratch_buf src_buf, dst_buf;
+	struct igt_buf src_buf, dst_buf;
 
 	scratch_buf_init_from_bo(&src_buf, src);
 	scratch_buf_init_from_bo(&dst_buf, dst);
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index 8e0ca91b98aa..0dd222722fb2 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -115,7 +115,7 @@ static int check_ring(drm_intel_bufmgr *bufmgr,
 		      const char *ring,
 		      render_copyfunc_t copy)
 {
-	struct scratch_buf src, tmp, dst;
+	struct igt_buf src, tmp, dst;
 	struct bo bo;
 	char output[100];
 	int i;
@@ -174,9 +174,9 @@ static int check_ring(drm_intel_bufmgr *bufmgr,
 
 static void blt_copy(struct intel_batchbuffer *batch,
 		     drm_intel_context *context,
-		     struct scratch_buf *src, unsigned src_x, unsigned src_y,
+		     struct igt_buf *src, unsigned src_x, unsigned src_y,
 		     unsigned w, unsigned h,
-		     struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
+		     struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
 {
 	BLIT_COPY_BATCH_START(batch->devid, 0);
 	OUT_BATCH((3 << 24) | /* 32 bits */
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index cc133a9acc9b..664e552cbfcc 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -70,7 +70,7 @@ struct option_struct {
 static struct option_struct options;
 
 static void init_buffer(drm_intel_bufmgr *bufmgr,
-			struct scratch_buf *buf,
+			struct igt_buf *buf,
 			drm_intel_bo *bo,
 			int width, int height)
 {
@@ -139,8 +139,8 @@ static void release_bo(drm_intel_bo *bo)
 	drm_intel_bo_unreference(bo);
 }
 
-static void render_copyfunc(struct scratch_buf *src,
-			    struct scratch_buf *dst,
+static void render_copyfunc(struct igt_buf *src,
+			    struct igt_buf *dst,
 			    int width,
 			    int height)
 {
@@ -188,7 +188,7 @@ static int run_sync_test(int num_buffers, bool verify)
 	int r = -1;
 	int failed = 0;
 	unsigned int *p_dst1, *p_dst2;
-	struct scratch_buf *s_src, *s_dst;
+	struct igt_buf *s_src, *s_dst;
 
 	fd = drm_open_any();
 	igt_assert(fd >= 0);
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index 527f7de823a3..20f2ca335485 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -117,7 +117,7 @@ struct option_struct options;
 #define BUSY_BUF_SIZE		(256*4096)
 #define TILE_BYTES(size)	((size)*(size)*sizeof(uint32_t))
 
-static struct scratch_buf buffers[2][MAX_BUFS];
+static struct igt_buf buffers[2][MAX_BUFS];
 /* tile i is at logical position tile_permutation[i] */
 static unsigned *tile_permutation;
 static unsigned num_buffers = 0;
@@ -133,7 +133,7 @@ struct {
 	unsigned max_failed_reads;
 } stats;
 
-static void tile2xy(struct scratch_buf *buf, unsigned tile, unsigned *x, unsigned *y)
+static void tile2xy(struct igt_buf *buf, unsigned tile, unsigned *x, unsigned *y)
 {
 	igt_assert(tile < buf->num_tiles);
 	*x = (tile*options.tile_size) % (buf->stride/sizeof(uint32_t));
@@ -194,15 +194,15 @@ static void keep_gpu_busy(void)
 		 busy_bo, 0, 4096, 0, 128);
 }
 
-static void set_to_cpu_domain(struct scratch_buf *buf, int writing)
+static void set_to_cpu_domain(struct igt_buf *buf, int writing)
 {
 	gem_set_domain(drm_fd, buf->bo->handle, I915_GEM_DOMAIN_CPU,
 		       writing ? I915_GEM_DOMAIN_CPU : 0);
 }
 
 static unsigned int copyfunc_seq = 0;
-static void (*copyfunc)(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+static void (*copyfunc)(struct igt_buf *src, unsigned src_x, unsigned src_y,
+			struct igt_buf *dst, unsigned dst_x, unsigned dst_y,
 			unsigned logical_tile_no);
 
 /* stride, x, y in units of uint32_t! */
@@ -240,8 +240,8 @@ static void cpucpy2d(uint32_t *src, unsigned src_stride, unsigned src_x, unsigne
 		stats.num_failed++;
 }
 
-static void cpu_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			 struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+static void cpu_copyfunc(struct igt_buf *src, unsigned src_x, unsigned src_y,
+			 struct igt_buf *dst, unsigned dst_x, unsigned dst_y,
 			 unsigned logical_tile_no)
 {
 	igt_assert(batch->ptr == batch->buffer);
@@ -259,8 +259,8 @@ static void cpu_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y
 		 logical_tile_no);
 }
 
-static void prw_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			 struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+static void prw_copyfunc(struct igt_buf *src, unsigned src_x, unsigned src_y,
+			 struct igt_buf *dst, unsigned dst_x, unsigned dst_y,
 			 unsigned logical_tile_no)
 {
 	uint32_t tmp_tile[options.tile_size*options.tile_size];
@@ -303,8 +303,8 @@ static void prw_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y
 	}
 }
 
-static void blitter_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			     struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+static void blitter_copyfunc(struct igt_buf *src, unsigned src_x, unsigned src_y,
+			     struct igt_buf *dst, unsigned dst_x, unsigned dst_y,
 			     unsigned logical_tile_no)
 {
 	static unsigned keep_gpu_busy_counter = 0;
@@ -333,8 +333,8 @@ static void blitter_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned s
 	}
 }
 
-static void render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			    struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+static void render_copyfunc(struct igt_buf *src, unsigned src_x, unsigned src_y,
+			    struct igt_buf *dst, unsigned dst_x, unsigned dst_y,
 			    unsigned logical_tile_no)
 {
 	static unsigned keep_gpu_busy_counter = 0;
@@ -453,28 +453,28 @@ static void fan_in_and_check(void)
 	}
 }
 
-static void sanitize_stride(struct scratch_buf *buf)
+static void sanitize_stride(struct igt_buf *buf)
 {
 
-	if (buf_height(buf) > options.max_dimension)
+	if (igt_buf_height(buf) > options.max_dimension)
 		buf->stride = buf->size / options.max_dimension;
 
-	if (buf_height(buf) < options.tile_size)
+	if (igt_buf_height(buf) < options.tile_size)
 		buf->stride = buf->size / options.tile_size;
 
-	if (buf_width(buf) < options.tile_size)
+	if (igt_buf_width(buf) < options.tile_size)
 		buf->stride = options.tile_size * sizeof(uint32_t);
 
 	igt_assert(buf->stride <= 8192);
-	igt_assert(buf_width(buf) <= options.max_dimension);
-	igt_assert(buf_height(buf) <= options.max_dimension);
+	igt_assert(igt_buf_width(buf) <= options.max_dimension);
+	igt_assert(igt_buf_height(buf) <= options.max_dimension);
 
-	igt_assert(buf_width(buf) >= options.tile_size);
-	igt_assert(buf_height(buf) >= options.tile_size);
+	igt_assert(igt_buf_width(buf) >= options.tile_size);
+	igt_assert(igt_buf_height(buf) >= options.tile_size);
 
 }
 
-static void init_buffer(struct scratch_buf *buf, unsigned size)
+static void init_buffer(struct igt_buf *buf, unsigned size)
 {
 	buf->bo = drm_intel_bo_alloc(bufmgr, "tiled bo", size, 4096);
 	buf->size = size;
@@ -499,12 +499,12 @@ static void init_buffer(struct scratch_buf *buf, unsigned size)
 
 static void exchange_buf(void *array, unsigned i, unsigned j)
 {
-	struct scratch_buf *buf_arr, tmp;
+	struct igt_buf *buf_arr, tmp;
 	buf_arr = array;
 
-	memcpy(&tmp, &buf_arr[i], sizeof(struct scratch_buf));
-	memcpy(&buf_arr[i], &buf_arr[j], sizeof(struct scratch_buf));
-	memcpy(&buf_arr[j], &tmp, sizeof(struct scratch_buf));
+	memcpy(&tmp, &buf_arr[i], sizeof(struct igt_buf));
+	memcpy(&buf_arr[i], &buf_arr[j], sizeof(struct igt_buf));
+	memcpy(&buf_arr[j], &tmp, sizeof(struct igt_buf));
 }
 
 
@@ -576,7 +576,7 @@ static void copy_tiles(unsigned *permutation)
 {
 	unsigned src_tile, src_buf_idx, src_x, src_y;
 	unsigned dst_tile, dst_buf_idx, dst_x, dst_y;
-	struct scratch_buf *src_buf, *dst_buf;
+	struct igt_buf *src_buf, *dst_buf;
 	int i, idx;
 	for (i = 0; i < num_total_tiles; i++) {
 		/* tile_permutation is independent of current_permutation, so
@@ -820,7 +820,7 @@ static void init(void)
 
 static void check_render_copyfunc(void)
 {
-	struct scratch_buf src, dst;
+	struct igt_buf src, dst;
 	uint32_t *ptr;
 	int i, j, pass;
 
@@ -831,10 +831,10 @@ static void check_render_copyfunc(void)
 	init_buffer(&dst, options.scratch_buf_size);
 
 	for (pass = 0; pass < 16; pass++) {
-		int sx = random() % (buf_width(&src)-options.tile_size);
-		int sy = random() % (buf_height(&src)-options.tile_size);
-		int dx = random() % (buf_width(&dst)-options.tile_size);
-		int dy = random() % (buf_height(&dst)-options.tile_size);
+		int sx = random() % (igt_buf_width(&src)-options.tile_size);
+		int sy = random() % (igt_buf_height(&src)-options.tile_size);
+		int dx = random() % (igt_buf_width(&dst)-options.tile_size);
+		int dy = random() % (igt_buf_height(&dst)-options.tile_size);
 
 		if (options.use_cpu_maps)
 			set_to_cpu_domain(&src, 1);
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index bb06bc491812..d05d14e0eca4 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -168,7 +168,7 @@ static void fill_blt(data_t *data, uint32_t handle, unsigned char color)
 	gem_bo_busy(data->drm_fd, handle);
 }
 
-static void scratch_buf_init(struct scratch_buf *buf, drm_intel_bo *bo)
+static void scratch_buf_init(struct igt_buf *buf, drm_intel_bo *bo)
 {
 	buf->bo = bo;
 	buf->stride = 4096;
@@ -204,7 +204,7 @@ static void fill_render(data_t *data, uint32_t handle,
 {
 	drm_intel_bo *src, *dst;
 	struct intel_batchbuffer *batch;
-	struct scratch_buf src_buf, dst_buf;
+	struct igt_buf src_buf, dst_buf;
 	const uint8_t buf[4] = { color, color, color, color };
 	render_copyfunc_t rendercopy = get_render_copyfunc(data->devid);
 
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 5ef5afa2c211..e89ae99d2abf 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -248,7 +248,7 @@ static void emit_dummy_load__rcs(struct test_output *o)
 {
 	const struct kmstest_fb *fb_info = &o->fb_info[o->current_fb_id];
 	render_copyfunc_t copyfunc;
-	struct scratch_buf sb[2], *src, *dst;
+	struct igt_buf sb[2], *src, *dst;
 	int i, limit;
 
 	copyfunc = get_render_copyfunc(devid);
@@ -277,7 +277,7 @@ static void emit_dummy_load__rcs(struct test_output *o)
 	dst = &sb[1];
 
 	for (i = 0; i < limit; i++) {
-		struct scratch_buf *tmp;
+		struct igt_buf *tmp;
 
 		copyfunc(batch, NULL,
 			 src, 0, 0,
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 09/28] lib/intel_batchbuffer: igt_ prefix for rendercopy/mediafill funcs
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (7 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 08/28] lib/intel_batchbuffer: igt_ namespace for the buffer structure Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 10/28] lib/intel_batchbuffer: drop cpu_mapping from igt_buf Daniel Vetter
                   ` (19 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Now everything is prepared to pour some neat api docs over this all.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_batchbuffer.c         | 14 +++++++-------
 lib/intel_batchbuffer.h         | 24 ++++++++++++------------
 tests/gem_ctx_basic.c           |  2 +-
 tests/gem_media_fill.c          |  4 ++--
 tests/gem_render_copy.c         |  4 ++--
 tests/gem_render_linear_blits.c |  4 ++--
 tests/gem_render_tiled_blits.c  |  4 ++--
 tests/gem_ring_sync_copy.c      |  4 ++--
 tests/gem_ringfill.c            |  6 +++---
 tests/gem_seqno_wrap.c          |  2 +-
 tests/gem_stress.c              |  2 +-
 tests/kms_fbc_crc.c             |  2 +-
 tests/kms_flip.c                |  4 ++--
 13 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 0da0043c0f50..6a585c7df967 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -298,9 +298,9 @@ intel_batchbuffer_data(struct intel_batchbuffer *batch,
  */
 void
 intel_blt_copy(struct intel_batchbuffer *batch,
-	      drm_intel_bo *src_bo, int src_x1, int src_y1, int src_pitch,
-	      drm_intel_bo *dst_bo, int dst_x1, int dst_y1, int dst_pitch,
-	      int width, int height, int bpp)
+	       drm_intel_bo *src_bo, int src_x1, int src_y1, int src_pitch,
+	       drm_intel_bo *dst_bo, int dst_x1, int dst_y1, int dst_pitch,
+	       int width, int height, int bpp)
 {
 	uint32_t src_tiling, dst_tiling, swizzle;
 	uint32_t cmd_bits = 0;
@@ -397,9 +397,9 @@ unsigned igt_buf_height(struct igt_buf *buf)
 	return buf->size/buf->stride;
 }
 
-render_copyfunc_t get_render_copyfunc(int devid)
+igt_render_copyfunc_t igt_get_render_copyfunc(int devid)
 {
-	render_copyfunc_t copy = NULL;
+	igt_render_copyfunc_t copy = NULL;
 
 	if (IS_GEN2(devid))
 		copy = gen2_render_copyfunc;
@@ -415,9 +415,9 @@ render_copyfunc_t get_render_copyfunc(int devid)
 	return copy;
 }
 
-media_fillfunc_t get_media_fillfunc(int devid)
+igt_media_fillfunc_t igt_get_media_fillfunc(int devid)
 {
-	media_fillfunc_t fill = NULL;
+	igt_media_fillfunc_t fill = NULL;
 
 	if (IS_GEN8(devid))
 		fill = gen8_media_fillfunc;
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 333b08946789..3daf33cdf276 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -209,20 +209,20 @@ struct igt_buf {
 unsigned igt_buf_width(struct igt_buf *buf);
 unsigned igt_buf_height(struct igt_buf *buf);
 
-typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch,
-				  drm_intel_context *context,
-				  struct igt_buf *src, unsigned src_x, unsigned src_y,
-				  unsigned width, unsigned height,
-				  struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
+typedef void (*igt_render_copyfunc_t)(struct intel_batchbuffer *batch,
+				      drm_intel_context *context,
+				      struct igt_buf *src, unsigned src_x, unsigned src_y,
+				      unsigned width, unsigned height,
+				      struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
 
-render_copyfunc_t get_render_copyfunc(int devid);
+igt_render_copyfunc_t igt_get_render_copyfunc(int devid);
 
-typedef void (*media_fillfunc_t)(struct intel_batchbuffer *batch,
-				struct igt_buf *dst,
-				unsigned x, unsigned y,
-				unsigned width, unsigned height,
-				uint8_t color);
+typedef void (*igt_media_fillfunc_t)(struct intel_batchbuffer *batch,
+				     struct igt_buf *dst,
+				     unsigned x, unsigned y,
+				     unsigned width, unsigned height,
+				     uint8_t color);
 
-media_fillfunc_t get_media_fillfunc(int devid);
+igt_media_fillfunc_t igt_get_media_fillfunc(int devid);
 
 #endif
diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c
index 67d6191e529c..3bfbe616eebd 100644
--- a/tests/gem_ctx_basic.c
+++ b/tests/gem_ctx_basic.c
@@ -74,7 +74,7 @@ static void init_buffer(drm_intel_bufmgr *bufmgr,
 static void *work(void *arg)
 {
 	struct intel_batchbuffer *batch;
-	render_copyfunc_t rendercopy = get_render_copyfunc(devid);
+	igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(devid);
 	drm_intel_context *context;
 	drm_intel_bufmgr *bufmgr;
 	int td_fd;
diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c
index 7fc567612f97..ef73ed68a8fa 100644
--- a/tests/gem_media_fill.c
+++ b/tests/gem_media_fill.c
@@ -105,7 +105,7 @@ igt_simple_main
 	data_t data = {0, };
 	struct intel_batchbuffer *batch = NULL;
 	struct igt_buf dst;
-	media_fillfunc_t media_fill = NULL;
+	igt_media_fillfunc_t media_fill = NULL;
 	int i, j;
 
 	data.drm_fd = drm_open_any_render();
@@ -114,7 +114,7 @@ igt_simple_main
 	data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096);
 	igt_assert(data.bufmgr);
 
-	media_fill = get_media_fillfunc(data.devid);
+	media_fill = igt_get_media_fillfunc(data.devid);
 
 	igt_require_f(media_fill,
 		"no media-fill function\n");
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index 7196a51a0198..2e029ebd2e54 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -125,7 +125,7 @@ int main(int argc, char **argv)
 	data_t data = {0, };
 	struct intel_batchbuffer *batch = NULL;
 	struct igt_buf src, dst;
-	render_copyfunc_t render_copy = NULL;
+	igt_render_copyfunc_t render_copy = NULL;
 	int opt;
 	int opt_dump_png = false;
 	int opt_dump_aub = drmtest_dump_aub();
@@ -149,7 +149,7 @@ int main(int argc, char **argv)
 		data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096);
 		igt_assert(data.bufmgr);
 
-		render_copy = get_render_copyfunc(data.devid);
+		render_copy = igt_get_render_copyfunc(data.devid);
 		igt_require_f(render_copy,
 			      "no render-copy function\n");
 
diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index 9d5d4ccf8cd0..b32a4cbb7574 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -61,7 +61,7 @@
 #define SIZE (HEIGHT*STRIDE)
 
 static uint32_t linear[WIDTH*HEIGHT];
-static render_copyfunc_t render_copy;
+static igt_render_copyfunc_t render_copy;
 
 static void
 check_bo(int fd, uint32_t handle, uint32_t val)
@@ -93,7 +93,7 @@ int main(int argc, char **argv)
 
 	fd = drm_open_any();
 
-	render_copy = get_render_copyfunc(intel_get_drm_devid(fd));
+	render_copy = igt_get_render_copyfunc(intel_get_drm_devid(fd));
 	if (render_copy == NULL) {
 		printf("no render-copy function, doing nothing\n");
 		return 77;
diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c
index 0552af1fff80..2456c2fb9b05 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -57,7 +57,7 @@
 #define HEIGHT 512
 #define SIZE (HEIGHT*STRIDE)
 
-static render_copyfunc_t render_copy;
+static igt_render_copyfunc_t render_copy;
 
 static void
 check_bo(drm_intel_bo *bo, uint32_t val)
@@ -94,7 +94,7 @@ int main(int argc, char **argv)
 
 	fd = drm_open_any();
 
-	render_copy = get_render_copyfunc(intel_get_drm_devid(fd));
+	render_copy = igt_get_render_copyfunc(intel_get_drm_devid(fd));
 	if (render_copy == NULL) {
 		printf("no render-copy function, doing nothing\n");
 		return 77;
diff --git a/tests/gem_ring_sync_copy.c b/tests/gem_ring_sync_copy.c
index 1ab9b0ce1224..b8b1454c90e5 100644
--- a/tests/gem_ring_sync_copy.c
+++ b/tests/gem_ring_sync_copy.c
@@ -69,7 +69,7 @@ typedef struct {
 	uint32_t linear[WIDTH * HEIGHT];
 
 	struct {
-		render_copyfunc_t copy;
+		igt_render_copyfunc_t copy;
 		struct igt_buf *srcs;
 		struct igt_buf *dsts;
 	} render;
@@ -336,7 +336,7 @@ igt_main
 		igt_assert(data.bufmgr);
 		drm_intel_bufmgr_gem_enable_reuse(data.bufmgr);
 
-		data.render.copy = get_render_copyfunc(data.devid);
+		data.render.copy = igt_get_render_copyfunc(data.devid);
 		igt_require_f(data.render.copy,
 			      "no render-copy function\n");
 
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index 0dd222722fb2..3c3df73bb338 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -113,7 +113,7 @@ static void destroy_bo(struct bo *b)
 static int check_ring(drm_intel_bufmgr *bufmgr,
 		      struct intel_batchbuffer *batch,
 		      const char *ring,
-		      render_copyfunc_t copy)
+		      igt_render_copyfunc_t copy)
 {
 	struct igt_buf src, tmp, dst;
 	struct bo bo;
@@ -197,7 +197,7 @@ static void blt_copy(struct intel_batchbuffer *batch,
 
 drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
-render_copyfunc_t copy;
+igt_render_copyfunc_t copy;
 int fd;
 
 igt_main
@@ -219,7 +219,7 @@ igt_main
 		/* Strictly only required on architectures with a separate BLT ring,
 		 * but lets stress everybody.
 		 */
-		copy = get_render_copyfunc(batch->devid);
+		copy = igt_get_render_copyfunc(batch->devid);
 		igt_require(copy);
 	}
 
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index 664e552cbfcc..25f11b4ea419 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -145,7 +145,7 @@ static void render_copyfunc(struct igt_buf *src,
 			    int height)
 {
 	const int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
-	render_copyfunc_t rendercopy = get_render_copyfunc(devid);
+	igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(devid);
 	static int warned = 0;
 
 	if (rendercopy) {
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index 20f2ca335485..a994f7f9424f 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -338,7 +338,7 @@ static void render_copyfunc(struct igt_buf *src, unsigned src_x, unsigned src_y,
 			    unsigned logical_tile_no)
 {
 	static unsigned keep_gpu_busy_counter = 0;
-	render_copyfunc_t rendercopy = get_render_copyfunc(devid);
+	igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(devid);
 
 	/* check both edges of the fence usage */
 	if (keep_gpu_busy_counter & 1)
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index d05d14e0eca4..07a572d2d488 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -206,7 +206,7 @@ static void fill_render(data_t *data, uint32_t handle,
 	struct intel_batchbuffer *batch;
 	struct igt_buf src_buf, dst_buf;
 	const uint8_t buf[4] = { color, color, color, color };
-	render_copyfunc_t rendercopy = get_render_copyfunc(data->devid);
+	igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(data->devid);
 
 	igt_skip_on(!rendercopy);
 
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index e89ae99d2abf..70d67e572059 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -247,11 +247,11 @@ static void emit_fence_stress(struct test_output *o)
 static void emit_dummy_load__rcs(struct test_output *o)
 {
 	const struct kmstest_fb *fb_info = &o->fb_info[o->current_fb_id];
-	render_copyfunc_t copyfunc;
+	igt_render_copyfunc_t copyfunc;
 	struct igt_buf sb[2], *src, *dst;
 	int i, limit;
 
-	copyfunc = get_render_copyfunc(devid);
+	copyfunc = igt_get_render_copyfunc(devid);
 	if (copyfunc == NULL)
 		return emit_dummy_load__bcs(o);
 
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 10/28] lib/intel_batchbuffer: drop cpu_mapping from igt_buf
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (8 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 09/28] lib/intel_batchbuffer: igt_ prefix for rendercopy/mediafill funcs Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 11/28] lib/intel_batchbuffer: api documentation for render copy/media fill Daniel Vetter
                   ` (18 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

It's unused. There's still num_tiles getting in the way of things,
but that is used by gem_stress a bit.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_batchbuffer.h | 1 -
 tests/gem_ringfill.c    | 1 -
 tests/gem_seqno_wrap.c  | 1 -
 3 files changed, 3 deletions(-)

diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 3daf33cdf276..6a65f6f7b36f 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -201,7 +201,6 @@ struct igt_buf {
     uint32_t stride;
     uint32_t tiling;
     uint32_t *data;
-    uint32_t *cpu_mapping;
     uint32_t size;
     unsigned num_tiles;
 };
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index 3c3df73bb338..ef98701c5b7c 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -126,7 +126,6 @@ static int check_ring(drm_intel_bufmgr *bufmgr,
 
 	src.stride = 4 * width;
 	src.tiling = 0;
-	src.data = src.cpu_mapping = NULL;
 	src.size = 4 * width * height;
 	src.num_tiles = 4 * width * height;
 	dst = tmp = src;
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index 25f11b4ea419..f97403249374 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -79,7 +79,6 @@ static void init_buffer(drm_intel_bufmgr *bufmgr,
 	buf->size = width * height * 4;
 	igt_assert(buf->bo);
 	buf->tiling = I915_TILING_NONE;
-	buf->data = buf->cpu_mapping = NULL;
 	buf->num_tiles = width * height * 4;
 	buf->stride = width * 4;
 }
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 11/28] lib/intel_batchbuffer: api documentation for render copy/media fill
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (9 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 10/28] lib/intel_batchbuffer: drop cpu_mapping from igt_buf Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 12/28] lib: Move non-register things out of intel-gpu-tools.h Daniel Vetter
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Also fix a fumble in the documentation for intel_blt_copy. One thing
we might want to do is unify the parameter ordering here a bit ...

Again gtkdoc fails to pick up the documentation for struct igt_buf :(

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_batchbuffer.c | 41 +++++++++++++++++++++++++++++++++++--
 lib/intel_batchbuffer.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 2 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 6a585c7df967..3a38f13326ec 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -286,8 +286,8 @@ intel_batchbuffer_data(struct intel_batchbuffer *batch,
  * @src_y1: source pixel y-coordination
  * @src_pitch: @src_bo's pitch in bytes
  * @dst_bo: destination libdrm buffer object
- * @dst_x1: source pixel x-coordination
- * @dst_y1: source pixel y-coordination
+ * @dst_x1: destination pixel x-coordination
+ * @dst_y1: destination pixel y-coordination
  * @dst_pitch: @dst_bo's pitch in bytes
  * @width: width of the copied rectangle
  * @height: height of the copied rectangle
@@ -387,16 +387,44 @@ intel_copy_bo(struct intel_batchbuffer *batch,
 		       4096/4, size/4096, 32);
 }
 
+/**
+ * igt_buf_width:
+ * @buf: the i-g-t buffer object
+ *
+ * Computes the widht in 32-bit pixels of the given buffer.
+ *
+ * Returns:
+ * The width of the buffer.
+ */
 unsigned igt_buf_width(struct igt_buf *buf)
 {
 	return buf->stride/sizeof(uint32_t);
 }
 
+/**
+ * igt_buf_height:
+ * @buf: the i-g-t buffer object
+ *
+ * Computes the height in 32-bit pixels of the given buffer.
+ *
+ * Returns:
+ * The height of the buffer.
+ */
 unsigned igt_buf_height(struct igt_buf *buf)
 {
 	return buf->size/buf->stride;
 }
 
+/**
+ * igt_get_render_copyfunc:
+ * @devid: pci device id
+ *
+ * Returns:
+ *
+ * The platform-specific render copy function pointer for the device
+ * specified with @devid. Will return NULL when no render copy function is
+ * implemented.
+ */
 igt_render_copyfunc_t igt_get_render_copyfunc(int devid)
 {
 	igt_render_copyfunc_t copy = NULL;
@@ -415,6 +443,15 @@ igt_render_copyfunc_t igt_get_render_copyfunc(int devid)
 	return copy;
 }
 
+/**
+ * igt_get_media_fillfunc:
+ * @devid: pci device id
+ *
+ * Returns:
+ *
+ * The platform-specific media fill function pointer for the device specified
+ * with @devid. Will return NULL when no media fill function is implemented.
+ */
 igt_media_fillfunc_t igt_get_media_fillfunc(int devid)
 {
 	igt_media_fillfunc_t fill = NULL;
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 6a65f6f7b36f..b3e4b8ffd4e5 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -196,6 +196,22 @@ void intel_copy_bo(struct intel_batchbuffer *batch,
 		   drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
 		   long int size);
 
+/**
+ * igt_buf:
+ * @bo: underlying libdrm buffer object
+ * @stride: stride of the buffer
+ * @tiling: tiling mode bits
+ * @data: pointer to the memory mapping of the buffer
+ * @size: size of the buffer object
+ * @num_tiles: number of tiles of the buffer object
+ *
+ * This is a i-g-t buffer object wrapper structure which augments the baseline
+ * libdrm buffer object with suitable data needed by the render copy and the
+ * media fill functions.
+ *
+ * Note that @num_tiles is only used by gem_stress.c internally and can be
+ * ignored.
+ */
 struct igt_buf {
     drm_intel_bo *bo;
     uint32_t stride;
@@ -208,6 +224,27 @@ struct igt_buf {
 unsigned igt_buf_width(struct igt_buf *buf);
 unsigned igt_buf_height(struct igt_buf *buf);
 
+/**
+ * igt_render_copyfunc_t:
+ * @batch: batchbuffer object
+ * @context: libdrm hardware context to use
+ * @src: source i-g-t buffer object
+ * @src_x: source pixel x-coordination
+ * @src_y: source pixel y-coordination
+ * @width: width of the copied rectangle
+ * @height: height of the copied rectangle
+ * @dst: destination i-g-t buffer object
+ * @dst_x: destination pixel x-coordination
+ * @dst_y: destination pixel y-coordination
+ *
+ * This is the type of the per-platform render copy functions. The
+ * platform-specific implementation can be obtained by calling
+ * igt_get_render_copyfunc().
+ *
+ * A render copy function will emit a batchbuffer to the kernel which executes
+ * the specified blit copy operation using the render engine. @context is
+ * optional and can be NULL.
+ */
 typedef void (*igt_render_copyfunc_t)(struct intel_batchbuffer *batch,
 				      drm_intel_context *context,
 				      struct igt_buf *src, unsigned src_x, unsigned src_y,
@@ -216,6 +253,23 @@ typedef void (*igt_render_copyfunc_t)(struct intel_batchbuffer *batch,
 
 igt_render_copyfunc_t igt_get_render_copyfunc(int devid);
 
+/**
+ * igt_media_fillfunc_t:
+ * @batch: batchbuffer object
+ * @dst: destination i-g-t buffer object
+ * @x: destination pixel x-coordination
+ * @y: destination pixel y-coordination
+ * @width: width of the filled rectangle
+ * @height: height of the filled rectangle
+ * @color: fill color to use
+ *
+ * This is the type of the per-platform media fill functions. The
+ * platform-specific implementation can be obtained by calling
+ * igt_get_media_fillfunc().
+ *
+ * A media fill function will emit a batchbuffer to the kernel which executes
+ * the specified blit fill operation using the media engine.
+ */
 typedef void (*igt_media_fillfunc_t)(struct intel_batchbuffer *batch,
 				     struct igt_buf *dst,
 				     unsigned x, unsigned y,
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 12/28] lib: Move non-register things out of intel-gpu-tools.h
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (10 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 11/28] lib/intel_batchbuffer: api documentation for render copy/media fill Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 13/28] tests|lib: remove assert.h includes Daniel Vetter
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Right now almost everything in there concerns itself with register
access. Move everything else out (into drmtest.h for lack of better
place) to prepare for api documentation.

Also rename intel_drm.c to intel_os.c since it contains OS, not
drm abstractions.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/Makefile.sources         |   2 +-
 lib/drmtest.h                |  17 +++++
 lib/intel_drm.c              | 158 -------------------------------------------
 lib/intel_gpu_tools.h        |  50 +++++---------
 lib/intel_os.c               | 158 +++++++++++++++++++++++++++++++++++++++++++
 tools/quick_dump/Makefile.am |   2 +-
 6 files changed, 194 insertions(+), 193 deletions(-)
 delete mode 100644 lib/intel_drm.c
 create mode 100644 lib/intel_os.c

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index e6ada3c900b4..e3942aceab2d 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -15,7 +15,7 @@ libintel_tools_la_SOURCES = 	\
 	intel_batchbuffer.c	\
 	intel_batchbuffer.h	\
 	intel_chipset.h		\
-	intel_drm.c		\
+	intel_os.c		\
 	intel_gpu_tools.h	\
 	intel_mmio.c		\
 	intel_chipset.c		\
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 593f31b97a11..ed6040f7e3b7 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -47,6 +47,19 @@
 #include "ioctl_wrappers.h"
 #include "igt_core.h"
 
+#ifdef ANDROID
+#ifndef HAVE_MMAP64
+extern void*  __mmap2(void *, size_t, int, int, int, off_t);
+static inline void *mmap64(void *addr, size_t length, int prot, int flags,
+        int fd, off64_t offset)
+{
+    return __mmap2(addr, length, prot, flags, fd, offset >> 12);
+}
+#endif
+#endif
+
+#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
+
 int drm_get_card(void);
 int drm_open_any(void);
 int drm_open_any_render(void);
@@ -85,4 +98,8 @@ void igt_drop_root(void);
 
 void igt_wait_for_keypress(void);
 
+/* sysinfo cross-arch wrappers from intel_os.c */
+uint64_t intel_get_total_ram_mb(void);
+uint64_t intel_get_total_swap_mb(void);
+
 #endif /* DRMTEST_H */
diff --git a/lib/intel_drm.c b/lib/intel_drm.c
deleted file mode 100644
index ce4dcbcad5b2..000000000000
--- a/lib/intel_drm.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright © 2008 Intel Corporation
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Eric Anholt <eric@anholt.net>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <err.h>
-#include <assert.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM
-#include <sys/sysinfo.h>
-#elif defined(HAVE_SWAPCTL) /* Solaris */
-#include <sys/swap.h>
-#endif
-
-#include "intel_gpu_tools.h"
-#include "i915_drm.h"
-
-uint64_t
-intel_get_total_ram_mb(void)
-{
-	uint64_t retval;
-
-#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */
-	struct sysinfo sysinf;
-	int ret;
-
-	ret = sysinfo(&sysinf);
-	assert(ret == 0);
-
-	retval = sysinf.totalram;
-	retval *= sysinf.mem_unit;
-#elif defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES) /* Solaris */
-	long pagesize, npages;
-
-	pagesize = sysconf(_SC_PAGESIZE);
-        npages = sysconf(_SC_PHYS_PAGES);
-
-	retval = (uint64_t) pagesize * npages;
-#else
-#error "Unknown how to get RAM size for this OS"
-#endif
-
-	return retval / (1024*1024);
-}
-
-uint64_t
-intel_get_total_swap_mb(void)
-{
-	uint64_t retval;
-
-#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */
-	struct sysinfo sysinf;
-	int ret;
-
-	ret = sysinfo(&sysinf);
-	assert(ret == 0);
-
-	retval = sysinf.freeswap;
-	retval *= sysinf.mem_unit;
-#elif defined(HAVE_SWAPCTL) /* Solaris */
-	long pagesize = sysconf(_SC_PAGESIZE);
-	uint64_t totalpages = 0;
-	swaptbl_t *swt;
-	char *buf;
-	int n, i;
-
-	if ((n = swapctl(SC_GETNSWP, NULL)) == -1) {
-	    perror("swapctl: GETNSWP");
-	    return 0;
-	}
-	if (n == 0) {
-	    /* no error, but no swap devices either */
-	    return 0;
-	}
-
-	swt = malloc(sizeof(struct swaptable) + (n * sizeof(swapent_t)));
-	buf = malloc(n * MAXPATHLEN);
-	if (!swt || !buf) {
-	    perror("malloc");
-	} else {
-	    swt->swt_n = n;
-	    for (i = 0 ; i < n; i++) {
-		swt->swt_ent[i].ste_path = buf + (i * MAXPATHLEN);
-	    }
-
-	    if ((n = swapctl(SC_LIST, swt)) == -1) {
-		perror("swapctl: LIST");
-	    } else {
-		for (i = 0; i < swt->swt_n; i++) {
-		    totalpages += swt->swt_ent[i].ste_pages;
-		}
-	    }
-	}
-	free(swt);
-	free(buf);
-
-	retval = (uint64_t) pagesize * totalpages;
-#else
-#warning "Unknown how to get swap size for this OS"
-	return 0;
-#endif
-
-	return retval / (1024*1024);
-}
-
-
-/*
- * When testing a port to a new platform, create a standalone test binary
- * by running:
- * cc -o porttest intel_drm.c -I.. -DSTANDALONE_TEST `pkg-config --cflags libdrm`
- * and then running the resulting porttest program.
- */
-#ifdef STANDALONE_TEST
-void *mmio;
-
-int main(int argc, char **argv)
-{
-    printf("Total RAM:  %" PRIu64 " Mb\n", intel_get_total_ram_mb());
-    printf("Total Swap: %" PRIu64 " Mb\n", intel_get_total_swap_mb());
-
-    return 0;
-}
-#endif /* STANDALONE_TEST */
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
index 37cbcb19bb4c..aab07290f77b 100644
--- a/lib/intel_gpu_tools.h
+++ b/lib/intel_gpu_tools.h
@@ -34,31 +34,32 @@
 
 #include "intel_chipset.h"
 #include "intel_reg.h"
+#include "drmtest.h"
 
-#ifdef ANDROID
-#ifndef HAVE_MMAP64
-extern void*  __mmap2(void *, size_t, int, int, int, off_t);
-static inline void *mmap64(void *addr, size_t length, int prot, int flags,
-        int fd, off64_t offset)
-{
-    return __mmap2(addr, length, prot, flags, fd, offset >> 12);
-}
-#endif
-#endif
-
-#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
-
+/* register access helpers from intel_mmio.c */
 extern void *mmio;
 void intel_get_mmio(struct pci_device *pci_dev);
+void intel_map_file(char *);
 
-/* New style register access API */
 int intel_register_access_init(struct pci_device *pci_dev, int safe);
 void intel_register_access_fini(void);
 uint32_t intel_register_read(uint32_t reg);
 void intel_register_write(uint32_t reg, uint32_t val);
 int intel_register_access_needs_fakewake(void);
 
-/* Following functions are relevant only for SoCs like Valleyview */
+static inline uint32_t
+INREG(uint32_t reg)
+{
+	return *(volatile uint32_t *)((volatile char *)mmio + reg);
+}
+
+static inline void
+OUTREG(uint32_t reg, uint32_t val)
+{
+	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
+}
+
+/* sideband access functions from intel_iosf.c */
 uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
 void intel_dpio_reg_write(uint32_t reg, uint32_t val, int phy);
 
@@ -67,6 +68,7 @@ int intel_punit_write(uint8_t addr, uint32_t val);
 int intel_nc_read(uint8_t addr, uint32_t *val);
 int intel_nc_write(uint8_t addr, uint32_t val);
 
+/* register maps from intel_reg_map.c */
 #define INTEL_RANGE_RSVD	(0<<0) /*  Shouldn't be read or written */
 #define INTEL_RANGE_READ	(1<<0)
 #define INTEL_RANGE_WRITE	(1<<1)
@@ -87,22 +89,4 @@ struct intel_register_map {
 struct intel_register_map intel_get_register_map(uint32_t devid);
 struct intel_register_range *intel_get_register_range(struct intel_register_map map, uint32_t offset, uint32_t mode);
 
-
-static inline uint32_t
-INREG(uint32_t reg)
-{
-	return *(volatile uint32_t *)((volatile char *)mmio + reg);
-}
-
-static inline void
-OUTREG(uint32_t reg, uint32_t val)
-{
-	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
-}
-
-uint64_t intel_get_total_ram_mb(void);
-uint64_t intel_get_total_swap_mb(void);
-
-void intel_map_file(char *);
-
 #endif /* INTEL_GPU_TOOLS_H */
diff --git a/lib/intel_os.c b/lib/intel_os.c
new file mode 100644
index 000000000000..ce4dcbcad5b2
--- /dev/null
+++ b/lib/intel_os.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <err.h>
+#include <assert.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM
+#include <sys/sysinfo.h>
+#elif defined(HAVE_SWAPCTL) /* Solaris */
+#include <sys/swap.h>
+#endif
+
+#include "intel_gpu_tools.h"
+#include "i915_drm.h"
+
+uint64_t
+intel_get_total_ram_mb(void)
+{
+	uint64_t retval;
+
+#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */
+	struct sysinfo sysinf;
+	int ret;
+
+	ret = sysinfo(&sysinf);
+	assert(ret == 0);
+
+	retval = sysinf.totalram;
+	retval *= sysinf.mem_unit;
+#elif defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES) /* Solaris */
+	long pagesize, npages;
+
+	pagesize = sysconf(_SC_PAGESIZE);
+        npages = sysconf(_SC_PHYS_PAGES);
+
+	retval = (uint64_t) pagesize * npages;
+#else
+#error "Unknown how to get RAM size for this OS"
+#endif
+
+	return retval / (1024*1024);
+}
+
+uint64_t
+intel_get_total_swap_mb(void)
+{
+	uint64_t retval;
+
+#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */
+	struct sysinfo sysinf;
+	int ret;
+
+	ret = sysinfo(&sysinf);
+	assert(ret == 0);
+
+	retval = sysinf.freeswap;
+	retval *= sysinf.mem_unit;
+#elif defined(HAVE_SWAPCTL) /* Solaris */
+	long pagesize = sysconf(_SC_PAGESIZE);
+	uint64_t totalpages = 0;
+	swaptbl_t *swt;
+	char *buf;
+	int n, i;
+
+	if ((n = swapctl(SC_GETNSWP, NULL)) == -1) {
+	    perror("swapctl: GETNSWP");
+	    return 0;
+	}
+	if (n == 0) {
+	    /* no error, but no swap devices either */
+	    return 0;
+	}
+
+	swt = malloc(sizeof(struct swaptable) + (n * sizeof(swapent_t)));
+	buf = malloc(n * MAXPATHLEN);
+	if (!swt || !buf) {
+	    perror("malloc");
+	} else {
+	    swt->swt_n = n;
+	    for (i = 0 ; i < n; i++) {
+		swt->swt_ent[i].ste_path = buf + (i * MAXPATHLEN);
+	    }
+
+	    if ((n = swapctl(SC_LIST, swt)) == -1) {
+		perror("swapctl: LIST");
+	    } else {
+		for (i = 0; i < swt->swt_n; i++) {
+		    totalpages += swt->swt_ent[i].ste_pages;
+		}
+	    }
+	}
+	free(swt);
+	free(buf);
+
+	retval = (uint64_t) pagesize * totalpages;
+#else
+#warning "Unknown how to get swap size for this OS"
+	return 0;
+#endif
+
+	return retval / (1024*1024);
+}
+
+
+/*
+ * When testing a port to a new platform, create a standalone test binary
+ * by running:
+ * cc -o porttest intel_drm.c -I.. -DSTANDALONE_TEST `pkg-config --cflags libdrm`
+ * and then running the resulting porttest program.
+ */
+#ifdef STANDALONE_TEST
+void *mmio;
+
+int main(int argc, char **argv)
+{
+    printf("Total RAM:  %" PRIu64 " Mb\n", intel_get_total_ram_mb());
+    printf("Total Swap: %" PRIu64 " Mb\n", intel_get_total_swap_mb());
+
+    return 0;
+}
+#endif /* STANDALONE_TEST */
diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
index e6329c9c2980..7572ee5e5cb5 100644
--- a/tools/quick_dump/Makefile.am
+++ b/tools/quick_dump/Makefile.am
@@ -8,7 +8,7 @@ bin_SCRIPTS = chipset.py
 lib_LTLIBRARIES = I915ChipsetPython.la
 I915ChipsetPython_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) $(PCIACCESS_LIBS)
 I915ChipsetPython_la_SOURCES = chipset_wrap_python.c chipset_macro_wrap.c \
-			       $(top_srcdir)/lib/intel_drm.c  \
+			       $(top_srcdir)/lib/intel_os.c  \
 			       $(top_srcdir)/lib/intel_chipset.c  \
 			       $(top_srcdir)/lib/intel_reg_map.c  \
 			       $(top_srcdir)/lib/intel_mmio.c  \
-- 
1.8.5.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 13/28] tests|lib: remove assert.h includes
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (11 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 12/28] lib: Move non-register things out of intel-gpu-tools.h Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 14/28] lib: add #include "foo.h" lines like in manpages Daniel Vetter
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Only the igt core and non-test tools should have asserts to catch
internal errors, tests and helper libraries should all user igt_asert
instead.

Fix things up where assert instead of igt_assert was used.

One tiny step towards header sanity.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/drmtest.c                    |  2 +-
 lib/drmtest.h                    |  1 -
 lib/igt_core.c                   |  1 +
 lib/igt_kms.c                    |  6 +++---
 lib/intel_batchbuffer.h          | 10 +++++-----
 lib/ioctl_wrappers.c             |  2 +-
 lib/media_fill.h                 |  1 -
 tests/drv_suspend.c              |  4 ++--
 tests/gem_ctx_basic.c            |  2 --
 tests/gem_fence_thrash.c         | 32 ++++++++++++++++----------------
 tests/gem_media_fill.c           |  2 --
 tests/gem_render_copy.c          |  2 --
 tests/gem_render_linear_blits.c  |  2 --
 tests/gem_render_tiled_blits.c   |  2 --
 tests/gem_storedw_batches_loop.c |  2 +-
 tests/gem_stress.c               |  2 --
 tests/gem_wait_render_timeout.c  |  2 --
 tests/igt_simulation.c           |  1 +
 tests/kms_setmode.c              | 25 ++++++++++++-------------
 tests/pm_rps.c                   |  2 +-
 tests/testdisplay.c              |  4 ++--
 tools/intel_l3_parity.c          |  1 +
 22 files changed, 47 insertions(+), 61 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 78b9999d76f6..c2751e75d86a 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -396,7 +396,7 @@ void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
 	num_trash_bos = gem_mappable_aperture_size() / (1024*1024);
 
 	trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *));
-	assert(trash_bos);
+	igt_assert(trash_bos);
 
 	for (i = 0; i < num_trash_bos; i++)
 		trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096);
diff --git a/lib/drmtest.h b/lib/drmtest.h
index ed6040f7e3b7..d048ee095386 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -31,7 +31,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <setjmp.h>
diff --git a/lib/igt_core.c b/lib/igt_core.c
index dbfcd74f9160..3ff7efa7de93 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -32,6 +32,7 @@
 #include <libgen.h>
 #endif
 #include <stdio.h>
+#include <assert.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index d5d9e0228408..ac27d7ae1534 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -146,7 +146,7 @@ int kmstest_cairo_printf_line(cairo_t *cr, enum kmstest_text_align align,
 
 	va_start(ap, fmt);
 	ret = vasprintf(&text, fmt, ap);
-	assert(ret >= 0);
+	igt_assert(ret >= 0);
 	va_end(ap);
 
 	cairo_text_extents(cr, text, &extents);
@@ -221,7 +221,7 @@ void kmstest_paint_test_pattern(cairo_t *cr, int width, int height)
 	paint_marker(cr, 0, height);
 	paint_marker(cr, width, height);
 
-	assert(!cairo_status(cr));
+	igt_assert(!cairo_status(cr));
 }
 
 void kmstest_paint_image(cairo_t *cr, const char *filename,
@@ -232,7 +232,7 @@ void kmstest_paint_image(cairo_t *cr, const char *filename,
 	double scale_x, scale_y;
 
 	image = cairo_image_surface_create_from_png(filename);
-	assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
+	igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
 
 	img_width = cairo_image_surface_get_width(image);
 	img_height = cairo_image_surface_get_height(image);
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index b3e4b8ffd4e5..7764064286b9 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -1,9 +1,9 @@
 #ifndef INTEL_BATCHBUFFER_H
 #define INTEL_BATCHBUFFER_H
 
-#include <assert.h>
 #include <stdint.h>
 #include "intel_bufmgr.h"
+#include "igt_core.h"
 
 #define BATCH_SZ 4096
 #define BATCH_RESERVED 16
@@ -58,7 +58,7 @@ intel_batchbuffer_space(struct intel_batchbuffer *batch)
 static inline void
 intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, uint32_t dword)
 {
-	assert(intel_batchbuffer_space(batch) >= 4);
+	igt_assert(intel_batchbuffer_space(batch) >= 4);
 	*(uint32_t *) (batch->ptr) = dword;
 	batch->ptr += 4;
 }
@@ -67,7 +67,7 @@ static inline void
 intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
                                 unsigned int sz)
 {
-	assert(sz < BATCH_SZ - BATCH_RESERVED);
+	igt_assert(sz < BATCH_SZ - BATCH_RESERVED);
 	if (intel_batchbuffer_space(batch) < sz)
 		intel_batchbuffer_flush(batch);
 }
@@ -110,7 +110,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
  * scope.
  */
 #define OUT_RELOC_FENCED(buf, read_domains, write_domain, delta) do {		\
-	assert((delta) >= 0);						\
+	igt_assert((delta) >= 0);						\
 	intel_batchbuffer_emit_reloc(batch, buf, delta,			\
 				     read_domains, write_domain, 1);	\
 } while (0)
@@ -128,7 +128,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
  * scope.
  */
 #define OUT_RELOC(buf, read_domains, write_domain, delta) do {		\
-	assert((delta) >= 0);						\
+	igt_assert((delta) >= 0);						\
 	intel_batchbuffer_emit_reloc(batch, buf, delta,			\
 				     read_domains, write_domain, 0);	\
 } while (0)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 375693062eb6..febfc8b7ff91 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -808,7 +808,7 @@ void gem_require_ring(int fd, int ring_id)
 		return;
 #endif
 	default:
-		assert(0);
+		igt_assert(0);
 		return;
 	}
 }
diff --git a/lib/media_fill.h b/lib/media_fill.h
index 2e1af325cac6..3568cf603955 100644
--- a/lib/media_fill.h
+++ b/lib/media_fill.h
@@ -5,7 +5,6 @@
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c
index 400c34b98fce..ff8a348bdd77 100644
--- a/tests/drv_suspend.c
+++ b/tests/drv_suspend.c
@@ -109,7 +109,7 @@ test_debugfs_reader(void)
 		snprintf(tmp, sizeof(tmp) - 1,
 			 "while true; do find %s/%i/ -type f | xargs cat > /dev/null 2>&1; done",
 			 dfs_base, drm_get_card());
-		assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
+		igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
 	}
 
 	sleep(1);
@@ -134,7 +134,7 @@ test_sysfs_reader(void)
 		snprintf(tmp, sizeof(tmp) - 1,
 			 "while true; do find %s%i*/ -type f | xargs cat > /dev/null 2>&1; done",
 			 dfs_base, drm_get_card());
-		assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
+		igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
 	}
 
 	sleep(1);
diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c
index 3bfbe616eebd..4340000e25a1 100644
--- a/tests/gem_ctx_basic.c
+++ b/tests/gem_ctx_basic.c
@@ -30,12 +30,10 @@
  */
 
 #include <pthread.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index bff73ddd7f92..86ee5bec30ce 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -113,8 +113,8 @@ _bo_write_verify(struct test *t)
 	unsigned int dwords = OBJECT_SIZE >> 2;
 	const char *tile_str[] = { "none", "x", "y" };
 
-	assert (t->tiling >= 0 && t->tiling <= I915_TILING_Y);
-	assert (t->num_surfaces > 0);
+	igt_assert(t->tiling >= 0 && t->tiling <= I915_TILING_Y);
+	igt_assert(t->num_surfaces > 0);
 
 	s = calloc(sizeof(*s), t->num_surfaces);
 	igt_assert(s);
@@ -171,7 +171,7 @@ static int run_test(int threads_per_fence, void *f, int tiling,
 	t.num_surfaces = surfaces_per_thread;
 
 	num_fences = gem_available_fences(t.fd);
-	assert (num_fences > 0);
+	igt_assert(num_fences > 0);
 
 	num_threads = threads_per_fence * num_fences;
 
@@ -181,7 +181,7 @@ static int run_test(int threads_per_fence, void *f, int tiling,
 
 	if (threads_per_fence) {
 		threads = calloc(sizeof(*threads), num_threads);
-		assert  (threads != NULL);
+		igt_assert(threads != NULL);
 
 		for (n = 0; n < num_threads; n++)
 			pthread_create (&threads[n], NULL, f, &t);
@@ -203,29 +203,29 @@ igt_main
 	igt_skip_on_simulation();
 
 	igt_subtest("bo-write-verify-none")
-		assert (run_test(0, bo_write_verify, I915_TILING_NONE, 80) == 0);
+		igt_assert(run_test(0, bo_write_verify, I915_TILING_NONE, 80) == 0);
 
 	igt_subtest("bo-write-verify-x")
-		assert (run_test(0, bo_write_verify, I915_TILING_X, 80) == 0);
+		igt_assert(run_test(0, bo_write_verify, I915_TILING_X, 80) == 0);
 
 	igt_subtest("bo-write-verify-y")
-		assert (run_test(0, bo_write_verify, I915_TILING_Y, 80) == 0);
+		igt_assert(run_test(0, bo_write_verify, I915_TILING_Y, 80) == 0);
 
 	igt_subtest("bo-write-verify-threaded-none")
-		assert (run_test(5, bo_write_verify, I915_TILING_NONE, 2) == 0);
+		igt_assert(run_test(5, bo_write_verify, I915_TILING_NONE, 2) == 0);
 
 	igt_subtest("bo-write-verify-threaded-x") {
-		assert (run_test(2, bo_write_verify, I915_TILING_X, 2) == 0);
-		assert (run_test(5, bo_write_verify, I915_TILING_X, 2) == 0);
-		assert (run_test(10, bo_write_verify, I915_TILING_X, 2) == 0);
-		assert (run_test(20, bo_write_verify, I915_TILING_X, 2) == 0);
+		igt_assert(run_test(2, bo_write_verify, I915_TILING_X, 2) == 0);
+		igt_assert(run_test(5, bo_write_verify, I915_TILING_X, 2) == 0);
+		igt_assert(run_test(10, bo_write_verify, I915_TILING_X, 2) == 0);
+		igt_assert(run_test(20, bo_write_verify, I915_TILING_X, 2) == 0);
 	}
 
 	igt_subtest("bo-write-verify-threaded-y") {
-		assert (run_test(2, bo_write_verify, I915_TILING_Y, 2) == 0);
-		assert (run_test(5, bo_write_verify, I915_TILING_Y, 2) == 0);
-		assert (run_test(10, bo_write_verify, I915_TILING_Y, 2) == 0);
-		assert (run_test(20, bo_write_verify, I915_TILING_Y, 2) == 0);
+		igt_assert(run_test(2, bo_write_verify, I915_TILING_Y, 2) == 0);
+		igt_assert(run_test(5, bo_write_verify, I915_TILING_Y, 2) == 0);
+		igt_assert(run_test(10, bo_write_verify, I915_TILING_Y, 2) == 0);
+		igt_assert(run_test(20, bo_write_verify, I915_TILING_Y, 2) == 0);
 	}
 
 	igt_subtest("bo-copy")
diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c
index ef73ed68a8fa..220f8629ea5d 100644
--- a/tests/gem_media_fill.c
+++ b/tests/gem_media_fill.c
@@ -32,12 +32,10 @@
 
 #include <stdbool.h>
 #include <unistd.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index 2e029ebd2e54..ad48bfc25848 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -32,12 +32,10 @@
 #include <stdbool.h>
 #include <unistd.h>
 #include <cairo.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index b32a4cbb7574..92c5bf6aaa32 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -37,12 +37,10 @@
 #include "config.h"
 #endif
 
-#include <assert.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c
index 2456c2fb9b05..5233b2314816 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -33,12 +33,10 @@
  * The goal is to simply ensure the basics work.
  */
 
-#include <assert.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/tests/gem_storedw_batches_loop.c b/tests/gem_storedw_batches_loop.c
index 96b5a4dfbb58..85d6f6c076eb 100644
--- a/tests/gem_storedw_batches_loop.c
+++ b/tests/gem_storedw_batches_loop.c
@@ -83,7 +83,7 @@ store_dword_loop(int divider, unsigned flags)
 			cmd_address_offset = j * 4;
 			buf[j++] = target_bo->offset;
 		}
-		assert(j > 0);
+		igt_assert(j > 0);
 		buf[j++] = 0x42000000 + val;
 
 		igt_assert(drm_intel_bo_references(cmd_bo, target_bo) == 0);
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index a994f7f9424f..3a94fb1aa5d5 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -49,12 +49,10 @@
  * In short: designed for maximum evilness.
  */
 
-#include <assert.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/tests/gem_wait_render_timeout.c b/tests/gem_wait_render_timeout.c
index 1c6aa7d1da18..074810490c55 100644
--- a/tests/gem_wait_render_timeout.c
+++ b/tests/gem_wait_render_timeout.c
@@ -27,12 +27,10 @@
 
 #include <stdio.h>
 #include <time.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/tests/igt_simulation.c b/tests/igt_simulation.c
index b9c6241d12e4..f4007b80929e 100644
--- a/tests/igt_simulation.c
+++ b/tests/igt_simulation.c
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <sys/wait.h>
 #include <sys/types.h>
+#include <assert.h>
 
 #include "drmtest.h"
 #include "igt_core.h"
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 593bc772c327..4c1a5676a7a0 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -24,7 +24,6 @@
 #include "config.h"
 #endif
 
-#include <assert.h>
 #include <cairo.h>
 #include <errno.h>
 #include <stdint.h>
@@ -193,7 +192,7 @@ static void create_fb_for_crtc(struct crtc_config *crtc,
 	fb_id = kmstest_create_fb(drm_fd, crtc->mode.hdisplay,
 				  crtc->mode.vdisplay, bpp, depth,
 				  enable_tiling, fb_info);
-	assert(fb_id > 0);
+	igt_assert(fb_id > 0);
 }
 
 static void get_mode_for_crtc(struct crtc_config *crtc,
@@ -239,7 +238,7 @@ static int get_encoder_idx(drmModeRes *resources, drmModeEncoder *encoder)
 	for (i = 0; i < resources->count_encoders; i++)
 		if (resources->encoders[i] == encoder->encoder_id)
 			return i;
-	assert(0);
+	igt_assert(0);
 }
 
 static void get_crtc_config_str(struct crtc_config *crtc, char *buf,
@@ -304,7 +303,7 @@ static void setup_crtcs(drmModeRes *resources, struct connector_config *cconf,
 
 		crtc->cconfs = malloc(sizeof(*crtc->cconfs) *
 				      crtc->connector_count);
-		assert(crtc->cconfs);
+		igt_assert(crtc->cconfs);
 
 		encoder_mask = 0;
 		for (j = 0; j < crtc->connector_count; j++) {
@@ -318,7 +317,7 @@ static void setup_crtcs(drmModeRes *resources, struct connector_config *cconf,
 			igt_assert(connector->count_encoders == 1);
 			encoder = drmModeGetEncoder(drm_fd,
 						    connector->encoders[0]);
-			assert(encoder);
+			igt_assert(encoder);
 
 			config_valid &= !!(encoder->possible_crtcs &
 					  (1 << crtc->crtc_idx));
@@ -371,7 +370,7 @@ static uint32_t *get_connector_ids(struct crtc_config *crtc)
 	int i;
 
 	ids = malloc(sizeof(*ids) * crtc->connector_count);
-	assert(ids);
+	igt_assert(ids);
 	for (i = 0; i < crtc->connector_count; i++)
 		ids[i] = crtc->cconfs[i].connector->connector_id;
 
@@ -502,7 +501,7 @@ static int get_one_connector(drmModeRes *resources, int connector_id,
 	drmModeModeInfo mode;
 
 	connector = drmModeGetConnector(drm_fd, connector_id);
-	assert(connector);
+	igt_assert(connector);
 	cconf->connector = connector;
 
 	cconf->connected = connector->connection == DRM_MODE_CONNECTED;
@@ -543,7 +542,7 @@ static int get_connectors(drmModeRes *resources, int *connector_idxs,
 		int connector_id;
 
 		connector_idx = connector_idxs[i];
-		assert(connector_idx < resources->count_connectors);
+		igt_assert(connector_idx < resources->count_connectors);
 		connector_id = resources->connectors[connector_idx];
 
 		if (get_one_connector(resources, connector_id, &cconfs[i]) < 0)
@@ -589,7 +588,7 @@ static void iterate_combinations(int n, int k, bool allow_repetitions,
 	int v;
 
 	if (!k) {
-		assert(set->count < ARRAY_SIZE(set->items));
+		igt_assert(set->count < ARRAY_SIZE(set->items));
 		set->items[set->count++] = *comb;
 		return;
 	}
@@ -608,7 +607,7 @@ static void get_combinations(int n, int k, bool allow_repetitions,
 {
 	struct combination comb;
 
-	assert(k <= ARRAY_SIZE(set->items[0].elems));
+	igt_assert(k <= ARRAY_SIZE(set->items[0].elems));
 	set->count = 0;
 	iterate_combinations(n, k, allow_repetitions, 0, 0, &comb, set);
 }
@@ -634,7 +633,7 @@ static void test_combinations(const struct test_config *tconf,
 		int j;
 
 		cconfs = malloc(sizeof(*cconfs) * connector_count);
-		assert(cconfs);
+		igt_assert(cconfs);
 
 		connector_idxs = &connector_combs.items[i].elems[0];
 		ret = get_connectors(tconf->resources, connector_idxs,
@@ -678,7 +677,7 @@ static int opt_handler(int opt, int opt_index)
 		filter_test_id = atoi(optarg);
 		break;
 	default:
-		assert(0);
+		igt_assert(0);
 	}
 
 	return 0;
@@ -723,7 +722,7 @@ int main(int argc, char **argv)
 			igt_set_vt_graphics_mode();
 
 		drm_resources = drmModeGetResources(drm_fd);
-		assert(drm_resources);
+		igt_assert(drm_resources);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index 2f321840edcd..038987c03b28 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -197,7 +197,7 @@ static void emit_store_dword_imm(uint32_t val)
 #define LOAD_HELPER_BO_SIZE (16*1024*1024)
 static void load_helper_set_load(enum load load)
 {
-	assert(lh.igt_proc.running);
+	igt_assert(lh.igt_proc.running);
 
 	if (lh.load == load)
 		return;
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index e667ab95e294..d0cd5123ab0c 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -504,7 +504,7 @@ static void stereo_fb_layout_from_mode(struct stereo_fb_layout *layout,
 		break;
 	}
 	default:
-		assert(0);
+		igt_assert(0);
 	}
 }
 
@@ -520,7 +520,7 @@ static const char *stereo_mode_str(drmModeModeInfo *mode)
 	case DRM_MODE_FLAG_3D_FRAME_PACKING:
 		return "FP";
 	default:
-		assert(0);
+		igt_assert(0);
 	}
 }
 
diff --git a/tools/intel_l3_parity.c b/tools/intel_l3_parity.c
index 79e591043869..aed36c83b73b 100644
--- a/tools/intel_l3_parity.c
+++ b/tools/intel_l3_parity.c
@@ -28,6 +28,7 @@
 #define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <assert.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 14/28] lib: add #include "foo.h" lines like in manpages
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (12 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 13/28] tests|lib: remove assert.h includes Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 15/28] lib: remove uncessary #includes from headers Daniel Vetter
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Should help in alleviating the header mess we have atm.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/igt_core.c          | 2 ++
 lib/igt_debugfs.c       | 2 ++
 lib/intel_batchbuffer.c | 2 ++
 lib/intel_chipset.c     | 2 ++
 lib/ioctl_wrappers.c    | 2 ++
 5 files changed, 10 insertions(+)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 3ff7efa7de93..efcc4a11fcc5 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -64,6 +64,8 @@
  * @short_description: Core i-g-t testing support
  * @title: i-g-t core
  *
+ * > #include "igt_core.h"
+ *
  * This libary implements the core of the i-g-t test support infrastructure.
  * Main features are the subtest enumeration, cmdline option parsing helpers for
  * subtest handling and various helpers to structure testcases with subtests and
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 05aed15618d2..05036fc06ba2 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -39,6 +39,8 @@
  * @short_description: Support code for debugfs features
  * @title: i-g-t debugfs
  *
+ * > #include "igt_debugfs.h"
+ *
  * This library provides helpers to access debugfs features. On top of some
  * basic functions to access debugfs files with e.g. igt_debugfs_open() it also
  * provides higher-level wrappers for some debugfs features
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 3a38f13326ec..7852c7ca750f 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -46,6 +46,8 @@
  * @short_description: Batchbuffer and blitter support
  * @title: intel batchbuffer
  *
+ * > #include "intel_batchbuffer.h"
+ *
  * This library provides some basic support for batchbuffers and using the
  * blitter engine based upon libdrm. A new batchbuffer is allocated with
  * intel_batchbuffer_alloc() and for simple blitter commands submitted with
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index 5ac90d1b8ed2..b117e3be2753 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -45,6 +45,8 @@
  * @short_description: Feature macros and chipset helpers
  * @title: intel chipset
  *
+ * > #include "intel_chipset.h"
+ *
  * This library mostly provides feature macros which use raw pci device ids. It
  * also provides a few more helper functions to handle pci devices, chipset
  * detection and related issues.
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index febfc8b7ff91..147334f3286b 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -63,6 +63,8 @@
  * @short_description: ioctl wrappers and related functions
  * @title: ioctl wrappers
  *
+ * > #include "ioctl_wrappers.h"
+ *
  * This helper library contains simple functions to wrap the raw drm/i915 kernel
  * ioctls. The normal versions never pass any error codes to the caller and use
  * igt_assert() to check for error conditions instead. For some ioctls raw
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 15/28] lib: remove uncessary #includes from headers
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (13 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 14/28] lib: add #include "foo.h" lines like in manpages Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 16/28] lib: more unecessary header removal Daniel Vetter
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Only include what the header itself needs. The big fish here is
intel-gpu-tools.h. More will follow.

One ugly thing removed here is the duplicated GEN6_TD_CTL #define, one
of which was broken.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 debugger/debug_rdata.c        | 1 +
 lib/drmtest.c                 | 1 +
 lib/gen6_render.h             | 8 --------
 lib/gen7_media.h              | 2 ++
 lib/gen8_media.h              | 2 ++
 lib/igt_core.h                | 2 ++
 lib/igt_debugfs.h             | 3 +--
 lib/igt_kms.h                 | 4 ++--
 lib/intel_batchbuffer.h       | 1 +
 lib/intel_chipset.h           | 2 +-
 lib/intel_gpu_tools.h         | 5 -----
 lib/intel_iosf.c              | 1 +
 lib/intel_mmio.c              | 1 +
 lib/intel_os.c                | 1 +
 lib/intel_reg_map.c           | 1 +
 lib/media_fill_gen7.c         | 1 +
 lib/media_fill_gen8.c         | 1 +
 lib/rendercopy_gen6.c         | 1 +
 lib/rendercopy_gen7.c         | 1 +
 lib/rendercopy_gen8.c         | 1 +
 tests/ddi_compute_wrpll.c     | 1 +
 tools/intel_audio_dump.c      | 3 +++
 tools/intel_backlight.c       | 2 ++
 tools/intel_bios_reader.c     | 2 ++
 tools/intel_dpio_read.c       | 1 +
 tools/intel_dpio_write.c      | 1 +
 tools/intel_error_decode.c    | 1 +
 tools/intel_forcewaked.c      | 1 +
 tools/intel_gpu_time.c        | 2 ++
 tools/intel_gpu_top.c         | 2 ++
 tools/intel_gtt.c             | 1 +
 tools/intel_infoframes.c      | 2 ++
 tools/intel_lid.c             | 1 +
 tools/intel_nc_read.c         | 1 +
 tools/intel_nc_write.c        | 1 +
 tools/intel_opregion_decode.c | 1 +
 tools/intel_panel_fitter.c    | 2 ++
 tools/intel_punit_read.c      | 1 +
 tools/intel_punit_write.c     | 1 +
 tools/intel_reg_checker.c     | 1 +
 tools/intel_reg_dumper.c      | 3 +++
 tools/intel_reg_read.c        | 1 +
 tools/intel_reg_snapshot.c    | 1 +
 tools/intel_reg_write.c       | 1 +
 tools/intel_stepping.c        | 1 +
 tools/intel_vga_read.c        | 1 +
 tools/intel_vga_write.c       | 1 +
 47 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/debugger/debug_rdata.c b/debugger/debug_rdata.c
index f7dc4245b962..fc7682b02581 100644
--- a/debugger/debug_rdata.c
+++ b/debugger/debug_rdata.c
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 struct eu_rdata {
 	union {
diff --git a/lib/drmtest.c b/lib/drmtest.c
index c2751e75d86a..112f04977445 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -55,6 +55,7 @@
 #include "igt_debugfs.h"
 #include "../version.h"
 #include "config.h"
+#include "intel_reg.h"
 
 /* This file contains a bunch of wrapper functions to directly use gem ioctls.
  * Mostly useful to write kernel tests. */
diff --git a/lib/gen6_render.h b/lib/gen6_render.h
index 902051484588..60dc93e6434e 100644
--- a/lib/gen6_render.h
+++ b/lib/gen6_render.h
@@ -261,10 +261,6 @@
 #define GEN6_TS_STRG_VAL		       0x7e04
 #define GEN6_TS_RDATA		       0x7e08
 
-/* TD_CTL on gen6 is 0x7000, to not break stuff which depends on this... */
-#ifndef GEN6_TD_CTL
-#define GEN6_TD_CTL		       0x8000
-#endif
 #define GEN6_TD_CTL_MUX_SHIFT	       8
 #define GEN6_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH	   (1 << 7)
 #define GEN6_TD_CTL_FORCE_EXTERNAL_HALT		   (1 << 6)
@@ -570,10 +566,6 @@
 #define GEN6_TS_STRG_VAL		       0x7e04
 #define GEN6_TS_RDATA		       0x7e08
 
-/* TD_CTL on gen6 is 0x7000, to not break stuff which depends on this... */
-#ifndef GEN6_TD_CTL
-#define GEN6_TD_CTL                   0x8000
-#endif
 #define GEN6_TD_CTL_MUX_SHIFT	       8
 #define GEN6_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH	   (1 << 7)
 #define GEN6_TD_CTL_FORCE_EXTERNAL_HALT		   (1 << 6)
diff --git a/lib/gen7_media.h b/lib/gen7_media.h
index d75ee1be8864..d5f9921adbc0 100644
--- a/lib/gen7_media.h
+++ b/lib/gen7_media.h
@@ -1,6 +1,8 @@
 #ifndef GEN7_MEDIA_H
 #define GEN7_MEDIA_H
 
+#include <stdint.h>
+
 #define GEN7_SURFACEFORMAT_R32G32B32A32_FLOAT             0x000
 #define GEN7_SURFACEFORMAT_R32G32B32A32_SINT              0x001
 #define GEN7_SURFACEFORMAT_R32G32B32A32_UINT              0x002
diff --git a/lib/gen8_media.h b/lib/gen8_media.h
index b890df4e0c8d..1214cd15a066 100644
--- a/lib/gen8_media.h
+++ b/lib/gen8_media.h
@@ -1,6 +1,8 @@
 #ifndef GEN8_MEDIA_H
 #define GEN8_MEDIA_H
 
+#include <stdint.h>
+
 #define GEN8_SURFACEFORMAT_R32G32B32A32_FLOAT             0x000
 #define GEN8_SURFACEFORMAT_R32G32B32A32_SINT              0x001
 #define GEN8_SURFACEFORMAT_R32G32B32A32_UINT              0x002
diff --git a/lib/igt_core.h b/lib/igt_core.h
index a8bb28e18e33..c21448e70add 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -30,6 +30,8 @@
 #ifndef IGT_CORE_H
 #define IGT_CORE_H
 
+#include <stdbool.h>
+
 bool __igt_fixture(void);
 void __igt_fixture_complete(void);
 void __igt_fixture_end(void) __attribute__((noreturn));
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index d3d23896b50c..3312a8bdb49c 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -27,9 +27,8 @@
 
 #include <stdbool.h>
 #include <stdint.h>
-#include <stdio.h>
 
-#include "igt_display.h"
+enum pipe;
 
 int igt_debugfs_open(const char *filename, int mode);
 FILE *igt_debugfs_fopen(const char *filename,
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index df658b0b4678..6590fd58dd15 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -26,11 +26,11 @@
 #define __IGT_KMS_H__
 
 #include <stdbool.h>
-
+#include <stdint.h>
 #include <drm_fourcc.h>
 #include <cairo.h>
 
-#include <igt_display.h>
+#include "igt_display.h"
 
 struct kmstest_connector_config {
 	drmModeCrtc *crtc;
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 7764064286b9..244bdbda195d 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -4,6 +4,7 @@
 #include <stdint.h>
 #include "intel_bufmgr.h"
 #include "igt_core.h"
+#include "intel_reg.h"
 
 #define BATCH_SZ 4096
 #define BATCH_RESERVED 16
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index 2f3077881dd4..f6757d4aace2 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -28,7 +28,6 @@
 #ifndef _INTEL_CHIPSET_H
 #define _INTEL_CHIPSET_H
 
-#include <sys/types.h>
 #include <pciaccess.h>
 
 struct pci_device *intel_get_pci_device(void);
@@ -36,6 +35,7 @@ uint32_t intel_get_drm_devid(int fd);
 int intel_gen(uint32_t devid);
 
 extern enum pch_type intel_pch;
+
 enum pch_type {
 	PCH_NONE,
 	PCH_IBX,
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
index aab07290f77b..591fd3f446c3 100644
--- a/lib/intel_gpu_tools.h
+++ b/lib/intel_gpu_tools.h
@@ -29,13 +29,8 @@
 #define INTEL_GPU_TOOLS_H
 
 #include <stdint.h>
-#include <sys/types.h>
 #include <pciaccess.h>
 
-#include "intel_chipset.h"
-#include "intel_reg.h"
-#include "drmtest.h"
-
 /* register access helpers from intel_mmio.c */
 extern void *mmio;
 void intel_get_mmio(struct pci_device *pci_dev);
diff --git a/lib/intel_iosf.c b/lib/intel_iosf.c
index f57212f6cc27..b7b4ce23626c 100644
--- a/lib/intel_iosf.c
+++ b/lib/intel_iosf.c
@@ -4,6 +4,7 @@
 #include <err.h>
 #include <errno.h>
 #include "intel_gpu_tools.h"
+#include "intel_reg.h"
 
 #define TIMEOUT_US 500000
 
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 224800989189..3e1aac740a50 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -43,6 +43,7 @@
 
 #include "intel_gpu_tools.h"
 #include "igt_debugfs.h"
+#include "intel_chipset.h"
 
 #define FAKEKEY 0x2468ace0
 
diff --git a/lib/intel_os.c b/lib/intel_os.c
index ce4dcbcad5b2..4b72f5175a30 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -49,6 +49,7 @@
 
 #include "intel_gpu_tools.h"
 #include "i915_drm.h"
+#include "drmtest.h"
 
 uint64_t
 intel_get_total_ram_mb(void)
diff --git a/lib/intel_reg_map.c b/lib/intel_reg_map.c
index 26ddd0651438..ec63d79edfb9 100644
--- a/lib/intel_reg_map.c
+++ b/lib/intel_reg_map.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static struct intel_register_range gen_bwcl_register_map[] = {
 	{0x00000000, 0x00000fff, INTEL_RANGE_RW},
diff --git a/lib/media_fill_gen7.c b/lib/media_fill_gen7.c
index 520c4a22ca75..7494d44d1536 100644
--- a/lib/media_fill_gen7.c
+++ b/lib/media_fill_gen7.c
@@ -1,5 +1,6 @@
 #include "media_fill.h"
 #include "gen7_media.h"
+#include "intel_reg.h"
 
 #include <assert.h>
 
diff --git a/lib/media_fill_gen8.c b/lib/media_fill_gen8.c
index 7e0a5677762b..d65d26085b20 100644
--- a/lib/media_fill_gen8.c
+++ b/lib/media_fill_gen8.c
@@ -1,5 +1,6 @@
 #include "media_fill.h"
 #include "gen8_media.h"
+#include "intel_reg.h"
 
 #include <assert.h>
 
diff --git a/lib/rendercopy_gen6.c b/lib/rendercopy_gen6.c
index 4f5b57904d4a..a908ae6bbe38 100644
--- a/lib/rendercopy_gen6.c
+++ b/lib/rendercopy_gen6.c
@@ -18,6 +18,7 @@
 #include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen6_render.h"
+#include "intel_reg.h"
 
 #define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
 #define VERTEX_SIZE (3*4)
diff --git a/lib/rendercopy_gen7.c b/lib/rendercopy_gen7.c
index ddd6b97c7619..05e6829319a4 100644
--- a/lib/rendercopy_gen7.c
+++ b/lib/rendercopy_gen7.c
@@ -18,6 +18,7 @@
 #include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen7_render.h"
+#include "intel_reg.h"
 
 #define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
 
diff --git a/lib/rendercopy_gen8.c b/lib/rendercopy_gen8.c
index f6dd2b5b0445..ef19ebf43a60 100644
--- a/lib/rendercopy_gen8.c
+++ b/lib/rendercopy_gen8.c
@@ -18,6 +18,7 @@
 #include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen8_render.h"
+#include "intel_reg.h"
 
 #include <intel_aub.h>
 
diff --git a/tests/ddi_compute_wrpll.c b/tests/ddi_compute_wrpll.c
index 9d31ebc2301e..c1db6c08de5b 100644
--- a/tests/ddi_compute_wrpll.c
+++ b/tests/ddi_compute_wrpll.c
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 
 #include "intel_gpu_tools.h"
+#include "drmtest.h"
 
 #define LC_FREQ 2700
 #define LC_FREQ_2K (LC_FREQ * 2000)
diff --git a/tools/intel_audio_dump.c b/tools/intel_audio_dump.c
index 3ed291800e40..9762b4f7a195 100644
--- a/tools/intel_audio_dump.c
+++ b/tools/intel_audio_dump.c
@@ -34,6 +34,9 @@
 #include <err.h>
 #include <arpa/inet.h>
 #include "intel_gpu_tools.h"
+#include "intel_reg.h"
+#include "intel_chipset.h"
+#include "drmtest.h"
 
 static uint32_t devid;
 
diff --git a/tools/intel_backlight.c b/tools/intel_backlight.c
index bd7c813b2383..e2591847f548 100644
--- a/tools/intel_backlight.c
+++ b/tools/intel_backlight.c
@@ -31,6 +31,8 @@
 #include <string.h>
 
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
 
 /* XXX PCH only today */
 
diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 19b0fd92a748..8eb46f3dead6 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -37,6 +37,8 @@
 
 #include "intel_bios.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "drmtest.h"
 
 static uint32_t devid = -1;
 
diff --git a/tools/intel_dpio_read.c b/tools/intel_dpio_read.c
index 85f8a18dc59f..2196041a6ac3 100644
--- a/tools/intel_dpio_read.c
+++ b/tools/intel_dpio_read.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_dpio_write.c b/tools/intel_dpio_write.c
index e09f9947bb60..c3c682a654c8 100644
--- a/tools/intel_dpio_write.c
+++ b/tools/intel_dpio_write.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c
index fff2aed57830..b1d51b74a6fc 100644
--- a/tools/intel_error_decode.c
+++ b/tools/intel_error_decode.c
@@ -55,6 +55,7 @@
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 #include "instdone.h"
+#include "intel_reg.h"
 
 static uint32_t
 print_head(unsigned int reg)
diff --git a/tools/intel_forcewaked.c b/tools/intel_forcewaked.c
index a90e73e0f1b8..b4e7b5cc6319 100644
--- a/tools/intel_forcewaked.c
+++ b/tools/intel_forcewaked.c
@@ -35,6 +35,7 @@
 #include <syslog.h>
 #include <unistd.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 bool daemonized;
 
diff --git a/tools/intel_gpu_time.c b/tools/intel_gpu_time.c
index c30b84d200c4..0b8ca9e4c578 100644
--- a/tools/intel_gpu_time.c
+++ b/tools/intel_gpu_time.c
@@ -35,6 +35,8 @@
 #include <sys/wait.h>
 
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
 
 #define SAMPLES_PER_SEC             10000
 
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 31e080a7bf4d..ccbe9736db23 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -44,6 +44,8 @@
 #endif
 #include "intel_gpu_tools.h"
 #include "instdone.h"
+#include "intel_reg.h"
+#include "intel_chipset.h"
 
 #define  FORCEWAKE	    0xA18C
 #define  FORCEWAKE_ACK	    0x130090
diff --git a/tools/intel_gtt.c b/tools/intel_gtt.c
index a21c26a76328..f3d1c3082052 100644
--- a/tools/intel_gtt.c
+++ b/tools/intel_gtt.c
@@ -35,6 +35,7 @@
 #include <unistd.h>
 
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define KB(x) ((x) * 1024)
 #define MB(x) ((x) * 1024 * 1024)
diff --git a/tools/intel_infoframes.c b/tools/intel_infoframes.c
index 81e034337277..76dd6271e1fd 100644
--- a/tools/intel_infoframes.c
+++ b/tools/intel_infoframes.c
@@ -31,6 +31,8 @@
 #include <string.h>
 #include <getopt.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "drmtest.h"
 
 typedef enum {
 	TRANSC_A = 0,
diff --git a/tools/intel_lid.c b/tools/intel_lid.c
index 51a95fee6c06..34960461382c 100644
--- a/tools/intel_lid.c
+++ b/tools/intel_lid.c
@@ -40,6 +40,7 @@
 #include "intel_gpu_tools.h"
 #include "intel_reg.h"
 #include "intel_bios.h"
+#include "intel_chipset.h"
 
 enum lid_status {
 	LID_UNKNOWN = -1,
diff --git a/tools/intel_nc_read.c b/tools/intel_nc_read.c
index a2c2e9f71e57..0ec3e75764b9 100644
--- a/tools/intel_nc_read.c
+++ b/tools/intel_nc_read.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_nc_write.c b/tools/intel_nc_write.c
index 58be79a6c8b7..5700f67f3f2f 100644
--- a/tools/intel_nc_write.c
+++ b/tools/intel_nc_write.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_opregion_decode.c b/tools/intel_opregion_decode.c
index 8a9ef209d4da..0beece699a1d 100644
--- a/tools/intel_opregion_decode.c
+++ b/tools/intel_opregion_decode.c
@@ -38,6 +38,7 @@
 #include <sys/types.h>
 
 #include "intel_gpu_tools.h"
+#include "drmtest.h"
 
 #define OPREGION_HEADER_OFFSET		0
 #define OPREGION_ACPI_OFFSET		0x100
diff --git a/tools/intel_panel_fitter.c b/tools/intel_panel_fitter.c
index f6723d1799f8..2e3f6883d9c5 100644
--- a/tools/intel_panel_fitter.c
+++ b/tools/intel_panel_fitter.c
@@ -31,6 +31,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
 
 int gen;
 
diff --git a/tools/intel_punit_read.c b/tools/intel_punit_read.c
index 3fa2ca8cd764..187bd77c7b0c 100644
--- a/tools/intel_punit_read.c
+++ b/tools/intel_punit_read.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_punit_write.c b/tools/intel_punit_write.c
index eb036ba96a50..c0aa08530353 100644
--- a/tools/intel_punit_write.c
+++ b/tools/intel_punit_write.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_reg_checker.c b/tools/intel_reg_checker.c
index daa8d0fbe6f3..a2c76419fbcd 100644
--- a/tools/intel_reg_checker.c
+++ b/tools/intel_reg_checker.c
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdbool.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static uint32_t devid;
 static int gen;
diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index 65fe41ebf610..432892aec3ac 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -34,6 +34,9 @@
 #include <err.h>
 #include <unistd.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
+#include "drmtest.h"
 
 static uint32_t devid = 0;
 
diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c
index ae631be02eb2..961248a02db4 100644
--- a/tools/intel_reg_read.c
+++ b/tools/intel_reg_read.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void bit_decode(uint32_t reg)
 {
diff --git a/tools/intel_reg_snapshot.c b/tools/intel_reg_snapshot.c
index 9c5fa839dc61..09a95b3932c4 100644
--- a/tools/intel_reg_snapshot.c
+++ b/tools/intel_reg_snapshot.c
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <assert.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 int main(int argc, char** argv)
 {
diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c
index dd636f65dcc3..0f73a7706ece 100644
--- a/tools/intel_reg_write.c
+++ b/tools/intel_reg_write.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 int main(int argc, char** argv)
 {
diff --git a/tools/intel_stepping.c b/tools/intel_stepping.c
index f6f15d1ac082..626c5bbb0010 100644
--- a/tools/intel_stepping.c
+++ b/tools/intel_stepping.c
@@ -33,6 +33,7 @@
 #include <err.h>
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
+#include "intel_reg.h"
 
 static void
 print_clock(const char *name, int clock) {
diff --git a/tools/intel_vga_read.c b/tools/intel_vga_read.c
index 7d868195b244..40a9cdc869ca 100644
--- a/tools/intel_vga_read.c
+++ b/tools/intel_vga_read.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <sys/io.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static uint8_t read_reg(uint32_t reg, bool use_mmio)
 {
diff --git a/tools/intel_vga_write.c b/tools/intel_vga_write.c
index effca462bfd6..91af0fe5017a 100644
--- a/tools/intel_vga_write.c
+++ b/tools/intel_vga_write.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <sys/io.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void write_reg(uint32_t reg, uint8_t val, bool use_mmio)
 {
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 16/28] lib: more unecessary header removal
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (14 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 15/28] lib: remove uncessary #includes from headers Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 17/28] lib: unnecessary header removal for drmtest.h, part 1 Daniel Vetter
                   ` (12 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

This time big with media_fill.h

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/igt_core.h             |  3 +++
 lib/igt_kms.h              |  1 -
 lib/intel_batchbuffer.h    |  2 +-
 lib/media_fill.h           | 16 +---------------
 lib/media_fill_gen7.c      |  3 +++
 lib/media_fill_gen8.c      |  3 +++
 tests/kms_cursor_crc.c     |  1 +
 tests/kms_pipe_crc_basic.c |  1 +
 tests/kms_plane.c          |  1 +
 9 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/lib/igt_core.h b/lib/igt_core.h
index c21448e70add..47576da652a0 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -30,7 +30,10 @@
 #ifndef IGT_CORE_H
 #define IGT_CORE_H
 
+#include <setjmp.h>
 #include <stdbool.h>
+#include <string.h>
+#include <sys/types.h>
 
 bool __igt_fixture(void);
 void __igt_fixture_complete(void);
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 6590fd58dd15..d141cfce8504 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -27,7 +27,6 @@
 
 #include <stdbool.h>
 #include <stdint.h>
-#include <drm_fourcc.h>
 #include <cairo.h>
 
 #include "igt_display.h"
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 244bdbda195d..e11281a3248a 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -2,7 +2,7 @@
 #define INTEL_BATCHBUFFER_H
 
 #include <stdint.h>
-#include "intel_bufmgr.h"
+#include <intel_bufmgr.h>
 #include "igt_core.h"
 #include "intel_reg.h"
 
diff --git a/lib/media_fill.h b/lib/media_fill.h
index 3568cf603955..d417c75a6cdd 100644
--- a/lib/media_fill.h
+++ b/lib/media_fill.h
@@ -1,22 +1,8 @@
 #ifndef RENDE_MEDIA_FILL_H
 #define RENDE_MEDIA_FILL_H
 
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <getopt.h>
-#include "drm.h"
-#include "i915_drm.h"
-#include "drmtest.h"
-#include "intel_bufmgr.h"
+#include <stdint.h>
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
 
 void
 gen8_media_fillfunc(struct intel_batchbuffer *batch,
diff --git a/lib/media_fill_gen7.c b/lib/media_fill_gen7.c
index 7494d44d1536..cdf4b60361e7 100644
--- a/lib/media_fill_gen7.c
+++ b/lib/media_fill_gen7.c
@@ -1,3 +1,6 @@
+#include <intel_bufmgr.h>
+#include <i915_drm.h>
+
 #include "media_fill.h"
 #include "gen7_media.h"
 #include "intel_reg.h"
diff --git a/lib/media_fill_gen8.c b/lib/media_fill_gen8.c
index d65d26085b20..996d4d02a14e 100644
--- a/lib/media_fill_gen8.c
+++ b/lib/media_fill_gen8.c
@@ -1,3 +1,6 @@
+#include <intel_bufmgr.h>
+#include <i915_drm.h>
+
 #include "media_fill.h"
 #include "gen8_media.h"
 #include "intel_reg.h"
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index f95448f47356..f87fe0ba9054 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -27,6 +27,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
+#include <drm_fourcc.h>
 
 #include "drmtest.h"
 #include "igt_debugfs.h"
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 75217df4f5e1..ef3ab4083eb6 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -26,6 +26,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
+#include <drm_fourcc.h>
 
 #include "drmtest.h"
 #include "igt_debugfs.h"
diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 223f0a772021..83d45c546322 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -28,6 +28,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
+#include <drm_fourcc.h>
 
 #include "drmtest.h"
 #include "igt_debugfs.h"
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 17/28] lib: unnecessary header removal for drmtest.h, part 1
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (15 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 16/28] lib: more unecessary header removal Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 18/28] lib: unnecessary header removal for drmtest.h, part 2 Daniel Vetter
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

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

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 benchmarks/intel_upload_blit_large.c     | 1 +
 benchmarks/intel_upload_blit_large_gtt.c | 1 +
 benchmarks/intel_upload_blit_large_map.c | 1 +
 benchmarks/intel_upload_blit_small.c     | 1 +
 demos/intel_sprite_on.c                  | 7 +++----
 lib/drmtest.c                            | 1 +
 lib/drmtest.h                            | 7 -------
 lib/igt_debugfs.c                        | 1 +
 lib/igt_kms.c                            | 1 +
 lib/ioctl_wrappers.h                     | 5 +++++
 lib/rendercopy_gen7.c                    | 1 +
 tests/core_get_client_auth.c             | 2 +-
 tests/drm_vma_limiter.c                  | 3 ++-
 tests/drm_vma_limiter_cached.c           | 3 ++-
 tests/drm_vma_limiter_cpu.c              | 3 ++-
 tests/drm_vma_limiter_gtt.c              | 3 ++-
 tests/drv_suspend.c                      | 2 +-
 tests/gem_bad_address.c                  | 3 ++-
 tests/gem_bad_batch.c                    | 3 ++-
 tests/gem_bad_blit.c                     | 3 ++-
 tests/gem_bad_length.c                   | 2 +-
 tests/gem_basic.c                        | 2 +-
 tests/gem_caching.c                      | 3 ++-
 tests/gem_close_race.c                   | 3 ++-
 tests/gem_concurrent_blit.c              | 3 ++-
 tests/gem_cpu_reloc.c                    | 3 ++-
 tests/gem_cs_prefetch.c                  | 3 ++-
 tests/gem_cs_tlb.c                       | 2 +-
 tests/gem_ctx_bad_destroy.c              | 2 +-
 tests/gem_ctx_bad_exec.c                 | 2 +-
 tests/gem_ctx_basic.c                    | 3 ++-
 tests/gem_ctx_create.c                   | 2 +-
 tests/gem_ctx_exec.c                     | 2 +-
 tests/gem_double_irq_loop.c              | 3 ++-
 tests/gem_dummy_reloc_loop.c             | 3 ++-
 tests/gem_evict_alignment.c              | 3 ++-
 tests/gem_evict_everything.c             | 3 ++-
 tests/gem_exec_bad_domains.c             | 3 ++-
 tests/gem_exec_big.c                     | 2 +-
 tests/gem_exec_blt.c                     | 2 +-
 tests/gem_exec_faulting_reloc.c          | 2 +-
 tests/gem_exec_lut_handle.c              | 2 +-
 tests/gem_exec_nop.c                     | 2 +-
 tests/gem_fd_exhaustion.c                | 1 +
 tests/gem_fence_thrash.c                 | 2 +-
 tests/gem_fenced_exec_thrash.c           | 3 ++-
 tests/gem_flink.c                        | 2 +-
 tests/gem_flink_race.c                   | 2 +-
 tests/gem_gtt_cpu_tlb.c                  | 2 +-
 tests/gem_gtt_hog.c                      | 3 ++-
 tests/gem_gtt_speed.c                    | 2 +-
 tests/gem_hang.c                         | 3 ++-
 tests/gem_hangcheck_forcewake.c          | 3 ++-
 tests/gem_largeobject.c                  | 2 +-
 tests/gem_linear_blits.c                 | 3 ++-
 tests/gem_lut_handle.c                   | 2 +-
 tests/gem_madvise.c                      | 2 +-
 tests/gem_media_fill.c                   | 3 ++-
 tests/gem_mmap.c                         | 2 +-
 tests/gem_mmap_gtt.c                     | 2 +-
 tests/gem_mmap_offset_exhaustion.c       | 2 +-
 tests/gem_non_secure_batch.c             | 3 ++-
 tests/gem_partial_pwrite_pread.c         | 3 ++-
 tests/gem_persistent_relocs.c            | 3 ++-
 tests/gem_pin.c                          | 2 +-
 tests/gem_pipe_control_store_loop.c      | 3 ++-
 tests/gem_pread.c                        | 2 +-
 tests/gem_pread_after_blit.c             | 3 ++-
 tests/gem_pwrite.c                       | 2 +-
 tests/gem_pwrite_pread.c                 | 3 ++-
 tests/gem_readwrite.c                    | 2 +-
 tests/gem_reg_read.c                     | 2 +-
 tests/gem_reloc_overflow.c               | 3 ++-
 tests/gem_reloc_vs_gpu.c                 | 3 ++-
 tests/gem_render_copy.c                  | 3 ++-
 tests/gem_render_linear_blits.c          | 4 +++-
 tests/gem_render_tiled_blits.c           | 3 ++-
 tests/gem_reset_stats.c                  | 3 ++-
 tests/gem_ring_sync_copy.c               | 3 ++-
 tests/gem_ring_sync_loop.c               | 3 ++-
 tests/gem_ringfill.c                     | 3 ++-
 tests/gem_seqno_wrap.c                   | 3 ++-
 tests/gem_set_tiling_vs_blt.c            | 3 ++-
 tests/gem_set_tiling_vs_gtt.c            | 3 ++-
 tests/gem_set_tiling_vs_pwrite.c         | 2 +-
 tests/gem_storedw_batches_loop.c         | 3 ++-
 tests/gem_storedw_loop_blt.c             | 3 ++-
 tests/gem_storedw_loop_bsd.c             | 3 ++-
 tests/gem_storedw_loop_render.c          | 3 ++-
 tests/gem_storedw_loop_vebox.c           | 3 ++-
 tests/gem_stress.c                       | 3 ++-
 tests/gem_threaded_access_tiled.c        | 2 +-
 tests/gem_tiled_blits.c                  | 3 ++-
 tests/gem_tiled_fence_blits.c            | 3 ++-
 tests/gem_tiled_partial_pwrite_pread.c   | 3 ++-
 tests/gem_tiled_pread.c                  | 3 ++-
 tests/gem_tiled_pread_pwrite.c           | 2 +-
 tests/gem_tiled_swapping.c               | 2 +-
 tests/gem_tiling_max_stride.c            | 3 ++-
 tests/gem_unfence_active_buffers.c       | 3 ++-
 tests/gem_unref_active_buffers.c         | 3 ++-
 tests/gem_vmap_blits.c                   | 2 +-
 tests/gem_wait_render_timeout.c          | 3 ++-
 tests/gem_write_read_ring_switch.c       | 3 ++-
 tests/gen3_mixed_blits.c                 | 3 ++-
 tests/gen3_render_linear_blits.c         | 3 ++-
 tests/gen3_render_mixed_blits.c          | 3 ++-
 tests/gen3_render_tiledx_blits.c         | 3 ++-
 tests/gen3_render_tiledy_blits.c         | 3 ++-
 tests/gen7_forcewake_mt.c                | 3 ++-
 tests/kms_addfb.c                        | 2 +-
 tests/kms_fbc_crc.c                      | 4 +++-
 tests/kms_flip.c                         | 6 ++++--
 tests/kms_render.c                       | 5 ++++-
 tests/pm_lpsp.c                          | 2 ++
 tests/pm_pc8.c                           | 3 ++-
 tests/pm_rps.c                           | 3 +++
 tests/prime_nv_api.c                     | 1 +
 tests/prime_nv_pcopy.c                   | 3 ++-
 tests/prime_nv_test.c                    | 3 ++-
 tests/prime_self_import.c                | 2 +-
 tests/prime_udl.c                        | 3 ++-
 tests/testdisplay.c                      | 2 +-
 tools/intel_perf_counters.c              | 1 +
 124 files changed, 208 insertions(+), 120 deletions(-)

diff --git a/benchmarks/intel_upload_blit_large.c b/benchmarks/intel_upload_blit_large.c
index 4d1b66f2c1a5..b44433f9a30d 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 6f864cbd57e6..4910710223a3 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 97b825dd3ae1..93433fc95db1 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 3fd095f3d922..e2f804bbdf06 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 98c0af912c9b..fb375f4f2b62 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 112f04977445..c6f7bdebe006 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 d048ee095386..4c55068ee54c 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 05036fc06ba2..f467ce0f3992 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 ac27d7ae1534..88ee83be2f91 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 6e3eb0f2d0dc..8ca218148b6b 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 05e6829319a4..75e0571618fc 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 566a6580ce72..eef97e029a2d 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 b38037ad466f..f14ced8c85b6 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 3a78436d6d16..7c40541c5ff5 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 77a50b1d3219..4da4673752cd 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 5104b0da43de..283bf6b47df8 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 ff8a348bdd77..ed393af40d13 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 6e5f0254b176..58819357bf2a 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 abeda881bc86..5bb08b442b5c 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 c518b4fd3350..ec414eaff7dc 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 ae48d5529289..4b93cdeb1031 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 5d8f840683cd..71d29ae79191 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 d788891b5336..da6f2d8f02f7 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 2087fed6080d..e46e2c150f9f 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 254bc4c265a3..29f42c7dc2d6 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 6e1f88861d8d..77d9109eef2c 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 9ff65732b3e7..842e4276dd84 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 6f1fd5b543a3..7d5c99dc67dd 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 3fcc946eae78..092f34221061 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 834b5fe30720..f0bb0fc9cc34 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 4340000e25a1..3dbef2bd767c 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 d7a45387c86a..f32c2287f8d9 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 8a20181bb7a2..3afa7652c8e9 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 47784adda578..f5c762962a43 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 955de96f8280..7c9da637e89c 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 c478f18e0e3a..46da5ba1fcd4 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 ad33c0ae2a04..c595302ecb89 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 e0e13de5e765..0000e9edd144 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 4be8559fc21b..707531643036 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 bac11f10f3fa..6c3ea37d60bb 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 d5ca18cf6ce2..51e5b6ed1ed3 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 c27e4d58f5d7..d0e212642f84 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 868f010e721e..28ec66b3b151 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 afaa10077e76..7d865d4278cc 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 86ee5bec30ce..9c1ff1c5396b 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 6b3608e06929..cd53cafc5fdf 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 4b3b7c2f69c3..339f7f1d2233 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 195ec1513d61..26c71cecce07 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 d66402589d5b..c087a37934a7 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 c7206dca45c9..7fd22bd01f30 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 2f70276fcb05..6ebe275e5fb4 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 a675eaed0048..5b1f5dc81be1 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 cd51d6ca6fc5..d1bf000efb7a 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 5f0bb558e7b2..c01045e5a8d4 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 e76de02a6d13..a7e398fb7d95 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 10fa22bd1509..e682ccf76470 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 17e59754c3b3..04a82aa355b1 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 220f8629ea5d..68bbdf23adf0 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 4c5be8fac074..a1b00fa5cf36 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 5f9e6382e8a2..7ba5e39c6ce9 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 670ca466323d..d5939ecbdfd2 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 101b9dcf1e5a..1d96222dc58b 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 0f4c9aed468d..c246537341c8 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 50d8e0e3fb11..1a705fad8fff 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 860e56524d8b..e57ddcc4c740 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 f4c03bad9631..41bfc1b0e40a 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 d1baf541fa6f..5f8246b4b9c9 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 eb8fd3a4854f..f263286c0f49 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 d04535b919ef..4d47f6f229df 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 db939b6ea3fe..c3314e48bc89 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 149254a2e514..5260fb962db7 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 a88c6a461c77..19f1351b3fd1 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 fa7baab5f0d0..98b7dd4a7b0c 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 34e81a20c094..07c79b33d937 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 ad48bfc25848..54f971d127b7 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 92c5bf6aaa32..ac2b29b00d14 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 5233b2314816..8481e51d3bda 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 8ac93a898243..90befd70a527 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 b8b1454c90e5..768d02d0d0f9 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 95fcd305a72b..5010d3562142 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 ef98701c5b7c..716ff5692cf7 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 f97403249374..19c0201e21ba 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 7335da87c017..1ad0e5c1e91b 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 5dc90aea57d1..abe096396d57 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 4ef372013e8c..d07ebafc3fa6 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 85d6f6c076eb..f07085c46a01 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 d08f5b0d50fe..b242b292017a 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 079b139f42d9..482e276b0158 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 2dc16b107925..7cbc0a80d08c 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 aa1987ac7ccc..872d4b2aa56b 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 3a94fb1aa5d5..d6434bcc5b63 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 cf07daf42fa0..3752a1f647a5 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 e21fc7894c0f..00b695549b35 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 b33be58c3e1b..3dfcf0039dba 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 bcae6e9e307a..322cca9d8794 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 0592b8c0bc8f..6f104a6ca38b 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 09d3ea4c9323..06c32fcc1fde 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 e8fcc7ef1ea0..28d21d458e68 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 e4b58dcb2670..ded965aef0ef 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 b79b124abf2d..9ccabe9fd29b 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 1e9e2146daff..8906705756ea 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 48297afc5e98..4fb2a215e3d5 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 074810490c55..d4c12fee17c8 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 524d6fb0de6e..cd235c95c190 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 17ccf202ce47..64041a0ec29b 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 129b5068388f..eed3ba5e47f1 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 d60e72612581..ac5452a8cde7 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 427a5c7185f7..1b2a00c50880 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 a82f994f1895..803054138002 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 db5dd3e0ff51..03eb6e92625f 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 3f727cc00eef..349e7fb96b62 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 07a572d2d488..db595c72036c 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 70d67e572059..d5292e8924e1 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 e661753e3abf..7bff958b876c 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 ede9149514a3..1dc7a73f5dae 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 c672e809d04e..5a1e74700760 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 038987c03b28..e6ab37907e8e 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 e2448befff02..c510c1cfe3bb 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 fd2018ba3e1f..3f3814afc786 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 640515b4bebb..ee54e7a6eb6c 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 2566af98e6f6..efdd24f6f2f7 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 d85308515873..892a952795a7 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 d0cd5123ab0c..b70287ec958a 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 23d9ed3a0006..c31111e60bbb 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
 
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 18/28] lib: unnecessary header removal for drmtest.h, part 2
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (16 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 17/28] lib: unnecessary header removal for drmtest.h, part 1 Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 19/28] lib: rename intel_gpu_tools.h to intel_io.h Daniel Vetter
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

I've left unistd.h in it - it's not strictly required but most users
of drmtest.h want it for the open helpers, and then you kinda need to
close that file descriptor again ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 benchmarks/intel_upload_blit_large.c | 6 ++++--
 lib/drmtest.h                        | 9 +++------
 lib/igt_core.c                       | 2 +-
 lib/igt_core.h                       | 2 ++
 lib/igt_debugfs.c                    | 1 +
 lib/igt_kms.c                        | 6 +++++-
 lib/igt_kms.h                        | 2 ++
 lib/ioctl_wrappers.c                 | 1 +
 tests/core_getclient.c               | 3 +++
 tests/core_getstats.c                | 5 +++++
 tests/gem_ctx_bad_destroy.c          | 2 ++
 tests/gem_ctx_create.c               | 2 ++
 tests/gem_fenced_exec_thrash.c       | 4 +++-
 tests/gem_flink_race.c               | 1 +
 tests/gem_reg_read.c                 | 2 ++
 tests/gem_seqno_wrap.c               | 1 +
 tests/gem_vmap_blits.c               | 1 +
 tests/igt_simulation.c               | 1 +
 tests/pm_psr.c                       | 2 ++
 tests/pm_rc6_residency.c             | 2 ++
 tests/pm_rps.c                       | 1 +
 tests/prime_udl.c                    | 3 ++-
 22 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/benchmarks/intel_upload_blit_large.c b/benchmarks/intel_upload_blit_large.c
index b44433f9a30d..40bdbcfb8fe3 100644
--- a/benchmarks/intel_upload_blit_large.c
+++ b/benchmarks/intel_upload_blit_large.c
@@ -53,8 +53,10 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "i915_drm.h"
+
+#include <drm.h>
+#include <i915_drm.h>
+
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 4c55068ee54c..97d60d0c29dd 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -28,16 +28,13 @@
 #ifndef DRMTEST_H
 #define DRMTEST_H
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
-#include <errno.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <sys/mman.h>
 
-#include "xf86drm.h"
-#include "xf86drmMode.h"
-#include "intel_batchbuffer.h"
+#include <xf86drm.h>
+#include <intel_batchbuffer.h>
 
 #ifdef ANDROID
 #ifndef HAVE_MMAP64
diff --git a/lib/igt_core.c b/lib/igt_core.c
index efcc4a11fcc5..81e37313fb45 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -48,9 +48,9 @@
 #include <sys/syscall.h>
 #include <sys/utsname.h>
 #include <termios.h>
+#include <errno.h>
 
 #include "drmtest.h"
-#include "i915_drm.h"
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 #include "igt_debugfs.h"
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 47576da652a0..7ede0d37a540 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -32,8 +32,10 @@
 
 #include <setjmp.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#include <stdarg.h>
 
 bool __igt_fixture(void);
 void __igt_fixture_complete(void);
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index f467ce0f3992..96adf396887b 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -27,6 +27,7 @@
 #include <sys/mount.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 88ee83be2f91..f74f7070d040 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -23,14 +23,18 @@
  */
 
 #define _GNU_SOURCE
+#include <unistd.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <string.h>
+#include <stdlib.h>
 #include <math.h>
 #include <linux/kd.h>
-#include "drm_fourcc.h"
+#include <errno.h>
+
+#include <drm_fourcc.h>
 
 #include "drmtest.h"
 #include "igt_kms.h"
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index d141cfce8504..95735e8ffdd7 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -29,6 +29,8 @@
 #include <stdint.h>
 #include <cairo.h>
 
+#include <xf86drmMode.h>
+
 #include "igt_display.h"
 
 struct kmstest_connector_config {
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 147334f3286b..5806f2a13bd8 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -47,6 +47,7 @@
 #include <sys/syscall.h>
 #include <sys/utsname.h>
 #include <termios.h>
+#include <errno.h>
 
 #include "drmtest.h"
 #include "i915_drm.h"
diff --git a/tests/core_getclient.c b/tests/core_getclient.c
index 22f0ab2e2b69..ed46e51924ea 100644
--- a/tests/core_getclient.c
+++ b/tests/core_getclient.c
@@ -27,6 +27,9 @@
 
 #include <limits.h>
 #include <sys/ioctl.h>
+#include <stdlib.h>
+#include <errno.h>
+
 #include "drmtest.h"
 
 /**
diff --git a/tests/core_getstats.c b/tests/core_getstats.c
index cce8271b561d..1e2c5651d5eb 100644
--- a/tests/core_getstats.c
+++ b/tests/core_getstats.c
@@ -27,6 +27,11 @@
 
 #include <limits.h>
 #include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <drm.h>
+
+#include "igt_core.h"
 #include "drmtest.h"
 
 /**
diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c
index 092f34221061..97a706660dc1 100644
--- a/tests/gem_ctx_bad_destroy.c
+++ b/tests/gem_ctx_bad_destroy.c
@@ -31,6 +31,8 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <errno.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index f32c2287f8d9..57494fc44638 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -27,6 +27,8 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <errno.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 
diff --git a/tests/gem_fenced_exec_thrash.c b/tests/gem_fenced_exec_thrash.c
index cd53cafc5fdf..2ba85f2bcb5a 100644
--- a/tests/gem_fenced_exec_thrash.c
+++ b/tests/gem_fenced_exec_thrash.c
@@ -33,9 +33,11 @@
 #include <string.h>
 #include <fcntl.h>
 #include <inttypes.h>
+#include <errno.h>
+
 #include <drm.h>
-#include "ioctl_wrappers.h"
 
+#include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c
index 26c71cecce07..3353b83e6acd 100644
--- a/tests/gem_flink_race.c
+++ b/tests/gem_flink_race.c
@@ -31,6 +31,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <pthread.h>
+#include <errno.h>
 
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
diff --git a/tests/gem_reg_read.c b/tests/gem_reg_read.c
index 19f1351b3fd1..b4a6650a64d4 100644
--- a/tests/gem_reg_read.c
+++ b/tests/gem_reg_read.c
@@ -27,6 +27,8 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <errno.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index 19c0201e21ba..30d1a8687090 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -41,6 +41,7 @@
 #include <wordexp.h>
 #include <getopt.h>
 #include <signal.h>
+#include <errno.h>
 
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
diff --git a/tests/gem_vmap_blits.c b/tests/gem_vmap_blits.c
index 4fb2a215e3d5..157d67460e6c 100644
--- a/tests/gem_vmap_blits.c
+++ b/tests/gem_vmap_blits.c
@@ -43,6 +43,7 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
diff --git a/tests/igt_simulation.c b/tests/igt_simulation.c
index f4007b80929e..d3331176cf2c 100644
--- a/tests/igt_simulation.c
+++ b/tests/igt_simulation.c
@@ -29,6 +29,7 @@
 #include <sys/wait.h>
 #include <sys/types.h>
 #include <assert.h>
+#include <errno.h>
 
 #include "drmtest.h"
 #include "igt_core.h"
diff --git a/tests/pm_psr.c b/tests/pm_psr.c
index 5d28c7a59a3b..4ba121f10a38 100644
--- a/tests/pm_psr.c
+++ b/tests/pm_psr.c
@@ -29,6 +29,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
+
 #include "drmtest.h"
 
 #define SLEEP_DURATION 5000 // in milliseconds
diff --git a/tests/pm_rc6_residency.c b/tests/pm_rc6_residency.c
index 3fd9d47e9db3..84eb8a909019 100644
--- a/tests/pm_rc6_residency.c
+++ b/tests/pm_rc6_residency.c
@@ -30,6 +30,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
+
 #include "drmtest.h"
 
 #define SLEEP_DURATION 3000 // in milliseconds
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index e6ab37907e8e..1f4b284cd42a 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -34,6 +34,7 @@
 #include <getopt.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <errno.h>
 
 #include "drmtest.h"
 #include "intel_gpu_tools.h"
diff --git a/tests/prime_udl.c b/tests/prime_udl.c
index 892a952795a7..96661fcb501f 100644
--- a/tests/prime_udl.c
+++ b/tests/prime_udl.c
@@ -24,7 +24,8 @@
 #include <errno.h>
 
 #include "xf86drm.h"
-#include "xf86drmMode.h"
+#include <xf86drmMode.h>
+
 #include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
 #include "intel_gpu_tools.h"
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 19/28] lib: rename intel_gpu_tools.h to intel_io.h
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (17 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 18/28] lib: unnecessary header removal for drmtest.h, part 2 Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 20/28] lib/intel_io: rename mmio setup functions Daniel Vetter
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

With the header cleanup we can now give this header a suitable name,
since it now really only contains register access and other I/O
functions and assorted definitions.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 benchmarks/intel_upload_blit_large.c               |  2 +-
 benchmarks/intel_upload_blit_large_gtt.c           |  2 +-
 benchmarks/intel_upload_blit_large_map.c           |  2 +-
 benchmarks/intel_upload_blit_small.c               |  2 +-
 debugger/debug_rdata.c                             |  2 +-
 debugger/eudb.c                                    |  2 +-
 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |  2 +-
 lib/Makefile.sources                               |  2 +-
 lib/drmtest.c                                      |  2 +-
 lib/igt_core.c                                     |  2 +-
 lib/intel_gpu_tools.h                              | 87 ----------------------
 lib/intel_io.h                                     | 87 ++++++++++++++++++++++
 lib/intel_iosf.c                                   |  2 +-
 lib/intel_mmio.c                                   |  2 +-
 lib/intel_os.c                                     |  2 +-
 lib/intel_reg_map.c                                |  2 +-
 lib/ioctl_wrappers.c                               |  2 +-
 lib/rendercopy_gen6.c                              |  2 +-
 lib/rendercopy_gen7.c                              |  2 +-
 lib/rendercopy_gen8.c                              |  2 +-
 lib/rendercopy_i830.c                              |  2 +-
 lib/rendercopy_i915.c                              |  2 +-
 tests/ddi_compute_wrpll.c                          |  2 +-
 tests/drm_vma_limiter.c                            |  2 +-
 tests/drm_vma_limiter_cached.c                     |  2 +-
 tests/drm_vma_limiter_cpu.c                        |  2 +-
 tests/drm_vma_limiter_gtt.c                        |  2 +-
 tests/gem_bad_address.c                            |  2 +-
 tests/gem_bad_batch.c                              |  2 +-
 tests/gem_bad_blit.c                               |  2 +-
 tests/gem_caching.c                                |  2 +-
 tests/gem_concurrent_blit.c                        |  2 +-
 tests/gem_cpu_reloc.c                              |  2 +-
 tests/gem_cs_prefetch.c                            |  2 +-
 tests/gem_cs_tlb.c                                 |  2 +-
 tests/gem_ctx_basic.c                              |  2 +-
 tests/gem_double_irq_loop.c                        |  2 +-
 tests/gem_dummy_reloc_loop.c                       |  2 +-
 tests/gem_exec_bad_domains.c                       |  2 +-
 tests/gem_exec_blt.c                               |  2 +-
 tests/gem_exec_faulting_reloc.c                    |  2 +-
 tests/gem_exec_nop.c                               |  2 +-
 tests/gem_fenced_exec_thrash.c                     |  2 +-
 tests/gem_gtt_cpu_tlb.c                            |  2 +-
 tests/gem_hang.c                                   |  2 +-
 tests/gem_hangcheck_forcewake.c                    |  2 +-
 tests/gem_linear_blits.c                           |  2 +-
 tests/gem_media_fill.c                             |  2 +-
 tests/gem_non_secure_batch.c                       |  2 +-
 tests/gem_partial_pwrite_pread.c                   |  2 +-
 tests/gem_persistent_relocs.c                      |  2 +-
 tests/gem_pin.c                                    |  2 +-
 tests/gem_pipe_control_store_loop.c                |  2 +-
 tests/gem_pread_after_blit.c                       |  2 +-
 tests/gem_pwrite_pread.c                           |  2 +-
 tests/gem_reloc_overflow.c                         |  2 +-
 tests/gem_reloc_vs_gpu.c                           |  2 +-
 tests/gem_render_copy.c                            |  2 +-
 tests/gem_render_linear_blits.c                    |  2 +-
 tests/gem_render_tiled_blits.c                     |  2 +-
 tests/gem_reset_stats.c                            |  2 +-
 tests/gem_ring_sync_loop.c                         |  2 +-
 tests/gem_ringfill.c                               |  2 +-
 tests/gem_seqno_wrap.c                             |  2 +-
 tests/gem_set_tiling_vs_blt.c                      |  2 +-
 tests/gem_set_tiling_vs_gtt.c                      |  2 +-
 tests/gem_set_tiling_vs_pwrite.c                   |  2 +-
 tests/gem_storedw_batches_loop.c                   |  2 +-
 tests/gem_storedw_loop_blt.c                       |  2 +-
 tests/gem_storedw_loop_bsd.c                       |  2 +-
 tests/gem_storedw_loop_render.c                    |  2 +-
 tests/gem_storedw_loop_vebox.c                     |  2 +-
 tests/gem_stress.c                                 |  2 +-
 tests/gem_tiled_blits.c                            |  2 +-
 tests/gem_tiled_fence_blits.c                      |  2 +-
 tests/gem_tiled_partial_pwrite_pread.c             |  2 +-
 tests/gem_tiled_pread.c                            |  2 +-
 tests/gem_tiled_pread_pwrite.c                     |  2 +-
 tests/gem_tiled_swapping.c                         |  2 +-
 tests/gem_tiling_max_stride.c                      |  2 +-
 tests/gem_unfence_active_buffers.c                 |  2 +-
 tests/gem_unref_active_buffers.c                   |  2 +-
 tests/gem_vmap_blits.c                             |  2 +-
 tests/gem_wait_render_timeout.c                    |  2 +-
 tests/gem_write_read_ring_switch.c                 |  2 +-
 tests/gen3_mixed_blits.c                           |  2 +-
 tests/gen3_render_linear_blits.c                   |  2 +-
 tests/gen3_render_mixed_blits.c                    |  2 +-
 tests/gen3_render_tiledx_blits.c                   |  2 +-
 tests/gen3_render_tiledy_blits.c                   |  2 +-
 tests/gen7_forcewake_mt.c                          |  2 +-
 tests/kms_render.c                                 |  2 +-
 tests/kms_setmode.c                                |  2 +-
 tests/pm_lpsp.c                                    |  2 +-
 tests/pm_pc8.c                                     |  2 +-
 tests/pm_rps.c                                     |  2 +-
 tests/prime_nv_api.c                               |  2 +-
 tests/prime_nv_pcopy.c                             |  2 +-
 tests/prime_nv_test.c                              |  2 +-
 tests/prime_udl.c                                  |  2 +-
 tools/intel_audio_dump.c                           |  2 +-
 tools/intel_backlight.c                            |  2 +-
 tools/intel_bios_reader.c                          |  2 +-
 tools/intel_dpio_read.c                            |  2 +-
 tools/intel_dpio_write.c                           |  2 +-
 tools/intel_error_decode.c                         |  2 +-
 tools/intel_forcewaked.c                           |  2 +-
 tools/intel_framebuffer_dump.c                     |  2 +-
 tools/intel_gpu_time.c                             |  2 +-
 tools/intel_gpu_top.c                              |  2 +-
 tools/intel_gtt.c                                  |  2 +-
 tools/intel_infoframes.c                           |  2 +-
 tools/intel_l3_parity.c                            |  2 +-
 tools/intel_lid.c                                  |  2 +-
 tools/intel_nc_read.c                              |  2 +-
 tools/intel_nc_write.c                             |  2 +-
 tools/intel_opregion_decode.c                      |  2 +-
 tools/intel_panel_fitter.c                         |  2 +-
 tools/intel_perf_counters.c                        |  2 +-
 tools/intel_punit_read.c                           |  2 +-
 tools/intel_punit_write.c                          |  2 +-
 tools/intel_reg_checker.c                          |  2 +-
 tools/intel_reg_dumper.c                           |  2 +-
 tools/intel_reg_read.c                             |  2 +-
 tools/intel_reg_snapshot.c                         |  2 +-
 tools/intel_reg_write.c                            |  2 +-
 tools/intel_stepping.c                             |  2 +-
 tools/intel_vga_read.c                             |  2 +-
 tools/intel_vga_write.c                            |  2 +-
 129 files changed, 214 insertions(+), 214 deletions(-)
 delete mode 100644 lib/intel_gpu_tools.h
 create mode 100644 lib/intel_io.h

diff --git a/benchmarks/intel_upload_blit_large.c b/benchmarks/intel_upload_blit_large.c
index 40bdbcfb8fe3..e12a2b1122ff 100644
--- a/benchmarks/intel_upload_blit_large.c
+++ b/benchmarks/intel_upload_blit_large.c
@@ -60,7 +60,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define OBJECT_WIDTH	1280
diff --git a/benchmarks/intel_upload_blit_large_gtt.c b/benchmarks/intel_upload_blit_large_gtt.c
index 4910710223a3..c06c56c66cb1 100644
--- a/benchmarks/intel_upload_blit_large_gtt.c
+++ b/benchmarks/intel_upload_blit_large_gtt.c
@@ -58,7 +58,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define OBJECT_WIDTH	1280
diff --git a/benchmarks/intel_upload_blit_large_map.c b/benchmarks/intel_upload_blit_large_map.c
index 93433fc95db1..18d2dfe41d49 100644
--- a/benchmarks/intel_upload_blit_large_map.c
+++ b/benchmarks/intel_upload_blit_large_map.c
@@ -61,7 +61,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define OBJECT_WIDTH	1280
diff --git a/benchmarks/intel_upload_blit_small.c b/benchmarks/intel_upload_blit_small.c
index e2f804bbdf06..05590b13afe7 100644
--- a/benchmarks/intel_upload_blit_small.c
+++ b/benchmarks/intel_upload_blit_small.c
@@ -54,7 +54,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 /* Happens to be 128k, the size of the VBOs used by i965's Mesa driver. */
diff --git a/debugger/debug_rdata.c b/debugger/debug_rdata.c
index fc7682b02581..61d82d9e51ad 100644
--- a/debugger/debug_rdata.c
+++ b/debugger/debug_rdata.c
@@ -28,7 +28,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 struct eu_rdata {
diff --git a/debugger/eudb.c b/debugger/eudb.c
index 4cbc2d7b8822..0e810db10aa8 100644
--- a/debugger/eudb.c
+++ b/debugger/eudb.c
@@ -44,7 +44,7 @@
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "intel_bufmgr.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_batchbuffer.h"
 #include "intel_debug.h"
 #include "debug.h"
diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index 0f117f71c9f9..bf196f27dfd4 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -23,7 +23,7 @@
     <xi:include href="xml/ioctl_wrappers.xml"/>
     <xi:include href="xml/intel_batchbuffer.xml"/>
     <xi:include href="xml/intel_chipset.xml"/>
-    <xi:include href="xml/intel_gpu_tools.xml"/>
+    <xi:include href="xml/intel_io.xml"/>
 
   </chapter>
   <index id="api-index-full">
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index e3942aceab2d..3e2a4b5b9c55 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -16,7 +16,7 @@ libintel_tools_la_SOURCES = 	\
 	intel_batchbuffer.h	\
 	intel_chipset.h		\
 	intel_os.c		\
-	intel_gpu_tools.h	\
+	intel_io.h		\
 	intel_mmio.c		\
 	intel_chipset.c		\
 	intel_reg.h		\
diff --git a/lib/drmtest.c b/lib/drmtest.c
index c6f7bdebe006..3c72ac8dba2c 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -51,7 +51,7 @@
 #include "drmtest.h"
 #include "i915_drm.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "igt_debugfs.h"
 #include "../version.h"
 #include "config.h"
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 81e37313fb45..cd094c431e3d 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -52,7 +52,7 @@
 
 #include "drmtest.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "igt_debugfs.h"
 #include "../version.h"
 #include "config.h"
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
deleted file mode 100644
index 591fd3f446c3..000000000000
--- a/lib/intel_gpu_tools.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Eric Anholt <eric@anholt.net>
- *
- */
-
-#ifndef INTEL_GPU_TOOLS_H
-#define INTEL_GPU_TOOLS_H
-
-#include <stdint.h>
-#include <pciaccess.h>
-
-/* register access helpers from intel_mmio.c */
-extern void *mmio;
-void intel_get_mmio(struct pci_device *pci_dev);
-void intel_map_file(char *);
-
-int intel_register_access_init(struct pci_device *pci_dev, int safe);
-void intel_register_access_fini(void);
-uint32_t intel_register_read(uint32_t reg);
-void intel_register_write(uint32_t reg, uint32_t val);
-int intel_register_access_needs_fakewake(void);
-
-static inline uint32_t
-INREG(uint32_t reg)
-{
-	return *(volatile uint32_t *)((volatile char *)mmio + reg);
-}
-
-static inline void
-OUTREG(uint32_t reg, uint32_t val)
-{
-	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
-}
-
-/* sideband access functions from intel_iosf.c */
-uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
-void intel_dpio_reg_write(uint32_t reg, uint32_t val, int phy);
-
-int intel_punit_read(uint8_t addr, uint32_t *val);
-int intel_punit_write(uint8_t addr, uint32_t val);
-int intel_nc_read(uint8_t addr, uint32_t *val);
-int intel_nc_write(uint8_t addr, uint32_t val);
-
-/* register maps from intel_reg_map.c */
-#define INTEL_RANGE_RSVD	(0<<0) /*  Shouldn't be read or written */
-#define INTEL_RANGE_READ	(1<<0)
-#define INTEL_RANGE_WRITE	(1<<1)
-#define INTEL_RANGE_RW		(INTEL_RANGE_READ | INTEL_RANGE_WRITE)
-#define INTEL_RANGE_END		(1<<31)
-
-struct intel_register_range {
-	uint32_t base;
-	uint32_t size;
-	uint32_t flags;
-};
-
-struct intel_register_map {
-	struct intel_register_range *map;
-	uint32_t top;
-	uint32_t alignment_mask;
-};
-struct intel_register_map intel_get_register_map(uint32_t devid);
-struct intel_register_range *intel_get_register_range(struct intel_register_map map, uint32_t offset, uint32_t mode);
-
-#endif /* INTEL_GPU_TOOLS_H */
diff --git a/lib/intel_io.h b/lib/intel_io.h
new file mode 100644
index 000000000000..591fd3f446c3
--- /dev/null
+++ b/lib/intel_io.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#ifndef INTEL_GPU_TOOLS_H
+#define INTEL_GPU_TOOLS_H
+
+#include <stdint.h>
+#include <pciaccess.h>
+
+/* register access helpers from intel_mmio.c */
+extern void *mmio;
+void intel_get_mmio(struct pci_device *pci_dev);
+void intel_map_file(char *);
+
+int intel_register_access_init(struct pci_device *pci_dev, int safe);
+void intel_register_access_fini(void);
+uint32_t intel_register_read(uint32_t reg);
+void intel_register_write(uint32_t reg, uint32_t val);
+int intel_register_access_needs_fakewake(void);
+
+static inline uint32_t
+INREG(uint32_t reg)
+{
+	return *(volatile uint32_t *)((volatile char *)mmio + reg);
+}
+
+static inline void
+OUTREG(uint32_t reg, uint32_t val)
+{
+	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
+}
+
+/* sideband access functions from intel_iosf.c */
+uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
+void intel_dpio_reg_write(uint32_t reg, uint32_t val, int phy);
+
+int intel_punit_read(uint8_t addr, uint32_t *val);
+int intel_punit_write(uint8_t addr, uint32_t val);
+int intel_nc_read(uint8_t addr, uint32_t *val);
+int intel_nc_write(uint8_t addr, uint32_t val);
+
+/* register maps from intel_reg_map.c */
+#define INTEL_RANGE_RSVD	(0<<0) /*  Shouldn't be read or written */
+#define INTEL_RANGE_READ	(1<<0)
+#define INTEL_RANGE_WRITE	(1<<1)
+#define INTEL_RANGE_RW		(INTEL_RANGE_READ | INTEL_RANGE_WRITE)
+#define INTEL_RANGE_END		(1<<31)
+
+struct intel_register_range {
+	uint32_t base;
+	uint32_t size;
+	uint32_t flags;
+};
+
+struct intel_register_map {
+	struct intel_register_range *map;
+	uint32_t top;
+	uint32_t alignment_mask;
+};
+struct intel_register_map intel_get_register_map(uint32_t devid);
+struct intel_register_range *intel_get_register_range(struct intel_register_map map, uint32_t offset, uint32_t mode);
+
+#endif /* INTEL_GPU_TOOLS_H */
diff --git a/lib/intel_iosf.c b/lib/intel_iosf.c
index b7b4ce23626c..ea7a320a5647 100644
--- a/lib/intel_iosf.c
+++ b/lib/intel_iosf.c
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <err.h>
 #include <errno.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_reg.h"
 
 #define TIMEOUT_US 500000
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 3e1aac740a50..444e44507eac 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -41,7 +41,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "igt_debugfs.h"
 #include "intel_chipset.h"
 
diff --git a/lib/intel_os.c b/lib/intel_os.c
index 4b72f5175a30..14dda1474d5d 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -47,7 +47,7 @@
 #include <sys/swap.h>
 #endif
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "i915_drm.h"
 #include "drmtest.h"
 
diff --git a/lib/intel_reg_map.c b/lib/intel_reg_map.c
index ec63d79edfb9..402274baabb9 100644
--- a/lib/intel_reg_map.c
+++ b/lib/intel_reg_map.c
@@ -29,7 +29,7 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static struct intel_register_range gen_bwcl_register_map[] = {
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 5806f2a13bd8..24185491d4b6 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -52,7 +52,7 @@
 #include "drmtest.h"
 #include "i915_drm.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "igt_debugfs.h"
 #include "../version.h"
 #include "config.h"
diff --git a/lib/rendercopy_gen6.c b/lib/rendercopy_gen6.c
index a908ae6bbe38..d806ceff5470 100644
--- a/lib/rendercopy_gen6.c
+++ b/lib/rendercopy_gen6.c
@@ -15,7 +15,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "rendercopy.h"
 #include "gen6_render.h"
 #include "intel_reg.h"
diff --git a/lib/rendercopy_gen7.c b/lib/rendercopy_gen7.c
index 75e0571618fc..1dc639f318a7 100644
--- a/lib/rendercopy_gen7.c
+++ b/lib/rendercopy_gen7.c
@@ -15,7 +15,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "rendercopy.h"
 #include "gen7_render.h"
diff --git a/lib/rendercopy_gen8.c b/lib/rendercopy_gen8.c
index ef19ebf43a60..424afa0aefa8 100644
--- a/lib/rendercopy_gen8.c
+++ b/lib/rendercopy_gen8.c
@@ -15,7 +15,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "rendercopy.h"
 #include "gen8_render.h"
 #include "intel_reg.h"
diff --git a/lib/rendercopy_i830.c b/lib/rendercopy_i830.c
index 5ebd31a4677a..f0235a538fda 100644
--- a/lib/rendercopy_i830.c
+++ b/lib/rendercopy_i830.c
@@ -14,7 +14,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #include "i830_reg.h"
 #include "rendercopy.h"
diff --git a/lib/rendercopy_i915.c b/lib/rendercopy_i915.c
index b63c5cc4f03d..1acf9da31799 100644
--- a/lib/rendercopy_i915.c
+++ b/lib/rendercopy_i915.c
@@ -14,7 +14,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #include "i915_reg.h"
 #include "i915_3d.h"
diff --git a/tests/ddi_compute_wrpll.c b/tests/ddi_compute_wrpll.c
index c1db6c08de5b..02a96547443b 100644
--- a/tests/ddi_compute_wrpll.c
+++ b/tests/ddi_compute_wrpll.c
@@ -3,7 +3,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "drmtest.h"
 
 #define LC_FREQ 2700
diff --git a/tests/drm_vma_limiter.c b/tests/drm_vma_limiter.c
index f14ced8c85b6..e1381fe3d3bc 100644
--- a/tests/drm_vma_limiter.c
+++ b/tests/drm_vma_limiter.c
@@ -37,7 +37,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/drm_vma_limiter_cached.c b/tests/drm_vma_limiter_cached.c
index 7c40541c5ff5..3b41caad91a8 100644
--- a/tests/drm_vma_limiter_cached.c
+++ b/tests/drm_vma_limiter_cached.c
@@ -37,7 +37,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/drm_vma_limiter_cpu.c b/tests/drm_vma_limiter_cpu.c
index 4da4673752cd..e17a679d9492 100644
--- a/tests/drm_vma_limiter_cpu.c
+++ b/tests/drm_vma_limiter_cpu.c
@@ -37,7 +37,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/drm_vma_limiter_gtt.c b/tests/drm_vma_limiter_gtt.c
index 283bf6b47df8..303e86da2a95 100644
--- a/tests/drm_vma_limiter_gtt.c
+++ b/tests/drm_vma_limiter_gtt.c
@@ -37,7 +37,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_bad_address.c b/tests/gem_bad_address.c
index 58819357bf2a..f8fda90d546c 100644
--- a/tests/gem_bad_address.c
+++ b/tests/gem_bad_address.c
@@ -40,7 +40,7 @@
 #include "intel_bufmgr.h"
 #include "intel_chipset.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_bad_batch.c b/tests/gem_bad_batch.c
index 5bb08b442b5c..33b3241f82e6 100644
--- a/tests/gem_bad_batch.c
+++ b/tests/gem_bad_batch.c
@@ -40,7 +40,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_bad_blit.c b/tests/gem_bad_blit.c
index ec414eaff7dc..9c031179a073 100644
--- a/tests/gem_bad_blit.c
+++ b/tests/gem_bad_blit.c
@@ -55,7 +55,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_caching.c b/tests/gem_caching.c
index da6f2d8f02f7..3d51f2617737 100644
--- a/tests/gem_caching.c
+++ b/tests/gem_caching.c
@@ -39,7 +39,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 /*
diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index 29f42c7dc2d6..03acf89c0c90 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -49,7 +49,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void
diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
index 77d9109eef2c..e0276e7f9a78 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -58,7 +58,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.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 842e4276dd84..ffa80f36fca1 100644
--- a/tests/gem_cs_prefetch.c
+++ b/tests/gem_cs_prefetch.c
@@ -48,7 +48,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_cs_tlb.c b/tests/gem_cs_tlb.c
index 7d5c99dc67dd..8f7bc61cd40b 100644
--- a/tests/gem_cs_tlb.c
+++ b/tests/gem_cs_tlb.c
@@ -49,7 +49,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define LOCAL_I915_EXEC_VEBOX (4<<0)
 #define BATCH_SIZE (1024*1024)
diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c
index 3dbef2bd767c..3e9b68806c6f 100644
--- a/tests/gem_ctx_basic.c
+++ b/tests/gem_ctx_basic.c
@@ -45,7 +45,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 /* options */
diff --git a/tests/gem_double_irq_loop.c b/tests/gem_double_irq_loop.c
index f5c762962a43..ee9846c39ba7 100644
--- a/tests/gem_double_irq_loop.c
+++ b/tests/gem_double_irq_loop.c
@@ -38,7 +38,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "i830_reg.h"
 #include "intel_chipset.h"
 
diff --git a/tests/gem_dummy_reloc_loop.c b/tests/gem_dummy_reloc_loop.c
index 7c9da637e89c..a61b59b0ea9e 100644
--- a/tests/gem_dummy_reloc_loop.c
+++ b/tests/gem_dummy_reloc_loop.c
@@ -38,7 +38,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "i830_reg.h"
 #include "intel_chipset.h"
 
diff --git a/tests/gem_exec_bad_domains.c b/tests/gem_exec_bad_domains.c
index 0000e9edd144..6fb9edb63dbe 100644
--- a/tests/gem_exec_bad_domains.c
+++ b/tests/gem_exec_bad_domains.c
@@ -38,7 +38,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 /* Testcase: Test whether the kernel rejects relocations with non-gpu domains
diff --git a/tests/gem_exec_blt.c b/tests/gem_exec_blt.c
index 6c3ea37d60bb..ee979e7f812c 100644
--- a/tests/gem_exec_blt.c
+++ b/tests/gem_exec_blt.c
@@ -40,7 +40,7 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c
index 51e5b6ed1ed3..acd703b60ded 100644
--- a/tests/gem_exec_faulting_reloc.c
+++ b/tests/gem_exec_faulting_reloc.c
@@ -40,7 +40,7 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "igt_debugfs.h"
 
 /* Testcase: Submit patches with relocations in memory that will fault
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 28ec66b3b151..eaece7967f75 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -39,7 +39,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define LOCAL_I915_EXEC_VEBOX (4<<0)
 
diff --git a/tests/gem_fenced_exec_thrash.c b/tests/gem_fenced_exec_thrash.c
index 2ba85f2bcb5a..3194e340cf2c 100644
--- a/tests/gem_fenced_exec_thrash.c
+++ b/tests/gem_fenced_exec_thrash.c
@@ -40,7 +40,7 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define WIDTH 1024
 #define HEIGHT 1024
diff --git a/tests/gem_gtt_cpu_tlb.c b/tests/gem_gtt_cpu_tlb.c
index c087a37934a7..953070c0c63d 100644
--- a/tests/gem_gtt_cpu_tlb.c
+++ b/tests/gem_gtt_cpu_tlb.c
@@ -42,7 +42,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define OBJ_SIZE (1024*1024)
 
diff --git a/tests/gem_hang.c b/tests/gem_hang.c
index 5b1f5dc81be1..656d9cd1f67a 100644
--- a/tests/gem_hang.c
+++ b/tests/gem_hang.c
@@ -40,7 +40,7 @@
 #include "intel_bufmgr.h"
 #include "intel_chipset.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_hangcheck_forcewake.c b/tests/gem_hangcheck_forcewake.c
index d1bf000efb7a..64f839f5de46 100644
--- a/tests/gem_hangcheck_forcewake.c
+++ b/tests/gem_hangcheck_forcewake.c
@@ -38,7 +38,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 /*
diff --git a/tests/gem_linear_blits.c b/tests/gem_linear_blits.c
index a7e398fb7d95..1b6742288220 100644
--- a/tests/gem_linear_blits.c
+++ b/tests/gem_linear_blits.c
@@ -47,7 +47,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c
index 68bbdf23adf0..cb081d8bde2b 100644
--- a/tests/gem_media_fill.c
+++ b/tests/gem_media_fill.c
@@ -47,7 +47,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define WIDTH 64
diff --git a/tests/gem_non_secure_batch.c b/tests/gem_non_secure_batch.c
index 1d96222dc58b..6a73e84edba4 100644
--- a/tests/gem_non_secure_batch.c
+++ b/tests/gem_non_secure_batch.c
@@ -39,7 +39,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "i830_reg.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_partial_pwrite_pread.c b/tests/gem_partial_pwrite_pread.c
index c246537341c8..a43a2b645fa0 100644
--- a/tests/gem_partial_pwrite_pread.c
+++ b/tests/gem_partial_pwrite_pread.c
@@ -39,7 +39,7 @@
 #include "intel_chipset.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 /*
  * Testcase: pwrite/pread consistency when touching partial cachelines
diff --git a/tests/gem_persistent_relocs.c b/tests/gem_persistent_relocs.c
index 1a705fad8fff..1795160bcd1b 100644
--- a/tests/gem_persistent_relocs.c
+++ b/tests/gem_persistent_relocs.c
@@ -42,7 +42,7 @@
 #include "intel_bufmgr.h"
 #include "intel_chipset.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "igt_debugfs.h"
 
 /*
diff --git a/tests/gem_pin.c b/tests/gem_pin.c
index e57ddcc4c740..9572d2886748 100644
--- a/tests/gem_pin.c
+++ b/tests/gem_pin.c
@@ -39,7 +39,7 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define COPY_BLT_CMD            (2<<29|0x53<<22|0x6)
 #define BLT_WRITE_ALPHA         (1<<21)
diff --git a/tests/gem_pipe_control_store_loop.c b/tests/gem_pipe_control_store_loop.c
index 41bfc1b0e40a..c95c2bdfa28e 100644
--- a/tests/gem_pipe_control_store_loop.c
+++ b/tests/gem_pipe_control_store_loop.c
@@ -45,7 +45,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index f263286c0f49..6c3f8227e9ee 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -48,7 +48,7 @@
 #include "intel_chipset.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_pwrite_pread.c b/tests/gem_pwrite_pread.c
index c3314e48bc89..7a0cdf39f0ee 100644
--- a/tests/gem_pwrite_pread.c
+++ b/tests/gem_pwrite_pread.c
@@ -42,7 +42,7 @@
 #include "intel_chipset.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/gem_reloc_overflow.c b/tests/gem_reloc_overflow.c
index 98b7dd4a7b0c..06a315fd45b6 100644
--- a/tests/gem_reloc_overflow.c
+++ b/tests/gem_reloc_overflow.c
@@ -46,7 +46,7 @@
 #include "ioctl_wrappers.h"
 #include "intel_chipset.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 /*
  * Testcase: Kernel relocation overflows are caught.
diff --git a/tests/gem_reloc_vs_gpu.c b/tests/gem_reloc_vs_gpu.c
index 07c79b33d937..8e8018762597 100644
--- a/tests/gem_reloc_vs_gpu.c
+++ b/tests/gem_reloc_vs_gpu.c
@@ -42,7 +42,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "igt_debugfs.h"
 
 /*
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index 54f971d127b7..12ac18d31251 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -47,7 +47,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define WIDTH 512
diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index ac2b29b00d14..14a3ae7e7a41 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -52,7 +52,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define WIDTH 512
diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c
index 8481e51d3bda..bee063fcc179 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -48,7 +48,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define WIDTH 512
diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 90befd70a527..a6d4edc72323 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -46,7 +46,7 @@
 #include "intel_bufmgr.h"
 #include "intel_chipset.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define RS_NO_ERROR      0
 #define RS_BATCH_ACTIVE  (1 << 0)
diff --git a/tests/gem_ring_sync_loop.c b/tests/gem_ring_sync_loop.c
index 5010d3562142..d4e7e2a82554 100644
--- a/tests/gem_ring_sync_loop.c
+++ b/tests/gem_ring_sync_loop.c
@@ -38,7 +38,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "i830_reg.h"
 #include "intel_chipset.h"
 
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index 716ff5692cf7..88c8a8eeef69 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -47,7 +47,7 @@
 #include "intel_bufmgr.h"
 #include "intel_chipset.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 struct bo {
 	const char *ring;
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index 30d1a8687090..a557c9857ed4 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -48,7 +48,7 @@
 #include "igt_core.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static int devid;
diff --git a/tests/gem_set_tiling_vs_blt.c b/tests/gem_set_tiling_vs_blt.c
index 1ad0e5c1e91b..e2f3f9751e18 100644
--- a/tests/gem_set_tiling_vs_blt.c
+++ b/tests/gem_set_tiling_vs_blt.c
@@ -59,7 +59,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_set_tiling_vs_gtt.c b/tests/gem_set_tiling_vs_gtt.c
index abe096396d57..384a85eab6b3 100644
--- a/tests/gem_set_tiling_vs_gtt.c
+++ b/tests/gem_set_tiling_vs_gtt.c
@@ -37,7 +37,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define OBJECT_SIZE (1024*1024)
diff --git a/tests/gem_set_tiling_vs_pwrite.c b/tests/gem_set_tiling_vs_pwrite.c
index d07ebafc3fa6..cc818f144731 100644
--- a/tests/gem_set_tiling_vs_pwrite.c
+++ b/tests/gem_set_tiling_vs_pwrite.c
@@ -37,7 +37,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define OBJECT_SIZE (1024*1024)
 #define TEST_STRIDE (1024*4)
diff --git a/tests/gem_storedw_batches_loop.c b/tests/gem_storedw_batches_loop.c
index f07085c46a01..90f004ed3d59 100644
--- a/tests/gem_storedw_batches_loop.c
+++ b/tests/gem_storedw_batches_loop.c
@@ -40,7 +40,7 @@
 #include "intel_bufmgr.h"
 #include "intel_chipset.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 static drm_intel_bo *target_bo;
diff --git a/tests/gem_storedw_loop_blt.c b/tests/gem_storedw_loop_blt.c
index b242b292017a..7cbf86d3d2d8 100644
--- a/tests/gem_storedw_loop_blt.c
+++ b/tests/gem_storedw_loop_blt.c
@@ -39,7 +39,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_storedw_loop_bsd.c b/tests/gem_storedw_loop_bsd.c
index 482e276b0158..c3ab32257713 100644
--- a/tests/gem_storedw_loop_bsd.c
+++ b/tests/gem_storedw_loop_bsd.c
@@ -39,7 +39,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_storedw_loop_render.c b/tests/gem_storedw_loop_render.c
index 7cbc0a80d08c..43ca09596926 100644
--- a/tests/gem_storedw_loop_render.c
+++ b/tests/gem_storedw_loop_render.c
@@ -39,7 +39,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_storedw_loop_vebox.c b/tests/gem_storedw_loop_vebox.c
index 872d4b2aa56b..c7136215c295 100644
--- a/tests/gem_storedw_loop_vebox.c
+++ b/tests/gem_storedw_loop_vebox.c
@@ -38,7 +38,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.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 d6434bcc5b63..bf3cde762142 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -64,7 +64,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define CMD_POLY_STIPPLE_OFFSET       0x7906
diff --git a/tests/gem_tiled_blits.c b/tests/gem_tiled_blits.c
index 00b695549b35..09be42efea2f 100644
--- a/tests/gem_tiled_blits.c
+++ b/tests/gem_tiled_blits.c
@@ -55,7 +55,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_tiled_fence_blits.c b/tests/gem_tiled_fence_blits.c
index 3dfcf0039dba..7cefca0b3afa 100644
--- a/tests/gem_tiled_fence_blits.c
+++ b/tests/gem_tiled_fence_blits.c
@@ -54,7 +54,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_tiled_partial_pwrite_pread.c b/tests/gem_tiled_partial_pwrite_pread.c
index 322cca9d8794..26fc145da8d1 100644
--- a/tests/gem_tiled_partial_pwrite_pread.c
+++ b/tests/gem_tiled_partial_pwrite_pread.c
@@ -39,7 +39,7 @@
 #include "intel_bufmgr.h"
 #include "intel_chipset.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 /*
  * Testcase: pwrite/pread consistency when touching partial cachelines
diff --git a/tests/gem_tiled_pread.c b/tests/gem_tiled_pread.c
index 6f104a6ca38b..73ed0bf657ee 100644
--- a/tests/gem_tiled_pread.c
+++ b/tests/gem_tiled_pread.c
@@ -47,7 +47,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define WIDTH 512
diff --git a/tests/gem_tiled_pread_pwrite.c b/tests/gem_tiled_pread_pwrite.c
index 06c32fcc1fde..08176f3d700d 100644
--- a/tests/gem_tiled_pread_pwrite.c
+++ b/tests/gem_tiled_pread_pwrite.c
@@ -56,7 +56,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c
index 28d21d458e68..fd9b40f3285c 100644
--- a/tests/gem_tiled_swapping.c
+++ b/tests/gem_tiled_swapping.c
@@ -56,7 +56,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/gem_tiling_max_stride.c b/tests/gem_tiling_max_stride.c
index ded965aef0ef..4d0553d4ad5b 100644
--- a/tests/gem_tiling_max_stride.c
+++ b/tests/gem_tiling_max_stride.c
@@ -38,7 +38,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.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 9ccabe9fd29b..219393123f12 100644
--- a/tests/gem_unfence_active_buffers.c
+++ b/tests/gem_unfence_active_buffers.c
@@ -52,7 +52,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_unref_active_buffers.c b/tests/gem_unref_active_buffers.c
index 8906705756ea..cdc30990f228 100644
--- a/tests/gem_unref_active_buffers.c
+++ b/tests/gem_unref_active_buffers.c
@@ -45,7 +45,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_vmap_blits.c b/tests/gem_vmap_blits.c
index 157d67460e6c..430338b73b14 100644
--- a/tests/gem_vmap_blits.c
+++ b/tests/gem_vmap_blits.c
@@ -49,7 +49,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 
 #if !defined(I915_PARAM_HAS_VMAP)
 #pragma message("No vmap support in drm, skipping")
diff --git a/tests/gem_wait_render_timeout.c b/tests/gem_wait_render_timeout.c
index d4c12fee17c8..b0b77adc0c38 100644
--- a/tests/gem_wait_render_timeout.c
+++ b/tests/gem_wait_render_timeout.c
@@ -42,7 +42,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define MSEC_PER_SEC	1000L
diff --git a/tests/gem_write_read_ring_switch.c b/tests/gem_write_read_ring_switch.c
index cd235c95c190..f19a7bef6e48 100644
--- a/tests/gem_write_read_ring_switch.c
+++ b/tests/gem_write_read_ring_switch.c
@@ -39,7 +39,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "i830_reg.h"
 
 #define LOCAL_I915_EXEC_VEBOX (4<<0)
diff --git a/tests/gen3_mixed_blits.c b/tests/gen3_mixed_blits.c
index 64041a0ec29b..80b626cfe91b 100644
--- a/tests/gen3_mixed_blits.c
+++ b/tests/gen3_mixed_blits.c
@@ -45,7 +45,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #include "i915_reg.h"
diff --git a/tests/gen3_render_linear_blits.c b/tests/gen3_render_linear_blits.c
index eed3ba5e47f1..3e2d1a4804bb 100644
--- a/tests/gen3_render_linear_blits.c
+++ b/tests/gen3_render_linear_blits.c
@@ -44,7 +44,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #include "i915_reg.h"
diff --git a/tests/gen3_render_mixed_blits.c b/tests/gen3_render_mixed_blits.c
index ac5452a8cde7..09275f73f401 100644
--- a/tests/gen3_render_mixed_blits.c
+++ b/tests/gen3_render_mixed_blits.c
@@ -45,7 +45,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #include "i915_reg.h"
diff --git a/tests/gen3_render_tiledx_blits.c b/tests/gen3_render_tiledx_blits.c
index 1b2a00c50880..574282890a73 100644
--- a/tests/gen3_render_tiledx_blits.c
+++ b/tests/gen3_render_tiledx_blits.c
@@ -45,7 +45,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #include "i915_reg.h"
diff --git a/tests/gen3_render_tiledy_blits.c b/tests/gen3_render_tiledy_blits.c
index 803054138002..1765dca57e22 100644
--- a/tests/gen3_render_tiledy_blits.c
+++ b/tests/gen3_render_tiledy_blits.c
@@ -45,7 +45,7 @@
 #include "drm.h"
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #include "i915_reg.h"
diff --git a/tests/gen7_forcewake_mt.c b/tests/gen7_forcewake_mt.c
index 03eb6e92625f..fdc34ced512a 100644
--- a/tests/gen7_forcewake_mt.c
+++ b/tests/gen7_forcewake_mt.c
@@ -38,7 +38,7 @@
 #include "ioctl_wrappers.h"
 #include "i915_pciids.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define FORCEWAKE_MT 0xa188
diff --git a/tests/kms_render.c b/tests/kms_render.c
index 7bff958b876c..2179e65d66ee 100644
--- a/tests/kms_render.c
+++ b/tests/kms_render.c
@@ -36,7 +36,7 @@
 #include "testdisplay.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "igt_kms.h"
 #include "ioctl_wrappers.h"
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 4c1a5676a7a0..703e93264e88 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -36,7 +36,7 @@
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "igt_kms.h"
 
 #define MAX_CONNECTORS  10
diff --git a/tests/pm_lpsp.c b/tests/pm_lpsp.c
index 1dc7a73f5dae..87397055558b 100644
--- a/tests/pm_lpsp.c
+++ b/tests/pm_lpsp.c
@@ -31,7 +31,7 @@
 
 #include "drmtest.h"
 #include "igt_kms.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 /* We know that if we don't enable audio runtime PM, snd_hda_intel will never
diff --git a/tests/pm_pc8.c b/tests/pm_pc8.c
index 5a1e74700760..3004c32eb94a 100644
--- a/tests/pm_pc8.c
+++ b/tests/pm_pc8.c
@@ -43,7 +43,7 @@
 #include "drm.h"
 #include "drmtest.h"
 #include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "ioctl_wrappers.h"
 #include "igt_kms.h"
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index 1f4b284cd42a..ce65edd75c1c 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -37,7 +37,7 @@
 #include <errno.h>
 
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
diff --git a/tests/prime_nv_api.c b/tests/prime_nv_api.c
index c510c1cfe3bb..73c0a0d24f5f 100644
--- a/tests/prime_nv_api.c
+++ b/tests/prime_nv_api.c
@@ -16,7 +16,7 @@
 
 #include "intel_bufmgr.h"
 #include "nouveau.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_batchbuffer.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
diff --git a/tests/prime_nv_pcopy.c b/tests/prime_nv_pcopy.c
index 3f3814afc786..7fa2e34cd04f 100644
--- a/tests/prime_nv_pcopy.c
+++ b/tests/prime_nv_pcopy.c
@@ -26,7 +26,7 @@
 #include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
 #include "nouveau.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "drmtest.h"
diff --git a/tests/prime_nv_test.c b/tests/prime_nv_test.c
index ee54e7a6eb6c..8211cd6f030e 100644
--- a/tests/prime_nv_test.c
+++ b/tests/prime_nv_test.c
@@ -25,7 +25,7 @@
 #include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
 #include "nouveau.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "drmtest.h"
diff --git a/tests/prime_udl.c b/tests/prime_udl.c
index 96661fcb501f..62b381a37d86 100644
--- a/tests/prime_udl.c
+++ b/tests/prime_udl.c
@@ -28,7 +28,7 @@
 
 #include "ioctl_wrappers.h"
 #include "intel_bufmgr.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_batchbuffer.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
diff --git a/tools/intel_audio_dump.c b/tools/intel_audio_dump.c
index 9762b4f7a195..26023743307b 100644
--- a/tools/intel_audio_dump.c
+++ b/tools/intel_audio_dump.c
@@ -33,7 +33,7 @@
 #include <string.h>
 #include <err.h>
 #include <arpa/inet.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_reg.h"
 #include "intel_chipset.h"
 #include "drmtest.h"
diff --git a/tools/intel_backlight.c b/tools/intel_backlight.c
index e2591847f548..b866ec8efaee 100644
--- a/tools/intel_backlight.c
+++ b/tools/intel_backlight.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "intel_reg.h"
 
diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 8eb46f3dead6..173772bf91d9 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -36,7 +36,7 @@
 #include <sys/types.h>
 
 #include "intel_bios.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "drmtest.h"
 
diff --git a/tools/intel_dpio_read.c b/tools/intel_dpio_read.c
index 2196041a6ac3..09f0376485bc 100644
--- a/tools/intel_dpio_read.c
+++ b/tools/intel_dpio_read.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include <string.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void usage(char *cmdname)
diff --git a/tools/intel_dpio_write.c b/tools/intel_dpio_write.c
index c3c682a654c8..15c79efe7dfe 100644
--- a/tools/intel_dpio_write.c
+++ b/tools/intel_dpio_write.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include <string.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void usage(char *cmdname)
diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c
index b1d51b74a6fc..1eeff0714395 100644
--- a/tools/intel_error_decode.c
+++ b/tools/intel_error_decode.c
@@ -53,7 +53,7 @@
 #include <intel_bufmgr.h>
 
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "instdone.h"
 #include "intel_reg.h"
 
diff --git a/tools/intel_forcewaked.c b/tools/intel_forcewaked.c
index b4e7b5cc6319..01ca02530d10 100644
--- a/tools/intel_forcewaked.c
+++ b/tools/intel_forcewaked.c
@@ -34,7 +34,7 @@
 #include <stdlib.h>
 #include <syslog.h>
 #include <unistd.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 bool daemonized;
diff --git a/tools/intel_framebuffer_dump.c b/tools/intel_framebuffer_dump.c
index a254324c601a..624a96136137 100644
--- a/tools/intel_framebuffer_dump.c
+++ b/tools/intel_framebuffer_dump.c
@@ -35,7 +35,7 @@
 #include <i915_drm.h>
 #include <cairo.h>
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "drmtest.h"
 
 int main(int argc, char **argv)
diff --git a/tools/intel_gpu_time.c b/tools/intel_gpu_time.c
index 0b8ca9e4c578..4096f1c5486f 100644
--- a/tools/intel_gpu_time.c
+++ b/tools/intel_gpu_time.c
@@ -34,7 +34,7 @@
 #include <sys/resource.h>
 #include <sys/wait.h>
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "intel_reg.h"
 
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index ccbe9736db23..a016bc9bdecc 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -42,7 +42,7 @@
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #endif
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "instdone.h"
 #include "intel_reg.h"
 #include "intel_chipset.h"
diff --git a/tools/intel_gtt.c b/tools/intel_gtt.c
index f3d1c3082052..9604a54792d3 100644
--- a/tools/intel_gtt.c
+++ b/tools/intel_gtt.c
@@ -34,7 +34,7 @@
 #include <pciaccess.h>
 #include <unistd.h>
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 #define KB(x) ((x) * 1024)
diff --git a/tools/intel_infoframes.c b/tools/intel_infoframes.c
index 76dd6271e1fd..794f423d2161 100644
--- a/tools/intel_infoframes.c
+++ b/tools/intel_infoframes.c
@@ -30,7 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "drmtest.h"
 
diff --git a/tools/intel_l3_parity.c b/tools/intel_l3_parity.c
index aed36c83b73b..a4b7d738e0b2 100644
--- a/tools/intel_l3_parity.c
+++ b/tools/intel_l3_parity.c
@@ -36,7 +36,7 @@
 #include <unistd.h>
 #include <getopt.h>
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "drmtest.h"
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/tools/intel_lid.c b/tools/intel_lid.c
index 34960461382c..7bcb63a772fd 100644
--- a/tools/intel_lid.c
+++ b/tools/intel_lid.c
@@ -37,7 +37,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_reg.h"
 #include "intel_bios.h"
 #include "intel_chipset.h"
diff --git a/tools/intel_nc_read.c b/tools/intel_nc_read.c
index 0ec3e75764b9..d6d09a81e5c4 100644
--- a/tools/intel_nc_read.c
+++ b/tools/intel_nc_read.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include <string.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void usage(char *cmdname)
diff --git a/tools/intel_nc_write.c b/tools/intel_nc_write.c
index 5700f67f3f2f..d76568847f86 100644
--- a/tools/intel_nc_write.c
+++ b/tools/intel_nc_write.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include <string.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void usage(char *cmdname)
diff --git a/tools/intel_opregion_decode.c b/tools/intel_opregion_decode.c
index 0beece699a1d..b19566108ed7 100644
--- a/tools/intel_opregion_decode.c
+++ b/tools/intel_opregion_decode.c
@@ -37,7 +37,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "drmtest.h"
 
 #define OPREGION_HEADER_OFFSET		0
diff --git a/tools/intel_panel_fitter.c b/tools/intel_panel_fitter.c
index 2e3f6883d9c5..5519361e6c8c 100644
--- a/tools/intel_panel_fitter.c
+++ b/tools/intel_panel_fitter.c
@@ -30,7 +30,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "intel_reg.h"
 
diff --git a/tools/intel_perf_counters.c b/tools/intel_perf_counters.c
index c31111e60bbb..e6eafb200ab1 100644
--- a/tools/intel_perf_counters.c
+++ b/tools/intel_perf_counters.c
@@ -45,7 +45,7 @@
 #include "drm.h"
 #include "i915_drm.h"
 #include "drmtest.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
diff --git a/tools/intel_punit_read.c b/tools/intel_punit_read.c
index 187bd77c7b0c..b0a2697addb9 100644
--- a/tools/intel_punit_read.c
+++ b/tools/intel_punit_read.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include <string.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void usage(char *cmdname)
diff --git a/tools/intel_punit_write.c b/tools/intel_punit_write.c
index c0aa08530353..9ffe018d8f5e 100644
--- a/tools/intel_punit_write.c
+++ b/tools/intel_punit_write.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include <string.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void usage(char *cmdname)
diff --git a/tools/intel_reg_checker.c b/tools/intel_reg_checker.c
index a2c76419fbcd..92b06fa152d4 100644
--- a/tools/intel_reg_checker.c
+++ b/tools/intel_reg_checker.c
@@ -26,7 +26,7 @@
 #include <err.h>
 #include <string.h>
 #include <stdbool.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static uint32_t devid;
diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index 432892aec3ac..04fd6b2d8b8c 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -33,7 +33,7 @@
 #include <string.h>
 #include <err.h>
 #include <unistd.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 #include "intel_reg.h"
 #include "drmtest.h"
diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c
index 961248a02db4..3b9129148878 100644
--- a/tools/intel_reg_read.c
+++ b/tools/intel_reg_read.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include <string.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void bit_decode(uint32_t reg)
diff --git a/tools/intel_reg_snapshot.c b/tools/intel_reg_snapshot.c
index 09a95b3932c4..166b68e25271 100644
--- a/tools/intel_reg_snapshot.c
+++ b/tools/intel_reg_snapshot.c
@@ -26,7 +26,7 @@
 
 #include <unistd.h>
 #include <assert.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 int main(int argc, char** argv)
diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c
index 0f73a7706ece..ff4e561ee4ab 100644
--- a/tools/intel_reg_write.c
+++ b/tools/intel_reg_write.c
@@ -29,7 +29,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <err.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 int main(int argc, char** argv)
diff --git a/tools/intel_stepping.c b/tools/intel_stepping.c
index 626c5bbb0010..7839ef5923e9 100644
--- a/tools/intel_stepping.c
+++ b/tools/intel_stepping.c
@@ -32,7 +32,7 @@
 #include <pciaccess.h>
 #include <err.h>
 #include "intel_chipset.h"
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_reg.h"
 
 static void
diff --git a/tools/intel_vga_read.c b/tools/intel_vga_read.c
index 40a9cdc869ca..e635c59cda3b 100644
--- a/tools/intel_vga_read.c
+++ b/tools/intel_vga_read.c
@@ -31,7 +31,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/io.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static uint8_t read_reg(uint32_t reg, bool use_mmio)
diff --git a/tools/intel_vga_write.c b/tools/intel_vga_write.c
index 91af0fe5017a..4fb09d6a247a 100644
--- a/tools/intel_vga_write.c
+++ b/tools/intel_vga_write.c
@@ -31,7 +31,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/io.h>
-#include "intel_gpu_tools.h"
+#include "intel_io.h"
 #include "intel_chipset.h"
 
 static void write_reg(uint32_t reg, uint8_t val, bool use_mmio)
-- 
1.8.5.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 20/28] lib/intel_io: rename mmio setup functions
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (18 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 19/28] lib: rename intel_gpu_tools.h to intel_io.h Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 21/28] lib/intel_io: api documentation Daniel Vetter
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Makes their intent a bit clearer.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_io.h             | 4 ++--
 lib/intel_mmio.c           | 6 +++---
 tools/intel_audio_dump.c   | 4 ++--
 tools/intel_backlight.c    | 2 +-
 tools/intel_gpu_time.c     | 2 +-
 tools/intel_gpu_top.c      | 2 +-
 tools/intel_lid.c          | 2 +-
 tools/intel_reg_checker.c  | 2 +-
 tools/intel_reg_dumper.c   | 2 +-
 tools/intel_reg_snapshot.c | 2 +-
 10 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/lib/intel_io.h b/lib/intel_io.h
index 591fd3f446c3..5ea50cab472c 100644
--- a/lib/intel_io.h
+++ b/lib/intel_io.h
@@ -33,8 +33,8 @@
 
 /* register access helpers from intel_mmio.c */
 extern void *mmio;
-void intel_get_mmio(struct pci_device *pci_dev);
-void intel_map_file(char *);
+void intel_mmio_use_pci_bar(struct pci_device *pci_dev);
+void intel_mmio_use_dump_file(char *);
 
 int intel_register_access_init(struct pci_device *pci_dev, int safe);
 void intel_register_access_fini(void);
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 444e44507eac..97eee5601f91 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -58,7 +58,7 @@ static struct _mmio_data {
 } mmio_data;
 
 void
-intel_map_file(char *file)
+intel_mmio_use_dump_file(char *file)
 {
 	int fd;
 	struct stat st;
@@ -80,7 +80,7 @@ intel_map_file(char *file)
 }
 
 void
-intel_get_mmio(struct pci_device *pci_dev)
+intel_mmio_use_pci_bar(struct pci_device *pci_dev)
 {
 	uint32_t devid, gen;
 	int mmio_bar, mmio_size;
@@ -132,7 +132,7 @@ intel_register_access_init(struct pci_device *pci_dev, int safe)
 
 	/* after old API is deprecated, remove this */
 	if (mmio == NULL)
-		intel_get_mmio(pci_dev);
+		intel_mmio_use_pci_bar(pci_dev);
 
 	assert(mmio != NULL);
 
diff --git a/tools/intel_audio_dump.c b/tools/intel_audio_dump.c
index 26023743307b..f3bb9ebdfd02 100644
--- a/tools/intel_audio_dump.c
+++ b/tools/intel_audio_dump.c
@@ -2277,9 +2277,9 @@ int main(int argc, char **argv)
 	do_self_tests();
 
 	if (argc == 2)
-		intel_map_file(argv[1]);
+		intel_mmio_use_dump_file(argv[1]);
 	else
-		intel_get_mmio(pci_dev);
+		intel_mmio_use_pci_bar(pci_dev);
 
 	if (IS_VALLEYVIEW(devid)) {
 		printf("Valleyview audio registers:\n\n");
diff --git a/tools/intel_backlight.c b/tools/intel_backlight.c
index b866ec8efaee..17deb88d4be8 100644
--- a/tools/intel_backlight.c
+++ b/tools/intel_backlight.c
@@ -50,7 +50,7 @@ int main(int argc, char** argv)
 {
 	uint32_t current, max;
 
-	intel_get_mmio(intel_get_pci_device());
+	intel_mmio_use_pci_bar(intel_get_pci_device());
 
 	current = reg_read(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
 	max = reg_read(BLC_PWM_PCH_CTL2) >> 16;
diff --git a/tools/intel_gpu_time.c b/tools/intel_gpu_time.c
index 4096f1c5486f..56d65fe07967 100644
--- a/tools/intel_gpu_time.c
+++ b/tools/intel_gpu_time.c
@@ -67,7 +67,7 @@ int main(int argc, char **argv)
 	static struct rusage rusage;
 	int status;
 
-	intel_get_mmio(intel_get_pci_device());
+	intel_mmio_use_pci_bar(intel_get_pci_device());
 
 	if (argc == 1) {
 		fprintf(stderr, "usage: %s cmd [args...]\n", argv[0]);
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index a016bc9bdecc..b5cfda043dd9 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -473,7 +473,7 @@ int main(int argc, char **argv)
 
 	pci_dev = intel_get_pci_device();
 	devid = pci_dev->device_id;
-	intel_get_mmio(pci_dev);
+	intel_mmio_use_pci_bar(pci_dev);
 	init_instdone_definitions(devid);
 
 	/* Do we have a command to run? */
diff --git a/tools/intel_lid.c b/tools/intel_lid.c
index 7bcb63a772fd..0703e2e1e14e 100644
--- a/tools/intel_lid.c
+++ b/tools/intel_lid.c
@@ -118,7 +118,7 @@ int main(int argc, char **argv)
 {
 	int swf14, acpi_lid;
 
-	intel_get_mmio(intel_get_pci_device());
+	intel_mmio_use_pci_bar(intel_get_pci_device());
 
 	while (1) {
 		swf14 = INREG(SWF14);
diff --git a/tools/intel_reg_checker.c b/tools/intel_reg_checker.c
index 92b06fa152d4..22d979613ea1 100644
--- a/tools/intel_reg_checker.c
+++ b/tools/intel_reg_checker.c
@@ -350,7 +350,7 @@ int main(int argc, char** argv)
 
 	dev = intel_get_pci_device();
 	devid = dev->device_id;
-	intel_get_mmio(dev);
+	intel_mmio_use_pci_bar(dev);
 
 	if (IS_GEN7(devid))
 		gen = 7;
diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index 04fd6b2d8b8c..4d3d2c7f0f17 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -2931,7 +2931,7 @@ int main(int argc, char** argv)
 	}
 
 	if (file) {
-		intel_map_file(file);
+		intel_mmio_use_dump_file(file);
 		if (devid) {
 			if (IS_GEN5(devid))
 				intel_pch = PCH_IBX;
diff --git a/tools/intel_reg_snapshot.c b/tools/intel_reg_snapshot.c
index 166b68e25271..b756bf690217 100644
--- a/tools/intel_reg_snapshot.c
+++ b/tools/intel_reg_snapshot.c
@@ -38,7 +38,7 @@ int main(int argc, char** argv)
 
 	pci_dev = intel_get_pci_device();
 	devid = pci_dev->device_id;
-	intel_get_mmio(pci_dev);
+	intel_mmio_use_pci_bar(pci_dev);
 
 	if (IS_GEN2(devid))
 		mmio_bar = 1;
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 21/28] lib/intel_io: api documentation
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (19 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 20/28] lib/intel_io: rename mmio setup functions Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 22/28] lib: s/drmtest_dumb_aub/igt_aub_dump_enabled/ Daniel Vetter
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

As usual de-inline functions for gtkdoc to see them.

I've decided to exclude the register map stuff since that's not
terribly interesting.

Aside: gtkdoc falls over when the title of a section contains a slash,
hence why it reads "IO" instead of "I/O". The fun ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_io.h   |  18 +++-----
 lib/intel_iosf.c |  58 ++++++++++++++++++++++++++
 lib/intel_mmio.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 185 insertions(+), 16 deletions(-)

diff --git a/lib/intel_io.h b/lib/intel_io.h
index 5ea50cab472c..d56d061d5b0a 100644
--- a/lib/intel_io.h
+++ b/lib/intel_io.h
@@ -34,7 +34,7 @@
 /* register access helpers from intel_mmio.c */
 extern void *mmio;
 void intel_mmio_use_pci_bar(struct pci_device *pci_dev);
-void intel_mmio_use_dump_file(char *);
+void intel_mmio_use_dump_file(char *file);
 
 int intel_register_access_init(struct pci_device *pci_dev, int safe);
 void intel_register_access_fini(void);
@@ -42,17 +42,8 @@ uint32_t intel_register_read(uint32_t reg);
 void intel_register_write(uint32_t reg, uint32_t val);
 int intel_register_access_needs_fakewake(void);
 
-static inline uint32_t
-INREG(uint32_t reg)
-{
-	return *(volatile uint32_t *)((volatile char *)mmio + reg);
-}
-
-static inline void
-OUTREG(uint32_t reg, uint32_t val)
-{
-	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
-}
+uint32_t INREG(uint32_t reg);
+void OUTREG(uint32_t reg, uint32_t val);
 
 /* sideband access functions from intel_iosf.c */
 uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
@@ -64,6 +55,8 @@ int intel_nc_read(uint8_t addr, uint32_t *val);
 int intel_nc_write(uint8_t addr, uint32_t val);
 
 /* register maps from intel_reg_map.c */
+#ifndef __GTK_DOC_IGNORE__
+
 #define INTEL_RANGE_RSVD	(0<<0) /*  Shouldn't be read or written */
 #define INTEL_RANGE_READ	(1<<0)
 #define INTEL_RANGE_WRITE	(1<<1)
@@ -83,5 +76,6 @@ struct intel_register_map {
 };
 struct intel_register_map intel_get_register_map(uint32_t devid);
 struct intel_register_range *intel_get_register_range(struct intel_register_map map, uint32_t offset, uint32_t mode);
+#endif /* __GTK_DOC_IGNORE__ */
 
 #endif /* INTEL_GPU_TOOLS_H */
diff --git a/lib/intel_iosf.c b/lib/intel_iosf.c
index ea7a320a5647..7e251599b593 100644
--- a/lib/intel_iosf.c
+++ b/lib/intel_iosf.c
@@ -55,26 +55,76 @@ static int vlv_sideband_rw(uint32_t port, uint8_t opcode, uint32_t addr,
 	return 0;
 }
 
+/**
+ * intel_punit_read:
+ * @addr: register offset
+ * @val: pointer to starge for the read result
+ *
+ * 32-bit read of the register at @offset through the P-Unit sideband port.
+ *
+ * Returns:
+ * 0 when the register access succeeded, negative errno code on failure.
+ */
 int intel_punit_read(uint8_t addr, uint32_t *val)
 {
 	return vlv_sideband_rw(IOSF_PORT_PUNIT, PUNIT_OPCODE_REG_READ, addr, val);
 }
 
+/**
+ * intel_punit_write:
+ * @addr: register offset
+ * @val: value to write
+ *
+ * 32-bit write of the register at @offset through the P-Unit sideband port.
+ *
+ * Returns:
+ * 0 when the register access succeeded, negative errno code on failure.
+ */
 int intel_punit_write(uint8_t addr, uint32_t val)
 {
 	return vlv_sideband_rw(IOSF_PORT_PUNIT, PUNIT_OPCODE_REG_WRITE, addr, &val);
 }
 
+/**
+ * intel_nc_read:
+ * @addr: register offset
+ * @val: pointer to starge for the read result
+ *
+ * 32-bit read of the register at @offset through the NC sideband port.
+ *
+ * Returns:
+ * 0 when the register access succeeded, negative errno code on failure.
+ */
 int intel_nc_read(uint8_t addr, uint32_t *val)
 {
 	return vlv_sideband_rw(IOSF_PORT_NC, PUNIT_OPCODE_REG_READ, addr, val);
 }
 
+/**
+ * intel_nc_write:
+ * @addr: register offset
+ * @val: value to write
+ *
+ * 32-bit write of the register at @offset through the NC sideband port.
+ *
+ * Returns:
+ * 0 when the register access succeeded, negative errno code on failure.
+ */
 int intel_nc_write(uint8_t addr, uint32_t val)
 {
 	return vlv_sideband_rw(IOSF_PORT_NC, PUNIT_OPCODE_REG_WRITE, addr, &val);
 }
 
+/**
+ * intel_dpio_reg_read:
+ * @reg: register offset
+ * @phy: DPIO PHY to use
+ *
+ * 32-bit read of the register at @offset through the DPIO sideband port.
+ *
+ * Returns:
+ * The value read from the register.
+ */
 uint32_t intel_dpio_reg_read(uint32_t reg, int phy)
 {
 	uint32_t val;
@@ -83,6 +133,14 @@ uint32_t intel_dpio_reg_read(uint32_t reg, int phy)
 	return val;
 }
 
+/**
+ * intel_dpio_reg_write:
+ * @reg: register offset
+ * @val: value to write
+ * @phy: dpio PHY to use
+ *
+ * 32-bit write of the register at @offset through the DPIO sideband port.
+ */
 void intel_dpio_reg_write(uint32_t reg, uint32_t val, int phy)
 {
 	vlv_sideband_rw(IOSF_PORT_DPIO, DPIO_OPCODE_REG_WRITE, reg, &val);
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 97eee5601f91..6666b9e75b12 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -45,8 +45,30 @@
 #include "igt_debugfs.h"
 #include "intel_chipset.h"
 
+/**
+ * SECTION:intel_io
+ * @short_description: Register access and sideband I/O libraray
+ * @title: intel io
+ *
+ * > #include "intel_io.h"
+ *
+ * This library provides register I/O helpers in both a basic version and a more
+ * fancy version which also handles forcewak and can optionally check registers
+ * against a white-list. All register function are compatible. Hence the same
+ * code can be used to decode registers with either of them, or also from a dump
+ * file using intel_mmio_use_dump_file().
+ *
+ * Futhermore this library also provides helper functions for accessing the
+ * various sideband interfaces found on Valleyview/Baytrail based platforms.
+ */
+
 #define FAKEKEY 0x2468ace0
 
+/**
+ * mmio:
+ *
+ * Pointer to the register range. It is not recommended to use this directly.
+ */
 void *mmio;
 
 static struct _mmio_data {
@@ -57,6 +79,14 @@ static struct _mmio_data {
 	int key;
 } mmio_data;
 
+/**
+ * intel_mmio_use_dump_file:
+ * @file: name of the register dump file to open
+ *
+ * Sets up #mmio to point at the data contained in @file. This allows the same
+ * code to get reused for dumping and decoding from running hardwared as from
+ * register dumps.
+ */
 void
 intel_mmio_use_dump_file(char *file)
 {
@@ -79,6 +109,16 @@ intel_mmio_use_dump_file(char *file)
 	close(fd);
 }
 
+/**
+ * intel_mmio_use_pci_bar:
+ * @pci_dev: intel gracphis pci device
+ *
+ * Sets up #mmio to point at the data contained in @file. This allows the same
+ * code to get reused for dumping and decoding from running hardwared as from
+ * register dumps.
+ *
+ * @pci_dev can be obtained from intel_get_pci_device().
+ */
 void
 intel_mmio_use_pci_bar(struct pci_device *pci_dev)
 {
@@ -119,11 +159,18 @@ release_forcewake_lock(int fd)
 	close(fd);
 }
 
-/*
- * Initialize register access library.
- *
- * @pci_dev: pci device we're mucking with
+/**
+ * intel_register_access_init:
+ * @pci_dev: intel gracphis pci device
  * @safe: use safe register access tables
+ *
+ * This initializes the new register access library, which supports forcewake
+ * handling and also allows register access to be checked with an explicit
+ * whitelist.
+ *
+ * It also initializes #mmio like intel_mmio_use_pci_bar().
+ *
+ * @pci_dev can be obtained from intel_get_pci_device().
  */
 int
 intel_register_access_init(struct pci_device *pci_dev, int safe)
@@ -157,17 +204,30 @@ intel_register_access_init(struct pci_device *pci_dev, int safe)
 	mmio_data.inited++;
 	return 0;
 }
+
 static int
 intel_register_access_needs_wake(void)
 {
 	return mmio_data.key != FAKEKEY;
 }
 
+/**
+ * intel_register_access_needs_fakewake:
+ *
+ * Returns:
+ * Non-zero when forcewake initialization failed.
+ */
 int intel_register_access_needs_fakewake(void)
 {
 	return mmio_data.key == FAKEKEY;
 }
 
+/**
+ * intel_register_access_fini:
+ *
+ * Clean up the register access helper initialized with
+ * intel_register_access_init().
+ */
 void
 intel_register_access_fini(void)
 {
@@ -176,6 +236,19 @@ intel_register_access_fini(void)
 	mmio_data.inited--;
 }
 
+/**
+ * intel_register_read:
+ * @reg: register offset
+ *
+ * 32-bit read of the register at @offset. This function only works when the new
+ * register access helper is initialized with intel_register_access_init().
+ *
+ * Compared to INREG() it can do optional checking with the register access
+ * white lists.
+ *
+ * Returns:
+ * The value read from the register.
+ */
 uint32_t
 intel_register_read(uint32_t reg)
 {
@@ -207,6 +280,17 @@ out:
 	return ret;
 }
 
+/**
+ * intel_register_write:
+ * @reg: register offset
+ * @val: value to write
+ *
+ * 32-bit write to the register at @offset. This function only works when the new
+ * register access helper is initialized with intel_register_access_init().
+ *
+ * Compared to OUTRET() it can do optional checking with the register access
+ * white lists.
+ */
 void
 intel_register_write(uint32_t reg, uint32_t val)
 {
@@ -232,3 +316,36 @@ intel_register_write(uint32_t reg, uint32_t val)
 write_out:
 	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
 }
+
+
+/**
+ * INREG:
+ * @reg: register offset
+ *
+ * 32-bit read of the register at @offset. This function only works when the new
+ * register access helper is initialized with intel_register_access_init().
+ *
+ * This function directly accesses the #mmio without safety checks.
+ *
+ * Returns:
+ * The value read from the register.
+ */
+uint32_t INREG(uint32_t reg)
+{
+	return *(volatile uint32_t *)((volatile char *)mmio + reg);
+}
+
+/**
+ * OUTRET:
+ * @reg: register offset
+ * @val: value to write
+ *
+ * 32-bit write to the register at @offset. This function only works when the new
+ * register access helper is initialized with intel_register_access_init().
+ *
+ * This function directly accesses the #mmio without safety checks.
+ */
+void OUTREG(uint32_t reg, uint32_t val)
+{
+	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
+}
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 22/28] lib: s/drmtest_dumb_aub/igt_aub_dump_enabled/
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (20 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 21/28] lib/intel_io: api documentation Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 23/28] lib: extract igt_aux.[hc] Daniel Vetter
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

This is prep work to extract a new igt aux library with all kinds
of random stuff. Also give it a bit a more suitable name to
indicate that this is just a flag and doesn't do the aub dumping
itself.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/drmtest.c           | 2 +-
 lib/drmtest.h           | 2 +-
 lib/rendercopy_gen8.c   | 2 +-
 tests/gem_render_copy.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 3c72ac8dba2c..9fcd221be450 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -329,7 +329,7 @@ bool igt_env_set(const char *env_var, bool default_value)
 	return atoi(val) != 0;
 }
 
-bool drmtest_dump_aub(void)
+bool igt_aub_dump_enabled(void)
 {
 	static int dump_aub = -1;
 
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 97d60d0c29dd..0985109b5247 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -66,7 +66,7 @@ void igt_permute_array(void *array, unsigned size,
 void igt_progress(const char *header, uint64_t i, uint64_t total);
 bool igt_env_set(const char *env_var, bool default_value);
 
-bool drmtest_dump_aub(void);
+bool igt_aub_dump_enabled(void);
 
 /* helpers based upon the libdrm buffer manager */
 void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
diff --git a/lib/rendercopy_gen8.c b/lib/rendercopy_gen8.c
index 424afa0aefa8..02333cfd8461 100644
--- a/lib/rendercopy_gen8.c
+++ b/lib/rendercopy_gen8.c
@@ -120,7 +120,7 @@ static void annotation_add_state(struct annotations_context *ctx,
 static void annotation_flush(struct annotations_context *ctx,
 			     struct intel_batchbuffer *batch)
 {
-	if (!drmtest_dump_aub())
+	if (!igt_aub_dump_enabled())
 		return;
 
 	drm_intel_bufmgr_gem_set_aub_annotations(batch->bo,
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index 12ac18d31251..86ae64385351 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -127,7 +127,7 @@ int main(int argc, char **argv)
 	igt_render_copyfunc_t render_copy = NULL;
 	int opt;
 	int opt_dump_png = false;
-	int opt_dump_aub = drmtest_dump_aub();
+	int opt_dump_aub = igt_aub_dump_enabled();
 
 	igt_simple_init();
 
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 23/28] lib: extract igt_aux.[hc]
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (21 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 22/28] lib: s/drmtest_dumb_aub/igt_aub_dump_enabled/ Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 24/28] lib/igt_aux: api documentation Daniel Vetter
                   ` (5 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

And shovel all the various helpers in there.

Also move igt_set_vt_graphics_mode to igt_kms.h since the function is
implemented in igt_kms.c. And it fits better. I kinda missed this in
the prep work.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/Makefile.sources                   |   2 +
 lib/drmtest.c                          | 188 -------------------------
 lib/drmtest.h                          |  36 +----
 lib/igt_aux.c                          | 249 +++++++++++++++++++++++++++++++++
 lib/igt_aux.h                          |  67 +++++++++
 lib/igt_core.c                         |   1 +
 lib/igt_kms.c                          |   1 +
 lib/igt_kms.h                          |   3 +
 lib/intel_os.c                         |   2 +-
 lib/rendercopy_gen8.c                  |   7 +-
 tests/drv_suspend.c                    |   5 +-
 tests/eviction_common.c                |   1 +
 tests/gem_caching.c                    |   5 +-
 tests/gem_concurrent_blit.c            |   5 +-
 tests/gem_cpu_reloc.c                  |   5 +-
 tests/gem_cs_prefetch.c                |   5 +-
 tests/gem_cs_tlb.c                     |   5 +-
 tests/gem_ctx_exec.c                   |   6 +-
 tests/gem_evict_alignment.c            |   5 +-
 tests/gem_fd_exhaustion.c              |   2 +
 tests/gem_fenced_exec_thrash.c         |   1 +
 tests/gem_linear_blits.c               |   7 +-
 tests/gem_partial_pwrite_pread.c       |   7 +-
 tests/gem_persistent_relocs.c          |   7 +-
 tests/gem_pin.c                        |   5 +-
 tests/gem_pread_after_blit.c           |   7 +-
 tests/gem_reloc_vs_gpu.c               |   7 +-
 tests/gem_render_copy.c                |   5 +-
 tests/gem_render_linear_blits.c        |   5 +-
 tests/gem_render_tiled_blits.c         |   5 +-
 tests/gem_reset_stats.c                |   3 +-
 tests/gem_ringfill.c                   |   6 +-
 tests/gem_seqno_wrap.c                 |   1 +
 tests/gem_stress.c                     |   5 +-
 tests/gem_tiled_blits.c                |   7 +-
 tests/gem_tiled_fence_blits.c          |   5 +-
 tests/gem_tiled_partial_pwrite_pread.c |   7 +-
 tests/gem_tiled_pread_pwrite.c         |   5 +-
 tests/gem_tiled_swapping.c             |   5 +-
 tests/gem_wait_render_timeout.c        |   5 +-
 tests/gem_write_read_ring_switch.c     |   7 +-
 tests/igt_fork_helper.c                |   1 +
 tests/kms_flip.c                       |   1 +
 43 files changed, 443 insertions(+), 271 deletions(-)
 create mode 100644 lib/igt_aux.c
 create mode 100644 lib/igt_aux.h

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 3e2a4b5b9c55..4e83d3118ea9 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -10,6 +10,8 @@ libintel_tools_la_SOURCES = 	\
 	igt_debugfs.h		\
 	igt_display.c		\
 	igt_display.h		\
+	igt_aux.c		\
+	igt_aux.h		\
 	instdone.c		\
 	instdone.h		\
 	intel_batchbuffer.c	\
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 9fcd221be450..8bb64f0cbf8b 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -277,191 +277,3 @@ int drm_open_any_render(void)
 
 	return fd;
 }
-
-/* signal interrupt helpers */
-static struct igt_helper_process signal_helper;
-long long int sig_stat;
-static void __attribute__((noreturn)) signal_helper_process(pid_t pid)
-{
-	/* Interrupt the parent process at 500Hz, just to be annoying */
-	while (1) {
-		usleep(1000 * 1000 / 500);
-		if (kill(pid, SIGUSR1)) /* Parent has died, so must we. */
-			exit(0);
-	}
-}
-
-static void sig_handler(int i)
-{
-	sig_stat++;
-}
-
-void igt_fork_signal_helper(void)
-{
-	if (igt_only_list_subtests())
-		return;
-
-	signal(SIGUSR1, sig_handler);
-
-	igt_fork_helper(&signal_helper) {
-		signal_helper_process(getppid());
-	}
-}
-
-void igt_stop_signal_helper(void)
-{
-	if (igt_only_list_subtests())
-		return;
-
-	igt_stop_helper(&signal_helper);
-
-	sig_stat = 0;
-}
-
-bool igt_env_set(const char *env_var, bool default_value)
-{
-	char *val;
-
-	val = getenv(env_var);
-	if (!val)
-		return default_value;
-
-	return atoi(val) != 0;
-}
-
-bool igt_aub_dump_enabled(void)
-{
-	static int dump_aub = -1;
-
-	if (dump_aub == -1)
-		dump_aub = igt_env_set("IGT_DUMP_AUB", false);
-
-	return dump_aub;
-}
-
-/* other helpers */
-void igt_exchange_int(void *array, unsigned i, unsigned j)
-{
-	int *int_arr, tmp;
-	int_arr = array;
-
-	tmp = int_arr[i];
-	int_arr[i] = int_arr[j];
-	int_arr[j] = tmp;
-}
-
-void igt_permute_array(void *array, unsigned size,
-			   void (*exchange_func)(void *array,
-						 unsigned i,
-						 unsigned j))
-{
-	int i;
-
-	for (i = size - 1; i > 1; i--) {
-		/* yes, not perfectly uniform, who cares */
-		long l = random() % (i +1);
-		if (i != l)
-			exchange_func(array, i, l);
-	}
-}
-
-void igt_progress(const char *header, uint64_t i, uint64_t total)
-{
-	int divider = 200;
-
-	if (!isatty(fileno(stderr)))
-		return;
-
-	if (i+1 >= total) {
-		fprintf(stderr, "\r%s100%%\n", header);
-		return;
-	}
-
-	if (total / 200 == 0)
-		divider = 1;
-
-	/* only bother updating about every 0.5% */
-	if (i % (total / divider) == 0 || i+1 >= total) {
-		fprintf(stderr, "\r%s%3llu%%", header,
-			(long long unsigned) i * 100 / total);
-	}
-}
-
-/* mappable aperture trasher helper */
-drm_intel_bo **trash_bos;
-int num_trash_bos;
-
-void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
-{
-	int i;
-
-	num_trash_bos = gem_mappable_aperture_size() / (1024*1024);
-
-	trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *));
-	igt_assert(trash_bos);
-
-	for (i = 0; i < num_trash_bos; i++)
-		trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096);
-}
-
-void igt_trash_aperture(void)
-{
-	int i;
-	uint8_t *gtt_ptr;
-
-	for (i = 0; i < num_trash_bos; i++) {
-		drm_intel_gem_bo_map_gtt(trash_bos[i]);
-		gtt_ptr = trash_bos[i]->virtual;
-		*gtt_ptr = 0;
-		drm_intel_gem_bo_unmap_gtt(trash_bos[i]);
-	}
-}
-
-void igt_cleanup_aperture_trashers(void)
-{
-	int i;
-
-	for (i = 0; i < num_trash_bos; i++)
-		drm_intel_bo_unreference(trash_bos[i]);
-
-	free(trash_bos);
-}
-
-void igt_system_suspend_autoresume(void)
-{
-	int ret;
-
-	/* FIXME: Simulation doesn't like suspend/resume, and not even a lighter
-	 * approach using /sys/power/pm_test to just test our driver's callbacks
-	 * seems to fare better. We need to investigate what's going on. */
-	igt_skip_on_simulation();
-
-	ret = system("rtcwake -s 30 -m mem");
-	igt_assert(ret == 0);
-}
-
-void igt_drop_root(void)
-{
-	igt_assert(getuid() == 0);
-
-	igt_assert(setgid(2) == 0);
-	igt_assert(setuid(2) == 0);
-
-	igt_assert(getgid() == 2);
-	igt_assert(getuid() == 2);
-}
-
-void igt_wait_for_keypress(void)
-{
-	struct termios oldt, newt;
-
-	if (!isatty(STDIN_FILENO))
-		return;
-
-	tcgetattr ( STDIN_FILENO, &oldt );
-	newt = oldt;
-	newt.c_lflag &= ~( ICANON | ECHO );
-	tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
-	getchar();
-	tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
-}
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 0985109b5247..631627cceb30 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -34,7 +34,8 @@
 #include <sys/mman.h>
 
 #include <xf86drm.h>
-#include <intel_batchbuffer.h>
+
+#include "intel_batchbuffer.h"
 
 #ifdef ANDROID
 #ifndef HAVE_MMAP64
@@ -55,40 +56,7 @@ int drm_open_any_render(void);
 
 void gem_quiescent_gpu(int fd);
 
-/* generally useful helpers */
-void igt_fork_signal_helper(void);
-void igt_stop_signal_helper(void);
-void igt_exchange_int(void *array, unsigned i, unsigned j);
-void igt_permute_array(void *array, unsigned size,
-			   void (*exchange_func)(void *array,
-						 unsigned i,
-						 unsigned j));
-void igt_progress(const char *header, uint64_t i, uint64_t total);
-bool igt_env_set(const char *env_var, bool default_value);
-
-bool igt_aub_dump_enabled(void);
-
-/* helpers based upon the libdrm buffer manager */
-void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
-void igt_trash_aperture(void);
-void igt_cleanup_aperture_trashers(void);
-
 #define do_or_die(x) igt_assert((x) == 0)
 #define do_ioctl(fd, ptr, sz) igt_assert(drmIoctl((fd), (ptr), (sz)) == 0)
 
-/* set vt into graphics mode, required to prevent fbcon from interfering */
-void igt_set_vt_graphics_mode(void);
-
-/* suspend and auto-resume system */
-void igt_system_suspend_autoresume(void);
-
-/* dropping priviledges */
-void igt_drop_root(void);
-
-void igt_wait_for_keypress(void);
-
-/* sysinfo cross-arch wrappers from intel_os.c */
-uint64_t intel_get_total_ram_mb(void);
-uint64_t intel_get_total_swap_mb(void);
-
 #endif /* DRMTEST_H */
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
new file mode 100644
index 000000000000..fff5f0e89387
--- /dev/null
+++ b/lib/igt_aux.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright © 2007, 2011, 2013, 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric@anholt.net>
+ *    Daniel Vetter <daniel.vetter@ffwll.ch>
+ *
+ */
+
+#ifndef ANDROID
+#define _GNU_SOURCE
+#else
+#include <libgen.h>
+#endif
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include <pciaccess.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/utsname.h>
+#include <termios.h>
+
+#include "drmtest.h"
+#include "i915_drm.h"
+#include "intel_chipset.h"
+#include "igt_aux.h"
+#include "igt_debugfs.h"
+#include "../version.h"
+#include "config.h"
+#include "intel_reg.h"
+#include "ioctl_wrappers.h"
+
+
+
+/* signal interrupt helpers */
+static struct igt_helper_process signal_helper;
+long long int sig_stat;
+static void __attribute__((noreturn)) signal_helper_process(pid_t pid)
+{
+	/* Interrupt the parent process at 500Hz, just to be annoying */
+	while (1) {
+		usleep(1000 * 1000 / 500);
+		if (kill(pid, SIGUSR1)) /* Parent has died, so must we. */
+			exit(0);
+	}
+}
+
+static void sig_handler(int i)
+{
+	sig_stat++;
+}
+
+void igt_fork_signal_helper(void)
+{
+	if (igt_only_list_subtests())
+		return;
+
+	signal(SIGUSR1, sig_handler);
+
+	igt_fork_helper(&signal_helper) {
+		signal_helper_process(getppid());
+	}
+}
+
+void igt_stop_signal_helper(void)
+{
+	if (igt_only_list_subtests())
+		return;
+
+	igt_stop_helper(&signal_helper);
+
+	sig_stat = 0;
+}
+
+bool igt_env_set(const char *env_var, bool default_value)
+{
+	char *val;
+
+	val = getenv(env_var);
+	if (!val)
+		return default_value;
+
+	return atoi(val) != 0;
+}
+
+bool igt_aub_dump_enabled(void)
+{
+	static int dump_aub = -1;
+
+	if (dump_aub == -1)
+		dump_aub = igt_env_set("IGT_DUMP_AUB", false);
+
+	return dump_aub;
+}
+
+/* other helpers */
+void igt_exchange_int(void *array, unsigned i, unsigned j)
+{
+	int *int_arr, tmp;
+	int_arr = array;
+
+	tmp = int_arr[i];
+	int_arr[i] = int_arr[j];
+	int_arr[j] = tmp;
+}
+
+void igt_permute_array(void *array, unsigned size,
+			   void (*exchange_func)(void *array,
+						 unsigned i,
+						 unsigned j))
+{
+	int i;
+
+	for (i = size - 1; i > 1; i--) {
+		/* yes, not perfectly uniform, who cares */
+		long l = random() % (i +1);
+		if (i != l)
+			exchange_func(array, i, l);
+	}
+}
+
+void igt_progress(const char *header, uint64_t i, uint64_t total)
+{
+	int divider = 200;
+
+	if (!isatty(fileno(stderr)))
+		return;
+
+	if (i+1 >= total) {
+		fprintf(stderr, "\r%s100%%\n", header);
+		return;
+	}
+
+	if (total / 200 == 0)
+		divider = 1;
+
+	/* only bother updating about every 0.5% */
+	if (i % (total / divider) == 0 || i+1 >= total) {
+		fprintf(stderr, "\r%s%3llu%%", header,
+			(long long unsigned) i * 100 / total);
+	}
+}
+
+/* mappable aperture trasher helper */
+drm_intel_bo **trash_bos;
+int num_trash_bos;
+
+void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
+{
+	int i;
+
+	num_trash_bos = gem_mappable_aperture_size() / (1024*1024);
+
+	trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *));
+	igt_assert(trash_bos);
+
+	for (i = 0; i < num_trash_bos; i++)
+		trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096);
+}
+
+void igt_trash_aperture(void)
+{
+	int i;
+	uint8_t *gtt_ptr;
+
+	for (i = 0; i < num_trash_bos; i++) {
+		drm_intel_gem_bo_map_gtt(trash_bos[i]);
+		gtt_ptr = trash_bos[i]->virtual;
+		*gtt_ptr = 0;
+		drm_intel_gem_bo_unmap_gtt(trash_bos[i]);
+	}
+}
+
+void igt_cleanup_aperture_trashers(void)
+{
+	int i;
+
+	for (i = 0; i < num_trash_bos; i++)
+		drm_intel_bo_unreference(trash_bos[i]);
+
+	free(trash_bos);
+}
+
+void igt_system_suspend_autoresume(void)
+{
+	int ret;
+
+	/* FIXME: Simulation doesn't like suspend/resume, and not even a lighter
+	 * approach using /sys/power/pm_test to just test our driver's callbacks
+	 * seems to fare better. We need to investigate what's going on. */
+	igt_skip_on_simulation();
+
+	ret = system("rtcwake -s 30 -m mem");
+	igt_assert(ret == 0);
+}
+
+void igt_drop_root(void)
+{
+	igt_assert(getuid() == 0);
+
+	igt_assert(setgid(2) == 0);
+	igt_assert(setuid(2) == 0);
+
+	igt_assert(getgid() == 2);
+	igt_assert(getuid() == 2);
+}
+
+void igt_wait_for_keypress(void)
+{
+	struct termios oldt, newt;
+
+	if (!isatty(STDIN_FILENO))
+		return;
+
+	tcgetattr ( STDIN_FILENO, &oldt );
+	newt = oldt;
+	newt.c_lflag &= ~( ICANON | ECHO );
+	tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
+	getchar();
+	tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
+}
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
new file mode 100644
index 000000000000..eb6371280c1b
--- /dev/null
+++ b/lib/igt_aux.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Daniel Vetter <daniel.vetter@ffwll.ch>
+ *
+ */
+
+#ifndef IGT_AUX_H
+#define IGT_AUX_H
+
+#include <intel_bufmgr.h>
+
+/* auxialiary igt helpers from igt_aux.c */
+/* generally useful helpers */
+void igt_fork_signal_helper(void);
+void igt_stop_signal_helper(void);
+void igt_exchange_int(void *array, unsigned i, unsigned j);
+void igt_permute_array(void *array, unsigned size,
+			   void (*exchange_func)(void *array,
+						 unsigned i,
+						 unsigned j));
+void igt_progress(const char *header, uint64_t i, uint64_t total);
+bool igt_env_set(const char *env_var, bool default_value);
+
+bool igt_aub_dump_enabled(void);
+
+/* helpers based upon the libdrm buffer manager */
+void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
+void igt_trash_aperture(void);
+void igt_cleanup_aperture_trashers(void);
+
+/* suspend and auto-resume system */
+void igt_system_suspend_autoresume(void);
+
+/* dropping priviledges */
+void igt_drop_root(void);
+
+void igt_wait_for_keypress(void);
+
+/* sysinfo cross-arch wrappers from intel_os.c */
+
+/* These are separate to allow easier testing when porting, see the comment at
+ * the bottom of intel_os.c. */
+uint64_t intel_get_total_ram_mb(void);
+uint64_t intel_get_total_swap_mb(void);
+
+#endif /* IGT_AUX_H */
diff --git a/lib/igt_core.c b/lib/igt_core.c
index cd094c431e3d..ed631f167b44 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -58,6 +58,7 @@
 #include "config.h"
 
 #include "igt_core.h"
+#include "igt_aux.h"
 
 /**
  * SECTION:igt_core
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f74f7070d040..5b7aca713505 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -38,6 +38,7 @@
 
 #include "drmtest.h"
 #include "igt_kms.h"
+#include "igt_aux.h"
 #include "ioctl_wrappers.h"
 
 /* helpers to create nice-looking framebuffers */
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 95735e8ffdd7..19c2649c91d2 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -164,6 +164,9 @@ struct igt_display {
 	igt_pipe_t pipes[I915_MAX_PIPES];
 };
 
+/* set vt into graphics mode, required to prevent fbcon from interfering */
+void igt_set_vt_graphics_mode(void);
+
 void igt_display_init(igt_display_t *display, int drm_fd);
 void igt_display_fini(igt_display_t *display);
 int  igt_display_commit(igt_display_t *display);
diff --git a/lib/intel_os.c b/lib/intel_os.c
index 14dda1474d5d..3a7397aa986a 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -48,8 +48,8 @@
 #endif
 
 #include "intel_io.h"
-#include "i915_drm.h"
 #include "drmtest.h"
+#include "igt_aux.h"
 
 uint64_t
 intel_get_total_ram_mb(void)
diff --git a/lib/rendercopy_gen8.c b/lib/rendercopy_gen8.c
index 02333cfd8461..e846376665e9 100644
--- a/lib/rendercopy_gen8.c
+++ b/lib/rendercopy_gen8.c
@@ -10,8 +10,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <getopt.h>
-#include "drm.h"
-#include "i915_drm.h"
+
+#include <drm.h>
+#include <i915_drm.h>
+
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
@@ -19,6 +21,7 @@
 #include "rendercopy.h"
 #include "gen8_render.h"
 #include "intel_reg.h"
+#include "igt_aux.h"
 
 #include <intel_aub.h>
 
diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c
index ed393af40d13..506ae16e8440 100644
--- a/tests/drv_suspend.c
+++ b/tests/drv_suspend.c
@@ -34,10 +34,13 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "igt_debugfs.h"
+#include "igt_aux.h"
 
 #define OBJECT_SIZE (16*1024*1024)
 
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index d1c4798af8e1..2d8e60ad08ef 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 
 #include "drmtest.h"
+#include "igt_aux.h"
 
 struct igt_eviction_test_ops
 {
diff --git a/tests/gem_caching.c b/tests/gem_caching.c
index 3d51f2617737..9a6a2944da7d 100644
--- a/tests/gem_caching.c
+++ b/tests/gem_caching.c
@@ -34,13 +34,16 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.h"
 
 /*
  * Testcase: snoop consistency when touching partial cachelines
diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index 03acf89c0c90..6a89aac5d06c 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -44,13 +44,16 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/wait.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.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 e0276e7f9a78..c22f9eb7a211 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -53,13 +53,16 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.h"
 
 static uint32_t use_blt;
 
diff --git a/tests/gem_cs_prefetch.c b/tests/gem_cs_prefetch.c
index ffa80f36fca1..63f4e9b9732c 100644
--- a/tests/gem_cs_prefetch.c
+++ b/tests/gem_cs_prefetch.c
@@ -43,13 +43,16 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.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 8f7bc61cd40b..b1c50584ef10 100644
--- a/tests/gem_cs_tlb.c
+++ b/tests/gem_cs_tlb.c
@@ -46,10 +46,13 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 #define LOCAL_I915_EXEC_VEBOX (4<<0)
 #define BATCH_SIZE (1024*1024)
diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c
index 3afa7652c8e9..9eddd9252355 100644
--- a/tests/gem_ctx_exec.c
+++ b/tests/gem_ctx_exec.c
@@ -40,9 +40,12 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "igt_aux.h"
 
 struct local_drm_i915_gem_context_destroy {
 	__u32 ctx_id;
@@ -56,6 +59,7 @@ static void context_destroy(int fd, uint32_t ctx_id)
 	struct local_drm_i915_gem_context_destroy destroy;
 	destroy.ctx_id = ctx_id;
 	do_ioctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
+#include "igt_aux.h"
 }
 
 /* Copied from gem_exec_nop.c */
diff --git a/tests/gem_evict_alignment.c b/tests/gem_evict_alignment.c
index 46da5ba1fcd4..c019b1891ffa 100644
--- a/tests/gem_evict_alignment.c
+++ b/tests/gem_evict_alignment.c
@@ -41,10 +41,13 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
+#include "igt_aux.h"
 
 #define HEIGHT 256
 #define WIDTH 1024
diff --git a/tests/gem_fd_exhaustion.c b/tests/gem_fd_exhaustion.c
index 7d865d4278cc..6032dd2788e7 100644
--- a/tests/gem_fd_exhaustion.c
+++ b/tests/gem_fd_exhaustion.c
@@ -31,8 +31,10 @@
 #include <sys/time.h>
 #include <fcntl.h>
 #include <limits.h>
+
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
+#include "igt_aux.h"
 
 
 #define FD_ARR_SZ 100
diff --git a/tests/gem_fenced_exec_thrash.c b/tests/gem_fenced_exec_thrash.c
index 3194e340cf2c..42b7841dfd15 100644
--- a/tests/gem_fenced_exec_thrash.c
+++ b/tests/gem_fenced_exec_thrash.c
@@ -41,6 +41,7 @@
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 #define WIDTH 1024
 #define HEIGHT 1024
diff --git a/tests/gem_linear_blits.c b/tests/gem_linear_blits.c
index 1b6742288220..a0ca2b1f6239 100644
--- a/tests/gem_linear_blits.c
+++ b/tests/gem_linear_blits.c
@@ -41,13 +41,14 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "intel_chipset.h"
 #include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/gem_partial_pwrite_pread.c b/tests/gem_partial_pwrite_pread.c
index a43a2b645fa0..dc72f550570b 100644
--- a/tests/gem_partial_pwrite_pread.c
+++ b/tests/gem_partial_pwrite_pread.c
@@ -33,13 +33,14 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 /*
  * Testcase: pwrite/pread consistency when touching partial cachelines
diff --git a/tests/gem_persistent_relocs.c b/tests/gem_persistent_relocs.c
index 1795160bcd1b..8b5a62efc158 100644
--- a/tests/gem_persistent_relocs.c
+++ b/tests/gem_persistent_relocs.c
@@ -36,14 +36,15 @@
 #include <sys/time.h>
 #include <signal.h>
 #include <sys/wait.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_bufmgr.h"
 #include "intel_chipset.h"
-#include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "igt_debugfs.h"
+#include "igt_aux.h"
 
 /*
  * Testcase: Persistent relocations as used by uxa/libva
diff --git a/tests/gem_pin.c b/tests/gem_pin.c
index 9572d2886748..91e1456a1c1c 100644
--- a/tests/gem_pin.c
+++ b/tests/gem_pin.c
@@ -35,11 +35,14 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 #define COPY_BLT_CMD            (2<<29|0x53<<22|0x6)
 #define BLT_WRITE_ALPHA         (1<<21)
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index 6c3f8227e9ee..4c87a382f762 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -42,13 +42,14 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_reloc_vs_gpu.c b/tests/gem_reloc_vs_gpu.c
index 8e8018762597..271f4f6731a5 100644
--- a/tests/gem_reloc_vs_gpu.c
+++ b/tests/gem_reloc_vs_gpu.c
@@ -36,14 +36,15 @@
 #include <sys/time.h>
 #include <signal.h>
 #include <sys/wait.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_debugfs.h"
+#include "igt_aux.h"
 
 /*
  * Testcase: Kernel relocations vs. gpu races
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index 86ae64385351..331b7ce5c6a2 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -42,13 +42,16 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <getopt.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.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 14a3ae7e7a41..a7121d0df26a 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -47,13 +47,16 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <getopt.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.h"
 
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c
index bee063fcc179..05c71b2aec05 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -43,13 +43,16 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <getopt.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.h"
 
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index a6d4edc72323..28679e771c7b 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -43,10 +43,9 @@
 #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_io.h"
+#include "igt_aux.h"
 
 #define RS_NO_ERROR      0
 #define RS_BATCH_ACTIVE  (1 << 0)
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index 88c8a8eeef69..6e91d8091b78 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -41,13 +41,13 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
-#include "drm.h"
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_bufmgr.h"
 #include "intel_chipset.h"
-#include "intel_batchbuffer.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 struct bo {
 	const char *ring;
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index a557c9857ed4..5e32fd600129 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -46,6 +46,7 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "igt_core.h"
+#include "igt_aux.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index bf3cde762142..4cbe8f4568d7 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -59,13 +59,16 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <getopt.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.h"
 
 #define CMD_POLY_STIPPLE_OFFSET       0x7906
 
diff --git a/tests/gem_tiled_blits.c b/tests/gem_tiled_blits.c
index 09be42efea2f..1f609ce7eff4 100644
--- a/tests/gem_tiled_blits.c
+++ b/tests/gem_tiled_blits.c
@@ -49,13 +49,14 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_tiled_fence_blits.c b/tests/gem_tiled_fence_blits.c
index 7cefca0b3afa..244b69076a05 100644
--- a/tests/gem_tiled_fence_blits.c
+++ b/tests/gem_tiled_fence_blits.c
@@ -49,13 +49,16 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.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 26fc145da8d1..40ade1fcd4d2 100644
--- a/tests/gem_tiled_partial_pwrite_pread.c
+++ b/tests/gem_tiled_partial_pwrite_pread.c
@@ -33,13 +33,14 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_bufmgr.h"
 #include "intel_chipset.h"
-#include "intel_batchbuffer.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 /*
  * Testcase: pwrite/pread consistency when touching partial cachelines
diff --git a/tests/gem_tiled_pread_pwrite.c b/tests/gem_tiled_pread_pwrite.c
index 08176f3d700d..b6d9d6273edb 100644
--- a/tests/gem_tiled_pread_pwrite.c
+++ b/tests/gem_tiled_pread_pwrite.c
@@ -53,10 +53,13 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c
index fd9b40f3285c..747236450d0f 100644
--- a/tests/gem_tiled_swapping.c
+++ b/tests/gem_tiled_swapping.c
@@ -53,10 +53,13 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_io.h"
+#include "igt_aux.h"
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/gem_wait_render_timeout.c b/tests/gem_wait_render_timeout.c
index b0b77adc0c38..9f4e8a1dcaf5 100644
--- a/tests/gem_wait_render_timeout.c
+++ b/tests/gem_wait_render_timeout.c
@@ -37,13 +37,16 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <getopt.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "igt_aux.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 f19a7bef6e48..76e1c2afa6db 100644
--- a/tests/gem_write_read_ring_switch.c
+++ b/tests/gem_write_read_ring_switch.c
@@ -33,14 +33,15 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
+
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "i830_reg.h"
+#include "igt_aux.h"
 
 #define LOCAL_I915_EXEC_VEBOX (4<<0)
 
diff --git a/tests/igt_fork_helper.c b/tests/igt_fork_helper.c
index a66ecde41d75..b4cf27eb5a47 100644
--- a/tests/igt_fork_helper.c
+++ b/tests/igt_fork_helper.c
@@ -26,6 +26,7 @@
  */
 
 #include "drmtest.h"
+#include "igt_aux.h"
 
 int main(int argc, char **argv)
 {
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index d5292e8924e1..7ba165687c21 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -43,6 +43,7 @@
 #include "intel_chipset.h"
 #include "intel_batchbuffer.h"
 #include "igt_kms.h"
+#include "igt_aux.h"
 
 #define TEST_DPMS		(1 << 0)
 #define TEST_WITH_DUMMY_BCS	(1 << 1)
-- 
1.8.5.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 24/28] lib/igt_aux: api documentation
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (22 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 23/28] lib: extract igt_aux.[hc] Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:18 ` [PATCH 25/28] lib: s/igt_env_set/igt_check_boolean_env_var Daniel Vetter
                   ` (4 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

I'm not really happy with the name of the igt_env_set function, I'll
follow up with a patch to change it.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   1 +
 lib/igt_aux.c                                      | 129 ++++++++++++++++++++-
 lib/intel_os.c                                     |  12 ++
 3 files changed, 139 insertions(+), 3 deletions(-)

diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index bf196f27dfd4..bd8294e5fd1e 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -20,6 +20,7 @@
     <xi:include href="xml/igt_debugfs.xml"/>
     <xi:include href="xml/igt_display.xml"/>
     <xi:include href="xml/igt_kms.xml"/>
+    <xi:include href="xml/igt_aux.xml"/>
     <xi:include href="xml/ioctl_wrappers.xml"/>
     <xi:include href="xml/intel_batchbuffer.xml"/>
     <xi:include href="xml/intel_chipset.xml"/>
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index fff5f0e89387..177f52da53f7 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -59,6 +59,17 @@
 #include "ioctl_wrappers.h"
 
 
+/**
+ * SECTION:igt_aux
+ * @short_description: Auxiliary libararies and support functions
+ * @title: i-g-t aux
+ *
+ * > #include "igt_aux.h"
+ *
+ * This library provides various auxiliary helper functions that don't really
+ * fit into any other topic.
+ */
+
 
 /* signal interrupt helpers */
 static struct igt_helper_process signal_helper;
@@ -78,6 +89,20 @@ static void sig_handler(int i)
 	sig_stat++;
 }
 
+/**
+ * igt_fork_signal_helper:
+ *
+ * Fork a child process using #igt_fork_helper to interrupt the parent process
+ * with a SIGUSR1 signal at regular quick intervals. The corresponding dummy
+ * signal handler is installed in the parent process.
+ *
+ * This is useful to exercise ioctl error paths, at least where those can be
+ * exercises by interrupting blocking waits, like stalling for the gpu. This
+ * helper can also be used from children spawned with #igt_fork.
+ *
+ * In tests with subtests this function can be called outside of failure
+ * catching code blocks like #igt_fixture or #igt_subtest.
+ */
 void igt_fork_signal_helper(void)
 {
 	if (igt_only_list_subtests())
@@ -90,6 +115,14 @@ void igt_fork_signal_helper(void)
 	}
 }
 
+/**
+ * igt_stop_signal_helper:
+ *
+ * Stops the child process spawned with igt_fork_signal_helper() again.
+ *
+ * In tests with subtests this function can be called outside of failure
+ * catching code blocks like #igt_fixture or #igt_subtest.
+ */
 void igt_stop_signal_helper(void)
 {
 	if (igt_only_list_subtests())
@@ -100,6 +133,17 @@ void igt_stop_signal_helper(void)
 	sig_stat = 0;
 }
 
+/**
+ * igt_env_set:
+ * @env_var: environment variable name
+ * @default_value: default value for the environment variable
+ *
+ * This function should be used to parse boolean environment variable options.
+ *
+ * Returns:
+ * The boolean value of the environment variable @env_var as decoded by atoi()
+ * if it is set and @default_value if the variable is not set.
+ */
 bool igt_env_set(const char *env_var, bool default_value)
 {
 	char *val;
@@ -111,6 +155,13 @@ bool igt_env_set(const char *env_var, bool default_value)
 	return atoi(val) != 0;
 }
 
+/**
+ * igt_aub_dump_enabled:
+ *
+ * Returns:
+ * True if AUB dumping is enabled with IGT_DUMP_AUB=1 in the environment, false
+ * otherwise.
+ */
 bool igt_aub_dump_enabled(void)
 {
 	static int dump_aub = -1;
@@ -122,6 +173,15 @@ bool igt_aub_dump_enabled(void)
 }
 
 /* other helpers */
+/**
+ * igt_exchange_int:
+ * @array: pointer to the array of integers
+ * @i: first position
+ * @j: second position
+ *
+ * Exchanges the two values at array indices @i and @j. Useful as an exchange
+ * function for igt_permute_array().
+ */
 void igt_exchange_int(void *array, unsigned i, unsigned j)
 {
 	int *int_arr, tmp;
@@ -132,10 +192,20 @@ void igt_exchange_int(void *array, unsigned i, unsigned j)
 	int_arr[j] = tmp;
 }
 
+/**
+ * igt_permute_array:
+ * @array: pointer to array
+ * @size: size of the array
+ * @exchange_func: function to exchange array elements
+ *
+ * This function randomly permutes the array using random() as the PRNG source.
+ * The @exchange_func function is called to exchange two elements in the array
+ * when needed.
+ */
 void igt_permute_array(void *array, unsigned size,
-			   void (*exchange_func)(void *array,
-						 unsigned i,
-						 unsigned j))
+                       void (*exchange_func)(void *array,
+                                             unsigned i,
+                                             unsigned j))
 {
 	int i;
 
@@ -147,6 +217,17 @@ void igt_permute_array(void *array, unsigned size,
 	}
 }
 
+/**
+ * igt_progress:
+ * @header: header string to prepend to the progress indicator
+ * @i: work processed thus far
+ * @total: total amount of work
+ *
+ * This function draws a progress indicator, which is useful for running
+ * long-winded tests manually on the console. To avoid spamming logfiles in
+ * automated runs the progress indicator is supressed when not running on a
+ * terminal.
+ */
 void igt_progress(const char *header, uint64_t i, uint64_t total)
 {
 	int divider = 200;
@@ -173,6 +254,13 @@ void igt_progress(const char *header, uint64_t i, uint64_t total)
 drm_intel_bo **trash_bos;
 int num_trash_bos;
 
+/**
+ * igt_init_aperture_trashers:
+ * @bufmgr: libdrm buffer manager
+ *
+ * Initialize the aperture trasher using @bufmgr, which can then be run with
+ * igt_trash_aperture().
+ */
 void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
 {
 	int i;
@@ -186,6 +274,11 @@ void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
 		trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096);
 }
 
+/**
+ * igt_trash_aperture:
+ *
+ * Trash the aperture by walking a set of GTT memory mapped objects.
+ */
 void igt_trash_aperture(void)
 {
 	int i;
@@ -199,6 +292,11 @@ void igt_trash_aperture(void)
 	}
 }
 
+/**
+ * igt_cleanup_aperture_trashers:
+ *
+ * Clean up all aperture trasher state set up with igt_init_aperture_trashers().
+ */
 void igt_cleanup_aperture_trashers(void)
 {
 	int i;
@@ -209,6 +307,14 @@ void igt_cleanup_aperture_trashers(void)
 	free(trash_bos);
 }
 
+/**
+ * igt_system_suspend_autoresume:
+ *
+ * Execute a system suspend-to-mem cycle and automatically wake up again using
+ * the firmwares resume timer.
+ *
+ * This is very handy for implementing any kind of suspend/resume test.
+ */
 void igt_system_suspend_autoresume(void)
 {
 	int ret;
@@ -222,6 +328,14 @@ void igt_system_suspend_autoresume(void)
 	igt_assert(ret == 0);
 }
 
+/**
+ * igt_drop_roo:
+ *
+ * Drop root priviledges and make sure it actually worked. Useful for tests
+ * which need to check security constraints. Note that this should only be
+ * called from manually forked processes, since the lack of root priviledges
+ * will wreak havoc with the automatic cleanup handlers.
+ */
 void igt_drop_root(void)
 {
 	igt_assert(getuid() == 0);
@@ -233,6 +347,15 @@ void igt_drop_root(void)
 	igt_assert(getuid() == 2);
 }
 
+/**
+ * igt_wait_for_keypress:
+ *
+ * Waits for a key press when run interactively. When not connected to a
+ * terminal immediately continues.
+ *
+ * This is useful for display tests where under certain situation manual
+ * inspection of the display is useful.
+ */
 void igt_wait_for_keypress(void)
 {
 	struct termios oldt, newt;
diff --git a/lib/intel_os.c b/lib/intel_os.c
index 3a7397aa986a..fb9f19cb5052 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -51,6 +51,12 @@
 #include "drmtest.h"
 #include "igt_aux.h"
 
+/**
+ * intel_get_total_ram_mb:
+ *
+ * Returns:
+ * The total amount of system RAM available in MB.
+ */
 uint64_t
 intel_get_total_ram_mb(void)
 {
@@ -79,6 +85,12 @@ intel_get_total_ram_mb(void)
 	return retval / (1024*1024);
 }
 
+/**
+ * intel_get_total_swap_mb:
+ *
+ * Returns:
+ * The total amount of swap space available in MB.
+ */
 uint64_t
 intel_get_total_swap_mb(void)
 {
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 25/28] lib: s/igt_env_set/igt_check_boolean_env_var
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (23 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 24/28] lib/igt_aux: api documentation Daniel Vetter
@ 2014-03-23 14:18 ` Daniel Vetter
  2014-03-23 14:19 ` [PATCH 26/28] lib: Use @include tag for include files Daniel Vetter
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

So I wasn't really happy with env_set since it's way too close to
setenv(), whic actually _sets_ and environment variable. So use check
instead of set as the verb (well adjective for env_set).

Also sprinkle in some hints that we talk about a boolean setting here.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/igt_aux.c  | 6 +++---
 lib/igt_aux.h  | 2 +-
 lib/igt_core.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 177f52da53f7..00a719c2563f 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -134,7 +134,7 @@ void igt_stop_signal_helper(void)
 }
 
 /**
- * igt_env_set:
+ * igt_check_boolean_env_var:
  * @env_var: environment variable name
  * @default_value: default value for the environment variable
  *
@@ -144,7 +144,7 @@ void igt_stop_signal_helper(void)
  * The boolean value of the environment variable @env_var as decoded by atoi()
  * if it is set and @default_value if the variable is not set.
  */
-bool igt_env_set(const char *env_var, bool default_value)
+bool igt_check_boolean_env_var(const char *env_var, bool default_value)
 {
 	char *val;
 
@@ -167,7 +167,7 @@ bool igt_aub_dump_enabled(void)
 	static int dump_aub = -1;
 
 	if (dump_aub == -1)
-		dump_aub = igt_env_set("IGT_DUMP_AUB", false);
+		dump_aub = igt_check_boolean_env_var("IGT_DUMP_AUB", false);
 
 	return dump_aub;
 }
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index eb6371280c1b..25a479f28970 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -40,7 +40,7 @@ void igt_permute_array(void *array, unsigned size,
 						 unsigned i,
 						 unsigned j));
 void igt_progress(const char *header, uint64_t i, uint64_t total);
-bool igt_env_set(const char *env_var, bool default_value);
+bool igt_check_boolean_env_var(const char *env_var, bool default_value);
 
 bool igt_aub_dump_enabled(void);
 
diff --git a/lib/igt_core.c b/lib/igt_core.c
index ed631f167b44..2fe74f5a23d6 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1111,7 +1111,7 @@ bool igt_run_in_simulation(void)
 	static int simulation = -1;
 
 	if (simulation == -1)
-		simulation = igt_env_set("INTEL_SIMULATION", false);
+		simulation = igt_check_boolean_env_var("INTEL_SIMULATION", false);
 
 	return simulation;
 }
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 26/28] lib: Use @include tag for include files
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (24 preceding siblings ...)
  2014-03-23 14:18 ` [PATCH 25/28] lib: s/igt_env_set/igt_check_boolean_env_var Daniel Vetter
@ 2014-03-23 14:19 ` Daniel Vetter
  2014-03-23 14:19 ` [PATCH 27/28] lib/drmtest: api documentation Daniel Vetter
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:19 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Occasionally useful to read documentation ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/igt_aux.c           | 1 +
 lib/igt_core.c          | 3 +--
 lib/igt_debugfs.c       | 3 +--
 lib/intel_batchbuffer.c | 3 +--
 lib/intel_chipset.c     | 3 +--
 lib/intel_mmio.c        | 3 +--
 lib/ioctl_wrappers.c    | 3 +--
 7 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 00a719c2563f..ec3bd187344a 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -63,6 +63,7 @@
  * SECTION:igt_aux
  * @short_description: Auxiliary libararies and support functions
  * @title: i-g-t aux
+ * @include: igt_aux.h
  *
  * > #include "igt_aux.h"
  *
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 2fe74f5a23d6..cf445efa51a5 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -64,8 +64,7 @@
  * SECTION:igt_core
  * @short_description: Core i-g-t testing support
  * @title: i-g-t core
- *
- * > #include "igt_core.h"
+ * @include: igt_core.h
  *
  * This libary implements the core of the i-g-t test support infrastructure.
  * Main features are the subtest enumeration, cmdline option parsing helpers for
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 96adf396887b..e04f8c5b9837 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -40,8 +40,7 @@
  * SECTION:igt_debugfs
  * @short_description: Support code for debugfs features
  * @title: i-g-t debugfs
- *
- * > #include "igt_debugfs.h"
+ * @include: igt_debugfs.h
  *
  * This library provides helpers to access debugfs features. On top of some
  * basic functions to access debugfs files with e.g. igt_debugfs_open() it also
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 7852c7ca750f..329239464678 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -45,8 +45,7 @@
  * SECTION:intel_batchbuffer
  * @short_description: Batchbuffer and blitter support
  * @title: intel batchbuffer
- *
- * > #include "intel_batchbuffer.h"
+ * @include: intel_batchbuffer.h
  *
  * This library provides some basic support for batchbuffers and using the
  * blitter engine based upon libdrm. A new batchbuffer is allocated with
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index b117e3be2753..eeafa314d6ee 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -44,8 +44,7 @@
  * SECTION:intel_chipset
  * @short_description: Feature macros and chipset helpers
  * @title: intel chipset
- *
- * > #include "intel_chipset.h"
+ * @include: intel_chipset.h
  *
  * This library mostly provides feature macros which use raw pci device ids. It
  * also provides a few more helper functions to handle pci devices, chipset
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 6666b9e75b12..45f39a46aff9 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -49,8 +49,7 @@
  * SECTION:intel_io
  * @short_description: Register access and sideband I/O libraray
  * @title: intel io
- *
- * > #include "intel_io.h"
+ * @include: intel_io.h
  *
  * This library provides register I/O helpers in both a basic version and a more
  * fancy version which also handles forcewak and can optionally check registers
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 24185491d4b6..df67b3747ba3 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -63,8 +63,7 @@
  * SECTION:ioctl_wrappers
  * @short_description: ioctl wrappers and related functions
  * @title: ioctl wrappers
- *
- * > #include "ioctl_wrappers.h"
+ * @include: ioctl_wrappers.h
  *
  * This helper library contains simple functions to wrap the raw drm/i915 kernel
  * ioctls. The normal versions never pass any error codes to the caller and use
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 27/28] lib/drmtest: api documentation
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (25 preceding siblings ...)
  2014-03-23 14:19 ` [PATCH 26/28] lib: Use @include tag for include files Daniel Vetter
@ 2014-03-23 14:19 ` Daniel Vetter
  2014-03-23 14:19 ` [PATCH 28/28] lib/intel_batchbuffer: document header dependencies Daniel Vetter
  2014-03-23 16:18 ` [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:19 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Also rename the arguments of do_ioctl a bit for better clarity.

I haven't figured out a way to reference other section headers, hence
the links to igt_core and intel_batchbuffer are a bit fragile
unfortunately. It gets the job done though.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/drmtest.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
 lib/drmtest.h | 26 +++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 6 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 8bb64f0cbf8b..d48af9c81cad 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -58,8 +58,20 @@
 #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. */
+/**
+ * SECTION:drmtest
+ * @short_description: Base library for drm tests and tools
+ * @title: drmtest
+ * @include: drmtest.h
+ *
+ * This library contains the basic support for writing tests, with the most
+ * important part being the helper function to open drm device nodes.
+ *
+ * But there's also a bit of other assorted stuff here.
+ *
+ * Note that this library's header pulls in the [i-g-t core](intel-gpu-tools-i-g-t-core.html)
+ * and [batchbuffer](intel-gpu-tools-intel-batchbuffer.html) libraries as depencies.
+ */
 
 static int
 is_intel(int fd)
@@ -77,7 +89,18 @@ is_intel(int fd)
 }
 
 #define LOCAL_I915_EXEC_VEBOX	(4 << 0)
-/* Ensure the gpu is idle by launching a nop execbuf and stalling for it. */
+/**
+ * gem_quiescent_gpu:
+ * @fd: open i915 drm file descriptor
+ *
+ * Ensure the gpu is idle by launching a nop execbuf and stalling for it. This
+ * is automatically run when opening a drm device node and is also installed as
+ * an exit handler to have the best assurance that the test is run in a pristine
+ * and controlled environment.
+ *
+ * This function simply allows tests to make additional calls in-between, if so
+ * desired.
+ */
 void gem_quiescent_gpu(int fd)
 {
 	uint32_t batch[2] = {MI_BATCH_BUFFER_END, 0};
@@ -134,9 +157,11 @@ void gem_quiescent_gpu(int fd)
 /**
  * drm_get_card:
  *
- * Get an intel card number for use in /dev or /sys
+ * Get an i915 drm card index number for use in /dev or /sys. The minor index of
+ * the legacy node is returned, not of the control or render node.
  *
- * Returns: -1 on error
+ * Returns:
+ * The i915 drm index or -1 on error
  */
 int drm_get_card(void)
 {
@@ -242,6 +267,14 @@ static void quiescent_gpu_at_exit_render(int sig)
 	at_exit_drm_render_fd = -1;
 }
 
+/**
+ * drm_open_any:
+ *
+ * Open an i915 drm legacy device node.
+ *
+ * Returns:
+ * The i915 drm file descriptor or -1 on error
+ */
 int drm_open_any(void)
 {
 	static int open_count;
@@ -259,6 +292,14 @@ int drm_open_any(void)
 	return fd;
 }
 
+/**
+ * drm_open_any:
+ *
+ * Open an i915 drm render device node.
+ *
+ * Returns:
+ * The i915 drm file descriptor or -1 on error
+ */
 int drm_open_any_render(void)
 {
 	static int open_count;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 631627cceb30..fdf98c624d33 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -48,6 +48,12 @@ static inline void *mmap64(void *addr, size_t length, int prot, int flags,
 #endif
 #endif
 
+/**
+ * ARRAY_SIZE:
+ * @arr: static array
+ *
+ * Macro to compute the size of the static array @arr.
+ */
 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
 
 int drm_get_card(void);
@@ -56,7 +62,25 @@ int drm_open_any_render(void);
 
 void gem_quiescent_gpu(int fd);
 
+/**
+ * do_or_die:
+ * @x: command
+ *
+ * Simple macro to execute x and check that it's return value is 0. Presumes
+ * that in any failure case the return value is non-zero and a precise error is
+ * logged into errno. Uses igt_assert() internally.
+ */
 #define do_or_die(x) igt_assert((x) == 0)
-#define do_ioctl(fd, ptr, sz) igt_assert(drmIoctl((fd), (ptr), (sz)) == 0)
+
+/**
+ * do_ioctl:
+ * @fd: open i915 drm file descriptor
+ * @ioc: ioctl op definition from drm headers
+ * @ioc_data: data pointer for the ioctl operation
+ *
+ * This macro wraps drmIoctl() and uses igt_assert to check that it has been
+ * successfully executed.
+ */
+#define do_ioctl(fd, ioc, ioc_data) igt_assert(drmIoctl((fd), (ioc), (ioc_data)) == 0)
 
 #endif /* DRMTEST_H */
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 28/28] lib/intel_batchbuffer: document header dependencies
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (26 preceding siblings ...)
  2014-03-23 14:19 ` [PATCH 27/28] lib/drmtest: api documentation Daniel Vetter
@ 2014-03-23 14:19 ` Daniel Vetter
  2014-03-23 16:18 ` [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
  28 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 14:19 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

At least with the core library headers the situation is now fairly
sane. There's still fun stuff going on around *_reg.h and most of the
source files just have a cargo-culted list of headers ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/intel_batchbuffer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 329239464678..0d583c73aa51 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -56,6 +56,9 @@
  * batchbuffers. All those macros presume that a pointer to a #intel_batchbuffer
  * structure called batch is in scope. The basic macros are #BEGIN_BATCH,
  * #OUT_BATCH, #OUT_RELOC and #ADVANCE_BATCH.
+ *
+ * Note that this library's header pulls in the [i-g-t core](intel-gpu-tools-i-g-t-core.html)
+ * library as a depency.
  */
 
 /**
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 00/28] more i-g-t docs and api polish
  2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
                   ` (27 preceding siblings ...)
  2014-03-23 14:19 ` [PATCH 28/28] lib/intel_batchbuffer: document header dependencies Daniel Vetter
@ 2014-03-23 16:18 ` Daniel Vetter
  2014-03-23 18:04   ` Ben Widawsky
  28 siblings, 1 reply; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 16:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

On Sun, Mar 23, 2014 at 03:18:34PM +0100, Daniel Vetter wrote:
> Hi all,
> 
> So this thing turned out to be fairly ugly overall, and I don't think it's worth
> the effort to polish the series through some giant rebasing. make distcheck
> still works so I don't think I've fumbled this too badly and will hence just
> push the patches as-is.
> 
> I'm still very much interested in feedback, I'll simply apply that as follow-up
> patches.
> 
> For those who want a peak at what the i-g-t docs look like now:
> 
> http://people.freedesktop.org/~danvet/igt/
> 
> Everything but the modeset helpers is now neatly documented, with some intro
> texts where useful. I think for the igt_display/kms libraries we first need to
> give the apis a bit more polish before documentation makes sense. There's still
> an awful lot of boilerplate going on in kms tests ...
> 
> Cheers, Daniel
> 
> Daniel Vetter (28):
>   lib: rename intel_pci.c to intel_chipset.c
>   lib: consolidate chipset helpers in intel_chipset.[hc]
>   lib/intel_chipset: intel_ prefix for pch global
>   lib/intel_chipset: api docs
>   lib: make rendercopy.h an internal header
>   lib: make media_fill.h an internal header
>   lib/intel_batchbuffer: un-inline buf_height/width
>   lib/intel_batchbuffer: igt_ namespace for the buffer structure
>   lib/intel_batchbuffer: igt_ prefix for rendercopy/mediafill funcs
>   lib/intel_batchbuffer: drop cpu_mapping from igt_buf
>   lib/intel_batchbuffer: api documentation for render copy/media fill
>   lib: Move non-register things out of intel-gpu-tools.h
>   tests|lib: remove assert.h includes
>   lib: add #include "foo.h" lines like in manpages
>   lib: remove uncessary #includes from headers
>   lib: more unecessary header removal
>   lib: unnecessary header removal for drmtest.h, part 1
>   lib: unnecessary header removal for drmtest.h, part 2
>   lib: rename intel_gpu_tools.h to intel_io.h
>   lib/intel_io: rename mmio setup functions
>   lib/intel_io: api documentation
>   lib: s/drmtest_dumb_aub/igt_aub_dump_enabled/
>   lib: extract igt_aux.[hc]
>   lib/igt_aux: api documentation
>   lib: s/igt_env_set/igt_check_boolean_env_var
>   lib: Use @include tag for include files
>   lib/drmtest: api documentation
>   lib/intel_batchbuffer: document header dependencies

Note that the quick_dump automake rules seem to be a bit fragile and fall
over a few of the renames in here. Running git clean -dfx and rebuilding
everything fixes that.

Unfortunately my autofoo isn't up to snuff to fix this.
-Daniel

> 
>  benchmarks/intel_upload_blit_large.c               |   9 +-
>  benchmarks/intel_upload_blit_large_gtt.c           |   3 +-
>  benchmarks/intel_upload_blit_large_map.c           |   3 +-
>  benchmarks/intel_upload_blit_small.c               |   3 +-
>  debugger/debug_rdata.c                             |   3 +-
>  debugger/eudb.c                                    |   2 +-
>  demos/intel_sprite_on.c                            |   7 +-
>  .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   5 +-
>  lib/Makefile.sources                               |   9 +-
>  lib/drmtest.c                                      | 243 +++-----------
>  lib/drmtest.h                                      |  80 +++--
>  lib/gen6_render.h                                  |   8 -
>  lib/gen7_media.h                                   |   2 +
>  lib/gen8_media.h                                   |   2 +
>  lib/igt_aux.c                                      | 373 +++++++++++++++++++++
>  lib/igt_aux.h                                      |  67 ++++
>  lib/igt_core.c                                     |   9 +-
>  lib/igt_core.h                                     |   7 +
>  lib/igt_debugfs.c                                  |   3 +
>  lib/igt_debugfs.h                                  |   3 +-
>  lib/igt_kms.c                                      |  14 +-
>  lib/igt_kms.h                                      |  10 +-
>  lib/intel_batchbuffer.c                            |  93 ++++-
>  lib/intel_batchbuffer.h                            |  96 +++++-
>  lib/intel_chipset.c                                | 215 ++++++++++++
>  lib/intel_chipset.h                                |  26 ++
>  lib/intel_drm.c                                    | 200 -----------
>  lib/intel_gpu_tools.h                              | 126 -------
>  lib/intel_io.h                                     |  81 +++++
>  lib/intel_iosf.c                                   |  61 +++-
>  lib/intel_mmio.c                                   | 133 +++++++-
>  lib/intel_os.c                                     | 171 ++++++++++
>  lib/intel_pci.c                                    | 123 -------
>  lib/intel_reg_map.c                                |   3 +-
>  lib/ioctl_wrappers.c                               |   6 +-
>  lib/ioctl_wrappers.h                               |   5 +
>  lib/media_fill.c                                   |  14 -
>  lib/media_fill.h                                   |  49 +--
>  lib/media_fill_gen7.c                              |  16 +-
>  lib/media_fill_gen8.c                              |  16 +-
>  lib/rendercopy.h                                   |  71 +---
>  lib/rendercopy_gen6.c                              |  51 ++-
>  lib/rendercopy_gen7.c                              |  44 ++-
>  lib/rendercopy_gen8.c                              |  58 ++--
>  lib/rendercopy_i830.c                              |  64 ++--
>  lib/rendercopy_i915.c                              |  30 +-
>  tests/core_get_client_auth.c                       |   2 +-
>  tests/core_getclient.c                             |   3 +
>  tests/core_getstats.c                              |   5 +
>  tests/ddi_compute_wrpll.c                          |   3 +-
>  tests/drm_vma_limiter.c                            |   5 +-
>  tests/drm_vma_limiter_cached.c                     |   5 +-
>  tests/drm_vma_limiter_cpu.c                        |   5 +-
>  tests/drm_vma_limiter_gtt.c                        |   5 +-
>  tests/drv_suspend.c                                |  11 +-
>  tests/eviction_common.c                            |   1 +
>  tests/gem_bad_address.c                            |   5 +-
>  tests/gem_bad_batch.c                              |   5 +-
>  tests/gem_bad_blit.c                               |   5 +-
>  tests/gem_bad_length.c                             |   2 +-
>  tests/gem_basic.c                                  |   2 +-
>  tests/gem_caching.c                                |  10 +-
>  tests/gem_close_race.c                             |   3 +-
>  tests/gem_concurrent_blit.c                        |  10 +-
>  tests/gem_cpu_reloc.c                              |  10 +-
>  tests/gem_cs_prefetch.c                            |  10 +-
>  tests/gem_cs_tlb.c                                 |   9 +-
>  tests/gem_ctx_bad_destroy.c                        |   4 +-
>  tests/gem_ctx_bad_exec.c                           |   2 +-
>  tests/gem_ctx_basic.c                              |  24 +-
>  tests/gem_ctx_create.c                             |   4 +-
>  tests/gem_ctx_exec.c                               |   8 +-
>  tests/gem_double_irq_loop.c                        |   5 +-
>  tests/gem_dummy_reloc_loop.c                       |   5 +-
>  tests/gem_evict_alignment.c                        |   8 +-
>  tests/gem_evict_everything.c                       |   3 +-
>  tests/gem_exec_bad_domains.c                       |   5 +-
>  tests/gem_exec_big.c                               |   2 +-
>  tests/gem_exec_blt.c                               |   4 +-
>  tests/gem_exec_faulting_reloc.c                    |   4 +-
>  tests/gem_exec_lut_handle.c                        |   2 +-
>  tests/gem_exec_nop.c                               |   4 +-
>  tests/gem_fd_exhaustion.c                          |   3 +
>  tests/gem_fence_thrash.c                           |  34 +-
>  tests/gem_fenced_exec_thrash.c                     |   8 +-
>  tests/gem_flink.c                                  |   2 +-
>  tests/gem_flink_race.c                             |   3 +-
>  tests/gem_gtt_cpu_tlb.c                            |   4 +-
>  tests/gem_gtt_hog.c                                |   3 +-
>  tests/gem_gtt_speed.c                              |   2 +-
>  tests/gem_hang.c                                   |   5 +-
>  tests/gem_hangcheck_forcewake.c                    |   5 +-
>  tests/gem_largeobject.c                            |   2 +-
>  tests/gem_linear_blits.c                           |  12 +-
>  tests/gem_lut_handle.c                             |   2 +-
>  tests/gem_madvise.c                                |   2 +-
>  tests/gem_media_fill.c                             |  29 +-
>  tests/gem_mmap.c                                   |   2 +-
>  tests/gem_mmap_gtt.c                               |   2 +-
>  tests/gem_mmap_offset_exhaustion.c                 |   2 +-
>  tests/gem_non_secure_batch.c                       |   5 +-
>  tests/gem_partial_pwrite_pread.c                   |  12 +-
>  tests/gem_persistent_relocs.c                      |  12 +-
>  tests/gem_pin.c                                    |   9 +-
>  tests/gem_pipe_control_store_loop.c                |   5 +-
>  tests/gem_pread.c                                  |   2 +-
>  tests/gem_pread_after_blit.c                       |  12 +-
>  tests/gem_pwrite.c                                 |   2 +-
>  tests/gem_pwrite_pread.c                           |   5 +-
>  tests/gem_readwrite.c                              |   2 +-
>  tests/gem_reg_read.c                               |   4 +-
>  tests/gem_reloc_overflow.c                         |   5 +-
>  tests/gem_reloc_vs_gpu.c                           |  12 +-
>  tests/gem_render_copy.c                            |  40 ++-
>  tests/gem_render_linear_blits.c                    |  31 +-
>  tests/gem_render_tiled_blits.c                     |  27 +-
>  tests/gem_reset_stats.c                            |  11 +-
>  tests/gem_ring_sync_copy.c                         |  21 +-
>  tests/gem_ring_sync_loop.c                         |   5 +-
>  tests/gem_ringfill.c                               |  26 +-
>  tests/gem_seqno_wrap.c                             |  22 +-
>  tests/gem_set_tiling_vs_blt.c                      |   5 +-
>  tests/gem_set_tiling_vs_gtt.c                      |   5 +-
>  tests/gem_set_tiling_vs_pwrite.c                   |   4 +-
>  tests/gem_storedw_batches_loop.c                   |   7 +-
>  tests/gem_storedw_loop_blt.c                       |   5 +-
>  tests/gem_storedw_loop_bsd.c                       |   5 +-
>  tests/gem_storedw_loop_render.c                    |   5 +-
>  tests/gem_storedw_loop_vebox.c                     |   5 +-
>  tests/gem_stress.c                                 |  87 +++--
>  tests/gem_threaded_access_tiled.c                  |   2 +-
>  tests/gem_tiled_blits.c                            |  12 +-
>  tests/gem_tiled_fence_blits.c                      |  10 +-
>  tests/gem_tiled_partial_pwrite_pread.c             |  12 +-
>  tests/gem_tiled_pread.c                            |   5 +-
>  tests/gem_tiled_pread_pwrite.c                     |   9 +-
>  tests/gem_tiled_swapping.c                         |   9 +-
>  tests/gem_tiling_max_stride.c                      |   5 +-
>  tests/gem_unfence_active_buffers.c                 |   5 +-
>  tests/gem_unref_active_buffers.c                   |   5 +-
>  tests/gem_vmap_blits.c                             |   5 +-
>  tests/gem_wait_render_timeout.c                    |  22 +-
>  tests/gem_write_read_ring_switch.c                 |  12 +-
>  tests/gen3_mixed_blits.c                           |   5 +-
>  tests/gen3_render_linear_blits.c                   |   5 +-
>  tests/gen3_render_mixed_blits.c                    |   5 +-
>  tests/gen3_render_tiledx_blits.c                   |   5 +-
>  tests/gen3_render_tiledy_blits.c                   |   5 +-
>  tests/gen7_forcewake_mt.c                          |   5 +-
>  tests/igt_fork_helper.c                            |   1 +
>  tests/igt_simulation.c                             |   2 +
>  tests/kms_addfb.c                                  |   2 +-
>  tests/kms_cursor_crc.c                             |   1 +
>  tests/kms_fbc_crc.c                                |  12 +-
>  tests/kms_flip.c                                   |  17 +-
>  tests/kms_pipe_crc_basic.c                         |   1 +
>  tests/kms_plane.c                                  |   1 +
>  tests/kms_render.c                                 |   7 +-
>  tests/kms_setmode.c                                |  27 +-
>  tests/pm_lpsp.c                                    |   2 +
>  tests/pm_pc8.c                                     |   5 +-
>  tests/pm_psr.c                                     |   2 +
>  tests/pm_rc6_residency.c                           |   2 +
>  tests/pm_rps.c                                     |   8 +-
>  tests/prime_nv_api.c                               |   3 +-
>  tests/prime_nv_pcopy.c                             |   5 +-
>  tests/prime_nv_test.c                              |   5 +-
>  tests/prime_self_import.c                          |   2 +-
>  tests/prime_udl.c                                  |   8 +-
>  tests/testdisplay.c                                |   6 +-
>  tools/intel_audio_dump.c                           |   9 +-
>  tools/intel_backlight.c                            |   6 +-
>  tools/intel_bios_reader.c                          |   4 +-
>  tools/intel_dpio_read.c                            |   3 +-
>  tools/intel_dpio_write.c                           |   3 +-
>  tools/intel_error_decode.c                         |   3 +-
>  tools/intel_forcewaked.c                           |   3 +-
>  tools/intel_framebuffer_dump.c                     |   2 +-
>  tools/intel_gpu_time.c                             |   6 +-
>  tools/intel_gpu_top.c                              |   6 +-
>  tools/intel_gtt.c                                  |   3 +-
>  tools/intel_infoframes.c                           |   8 +-
>  tools/intel_l3_parity.c                            |   3 +-
>  tools/intel_lid.c                                  |   5 +-
>  tools/intel_nc_read.c                              |   3 +-
>  tools/intel_nc_write.c                             |   3 +-
>  tools/intel_opregion_decode.c                      |   3 +-
>  tools/intel_panel_fitter.c                         |   4 +-
>  tools/intel_perf_counters.c                        |   3 +-
>  tools/intel_punit_read.c                           |   3 +-
>  tools/intel_punit_write.c                          |   3 +-
>  tools/intel_reg_checker.c                          |   5 +-
>  tools/intel_reg_dumper.c                           |  17 +-
>  tools/intel_reg_read.c                             |   3 +-
>  tools/intel_reg_snapshot.c                         |   5 +-
>  tools/intel_reg_write.c                            |   3 +-
>  tools/intel_stepping.c                             |   3 +-
>  tools/intel_vga_read.c                             |   3 +-
>  tools/intel_vga_write.c                            |   3 +-
>  tools/quick_dump/Makefile.am                       |   6 +-
>  tools/quick_dump/chipset_macro_wrap.c              |  33 ++
>  tools/quick_dump/intel_chipset.c                   |  33 --
>  202 files changed, 2401 insertions(+), 1398 deletions(-)
>  create mode 100644 lib/igt_aux.c
>  create mode 100644 lib/igt_aux.h
>  create mode 100644 lib/intel_chipset.c
>  delete mode 100644 lib/intel_drm.c
>  delete mode 100644 lib/intel_gpu_tools.h
>  create mode 100644 lib/intel_io.h
>  create mode 100644 lib/intel_os.c
>  delete mode 100644 lib/intel_pci.c
>  delete mode 100644 lib/media_fill.c
>  create mode 100644 tools/quick_dump/chipset_macro_wrap.c
>  delete mode 100644 tools/quick_dump/intel_chipset.c
> 
> -- 
> 1.8.5.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 00/28] more i-g-t docs and api polish
  2014-03-23 16:18 ` [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
@ 2014-03-23 18:04   ` Ben Widawsky
  2014-03-23 23:04     ` Daniel Vetter
  0 siblings, 1 reply; 32+ messages in thread
From: Ben Widawsky @ 2014-03-23 18:04 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development

On Sun, Mar 23, 2014 at 05:18:37PM +0100, Daniel Vetter wrote:
> On Sun, Mar 23, 2014 at 03:18:34PM +0100, Daniel Vetter wrote:
> > Hi all,
> > 
> > So this thing turned out to be fairly ugly overall, and I don't think it's worth
> > the effort to polish the series through some giant rebasing. make distcheck
> > still works so I don't think I've fumbled this too badly and will hence just
> > push the patches as-is.
> > 
> > I'm still very much interested in feedback, I'll simply apply that as follow-up
> > patches.

Documenting the tools is far more important IMO (or does this exist
already somewhere).

> > 
> > For those who want a peak at what the i-g-t docs look like now:
> > 
> > http://people.freedesktop.org/~danvet/igt/
> > 
> > Everything but the modeset helpers is now neatly documented, with some intro
> > texts where useful. I think for the igt_display/kms libraries we first need to
> > give the apis a bit more polish before documentation makes sense. There's still
> > an awful lot of boilerplate going on in kms tests ...
> > 
> > Cheers, Daniel
> > 
> > Daniel Vetter (28):
> >   lib: rename intel_pci.c to intel_chipset.c
> >   lib: consolidate chipset helpers in intel_chipset.[hc]
> >   lib/intel_chipset: intel_ prefix for pch global
> >   lib/intel_chipset: api docs
> >   lib: make rendercopy.h an internal header
> >   lib: make media_fill.h an internal header
> >   lib/intel_batchbuffer: un-inline buf_height/width
> >   lib/intel_batchbuffer: igt_ namespace for the buffer structure
> >   lib/intel_batchbuffer: igt_ prefix for rendercopy/mediafill funcs
> >   lib/intel_batchbuffer: drop cpu_mapping from igt_buf
> >   lib/intel_batchbuffer: api documentation for render copy/media fill
> >   lib: Move non-register things out of intel-gpu-tools.h
> >   tests|lib: remove assert.h includes
> >   lib: add #include "foo.h" lines like in manpages
> >   lib: remove uncessary #includes from headers
> >   lib: more unecessary header removal
> >   lib: unnecessary header removal for drmtest.h, part 1
> >   lib: unnecessary header removal for drmtest.h, part 2
> >   lib: rename intel_gpu_tools.h to intel_io.h
> >   lib/intel_io: rename mmio setup functions
> >   lib/intel_io: api documentation
> >   lib: s/drmtest_dumb_aub/igt_aub_dump_enabled/
> >   lib: extract igt_aux.[hc]
> >   lib/igt_aux: api documentation
> >   lib: s/igt_env_set/igt_check_boolean_env_var
> >   lib: Use @include tag for include files
> >   lib/drmtest: api documentation
> >   lib/intel_batchbuffer: document header dependencies
> 
> Note that the quick_dump automake rules seem to be a bit fragile and fall
> over a few of the renames in here. Running git clean -dfx and rebuilding
> everything fixes that.
> 
> Unfortunately my autofoo isn't up to snuff to fix this.
> -Daniel
> 
> > 
> >  benchmarks/intel_upload_blit_large.c               |   9 +-
> >  benchmarks/intel_upload_blit_large_gtt.c           |   3 +-
> >  benchmarks/intel_upload_blit_large_map.c           |   3 +-
> >  benchmarks/intel_upload_blit_small.c               |   3 +-
> >  debugger/debug_rdata.c                             |   3 +-
> >  debugger/eudb.c                                    |   2 +-
> >  demos/intel_sprite_on.c                            |   7 +-
> >  .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   5 +-
> >  lib/Makefile.sources                               |   9 +-
> >  lib/drmtest.c                                      | 243 +++-----------
> >  lib/drmtest.h                                      |  80 +++--
> >  lib/gen6_render.h                                  |   8 -
> >  lib/gen7_media.h                                   |   2 +
> >  lib/gen8_media.h                                   |   2 +
> >  lib/igt_aux.c                                      | 373 +++++++++++++++++++++
> >  lib/igt_aux.h                                      |  67 ++++
> >  lib/igt_core.c                                     |   9 +-
> >  lib/igt_core.h                                     |   7 +
> >  lib/igt_debugfs.c                                  |   3 +
> >  lib/igt_debugfs.h                                  |   3 +-
> >  lib/igt_kms.c                                      |  14 +-
> >  lib/igt_kms.h                                      |  10 +-
> >  lib/intel_batchbuffer.c                            |  93 ++++-
> >  lib/intel_batchbuffer.h                            |  96 +++++-
> >  lib/intel_chipset.c                                | 215 ++++++++++++
> >  lib/intel_chipset.h                                |  26 ++
> >  lib/intel_drm.c                                    | 200 -----------
> >  lib/intel_gpu_tools.h                              | 126 -------
> >  lib/intel_io.h                                     |  81 +++++
> >  lib/intel_iosf.c                                   |  61 +++-
> >  lib/intel_mmio.c                                   | 133 +++++++-
> >  lib/intel_os.c                                     | 171 ++++++++++
> >  lib/intel_pci.c                                    | 123 -------
> >  lib/intel_reg_map.c                                |   3 +-
> >  lib/ioctl_wrappers.c                               |   6 +-
> >  lib/ioctl_wrappers.h                               |   5 +
> >  lib/media_fill.c                                   |  14 -
> >  lib/media_fill.h                                   |  49 +--
> >  lib/media_fill_gen7.c                              |  16 +-
> >  lib/media_fill_gen8.c                              |  16 +-
> >  lib/rendercopy.h                                   |  71 +---
> >  lib/rendercopy_gen6.c                              |  51 ++-
> >  lib/rendercopy_gen7.c                              |  44 ++-
> >  lib/rendercopy_gen8.c                              |  58 ++--
> >  lib/rendercopy_i830.c                              |  64 ++--
> >  lib/rendercopy_i915.c                              |  30 +-
> >  tests/core_get_client_auth.c                       |   2 +-
> >  tests/core_getclient.c                             |   3 +
> >  tests/core_getstats.c                              |   5 +
> >  tests/ddi_compute_wrpll.c                          |   3 +-
> >  tests/drm_vma_limiter.c                            |   5 +-
> >  tests/drm_vma_limiter_cached.c                     |   5 +-
> >  tests/drm_vma_limiter_cpu.c                        |   5 +-
> >  tests/drm_vma_limiter_gtt.c                        |   5 +-
> >  tests/drv_suspend.c                                |  11 +-
> >  tests/eviction_common.c                            |   1 +
> >  tests/gem_bad_address.c                            |   5 +-
> >  tests/gem_bad_batch.c                              |   5 +-
> >  tests/gem_bad_blit.c                               |   5 +-
> >  tests/gem_bad_length.c                             |   2 +-
> >  tests/gem_basic.c                                  |   2 +-
> >  tests/gem_caching.c                                |  10 +-
> >  tests/gem_close_race.c                             |   3 +-
> >  tests/gem_concurrent_blit.c                        |  10 +-
> >  tests/gem_cpu_reloc.c                              |  10 +-
> >  tests/gem_cs_prefetch.c                            |  10 +-
> >  tests/gem_cs_tlb.c                                 |   9 +-
> >  tests/gem_ctx_bad_destroy.c                        |   4 +-
> >  tests/gem_ctx_bad_exec.c                           |   2 +-
> >  tests/gem_ctx_basic.c                              |  24 +-
> >  tests/gem_ctx_create.c                             |   4 +-
> >  tests/gem_ctx_exec.c                               |   8 +-
> >  tests/gem_double_irq_loop.c                        |   5 +-
> >  tests/gem_dummy_reloc_loop.c                       |   5 +-
> >  tests/gem_evict_alignment.c                        |   8 +-
> >  tests/gem_evict_everything.c                       |   3 +-
> >  tests/gem_exec_bad_domains.c                       |   5 +-
> >  tests/gem_exec_big.c                               |   2 +-
> >  tests/gem_exec_blt.c                               |   4 +-
> >  tests/gem_exec_faulting_reloc.c                    |   4 +-
> >  tests/gem_exec_lut_handle.c                        |   2 +-
> >  tests/gem_exec_nop.c                               |   4 +-
> >  tests/gem_fd_exhaustion.c                          |   3 +
> >  tests/gem_fence_thrash.c                           |  34 +-
> >  tests/gem_fenced_exec_thrash.c                     |   8 +-
> >  tests/gem_flink.c                                  |   2 +-
> >  tests/gem_flink_race.c                             |   3 +-
> >  tests/gem_gtt_cpu_tlb.c                            |   4 +-
> >  tests/gem_gtt_hog.c                                |   3 +-
> >  tests/gem_gtt_speed.c                              |   2 +-
> >  tests/gem_hang.c                                   |   5 +-
> >  tests/gem_hangcheck_forcewake.c                    |   5 +-
> >  tests/gem_largeobject.c                            |   2 +-
> >  tests/gem_linear_blits.c                           |  12 +-
> >  tests/gem_lut_handle.c                             |   2 +-
> >  tests/gem_madvise.c                                |   2 +-
> >  tests/gem_media_fill.c                             |  29 +-
> >  tests/gem_mmap.c                                   |   2 +-
> >  tests/gem_mmap_gtt.c                               |   2 +-
> >  tests/gem_mmap_offset_exhaustion.c                 |   2 +-
> >  tests/gem_non_secure_batch.c                       |   5 +-
> >  tests/gem_partial_pwrite_pread.c                   |  12 +-
> >  tests/gem_persistent_relocs.c                      |  12 +-
> >  tests/gem_pin.c                                    |   9 +-
> >  tests/gem_pipe_control_store_loop.c                |   5 +-
> >  tests/gem_pread.c                                  |   2 +-
> >  tests/gem_pread_after_blit.c                       |  12 +-
> >  tests/gem_pwrite.c                                 |   2 +-
> >  tests/gem_pwrite_pread.c                           |   5 +-
> >  tests/gem_readwrite.c                              |   2 +-
> >  tests/gem_reg_read.c                               |   4 +-
> >  tests/gem_reloc_overflow.c                         |   5 +-
> >  tests/gem_reloc_vs_gpu.c                           |  12 +-
> >  tests/gem_render_copy.c                            |  40 ++-
> >  tests/gem_render_linear_blits.c                    |  31 +-
> >  tests/gem_render_tiled_blits.c                     |  27 +-
> >  tests/gem_reset_stats.c                            |  11 +-
> >  tests/gem_ring_sync_copy.c                         |  21 +-
> >  tests/gem_ring_sync_loop.c                         |   5 +-
> >  tests/gem_ringfill.c                               |  26 +-
> >  tests/gem_seqno_wrap.c                             |  22 +-
> >  tests/gem_set_tiling_vs_blt.c                      |   5 +-
> >  tests/gem_set_tiling_vs_gtt.c                      |   5 +-
> >  tests/gem_set_tiling_vs_pwrite.c                   |   4 +-
> >  tests/gem_storedw_batches_loop.c                   |   7 +-
> >  tests/gem_storedw_loop_blt.c                       |   5 +-
> >  tests/gem_storedw_loop_bsd.c                       |   5 +-
> >  tests/gem_storedw_loop_render.c                    |   5 +-
> >  tests/gem_storedw_loop_vebox.c                     |   5 +-
> >  tests/gem_stress.c                                 |  87 +++--
> >  tests/gem_threaded_access_tiled.c                  |   2 +-
> >  tests/gem_tiled_blits.c                            |  12 +-
> >  tests/gem_tiled_fence_blits.c                      |  10 +-
> >  tests/gem_tiled_partial_pwrite_pread.c             |  12 +-
> >  tests/gem_tiled_pread.c                            |   5 +-
> >  tests/gem_tiled_pread_pwrite.c                     |   9 +-
> >  tests/gem_tiled_swapping.c                         |   9 +-
> >  tests/gem_tiling_max_stride.c                      |   5 +-
> >  tests/gem_unfence_active_buffers.c                 |   5 +-
> >  tests/gem_unref_active_buffers.c                   |   5 +-
> >  tests/gem_vmap_blits.c                             |   5 +-
> >  tests/gem_wait_render_timeout.c                    |  22 +-
> >  tests/gem_write_read_ring_switch.c                 |  12 +-
> >  tests/gen3_mixed_blits.c                           |   5 +-
> >  tests/gen3_render_linear_blits.c                   |   5 +-
> >  tests/gen3_render_mixed_blits.c                    |   5 +-
> >  tests/gen3_render_tiledx_blits.c                   |   5 +-
> >  tests/gen3_render_tiledy_blits.c                   |   5 +-
> >  tests/gen7_forcewake_mt.c                          |   5 +-
> >  tests/igt_fork_helper.c                            |   1 +
> >  tests/igt_simulation.c                             |   2 +
> >  tests/kms_addfb.c                                  |   2 +-
> >  tests/kms_cursor_crc.c                             |   1 +
> >  tests/kms_fbc_crc.c                                |  12 +-
> >  tests/kms_flip.c                                   |  17 +-
> >  tests/kms_pipe_crc_basic.c                         |   1 +
> >  tests/kms_plane.c                                  |   1 +
> >  tests/kms_render.c                                 |   7 +-
> >  tests/kms_setmode.c                                |  27 +-
> >  tests/pm_lpsp.c                                    |   2 +
> >  tests/pm_pc8.c                                     |   5 +-
> >  tests/pm_psr.c                                     |   2 +
> >  tests/pm_rc6_residency.c                           |   2 +
> >  tests/pm_rps.c                                     |   8 +-
> >  tests/prime_nv_api.c                               |   3 +-
> >  tests/prime_nv_pcopy.c                             |   5 +-
> >  tests/prime_nv_test.c                              |   5 +-
> >  tests/prime_self_import.c                          |   2 +-
> >  tests/prime_udl.c                                  |   8 +-
> >  tests/testdisplay.c                                |   6 +-
> >  tools/intel_audio_dump.c                           |   9 +-
> >  tools/intel_backlight.c                            |   6 +-
> >  tools/intel_bios_reader.c                          |   4 +-
> >  tools/intel_dpio_read.c                            |   3 +-
> >  tools/intel_dpio_write.c                           |   3 +-
> >  tools/intel_error_decode.c                         |   3 +-
> >  tools/intel_forcewaked.c                           |   3 +-
> >  tools/intel_framebuffer_dump.c                     |   2 +-
> >  tools/intel_gpu_time.c                             |   6 +-
> >  tools/intel_gpu_top.c                              |   6 +-
> >  tools/intel_gtt.c                                  |   3 +-
> >  tools/intel_infoframes.c                           |   8 +-
> >  tools/intel_l3_parity.c                            |   3 +-
> >  tools/intel_lid.c                                  |   5 +-
> >  tools/intel_nc_read.c                              |   3 +-
> >  tools/intel_nc_write.c                             |   3 +-
> >  tools/intel_opregion_decode.c                      |   3 +-
> >  tools/intel_panel_fitter.c                         |   4 +-
> >  tools/intel_perf_counters.c                        |   3 +-
> >  tools/intel_punit_read.c                           |   3 +-
> >  tools/intel_punit_write.c                          |   3 +-
> >  tools/intel_reg_checker.c                          |   5 +-
> >  tools/intel_reg_dumper.c                           |  17 +-
> >  tools/intel_reg_read.c                             |   3 +-
> >  tools/intel_reg_snapshot.c                         |   5 +-
> >  tools/intel_reg_write.c                            |   3 +-
> >  tools/intel_stepping.c                             |   3 +-
> >  tools/intel_vga_read.c                             |   3 +-
> >  tools/intel_vga_write.c                            |   3 +-
> >  tools/quick_dump/Makefile.am                       |   6 +-
> >  tools/quick_dump/chipset_macro_wrap.c              |  33 ++
> >  tools/quick_dump/intel_chipset.c                   |  33 --
> >  202 files changed, 2401 insertions(+), 1398 deletions(-)
> >  create mode 100644 lib/igt_aux.c
> >  create mode 100644 lib/igt_aux.h
> >  create mode 100644 lib/intel_chipset.c
> >  delete mode 100644 lib/intel_drm.c
> >  delete mode 100644 lib/intel_gpu_tools.h
> >  create mode 100644 lib/intel_io.h
> >  create mode 100644 lib/intel_os.c
> >  delete mode 100644 lib/intel_pci.c
> >  delete mode 100644 lib/media_fill.c
> >  create mode 100644 tools/quick_dump/chipset_macro_wrap.c
> >  delete mode 100644 tools/quick_dump/intel_chipset.c
> > 
> > -- 
> > 1.8.5.2
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ben Widawsky, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 00/28] more i-g-t docs and api polish
  2014-03-23 18:04   ` Ben Widawsky
@ 2014-03-23 23:04     ` Daniel Vetter
  0 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2014-03-23 23:04 UTC (permalink / raw)
  To: Ben Widawsky; +Cc: Intel Graphics Development

On Sun, Mar 23, 2014 at 7:04 PM, Ben Widawsky <ben@bwidawsk.net> wrote:
> On Sun, Mar 23, 2014 at 05:18:37PM +0100, Daniel Vetter wrote:
>> On Sun, Mar 23, 2014 at 03:18:34PM +0100, Daniel Vetter wrote:
>> > Hi all,
>> >
>> > So this thing turned out to be fairly ugly overall, and I don't think it's worth
>> > the effort to polish the series through some giant rebasing. make distcheck
>> > still works so I don't think I've fumbled this too badly and will hence just
>> > push the patches as-is.
>> >
>> > I'm still very much interested in feedback, I'll simply apply that as follow-up
>> > patches.
>
> Documenting the tools is far more important IMO (or does this exist
> already somewhere).

There are manpages which are semi-maintained. The goal here is to
reduce excuses for not writing testcases or not using i-g-t ;-)
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2014-03-23 23:04 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-23 14:18 [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
2014-03-23 14:18 ` [PATCH 01/28] lib: rename intel_pci.c to intel_chipset.c Daniel Vetter
2014-03-23 14:18 ` [PATCH 02/28] lib: consolidate chipset helpers in intel_chipset.[hc] Daniel Vetter
2014-03-23 14:18 ` [PATCH 03/28] lib/intel_chipset: intel_ prefix for pch global Daniel Vetter
2014-03-23 14:18 ` [PATCH 04/28] lib/intel_chipset: api docs Daniel Vetter
2014-03-23 14:18 ` [PATCH 05/28] lib: make rendercopy.h an internal header Daniel Vetter
2014-03-23 14:18 ` [PATCH 06/28] lib: make media_fill.h " Daniel Vetter
2014-03-23 14:18 ` [PATCH 07/28] lib/intel_batchbuffer: un-inline buf_height/width Daniel Vetter
2014-03-23 14:18 ` [PATCH 08/28] lib/intel_batchbuffer: igt_ namespace for the buffer structure Daniel Vetter
2014-03-23 14:18 ` [PATCH 09/28] lib/intel_batchbuffer: igt_ prefix for rendercopy/mediafill funcs Daniel Vetter
2014-03-23 14:18 ` [PATCH 10/28] lib/intel_batchbuffer: drop cpu_mapping from igt_buf Daniel Vetter
2014-03-23 14:18 ` [PATCH 11/28] lib/intel_batchbuffer: api documentation for render copy/media fill Daniel Vetter
2014-03-23 14:18 ` [PATCH 12/28] lib: Move non-register things out of intel-gpu-tools.h Daniel Vetter
2014-03-23 14:18 ` [PATCH 13/28] tests|lib: remove assert.h includes Daniel Vetter
2014-03-23 14:18 ` [PATCH 14/28] lib: add #include "foo.h" lines like in manpages Daniel Vetter
2014-03-23 14:18 ` [PATCH 15/28] lib: remove uncessary #includes from headers Daniel Vetter
2014-03-23 14:18 ` [PATCH 16/28] lib: more unecessary header removal Daniel Vetter
2014-03-23 14:18 ` [PATCH 17/28] lib: unnecessary header removal for drmtest.h, part 1 Daniel Vetter
2014-03-23 14:18 ` [PATCH 18/28] lib: unnecessary header removal for drmtest.h, part 2 Daniel Vetter
2014-03-23 14:18 ` [PATCH 19/28] lib: rename intel_gpu_tools.h to intel_io.h Daniel Vetter
2014-03-23 14:18 ` [PATCH 20/28] lib/intel_io: rename mmio setup functions Daniel Vetter
2014-03-23 14:18 ` [PATCH 21/28] lib/intel_io: api documentation Daniel Vetter
2014-03-23 14:18 ` [PATCH 22/28] lib: s/drmtest_dumb_aub/igt_aub_dump_enabled/ Daniel Vetter
2014-03-23 14:18 ` [PATCH 23/28] lib: extract igt_aux.[hc] Daniel Vetter
2014-03-23 14:18 ` [PATCH 24/28] lib/igt_aux: api documentation Daniel Vetter
2014-03-23 14:18 ` [PATCH 25/28] lib: s/igt_env_set/igt_check_boolean_env_var Daniel Vetter
2014-03-23 14:19 ` [PATCH 26/28] lib: Use @include tag for include files Daniel Vetter
2014-03-23 14:19 ` [PATCH 27/28] lib/drmtest: api documentation Daniel Vetter
2014-03-23 14:19 ` [PATCH 28/28] lib/intel_batchbuffer: document header dependencies Daniel Vetter
2014-03-23 16:18 ` [PATCH 00/28] more i-g-t docs and api polish Daniel Vetter
2014-03-23 18:04   ` Ben Widawsky
2014-03-23 23:04     ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.