Re: [Intel-gfx] [igt PATCH 4/4] tests: add kms_setmode

2013-08-06 Thread Daniel Vetter
On Mon, Aug 05, 2013 at 02:45:26PM +0300, Imre Deak wrote:
 Iterate through all valid/invalid crtc/connector combinations. At the
 moment only clone configurations are tested as the single output cases
 are tested already by testdisplay. Also from combinations where all
 connectors are on the same crtc (clone-single-crtc) only those are
 tested that are invalid, as I haven't found any machine that supports
 these (have to be GT2 with dvo and vga output).
 
 For configurations with one crtc per connector the FBs are per-crtc atm.
 
 Signed-off-by: Imre Deak imre.d...@intel.com

lgtm. Please push as soon as we've figured out what to do with patch 3.

I wonder whether we shouldn't change our DP code a bit and force the
port into normal mode (with some conservative link training values) even
when link training fails. Contrary to fdi links I think the pixels would
still flow and so would allow us to exercise more codepaths. But that's
for another time I guess.

Depending upon how the kms_ tests shape up we might want to extract a bit
more code from here, but again we can do that later.

Thanks, Daniel

 ---
  tests/.gitignore|   1 +
  tests/Makefile.am   |   1 +
  tests/kms_setmode.c | 739 
 
  3 files changed, 741 insertions(+)
  create mode 100644 tests/kms_setmode.c
 
 diff --git a/tests/.gitignore b/tests/.gitignore
 index 451ab2d..8303526 100644
 --- a/tests/.gitignore
 +++ b/tests/.gitignore
 @@ -90,6 +90,7 @@ getstats
  getversion
  kms_flip
  kms_render
 +kms_setmode
  prime_nv_api
  prime_nv_pcopy
  prime_nv_test
 diff --git a/tests/Makefile.am b/tests/Makefile.am
 index a59c25f..36caa2a 100644
 --- a/tests/Makefile.am
 +++ b/tests/Makefile.am
 @@ -39,6 +39,7 @@ TESTS_progs_M = \
   gem_write_read_ring_switch \
   kms_flip \
   kms_render \
 + kms_setmode \
   $(NOUVEAU_TESTS_M) \
   prime_self_import \
   $(NULL)
 diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
 new file mode 100644
 index 000..8a1973d
 --- /dev/null
 +++ b/tests/kms_setmode.c
 @@ -0,0 +1,739 @@
 +/*
 + * 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 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:
 + *Imre Deak imre.d...@intel.com
 + */
 +#ifdef HAVE_CONFIG_H
 +#include config.h
 +#endif
 +
 +#include assert.h
 +#include cairo.h
 +#include errno.h
 +#include stdint.h
 +#include unistd.h
 +#include string.h
 +#include getopt.h
 +#include sys/time.h
 +
 +#include drm_fourcc.h
 +#include drmtest.h
 +#include intel_bufmgr.h
 +#include intel_batchbuffer.h
 +#include intel_gpu_tools.h
 +
 +#define MAX_CONNECTORS  10
 +#define MAX_CRTCS   3
 +
 +/* max combinations with repetitions */
 +#define MAX_COMBINATION_COUNT   \
 + (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)
 +#define MAX_COMBINATION_ELEMS   MAX_CRTCS
 +
 +static int drm_fd;
 +static int filter_test_id;
 +static bool dry_run;
 +
 +const drmModeModeInfo mode_640_480 = {
 + .name   = 640x480,
 + .vrefresh   = 60,
 + .clock  = 25200,
 +
 + .hdisplay   = 640,
 + .hsync_start= 656,
 + .hsync_end  = 752,
 + .htotal = 800,
 +
 + .vdisplay   = 480,
 + .vsync_start= 490,
 + .vsync_end  = 492,
 + .vtotal = 525,
 +
 + .flags  = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
 +};
 +
 +enum test_flags {
 + TEST_INVALID= 0x01,
 + TEST_CLONE  = 0x02,
 + TEST_SINGLE_CRTC_CLONE  = 0x04,
 + TEST_EXCLUSIVE_CRTC_CLONE   = 0x08,
 +};
 +
 +struct test_config {
 + const char *name;
 + enum test_flags flags;
 + drmModeRes *resources;
 +};
 +
 +struct connector_config {
 + drmModeConnector *connector;
 + int crtc_idx;
 + bool connected;
 + drmModeModeInfo default_mode;
 +};
 +
 +struct crtc_config {
 + int crtc_idx;
 + int crtc_id;
 + int pipe_id;
 + int 

[Intel-gfx] [igt PATCH 4/4] tests: add kms_setmode

2013-08-05 Thread Imre Deak
Iterate through all valid/invalid crtc/connector combinations. At the
moment only clone configurations are tested as the single output cases
are tested already by testdisplay. Also from combinations where all
connectors are on the same crtc (clone-single-crtc) only those are
tested that are invalid, as I haven't found any machine that supports
these (have to be GT2 with dvo and vga output).

For configurations with one crtc per connector the FBs are per-crtc atm.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/.gitignore|   1 +
 tests/Makefile.am   |   1 +
 tests/kms_setmode.c | 739 
 3 files changed, 741 insertions(+)
 create mode 100644 tests/kms_setmode.c

diff --git a/tests/.gitignore b/tests/.gitignore
index 451ab2d..8303526 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -90,6 +90,7 @@ getstats
 getversion
 kms_flip
 kms_render
+kms_setmode
 prime_nv_api
 prime_nv_pcopy
 prime_nv_test
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a59c25f..36caa2a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -39,6 +39,7 @@ TESTS_progs_M = \
gem_write_read_ring_switch \
kms_flip \
kms_render \
+   kms_setmode \
$(NOUVEAU_TESTS_M) \
prime_self_import \
$(NULL)
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
new file mode 100644
index 000..8a1973d
--- /dev/null
+++ b/tests/kms_setmode.c
@@ -0,0 +1,739 @@
+/*
+ * 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 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:
+ *Imre Deak imre.d...@intel.com
+ */
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include assert.h
+#include cairo.h
+#include errno.h
+#include stdint.h
+#include unistd.h
+#include string.h
+#include getopt.h
+#include sys/time.h
+
+#include drm_fourcc.h
+#include drmtest.h
+#include intel_bufmgr.h
+#include intel_batchbuffer.h
+#include intel_gpu_tools.h
+
+#define MAX_CONNECTORS  10
+#define MAX_CRTCS   3
+
+/* max combinations with repetitions */
+#define MAX_COMBINATION_COUNT   \
+   (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)
+#define MAX_COMBINATION_ELEMS   MAX_CRTCS
+
+static int drm_fd;
+static int filter_test_id;
+static bool dry_run;
+
+const drmModeModeInfo mode_640_480 = {
+   .name   = 640x480,
+   .vrefresh   = 60,
+   .clock  = 25200,
+
+   .hdisplay   = 640,
+   .hsync_start= 656,
+   .hsync_end  = 752,
+   .htotal = 800,
+
+   .vdisplay   = 480,
+   .vsync_start= 490,
+   .vsync_end  = 492,
+   .vtotal = 525,
+
+   .flags  = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+};
+
+enum test_flags {
+   TEST_INVALID= 0x01,
+   TEST_CLONE  = 0x02,
+   TEST_SINGLE_CRTC_CLONE  = 0x04,
+   TEST_EXCLUSIVE_CRTC_CLONE   = 0x08,
+};
+
+struct test_config {
+   const char *name;
+   enum test_flags flags;
+   drmModeRes *resources;
+};
+
+struct connector_config {
+   drmModeConnector *connector;
+   int crtc_idx;
+   bool connected;
+   drmModeModeInfo default_mode;
+};
+
+struct crtc_config {
+   int crtc_idx;
+   int crtc_id;
+   int pipe_id;
+   int connector_count;
+   struct connector_config *cconfs;
+   struct kmstest_fb fb_info;
+   drmModeModeInfo mode;
+};
+
+static bool drm_mode_equal(drmModeModeInfo *m1, drmModeModeInfo *m2)
+{
+#define COMP(x) do { if (m1-x != m2-x) return false; } while (0)
+   COMP(vrefresh);
+   COMP(clock);
+   COMP(hdisplay);
+   COMP(hsync_start);
+   COMP(hsync_end);
+   COMP(htotal);
+   COMP(vdisplay);
+   COMP(vsync_start);
+   COMP(vsync_end);
+   COMP(vtotal);
+   COMP(flags);
+
+   return true;
+}
+
+static bool connector_supports_mode(drmModeConnector *connector,
+   drmModeModeInfo *mode)