[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

intel-gpu-tools: Changes to 'debian-unstable'



 NEWS                                                    |   30 
 README                                                  |   16 
 benchmarks/Makefile.am                                  |    4 
 benchmarks/gem_userptr_benchmark.c                      |   97 
 configure.ac                                            |   31 
 debugger/Makefile.am                                    |    3 
 debugger/eudb.c                                         |    6 
 demos/Makefile.am                                       |    4 
 docs/reference/intel-gpu-tools/Makefile.am              |   29 
 docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml |    1 
 lib/Android.mk                                          |    6 
 lib/Makefile.am                                         |    8 
 lib/Makefile.sources                                    |    4 
 lib/drmtest.h                                           |    2 
 lib/igt.cocci                                           |   30 
 lib/igt_aux.c                                           |  216 +
 lib/igt_aux.h                                           |   48 
 lib/igt_core.c                                          |  171 -
 lib/igt_core.h                                          |   58 
 lib/igt_debugfs.c                                       |   82 
 lib/igt_debugfs.h                                       |    3 
 lib/igt_draw.c                                          |  574 +++
 lib/igt_draw.h                                          |   65 
 lib/igt_fb.c                                            |   81 
 lib/igt_fb.h                                            |    4 
 lib/igt_gt.c                                            |    2 
 lib/igt_kms.c                                           |  220 +
 lib/igt_kms.h                                           |   16 
 lib/intel_batchbuffer.c                                 |   51 
 lib/intel_batchbuffer.h                                 |   23 
 lib/intel_chipset.h                                     |   16 
 lib/intel_io.h                                          |   14 
 lib/intel_iosf.c                                        |   10 
 lib/intel_mmio.c                                        |  120 
 lib/intel_os.c                                          |    2 
 lib/ioctl_wrappers.c                                    |  166 
 lib/ioctl_wrappers.h                                    |   13 
 lib/media_spin.c                                        |  540 +++
 lib/media_spin.h                                        |   39 
 lib/rendercopy_gen8.c                                   |    2 
 lib/rendercopy_gen9.c                                   |    2 
 lib/tests/Android.mk                                    |   41 
 lib/tests/Makefile.am                                   |    2 
 lib/tests/Makefile.sources                              |    1 
 lib/tests/igt_command_line.sh                           |    2 
 m4/as-compiler-flag.m4                                  |   62 
 man/Makefile.am                                         |   12 
 man/intel_reg.rst                                       |  229 +
 overlay/.gitignore                                      |    2 
 overlay/gem-objects.c                                   |   21 
 overlay/overlay.c                                       |    2 
 scripts/list-workarounds                                |   10 
 scripts/run-tests.sh                                    |   28 
 tests/.gitignore                                        |   18 
 tests/Android.mk                                        |   31 
 tests/Makefile.am                                       |   55 
 tests/Makefile.sources                                  |   24 
 tests/drm_auth.c                                        |  163 
 tests/drv_getparams.c                                   |  165 
 tests/eviction_common.c                                 |   67 
 tests/gem_bad_blit.c                                    |    2 
 tests/gem_concurrent_all.c                              | 1100 ++++++
 tests/gem_concurrent_blit.c                             |  862 -----
 tests/gem_cpu_reloc.c                                   |   56 
 tests/gem_cs_prefetch.c                                 |   24 
 tests/gem_cs_tlb.c                                      |    2 
 tests/gem_ctx_basic.c                                   |    4 
 tests/gem_ctx_exec.c                                    |   30 
 tests/gem_evict_everything.c                            |   19 
 tests/gem_exec_big.c                                    |   81 
 tests/gem_exec_blt.c                                    |  214 -
 tests/gem_exec_lut_handle.c                             |  193 -
 tests/gem_exec_nop.c                                    |  220 -
 tests/gem_exec_parse.c                                  |   10 
 tests/gem_flink_race.c                                  |    5 
 tests/gem_linear_blits.c                                |   64 
 tests/gem_mmap.c                                        |   78 
 tests/gem_mmap_gtt.c                                    |  216 +
 tests/gem_mmap_wc.c                                     |   26 
 tests/gem_persistent_relocs.c                           |    2 
 tests/gem_ppgtt.c                                       |   73 
 tests/gem_pwrite.c                                      |   66 
 tests/gem_read_read_speed.c                             |  235 +
 tests/gem_render_copy.c                                 |    5 
 tests/gem_reset_stats.c                                 |    8 
 tests/gem_ring_sync_copy.c                              |    2 
 tests/gem_seqno_wrap.c                                  |    4 
 tests/gem_storedw_batches_loop.c                        |   16 
 tests/gem_streaming_writes.c                            |  401 ++
 tests/gem_stress.c                                      |    4 
 tests/gem_tiled_fence_blits.c                           |   51 
 tests/gem_tiled_swapping.c                              |    2 
 tests/gem_userptr_blits.c                               |   20 
 tests/gem_wait.c                                        |    2 
 tests/gen7_forcewake_mt.c                               |    1 
 tests/kms_3d.c                                          |    2 
 tests/kms_crtc_background_color.c                       |  194 +
 tests/kms_cursor_crc.c                                  |   52 
 tests/kms_draw_crc.c                                    |  244 +
 tests/kms_fbc_crc.c                                     |  258 -
 tests/kms_flip_tiling.c                                 |  232 +
 tests/kms_frontbuffer_tracking.c                        | 2225 +++++++++++++
 tests/kms_legacy_colorkey.c                             |   72 
 tests/kms_mmio_vs_cs_flip.c                             |    4 
 tests/kms_panel_fitting.c                               |  261 +
 tests/kms_pipe_b_c_ivb.c                                |  289 +
 tests/kms_pipe_crc_basic.c                              |   14 
 tests/kms_plane.c                                       |   12 
 tests/kms_plane_scaling.c                               |  369 ++
 tests/kms_psr_sink_crc.c                                |  276 +
 tests/kms_pwrite_crc.c                                  |    6 
 tests/kms_rotation_crc.c                                |  266 +
 tests/kms_setmode.c                                     |    4 
 tests/kms_sink_crc_basic.c                              |    2 
 tests/kms_universal_plane.c                             |   14 
 tests/kms_vblank.c                                      |  205 +
 tests/pm_backlight.c                                    |  171 +
 tests/pm_lpsp.c                                         |    4 
 tests/pm_rc6_residency.c                                |  201 -
 tests/pm_rpm.c                                          |   32 
 tests/pm_rps.c                                          |   41 
 tests/pm_sseu.c                                         |  378 ++
 tests/prime_self_import.c                               |    6 
 tests/prime_udl.c                                       |    2 
 tests/template.c                                        |    2 
 tests/testdisplay.c                                     |   25 
 tests/tools_test                                        |    6 
 tools/.gitignore                                        |    8 
 tools/Makefile.am                                       |    4 
 tools/Makefile.sources                                  |   16 
 tools/ddi_compute_wrpll.c                               |  649 ---
 tools/hsw_compute_wrpll.c                               |  649 +++
 tools/intel_backlight.c                                 |   20 
 tools/intel_bios_reader.c                               |    5 
 tools/intel_display_crc.c                               |  110 
 tools/intel_display_poller.c                            |    8 
 tools/intel_dpio_read.c                                 |   69 
 tools/intel_dpio_write.c                                |   70 
 tools/intel_error_decode.c                              |   80 
 tools/intel_iosf_sb_read.c                              |  129 
 tools/intel_iosf_sb_write.c                             |  121 
 tools/intel_reg.c                                       |  897 +++++
 tools/intel_reg_checker.c                               |    8 
 tools/intel_reg_decode.c                                | 2713 ++++++++++++++++
 tools/intel_reg_dumper.c                                |   98 
 tools/intel_reg_read.c                                  |    8 
 tools/intel_reg_snapshot.c                              |    6 
 tools/intel_reg_spec.c                                  |  345 ++
 tools/intel_reg_spec.h                                  |   77 
 tools/intel_reg_write.c                                 |   11 
 tools/intel_vga_read.c                                  |    5 
 tools/intel_vga_write.c                                 |    5 
 tools/intel_watermark.c                                 |  898 +++++
 tools/quick_dump/Makefile.am                            |    5 
 tools/quick_dump/skl_display.txt                        |  115 
 tools/quick_dump/skl_powerwells.txt                     |    4 
 tools/quick_dump/skylake                                |    1 
 tools/skl_compute_wrpll.c                               |  910 +++++
 158 files changed, 18695 insertions(+), 3060 deletions(-)

New commits:
commit b88212c036fbd909d70b8388fc8fffb1fac75e5b
Author: Thomas Wood <thomas.wood@intel.com>
Date:   Thu Jun 11 16:08:23 2015 +0100

    Update version to 1.11 and add the release date
    
    Signed-off-by: Thomas Wood <thomas.wood@intel.com>

diff --git a/NEWS b/NEWS
index 00a3ccc..7ac3f11 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Release 1.11 (XXXX-XX-XX)
+Release 1.11 (2015-06-11)
 -------------------------
 
 - Various new tests and tools
diff --git a/configure.ac b/configure.ac
index c370ec3..4208f00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ([2.60])
 AC_INIT([intel-gpu-tools],
-	[1.10],
+	[1.11],
 	[https://bugs.freedesktop.org/enter_bug.cgi?product=DRI&component=DRM/Intel],
 	[intel-gpu-tools])
 

commit 0cc16b37ab9b3f8d5687380f83c0361c9de1beb6
Author: Thomas Wood <thomas.wood@intel.com>
Date:   Thu Jun 11 16:06:33 2015 +0100

    NEWS: Updates
    
    Signed-off-by: Thomas Wood <thomas.wood@intel.com>

diff --git a/NEWS b/NEWS
index 21b624d..00a3ccc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 Release 1.11 (XXXX-XX-XX)
 -------------------------
 
+- Various new tests and tools
+
 - Single combined test list (supported by piglit since commit 8a122bb)
 
 - Optional dependency on libunwind to provide automatic stack traces on test
@@ -14,6 +16,17 @@ Release 1.11 (XXXX-XX-XX)
   tests can still be disabled by the --disable-tests configure flag.)
   (Joonas Lahtinen)
 
+- New tool to decode watermark registers (Ville Syrjälä)
+
+- Timeout mechanism now reports test as failed
+
+- Introduce intel_reg as the one Intel graphics register multitool to replace
+  intel_reg_read, intel_reg_write, intel_iosf_sb_read, intel_iosf_sb_write,
+  intel_vga_read, intel_vga_write, intel_reg_dumper, intel_reg_snapshot,
+  and quick_dump.py. (Jani Nikula)
+
+- Add functions to manipulate i915.ko parameters and ensure features are enabled
+  for testing. (Paulo Zanoni)
 
 Release 1.10 (2015-03-12)
 -------------------------

commit aa75f373978756aba32ac9c009740ac45e2eb180
Author: Thomas Wood <thomas.wood@intel.com>
Date:   Mon Jun 8 16:41:34 2015 +0100

    tools: print a warning for tools replaced by intel_reg
    
    Cc: Jani Nikula <jani.nikula@intel.com>
    Signed-off-by: Thomas Wood <thomas.wood@intel.com>

diff --git a/tools/intel_iosf_sb_read.c b/tools/intel_iosf_sb_read.c
index f188cda..097b0b8 100644
--- a/tools/intel_iosf_sb_read.c
+++ b/tools/intel_iosf_sb_read.c
@@ -94,6 +94,9 @@ int main(int argc, char *argv[])
 	int i, nregs, count = 1, reg_stride;
 	const char *name;
 
+	fprintf(stderr, "WARNING: Use of %s has been deprecated and replaced by"
+		" intel_reg.\n", argv[0]);
+
 	if (!IS_VALLEYVIEW(dev->device_id) &&
 	    !IS_CHERRYVIEW(dev->device_id)) {
 		usage(argv[0]);
diff --git a/tools/intel_iosf_sb_write.c b/tools/intel_iosf_sb_write.c
index eb6700d..a091a0d 100644
--- a/tools/intel_iosf_sb_write.c
+++ b/tools/intel_iosf_sb_write.c
@@ -89,6 +89,9 @@ int main(int argc, char** argv)
 	int i, nregs;
 	const char *name;
 
+	fprintf(stderr, "WARNING: Use of %s has been deprecated and replaced by"
+		" intel_reg.\n", argv[0]);
+
 	if (!IS_VALLEYVIEW(dev->device_id) &&
 	    !IS_CHERRYVIEW(dev->device_id)) {
 		usage(argv[0]);
diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index 3d32005..f9b4d06 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -2931,6 +2931,9 @@ int main(int argc, char** argv)
 	char *file = NULL, *reg_name = NULL;
 	uint32_t reg_val, power_well;
 
+	fprintf(stderr, "WARNING: Use of %s has been deprecated and replaced by"
+		" intel_reg.\n", argv[0]);
+
 	while ((opt = getopt(argc, argv, "d:h")) != -1) {
 		switch (opt) {
 		case 'd':
diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c
index 46fa664..39671ff 100644
--- a/tools/intel_reg_read.c
+++ b/tools/intel_reg_read.c
@@ -74,6 +74,9 @@ int main(int argc, char** argv)
 	int decode_bits = 0;
 	int dwords = 1;
 
+	fprintf(stderr, "WARNING: Use of %s has been deprecated and replaced by"
+		" intel_reg.\n", argv[0]);
+
 	while ((ch = getopt(argc, argv, "dfhc:")) != -1) {
 		switch(ch) {
 		case 'd':
diff --git a/tools/intel_reg_snapshot.c b/tools/intel_reg_snapshot.c
index 50dafd6..8b097e6 100644
--- a/tools/intel_reg_snapshot.c
+++ b/tools/intel_reg_snapshot.c
@@ -26,6 +26,7 @@
 
 #include <unistd.h>
 #include <assert.h>
+#include <stdio.h>
 #include "intel_io.h"
 #include "intel_chipset.h"
 
@@ -36,6 +37,9 @@ int main(int argc, char** argv)
 	int mmio_bar;
 	int ret;
 
+	fprintf(stderr, "WARNING: Use of %s has been deprecated and replaced by"
+		" intel_reg.\n", argv[0]);
+
 	pci_dev = intel_get_pci_device();
 	devid = pci_dev->device_id;
 	intel_mmio_use_pci_bar(pci_dev);
diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c
index b0ddffe..127519c 100644
--- a/tools/intel_reg_write.c
+++ b/tools/intel_reg_write.c
@@ -36,6 +36,9 @@ int main(int argc, char** argv)
 {
 	uint32_t reg, value;
 
+	fprintf(stderr, "WARNING: Use of %s has been deprecated and replaced by"
+		" intel_reg.\n", argv[0]);
+
 	if (argc < 3) {
 		printf("Usage: %s addr value\n", argv[0]);
 		printf("  WARNING: This is dangerous to you and your system's health.\n");
diff --git a/tools/intel_vga_read.c b/tools/intel_vga_read.c
index ea50705..8305fb8 100644
--- a/tools/intel_vga_read.c
+++ b/tools/intel_vga_read.c
@@ -57,6 +57,9 @@ int main(int argc, char *argv[])
 	int i, ch;
 	const char *cmdname = argv[0];
 
+	fprintf(stderr, "WARNING: Use of %s has been deprecated and replaced by"
+		" intel_reg.\n", argv[0]);
+
 	while ((ch = getopt(argc, argv, "m")) != -1) {
 		switch(ch) {
 		case 'm':
diff --git a/tools/intel_vga_write.c b/tools/intel_vga_write.c
index 8215962..cb1ed98 100644
--- a/tools/intel_vga_write.c
+++ b/tools/intel_vga_write.c
@@ -57,6 +57,9 @@ int main(int argc, char *argv[])
 	int ch;
 	const char *cmdname = argv[0];
 
+	fprintf(stderr, "WARNING: Use of %s has been deprecated and replaced by"
+		" intel_reg.\n", argv[0]);
+
 	while ((ch = getopt(argc, argv, "m")) != -1) {
 		switch(ch) {
 		case 'm':

commit 87f15fc3da374082933aef4d2183f319e596c9ba
Author: Thomas Wood <thomas.wood@intel.com>
Date:   Mon Jun 8 10:16:00 2015 +0100

    overlay: update .gitignore
    
    Signed-off-by: Thomas Wood <thomas.wood@intel.com>

diff --git a/overlay/.gitignore b/overlay/.gitignore
index 0aa8184..bf91f08 100644
--- a/overlay/.gitignore
+++ b/overlay/.gitignore
@@ -1 +1,3 @@
 intel-gpu-overlay
+kms/.dirstamp
+x11/.dirstamp

commit d8acd24bdb0210e1b590cebc58ddcd266045ae08
Author: Paulo Zanoni <paulo.r.zanoni@intel.com>
Date:   Tue Dec 2 10:40:05 2014 -0200

    tests: add kms_frontbuffer_tracking
    
    This is a new test that should exercise the frontbuffer tracking
    feature of the Kernel in a number of different ways. We use different
    drawing methods, we use the primary, cursor and sprite planes, we can
    test both on single and dual pipes, also on buffers not associated
    with any CRTCs, etc.
    
    We currently have assertions for both FBC and PSR, and we also have a
    "nop" test mode that should disable both FBC and PSR, and can be
    used for debugging.
    
    This test is also capable of testing both FBC and PSR even if they are
    disabled by default on the Kernel: the test knows how to change the
    i915.ko parameters and then set them back after testing.
    
    I am getting a significant number of failures when I run this test,
    which means we have some work to do on the Kernel.
    
    I also still have a small list of additional subtests that I plan to
    add to this test, and those tests are documented on the main function.
    
    v2:
     - Use igt_debugfs_open() (Thomas).
     - Use igt_test_description() (Thomas).
     - Don't check drm_open_any_master()'s result (Thomas).
     - Use igt_require_f() in some cases (Thomas).
     - Standardize some assertions.
     - Use the new module param functions.
     - Check if FBC is supported by the chipset.
     - Add new subtests (multidraw, enum fbs, fbc+psr).
     - Make tests a little shorter.
     - Reorganize which tests ara ran by default.
     - Better comments everywhere.
     - Rebase.
    
    v3:
     - Fix a small typo.
     - Improve the log messages a little bit more.
    
    Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>

diff --git a/tests/.gitignore b/tests/.gitignore
index f816ded..c17264c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -134,6 +134,7 @@ kms_flip
 kms_flip_event_leak
 kms_flip_tiling
 kms_force_connector
+kms_frontbuffer_tracking
 kms_legacy_colorkey
 kms_mmio_vs_cs_flip
 kms_pipe_b_c_ivb
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index d2a44e8..551c600 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -66,6 +66,7 @@ TESTS_progs_M = \
 	kms_flip \
 	kms_flip_event_leak \
 	kms_flip_tiling \
+	kms_frontbuffer_tracking \
 	kms_legacy_colorkey \
 	kms_mmio_vs_cs_flip \
 	kms_pipe_b_c_ivb \
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
new file mode 100644
index 0000000..3239779
--- /dev/null
+++ b/tests/kms_frontbuffer_tracking.c
@@ -0,0 +1,2225 @@
+/*
+ * Copyright © 2015 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: Paulo Zanoni <paulo.r.zanoni@intel.com>
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "drmtest.h"
+#include "igt_aux.h"
+#include "igt_draw.h"
+#include "igt_kms.h"
+#include "igt_debugfs.h"
+#include "intel_chipset.h"
+#include "ioctl_wrappers.h"
+
+IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
+		     "its related features: FBC and PSR");
+
+/*
+ * One of the aspects of this test is that, for every subtest, we try different
+ * combinations of the parameters defined by the struct below. Because of this,
+ * a single addition of a new parameter or subtest function can lead to hundreds
+ * of new subtests.
+ *
+ * In order to reduce the number combinations we cut the cases that don't make
+ * sense, such as writing on the secondary screen when there is only a single
+ * pipe, or flipping when the target is the offscreen buffer. We also hide some
+ * combinations that are somewhat redundant and don't add much value to the
+ * test. For example, since we already do the offscreen testing with a single
+ * pipe enabled, there's no much value in doing it again with dual pipes. If you
+ * still want to try these redundant tests, you need to use the --show-hidden
+ * option.
+ *
+ * The most important hidden thing is the FEATURE_NONE set of tests. Whenever
+ * you get a failure on any test, it is important to check whether the same test
+ * fails with FEATURE_NONE - replace the feature name for "nop". If the nop test
+ * also fails, then it's likely the problem will be on the IGT side instead of
+ * the Kernel side. We don't expose this set of tests by default because (i)
+ * they take a long time to test; and (ii) if the feature tests work, then it's
+ * very likely that the nop tests will also work.
+ */
+struct test_mode {
+	/* Are we going to enable just one monitor, or are we going to setup a
+	 * dual screen environment for the test? */
+	enum {
+		PIPE_SINGLE = 0,
+		PIPE_DUAL,
+		PIPE_COUNT,
+	} pipes;
+
+	/* The primary screen is the one that's supposed to have the "feature"
+	 * enabled on, but we have the option to draw on the secondary screen or
+	 * on some offscreen buffer. We also only theck the CRC of the primary
+	 * screen. */
+	enum {
+		SCREEN_PRIM = 0,
+		SCREEN_SCND,
+		SCREEN_OFFSCREEN,
+		SCREEN_COUNT,
+	} screen;
+
+	/* When we draw, we can draw directly on the primary plane, on the
+	 * cursor or on the sprite plane. */
+	enum {
+		PLANE_PRI = 0,
+		PLANE_CUR,
+		PLANE_SPR,
+		PLANE_COUNT,
+	} plane;
+
+	/* We can organize the screens in a way that each screen has its own
+	 * framebuffer, or in a way that all screens point to the same
+	 * framebuffer, but on different places. This includes the offscreen
+	 * screen. */
+	enum {
+		FBS_SINGLE = 0,
+		FBS_MULTI,
+		FBS_COUNT
+	} fbs;
+
+	/* Which features are we going to test now? This is a mask! */
+	enum {
+		FEATURE_NONE  = 0,
+		FEATURE_FBC   = 1,
+		FEATURE_PSR   = 2,
+		FEATURE_COUNT = 4,
+	} feature;
+
+	enum igt_draw_method method;
+};
+
+enum feature_status {
+	ENABLED,
+	DISABLED,
+};
+
+struct rect {
+	int x;
+	int y;
+	int w;
+	int h;
+	uint32_t color;
+};
+
+#define MAX_CONNECTORS 32
+struct {
+	int fd;
+	drmModeResPtr res;
+	drmModeConnectorPtr connectors[MAX_CONNECTORS];
+	drmModePlaneResPtr planes;
+	drm_intel_bufmgr *bufmgr;
+} drm;
+
+struct {
+	int fd;
+	bool can_test;
+
+	bool supports_compressing;
+	bool supports_last_action;
+
+	struct timespec last_action;
+} fbc = {
+	.fd = -1,
+	.can_test = false,
+	.supports_last_action = false,
+	.supports_compressing = false,
+};
+
+struct {
+	int fd;
+	bool can_test;
+} psr = {
+	.fd = -1,
+	.can_test = false,
+};
+
+
+#define SINK_CRC_SIZE 12
+typedef struct {
+	char data[SINK_CRC_SIZE];
+} sink_crc_t;
+
+struct both_crcs {
+	igt_crc_t pipe;
+	sink_crc_t sink;
+};
+
+igt_pipe_crc_t *pipe_crc;
+struct both_crcs blue_crc;
+struct both_crcs *wanted_crc;
+
+struct {
+	int fd;
+} sink_crc;
+
+/* The goal of this structure is to easily allow us to deal with cases where we
+ * have a big framebuffer and the CRTC is just displaying a subregion of this
+ * big FB. */
+struct fb_region {
+	struct igt_fb *fb;
+	int x;
+	int y;
+	int w;
+	int h;
+};
+
+struct draw_pattern_info {
+	bool initialized;
+	bool frames_stack;
+	int n_rects;
+	struct both_crcs *crcs;
+	struct rect (*get_rect)(struct fb_region *fb, int r);
+};
+
+/* Draw big rectangles on the screen. */
+struct draw_pattern_info pattern1;
+/* 64x64 rectangles at x:0,y:0, just so we can draw on the cursor and sprite. */
+struct draw_pattern_info pattern2;
+/* 64x64 rectangles at different positions, same color, for the move test. */
+struct draw_pattern_info pattern3;
+/* Just a fullscreen green square. */
+struct draw_pattern_info pattern4;
+
+/* Command line parameters. */
+struct {
+	bool check_status;
+	bool check_crc;
+	bool fbc_check_compression;
+	bool fbc_check_last_action;
+	bool no_edp;
+	bool small_modes;
+	bool show_hidden;
+	int step;
+	int only_feature;
+	int only_pipes;
+} opt = {
+	.check_status = true,
+	.check_crc = true,
+	.fbc_check_compression = true,
+	.fbc_check_last_action = true,
+	.no_edp = false,
+	.small_modes = false,
+	.show_hidden= false,
+	.step = 0,
+	.only_feature = FEATURE_COUNT,
+	.only_pipes = PIPE_COUNT,
+};
+
+struct modeset_params {
+	uint32_t crtc_id;
+	uint32_t connector_id;
+	uint32_t sprite_id;
+	drmModeModeInfoPtr mode;
+	struct fb_region fb;
+	struct fb_region cursor;
+	struct fb_region sprite;
+};
+
+struct modeset_params prim_mode_params;
+struct modeset_params scnd_mode_params;
+struct fb_region offscreen_fb;
+struct {
+	struct igt_fb prim_pri;
+	struct igt_fb prim_cur;
+	struct igt_fb prim_spr;
+
+	struct igt_fb scnd_pri;
+	struct igt_fb scnd_cur;
+	struct igt_fb scnd_spr;
+
+	struct igt_fb offscreen;
+	struct igt_fb big;
+} fbs;
+
+static drmModeModeInfoPtr get_connector_smallest_mode(drmModeConnectorPtr c)
+{
+	int i;
+	drmModeModeInfoPtr smallest = NULL;
+
+	for (i = 0; i < c->count_modes; i++) {
+		drmModeModeInfoPtr mode = &c->modes[i];
+
+		if (!smallest)
+			smallest = mode;
+
+		if (mode->hdisplay * mode->vdisplay <
+		    smallest->hdisplay * smallest->vdisplay)
+			smallest = mode;
+	}
+
+	return smallest;
+}
+
+static drmModeConnectorPtr get_connector(uint32_t id)
+{
+	int i;
+
+	for (i = 0; i < drm.res->count_connectors; i++)
+		if (drm.res->connectors[i] == id)
+			return drm.connectors[i];
+
+	igt_assert(false);
+}
+
+static void print_mode_info(const char *screen, struct modeset_params *params)
+{
+	drmModeConnectorPtr c = get_connector(params->connector_id);
+
+	igt_info("%s screen: %s %s\n",
+		 screen,
+		 kmstest_connector_type_str(c->connector_type),
+		 params->mode->name);
+}
+
+static void init_mode_params(struct modeset_params *params, uint32_t crtc_id,
+			     int crtc_index, uint32_t connector_id,
+			     drmModeModeInfoPtr mode)
+{
+	uint32_t plane_id = 0;
+	int i;
+
+	for (i = 0; i < drm.planes->count_planes && plane_id == 0; i++) {
+		drmModePlanePtr plane;
+
+		plane = drmModeGetPlane(drm.fd, drm.planes->planes[i]);
+		igt_assert(plane);
+
+		if (plane->possible_crtcs & (1 << crtc_index))
+			plane_id = plane->plane_id;
+
+		drmModeFreePlane(plane);
+	}
+	igt_assert(plane_id);
+
+	params->crtc_id = crtc_id;
+	params->connector_id = connector_id;
+	params->mode = mode;
+	params->sprite_id = plane_id;
+
+	params->fb.fb = NULL;
+	params->fb.w = mode->hdisplay;
+	params->fb.h = mode->vdisplay;
+
+	params->cursor.fb = NULL;
+	params->cursor.x = 0;
+	params->cursor.y = 0;
+	params->cursor.w = 64;
+	params->cursor.h = 64;
+
+	params->sprite.fb = NULL;
+	params->sprite.x = 0;
+	params->sprite.y = 0;
+	params->sprite.w = 64;
+	params->sprite.h = 64;
+}
+
+drmModeModeInfo std_1024_mode = {
+	.clock = 65000,
+	.hdisplay = 1024,
+	.hsync_start = 1048,
+	.hsync_end = 1184,
+	.htotal = 1344,
+	.vtotal = 806,
+	.hskew = 0,
+	.vdisplay = 768,
+	.vsync_start = 771,
+	.vsync_end = 777,
+	.vtotal = 806,
+	.vscan = 0,
+	.vrefresh = 60,
+	.flags = 0xA,
+	.type = 0x40,
+	.name = "Custom 1024x768",
+};
+
+static bool connector_get_mode(drmModeConnectorPtr c, drmModeModeInfoPtr *mode)
+{
+	*mode = NULL;
+
+	if (c->connection != DRM_MODE_CONNECTED || !c->count_modes)
+		return false;
+
+	if (c->connector_type == DRM_MODE_CONNECTOR_eDP && opt.no_edp)
+		return false;
+
+	if (opt.small_modes)
+		*mode = get_connector_smallest_mode(c);
+	else
+		*mode = &c->modes[0];
+
+	/* Because on some machines we don't have enough stolen memory to fit in
+	 * those 3k panels. And on HSW the CRC WA is so awful that it makes you
+	 * think everything is bugged. */
+	if (c->connector_type == DRM_MODE_CONNECTOR_eDP)
+		*mode = &std_1024_mode;
+
+	return true;
+}
+
+static bool init_modeset_cached_params(void)
+{
+	int i;
+	uint32_t prim_connector_id = 0, scnd_connector_id = 0;
+	drmModeModeInfoPtr prim_mode = NULL, scnd_mode = NULL;
+	drmModeModeInfoPtr tmp_mode;
+
+	/* First, try to find an eDP monitor since it's the only possible type
+	 * for PSR.  */
+	for (i = 0; i < drm.res->count_connectors; i++) {
+		if (drm.connectors[i]->connector_type != DRM_MODE_CONNECTOR_eDP)
+			continue;
+
+		if (connector_get_mode(drm.connectors[i], &tmp_mode)) {
+			prim_connector_id = drm.res->connectors[i];
+			prim_mode = tmp_mode;
+		}
+	}
+	for (i = 0; i < drm.res->count_connectors; i++) {
+		/* Don't pick again what we just selected on the above loop. */
+		if (drm.res->connectors[i] == prim_connector_id)
+			continue;
+
+		if (connector_get_mode(drm.connectors[i], &tmp_mode)) {
+			if (!prim_connector_id) {
+				prim_connector_id = drm.res->connectors[i];
+				prim_mode = tmp_mode;
+			} else if (!scnd_connector_id) {
+				scnd_connector_id = drm.res->connectors[i];
+				scnd_mode = tmp_mode;
+				break;
+			}
+		}
+	}
+
+	if (!prim_connector_id)
+		return false;
+
+	init_mode_params(&prim_mode_params, drm.res->crtcs[0], 0,
+			 prim_connector_id, prim_mode);
+	print_mode_info("Primary", &prim_mode_params);
+
+	if (!scnd_connector_id) {
+		scnd_mode_params.connector_id = 0;
+		return true;
+	}
+
+	igt_assert(drm.res->count_crtcs >= 2);
+	init_mode_params(&scnd_mode_params, drm.res->crtcs[1], 1,
+			 scnd_connector_id, scnd_mode);
+	print_mode_info("Secondary", &scnd_mode_params);
+
+	return true;
+}
+
+/*
+ * This is how the prim, scnd and offscreens FB should be positioned inside the
+ * big FB. The prim buffer starts at a 500x500 offset, then scnd starts at the
+ * same 500 pixel Y offset, right after prim ends on the X axis, then the
+ * offscreen fb starts after scnd ends.
+ * +------------------------------------+
+ * | big                                |
+ * |   +--------+-----------+-----------+
+ * |   | prim   | scnd      | offscreen |
+ * |   |        |           |           |
+ * |   |        +-----------+           |
+ * |   |        |           +-----------+
+ * +---+--------+-----------------------+
+ */
+static void create_big_fb(void)
+{
+	int prim_w, prim_h, scnd_w, scnd_h, offs_w, offs_h, big_w, big_h;
+
+	prim_w = prim_mode_params.mode->hdisplay;
+	prim_h = prim_mode_params.mode->vdisplay;
+
+	if (scnd_mode_params.connector_id) {
+		scnd_w = scnd_mode_params.mode->hdisplay;
+		scnd_h = scnd_mode_params.mode->vdisplay;
+	} else {
+		scnd_w = 0;
+		scnd_h = 0;
+	}
+	offs_w = offscreen_fb.w;
+	offs_h = offscreen_fb.h;
+
+	big_w = prim_w + scnd_w + offs_w + 500;
+
+	big_h = prim_h;
+	if (scnd_h > big_h)
+		big_h = scnd_h;
+	if (offs_h > big_h)
+		big_h = offs_h;
+	big_h += 500;
+
+	igt_create_fb(drm.fd, big_w, big_h, DRM_FORMAT_XRGB8888,
+		      LOCAL_I915_FORMAT_MOD_X_TILED, &fbs.big);
+}
+
+static void create_fbs(void)
+{
+	igt_create_fb(drm.fd, prim_mode_params.mode->hdisplay,
+		      prim_mode_params.mode->vdisplay,
+		      DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED,
+		      &fbs.prim_pri);
+	igt_create_fb(drm.fd, prim_mode_params.cursor.w,
+		      prim_mode_params.cursor.h, DRM_FORMAT_ARGB8888,
+		      LOCAL_DRM_FORMAT_MOD_NONE, &fbs.prim_cur);
+	igt_create_fb(drm.fd, prim_mode_params.sprite.w,
+		      prim_mode_params.sprite.h, DRM_FORMAT_XRGB8888,
+		      LOCAL_I915_FORMAT_MOD_X_TILED, &fbs.prim_spr);
+
+	igt_create_fb(drm.fd, offscreen_fb.w, offscreen_fb.h,
+		      DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED,
+		      &fbs.offscreen);
+
+	create_big_fb();
+
+	if (!scnd_mode_params.connector_id)
+		return;
+
+	igt_create_fb(drm.fd, scnd_mode_params.mode->hdisplay,
+		      scnd_mode_params.mode->vdisplay,
+		      DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED,
+		      &fbs.scnd_pri);
+	igt_create_fb(drm.fd, scnd_mode_params.cursor.w,
+		      scnd_mode_params.cursor.h, DRM_FORMAT_ARGB8888,
+		      LOCAL_DRM_FORMAT_MOD_NONE, &fbs.scnd_cur);
+	igt_create_fb(drm.fd, scnd_mode_params.sprite.w,
+		      scnd_mode_params.sprite.h, DRM_FORMAT_XRGB8888,
+		      LOCAL_I915_FORMAT_MOD_X_TILED, &fbs.scnd_spr);
+}
+
+static bool set_mode_for_params(struct modeset_params *params)
+{
+	int rc;
+
+	rc = drmModeSetCrtc(drm.fd, params->crtc_id, params->fb.fb->fb_id,
+			    params->fb.x, params->fb.y,
+			    &params->connector_id, 1, params->mode);
+	return (rc == 0);
+}
+
+#define DEBUGFS_MSG_SIZE 256
+
+static void get_debugfs_string(int fd, char *buf)
+{
+	ssize_t n_read;
+
+	lseek(fd, 0, SEEK_SET);
+
+	n_read = read(fd, buf, DEBUGFS_MSG_SIZE -1);
+	igt_assert(n_read >= 0);
+	buf[n_read] = '\0';
+}
+
+static enum feature_status fbc_get_status(void)
+{
+	char buf[DEBUGFS_MSG_SIZE];
+
+	get_debugfs_string(fbc.fd, buf);
+


Reply to: