All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t v2 12/15] tests: Add kms_atomic_transition
Date: Wed,  6 Jul 2016 11:55:52 +0200	[thread overview]
Message-ID: <1467798955-7324-13-git-send-email-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <1467798955-7324-1-git-send-email-maarten.lankhorst@linux.intel.com>

This is meant as a stress test, to ensure that all combinations of
atomic transitions work correctly. This could be useful for other
drivers too, so I kept it generic. For i915 this will mainly be a
stress test on watermark calculations.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 tests/Makefile.sources        |   1 +
 tests/kms_atomic_transition.c | 189 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 190 insertions(+)
 create mode 100644 tests/kms_atomic_transition.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 2ab25eac7764..6e86c723f78e 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -84,6 +84,7 @@ TESTS_progs_M = \
 	gvt_basic \
 	kms_addfb_basic \
 	kms_atomic \
+	kms_atomic_transition \
 	kms_chv_cursor_fail \
 	kms_cursor_crc \
 	kms_cursor_legacy \
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
new file mode 100644
index 000000000000..29d89802ce40
--- /dev/null
+++ b/tests/kms_atomic_transition.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright © 2016 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.
+ */
+
+#include "igt.h"
+#include "drmtest.h"
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#ifndef DRM_CAP_CURSOR_WIDTH
+#define DRM_CAP_CURSOR_WIDTH 0x8
+#endif
+#ifndef DRM_CAP_CURSOR_HEIGHT
+#define DRM_CAP_CURSOR_HEIGHT 0x9
+#endif
+
+static void
+wm_setup_plane(igt_display_t *display, enum pipe pipe, uint32_t mask,
+	       struct igt_fb *fb, struct igt_fb *argb_fb,
+	       uint64_t cursor_width, uint64_t cursor_height)
+{
+	igt_plane_t *plane;
+
+	/*
+	* Make sure these buffers are suited for display use
+	* because most of the modeset operations must be fast
+	* later on.
+	*/
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (!((1 << plane->index) & mask)) {
+			igt_plane_set_fb(plane, NULL);
+			continue;
+		}
+
+		if (plane->is_primary)
+			igt_plane_set_fb(plane, fb);
+		else
+			igt_plane_set_fb(plane, argb_fb);
+
+		if (plane->is_cursor) {
+			igt_fb_set_size(argb_fb, plane, cursor_width, cursor_height);
+			igt_plane_set_size(plane, cursor_width, cursor_height);
+		}
+	}
+}
+
+/*
+ * 1. Set primary plane to a known fb.
+ * 2. Make sure getcrtc returns the correct fb id.
+ * 3. Call rmfb on the fb.
+ * 4. Make sure getcrtc returns 0 fb id.
+ *
+ * RMFB is supposed to free the framebuffers from any and all planes,
+ * so test this and make sure it works.
+ */
+static void
+run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output, bool modeset)
+{
+	struct igt_fb fb, argb_fb;
+	drmModeModeInfo *mode;
+	igt_plane_t *plane;
+	uint64_t cursor_width, cursor_height;
+	uint32_t iter_max = 1 << display->pipes[pipe].n_planes, i, j;
+
+	mode = igt_output_get_mode(output);
+
+	igt_create_fb(display->drm_fd, mode->hdisplay, mode->vdisplay,
+		      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+
+	igt_create_fb(display->drm_fd, mode->hdisplay, mode->vdisplay,
+		      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE, &argb_fb);
+
+	do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_WIDTH, &cursor_width));
+	if (cursor_width > mode->hdisplay)
+		cursor_width = mode->hdisplay;
+
+	do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height));
+	if (cursor_height > mode->vdisplay)
+		cursor_height = mode->vdisplay;
+
+	if (modeset) {
+		igt_output_set_pipe(output, PIPE_NONE);
+
+		wm_setup_plane(display, pipe, 0, NULL, NULL,
+			      cursor_width, cursor_height);
+
+		igt_display_commit2(display, COMMIT_ATOMIC);
+	}
+
+	for (i = 0; i < iter_max; i++) {
+		igt_output_set_pipe(output, pipe);
+
+		wm_setup_plane(display, pipe, i, &fb, &argb_fb,
+			       cursor_width, cursor_height);
+
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		if (modeset) {
+			igt_output_set_pipe(output, PIPE_NONE);
+
+			wm_setup_plane(display, pipe, 0, NULL, NULL,
+				       cursor_width, cursor_height);
+
+			igt_display_commit2(display, COMMIT_ATOMIC);
+		} else {
+			/* i -> i+1 will be done when i increases, can be skipped here */
+			for (j = iter_max - 1; j > i + 1; j--) {
+				wm_setup_plane(display, pipe, j, &fb, &argb_fb,
+					      cursor_width, cursor_height);
+
+				igt_display_commit2(display, COMMIT_ATOMIC);
+
+				wm_setup_plane(display, pipe, i, &fb, &argb_fb,
+					      cursor_width, cursor_height);
+				igt_display_commit2(display, COMMIT_ATOMIC);
+			}
+		}
+	}
+
+	igt_output_set_pipe(output, PIPE_NONE);
+
+	for_each_plane_on_pipe(display, pipe, plane)
+		igt_plane_set_fb(plane, NULL);
+
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_remove_fb(display->drm_fd, &fb);
+	igt_remove_fb(display->drm_fd, &argb_fb);
+}
+
+igt_main
+{
+	igt_display_t display;
+	igt_output_t *output;
+	enum pipe pipe;
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		int valid_outputs = 0;
+
+		display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_init(&display, display.drm_fd);
+
+		igt_require(display.is_atomic);
+
+		for_each_pipe_with_valid_output(&display, pipe, output)
+			valid_outputs++;
+
+		igt_require_f(valid_outputs, "no valid crtc/connector combinations found\n");
+	}
+
+	igt_subtest_f("plane-all-transition")
+		for_each_pipe_with_valid_output(&display, pipe, output)
+			run_transition_test(&display, pipe, output, false);
+
+	igt_subtest_f("plane-modeset-transition")
+		for_each_pipe_with_valid_output(&display, pipe, output)
+			run_transition_test(&display, pipe, output, true);
+
+	igt_fixture {
+		igt_display_fini(&display);
+	}
+}
-- 
2.5.5

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

  parent reply	other threads:[~2016-07-06  9:56 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06  9:55 [PATCH i-g-t v2 00/15] Add support for atomic modeset to IGT Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 01/15] igt_kms: Remove kmstest_connector_config.crtc_idx Maarten Lankhorst
2016-07-13 12:13   ` Daniel Vetter
2016-07-19 12:52     ` Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 02/15] igt_kms: Find optimal encoder only after selecting pipe Maarten Lankhorst
2016-07-15 11:14   ` Ander Conselvan De Oliveira
2016-07-06  9:55 ` [PATCH i-g-t v2 03/15] kms_psr_sink_crc: Use for_each_pipe_with_valid_output to find a valid config Maarten Lankhorst
2016-07-15 11:15   ` Ander Conselvan De Oliveira
2016-07-19 13:58     ` Ander Conselvan De Oliveira
2016-07-20  7:53       ` Maarten Lankhorst
2016-07-20 12:17         ` Ander Conselvan De Oliveira
2016-07-06  9:55 ` [PATCH i-g-t v2 04/15] igt_kms: Make PIPE_ANY a alias for PIPE_NONE Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 05/15] tests/kms: Clean up more users of unassigned pipes Maarten Lankhorst
2016-07-20 12:56   ` Ander Conselvan De Oliveira
2016-07-21  9:21     ` Maarten Lankhorst
2016-07-25 13:04     ` Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 06/15] igt_kms: Change PIPE_ANY behavior to mean unassigned Maarten Lankhorst
2016-07-21  9:23   ` Ander Conselvan De Oliveira
2016-07-06  9:55 ` [PATCH i-g-t v2 07/15] igt_kms: Handle atomic pipe properties better Maarten Lankhorst
2016-07-21 10:07   ` Ander Conselvan De Oliveira
2016-07-06  9:55 ` [PATCH i-g-t v2 08/15] igt_kms: Remove pan members from igt_plane, v2 Maarten Lankhorst
2016-07-21 11:42   ` Ander Conselvan De Oliveira
2016-07-21 12:37     ` Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 09/15] igt_kms: Clear all _changed members centrally Maarten Lankhorst
2016-07-21 12:13   ` Ander Conselvan De Oliveira
2016-07-21 12:43     ` Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 10/15] igt_kms: Add modeset support to atomic commits Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 11/15] tests: Add kms_rmfb test Maarten Lankhorst
2016-07-06  9:55 ` Maarten Lankhorst [this message]
2016-07-06  9:55 ` [PATCH i-g-t v2 13/15] igt_kms: Add more apis for panel fitting test Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 14/15] igt_kms: Allow disabling previous override mode Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 15/15] kms_panel_fitting: Add tests for fastboot Maarten Lankhorst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467798955-7324-13-git-send-email-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.