All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeevan B <jeevan.b@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: petri.latvala@intel.com
Subject: [igt-dev] [PATCH i-g-t v8] tests/kms_display_modes: Add test for extended mode
Date: Tue, 22 Feb 2022 00:25:41 +0530	[thread overview]
Message-ID: <20220221185541.6628-1-jeevan.b@intel.com> (raw)

Add test for validation of extended mode.

v2: - make subtest dynamic
    - rename testname
    - rename and delete unsed variable
v3: - break the loop after second output is found
v4: - add logic to set valid pipes for dynamic test

Signed-off-by: Jeevan B <jeevan.b@intel.com>
Reviewed-by: Karthik B S <karthik.b.s@intel.com>
---
 tests/kms_display_modes.c | 173 ++++++++++++++++++++++++++++++++++++++
 tests/meson.build         |   1 +
 2 files changed, 174 insertions(+)
 create mode 100644 tests/kms_display_modes.c

diff --git a/tests/kms_display_modes.c b/tests/kms_display_modes.c
new file mode 100644
index 00000000..b96eb4d4
--- /dev/null
+++ b/tests/kms_display_modes.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright © 2022 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.
+ *
+ * Author:
+ *  Jeevan B <jeevan.b@intel.com>
+ */
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Test Display Modes");
+
+typedef struct {
+	int drm_fd;
+	igt_display_t display;
+	int n_pipes;
+} data_t;
+
+static void run_extendedmode_basic(data_t *data, int pipe1, int pipe2)
+{
+	struct igt_fb fb, fbs[2];
+	drmModeModeInfo *mode[2];
+	igt_output_t *output, *extended_output[2];
+	igt_display_t *display = &data->display;
+	igt_plane_t *plane[2];
+	igt_pipe_crc_t *pipe_crc[2] = { 0 };
+	igt_crc_t ref_crc[2], crc[2];
+	int count = 0, width, height;
+	cairo_t *cr;
+
+	for_each_connected_output(display, output) {
+		extended_output[count] = output;
+		count++;
+
+		if (count > 1)
+			break;
+	}
+
+	igt_output_set_pipe(extended_output[0], pipe1);
+	igt_output_set_pipe(extended_output[1], pipe2);
+
+	mode[0] = igt_output_get_mode(extended_output[0]);
+	mode[1] = igt_output_get_mode(extended_output[1]);
+
+	pipe_crc[0] = igt_pipe_crc_new(data->drm_fd, pipe1, INTEL_PIPE_CRC_SOURCE_AUTO);
+	pipe_crc[1] = igt_pipe_crc_new(data->drm_fd, pipe2, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	igt_create_color_fb(data->drm_fd, mode[0]->hdisplay, mode[0]->vdisplay,
+			     DRM_FORMAT_XRGB8888, 0, 1, 0, 0, &fbs[0]);
+	igt_create_color_fb(data->drm_fd, mode[1]->hdisplay, mode[1]->vdisplay,
+			     DRM_FORMAT_XRGB8888, 0, 0, 0, 1, &fbs[1]);
+
+	plane[0] = igt_pipe_get_plane_type(&display->pipes[pipe1], DRM_PLANE_TYPE_PRIMARY);
+	plane[1] = igt_pipe_get_plane_type(&display->pipes[pipe2], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_plane_set_fb(plane[0], &fbs[0]);
+	igt_fb_set_size(&fbs[0], plane[0], mode[0]->hdisplay, mode[0]->vdisplay);
+	igt_plane_set_size(plane[0], mode[0]->hdisplay, mode[0]->vdisplay);
+
+	igt_plane_set_fb(plane[1], &fbs[1]);
+	igt_fb_set_size(&fbs[1], plane[1], mode[1]->hdisplay, mode[1]->vdisplay);
+	igt_plane_set_size(plane[1], mode[1]->hdisplay, mode[1]->vdisplay);
+
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_pipe_crc_collect_crc(pipe_crc[0], &ref_crc[0]);
+	igt_pipe_crc_collect_crc(pipe_crc[1], &ref_crc[1]);
+
+	/*Create a big framebuffer and display it on 2 monitors*/
+	width = mode[0]->hdisplay + mode[1]->hdisplay;
+	height = max(mode[0]->vdisplay, mode[1]->vdisplay);
+
+	igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888, 0, &fb);
+	cr = igt_get_cairo_ctx(data->drm_fd, &fb);
+	igt_paint_color(cr, 0, 0, mode[0]->hdisplay, mode[0]->vdisplay, 1, 0, 0);
+	igt_paint_color(cr, mode[0]->hdisplay, 0, mode[1]->hdisplay, mode[1]->vdisplay, 0, 0, 1);
+	igt_put_cairo_ctx(cr);
+
+	igt_plane_set_fb(plane[0], &fb);
+	igt_fb_set_position(&fb, plane[0], 0, 0);
+	igt_fb_set_size(&fb, plane[0], mode[0]->hdisplay, mode[0]->vdisplay);
+
+	igt_plane_set_fb(plane[1], &fb);
+	igt_fb_set_position(&fb, plane[1], mode[0]->hdisplay, 0);
+	igt_fb_set_size(&fb, plane[1], mode[1]->hdisplay, mode[1]->vdisplay);
+
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_pipe_crc_collect_crc(pipe_crc[0], &crc[0]);
+	igt_pipe_crc_collect_crc(pipe_crc[1], &crc[1]);
+
+	/*Clean up*/
+	igt_remove_fb(data->drm_fd, &fbs[0]);
+	igt_remove_fb(data->drm_fd, &fbs[1]);
+	igt_remove_fb(data->drm_fd, &fb);
+
+	igt_pipe_crc_free(pipe_crc[0]);
+	igt_pipe_crc_free(pipe_crc[1]);
+
+	igt_output_set_pipe(extended_output[0], PIPE_NONE);
+	igt_output_set_pipe(extended_output[1], PIPE_NONE);
+
+	igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe1],
+			  DRM_PLANE_TYPE_PRIMARY), NULL);
+	igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe2],
+			  DRM_PLANE_TYPE_PRIMARY), NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	/*Compare CRC*/
+	igt_assert_crc_equal(&crc[0], &ref_crc[0]);
+	igt_assert_crc_equal(&crc[1], &ref_crc[1]);
+}
+
+igt_main
+{
+	data_t data;
+	int valid_output = 0, i, j = 0;
+	igt_output_t *output;
+	int pipe[IGT_MAX_PIPES];
+
+	igt_fixture {
+		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+		kmstest_set_vt_graphics_mode();
+		igt_display_require(&data.display, data.drm_fd);
+
+		for_each_connected_output(&data.display, output) {
+			valid_output++;
+
+			if (valid_output > 1)
+				break;
+		}
+
+		data.n_pipes = 0;
+		for_each_pipe(&data.display, i) {
+			data.n_pipes++;
+			pipe[j] = i;
+			j++;
+		}
+
+		igt_require_f(valid_output > 1, "No valid Second output found\n");
+	}
+
+	igt_describe("Test for validating display extended mode with a pair of connected displays");
+	igt_subtest_with_dynamic("extended-mode-basic") {
+		for (i = 0; i < data.n_pipes - 1; i++) {
+			igt_dynamic_f("pipe-%s%s", kmstest_pipe_name(pipe[i]),
+					kmstest_pipe_name(pipe[i+1]));
+			run_extendedmode_basic(&data, pipe[i], pipe[i+1]);
+		}
+	}
+
+	igt_fixture {
+		igt_display_fini(&data.display);
+	}
+}
diff --git a/tests/meson.build b/tests/meson.build
index 7003d064..3dbba7a1 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -26,6 +26,7 @@ test_progs = [
 	'kms_cursor_edge_walk',
 	'kms_cursor_legacy',
 	'kms_dither',
+	'kms_display_modes',
 	'kms_dp_aux_dev',
 	'kms_dp_tiled_display',
 	'kms_flip',
-- 
2.17.1

             reply	other threads:[~2022-02-21 18:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 18:55 Jeevan B [this message]
2022-02-21 19:37 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_display_modes: Add test for extended mode (rev3) Patchwork
2022-02-22  1:15 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-02-22 14:04 ` [igt-dev] [PATCH i-g-t v8] tests/kms_display_modes: Add test for extended mode Petri Latvala

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=20220221185541.6628-1-jeevan.b@intel.com \
    --to=jeevan.b@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /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.