public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 3/3] kms_universal_plane: Universal plane testing
Date: Thu, 10 Apr 2014 17:26:25 -0700	[thread overview]
Message-ID: <1397175985-3328-4-git-send-email-matthew.d.roper@intel.com> (raw)
In-Reply-To: <1397175985-3328-1-git-send-email-matthew.d.roper@intel.com>

Add a simple test to exercise universal plane support.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 tests/Makefile.sources      |   1 +
 tests/kms_universal_plane.c | 211 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 212 insertions(+)
 create mode 100644 tests/kms_universal_plane.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index bf02a48..4911914 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -63,6 +63,7 @@ TESTS_progs_M = \
 	kms_plane \
 	kms_render \
 	kms_setmode \
+	kms_universal_plane \
 	pm_lpsp \
 	pm_pc8 \
 	pm_rps \
diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c
new file mode 100644
index 0000000..f1ec6fb
--- /dev/null
+++ b/tests/kms_universal_plane.c
@@ -0,0 +1,211 @@
+/*
+ * 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.
+ */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "drmtest.h"
+#include "igt_debugfs.h"
+#include "igt_kms.h"
+
+typedef struct {
+	int drm_fd;
+	igt_display_t display;
+} data_t;
+
+/*
+ * Universal plane testing.
+ *   - Black primary plane via traditional interfaces, red sprite, grab CRC:1.
+ *   - Blue primary plane via traditional interfaces, red sprite, grab CRC:2.
+ *   - Yellow primary via traditional interfaces
+ *   - Blue primary plane, red sprite via universal planes, grab CRC:3 and compare
+ *     with CRC:2 (should be the same)
+ *   - Disable primary plane, grab CRC:4 (should be same as CRC:1)
+ *   - Reenable primary, grab CRC:5 (should be same as CRC:2 and CRC:3)
+ */
+
+typedef struct {
+	data_t *data;
+	igt_pipe_crc_t *pipe_crc;
+	igt_crc_t crc_1, crc_2, crc_3, crc_4, crc_5;
+	struct igt_fb red_fb, blue_fb, black_fb, yellow_fb;
+} test_t;
+
+static void
+test_init(test_t *test, igt_output_t *output, enum pipe pipe)
+{
+	data_t *data = test->data;
+	drmModeModeInfo *mode;
+
+	test->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	igt_output_set_pipe(output, pipe);
+
+	mode = igt_output_get_mode(output);
+	igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+				DRM_FORMAT_XRGB8888,
+				false, /* tiled */
+				0.0, 0.0, 0.0,
+				&test->black_fb);
+	igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+				DRM_FORMAT_XRGB8888,
+				false, /* tiled */
+				0.0, 0.0, 1.0,
+				&test->blue_fb);
+	igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+				DRM_FORMAT_XRGB8888,
+				false, /* tiled */
+				1.0, 1.0, 0.0,
+				&test->yellow_fb);
+	igt_create_color_fb(data->drm_fd, 100, 100,
+				DRM_FORMAT_XRGB8888,
+				false, /* tiled */
+				1.0, 0.0, 0.0,
+				&test->red_fb);
+}
+
+static void
+test_fini(test_t *test, igt_output_t *output)
+{
+	igt_pipe_crc_free(test->pipe_crc);
+
+	igt_remove_fb(test->data->drm_fd, &test->black_fb);
+	igt_remove_fb(test->data->drm_fd, &test->blue_fb);
+	igt_remove_fb(test->data->drm_fd, &test->red_fb);
+	igt_remove_fb(test->data->drm_fd, &test->yellow_fb);
+
+	igt_display_use_universal_commits(&test->data->display, false);
+	igt_output_set_pipe(output, PIPE_ANY);
+	igt_display_commit(&test->data->display);
+}
+
+static void
+test_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+	test_t test = { .data = data };
+	igt_plane_t *primary, *sprite;
+
+	igt_skip_on(pipe >= data->display.n_pipes);
+
+	fprintf(stdout, "Testing connector %s using pipe %c\n",
+		igt_output_name(output), pipe_name(pipe));
+
+	test_init(&test, output, pipe);
+
+	primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+	sprite = igt_output_get_plane(output, IGT_PLANE_2);
+	if (!sprite) {
+		test_fini(&test, output);
+		igt_skip("No sprite plane available\n");
+	}
+
+	igt_plane_set_position(sprite, 100, 100);
+
+	/* Step 1: Legacy API's, black primary, red sprite (CRC 1) */
+	igt_plane_set_fb(primary, &test.black_fb);
+	igt_plane_set_fb(sprite, &test.red_fb);
+	igt_display_commit(&data->display);
+	igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_1);
+
+	/* Step 2: Legacy API', blue primary, red sprite (CRC 2) */
+	igt_plane_set_fb(primary, &test.blue_fb);
+	igt_plane_set_fb(sprite, &test.red_fb);
+	igt_display_commit(&data->display);
+	igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_2);
+
+	/* Step 3: Legacy API's, yellow primary */
+	igt_plane_set_fb(primary, &test.yellow_fb);
+	igt_display_commit(&data->display);
+
+	/* Step 4: Universal API's, blue primary, red sprite (CRC 3) */
+	igt_display_use_universal_commits(&test.data->display, true);
+	igt_plane_set_fb(primary, &test.blue_fb);
+	igt_plane_set_fb(sprite, &test.red_fb);
+	igt_display_commit(&data->display);
+	igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_3);
+
+	/* Step 5: Universal API's, disable primary plane (CRC 4) */
+	igt_plane_set_fb(primary, NULL);
+	igt_display_commit(&data->display);
+	igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_4);
+
+	/* Step 6: Universal API's, re-enable primary with blue (CRC 5) */
+	igt_display_use_universal_commits(&test.data->display, true);
+	igt_plane_set_fb(primary, &test.blue_fb);
+	igt_display_commit(&data->display);
+	igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_5);
+
+	/* Blue bg + red sprite should be same under both types of API's */
+	igt_assert(igt_crc_equal(&test.crc_2, &test.crc_3));
+
+	/* Disabling primary plane should be same as black primary */
+	igt_assert(igt_crc_equal(&test.crc_1, &test.crc_4));
+
+	/* Re-enabling primary should return to blue properly */
+	igt_assert(igt_crc_equal(&test.crc_2, &test.crc_5));
+
+	igt_plane_set_fb(primary, NULL);
+	igt_plane_set_fb(sprite, NULL);
+
+	test_fini(&test, output);
+}
+
+static void
+run_tests_for_pipe(data_t *data, enum pipe pipe)
+{
+	igt_output_t *output;
+
+	igt_assert(data->display.has_universal_planes);
+
+	igt_subtest_f("universal-plane-pipe-%c", pipe_name(pipe))
+		for_each_connected_output(&data->display, output)
+			test_pipe(data, pipe, output);
+}
+
+static data_t data;
+
+igt_main
+{
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		data.drm_fd = drm_open_any();
+
+		igt_set_vt_graphics_mode();
+
+		igt_require_pipe_crc();
+		igt_display_init(&data.display, data.drm_fd);
+
+		igt_require(data.display.has_universal_planes);
+	}
+
+	for (int pipe = 0; pipe < 3; pipe++)
+		run_tests_for_pipe(&data, pipe);
+
+	igt_fixture {
+		igt_display_fini(&data.display);
+	}
+}
-- 
1.8.5.1

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

  parent reply	other threads:[~2014-04-11  0:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-11  0:24 [PATCH] drm/i915: Intel-specific primary plane handling (v2) Matt Roper
2014-04-11  0:26 ` [PATCH i-g-t 0/3] Universal plane testing Matt Roper
2014-04-11  0:26   ` [PATCH i-g-t 1/3] kms: Add universal plane support Matt Roper
2014-04-11  0:26   ` [PATCH i-g-t 2/3] kms_plane: Update for universal plane changes Matt Roper
2014-04-11  0:26   ` Matt Roper [this message]
2014-04-11  9:22     ` [PATCH i-g-t 3/3] kms_universal_plane: Universal plane testing Daniel Vetter
2014-04-11 11:57       ` Daniel Vetter
2014-04-11  9:34 ` [PATCH] drm/i915: Intel-specific primary plane handling (v2) Daniel Vetter
2014-04-11 14:17   ` Matt Roper
2014-04-11 14:23     ` Daniel Vetter
2014-04-11 17:41   ` Matt Roper
2014-04-11 18:27     ` Daniel Vetter
2014-04-11 20:44 ` [PATCH] drm/i915: Intel-specific primary plane handling (v3) Matt Roper
2014-04-11 21:13   ` [PATCH] drm/i915: Intel-specific primary plane handling (v4) Matt Roper
2014-04-22 12:47     ` Ville Syrjälä
2014-04-22 15:18       ` Matt Roper
2014-04-22 17:14         ` Daniel Vetter
2014-04-22 17:32           ` Matt Roper

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=1397175985-3328-4-git-send-email-matthew.d.roper@intel.com \
    --to=matthew.d.roper@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox