All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stylon Wang <stylon.wang@amd.com>
To: igt-dev@lists.freedesktop.org
Cc: Bhawanpreet.Lakha@amd.com, Ahmad.Othman@amd.com,
	Victor Lu <victorchengchi.lu@amd.com>,
	Hayden.Goodfellow@amd.com
Subject: [igt-dev] [PATCH i-g-t v2 01/11] tests/amdgpu/amd_plane: Introduced 4K MPO test
Date: Wed, 1 Dec 2021 14:54:24 +0800	[thread overview]
Message-ID: <20211201065434.48827-2-stylon.wang@amd.com> (raw)
In-Reply-To: <20211201065434.48827-1-stylon.wang@amd.com>

From: Victor Lu <victorchengchi.lu@amd.com>

Tests MPO using a primary plane and an overlay plane with a transparent
cutout.

Signed-off-by: Victor Lu <victorchengchi.lu@amd.com>
---
 tests/amdgpu/amd_plane.c | 158 +++++++++++++++++++++++++++++++++++++++
 tests/amdgpu/meson.build |   1 +
 2 files changed, 159 insertions(+)
 create mode 100644 tests/amdgpu/amd_plane.c

diff --git a/tests/amdgpu/amd_plane.c b/tests/amdgpu/amd_plane.c
new file mode 100644
index 00000000..64273330
--- /dev/null
+++ b/tests/amdgpu/amd_plane.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2019 Advanced Micro Devices, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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"
+
+/* Common test data. */
+typedef struct data {
+	igt_display_t display;
+	igt_plane_t *primary;
+	igt_plane_t *overlay;
+	igt_output_t *output;
+	igt_pipe_t *pipe;
+	igt_pipe_crc_t *pipe_crc;
+	drmModeModeInfo *mode;
+	enum pipe pipe_id;
+	int fd;
+	int w;
+	int h;
+} data_t;
+
+static void test_init(data_t *data)
+{
+	igt_display_t *display = &data->display;
+
+	/* It doesn't matter which pipe we choose on amdpgu. */
+	data->pipe_id = PIPE_A;
+	data->pipe = &data->display.pipes[data->pipe_id];
+
+	igt_display_reset(display);
+
+	data->output = igt_get_single_output_for_pipe(display, data->pipe_id);
+	igt_require(data->output);
+
+	data->mode = igt_output_get_mode(data->output);
+	igt_assert(data->mode);
+
+	data->primary =
+		igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY);
+	data->overlay =
+		igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_OVERLAY);
+
+	data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id,
+					  INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	igt_output_set_pipe(data->output, data->pipe_id);
+
+	data->w = data->mode->hdisplay;
+	data->h = data->mode->vdisplay;
+}
+
+static void test_fini(data_t *data)
+{
+	igt_pipe_crc_free(data->pipe_crc);
+	igt_display_reset(&data->display);
+}
+
+static void draw_color_alpha(igt_fb_t *fb, int x, int y, int w, int h,
+		             double r, double g, double b, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	igt_paint_color_alpha(cr, x, y, w, h, r, g, b, a);
+	igt_put_cairo_ctx(cr);
+}
+
+/*
+ * Compares a white 4K reference FB against a white 4K primary FB and a
+ * white 4K overlay with an RGBA (0, 0, 0, 0) cutout in the center.
+ */
+static void test_mpo_4k(data_t *data)
+{
+	igt_fb_t r_fb, p_fb, o_fb;
+	igt_crc_t ref_crc, new_crc;
+	igt_display_t *display = &data->display;
+	int cutout_x, cutout_y, cutout_w, cutout_h;
+
+	test_init(data);
+
+	/* Skip if not 4K resolution. */
+	igt_skip_on(!(data->mode->hdisplay == 3840 &&
+		    data->mode->vdisplay == 2160));
+
+	cutout_x = cutout_w = 1280;
+	cutout_y = cutout_h = 720;
+
+	igt_create_color_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888,
+			    0, 1.00, 1.00, 1.00, &r_fb);
+	igt_create_color_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888,
+			    0, 1.00, 1.00, 1.00, &p_fb);
+	igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_ARGB8888,
+		      0, &o_fb);
+	draw_color_alpha(&o_fb, 0, 0, o_fb.width, o_fb.height, 1.00, 1.00, 1.00, 1.00);
+	draw_color_alpha(&o_fb, cutout_x, cutout_y, cutout_w, cutout_h,
+			 0.00, 0.00, 0.00, 0.00);
+
+	igt_plane_set_fb(data->primary, &r_fb);
+	igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(data->primary, &p_fb);
+	igt_plane_set_fb(data->overlay, &o_fb);
+	igt_display_commit_atomic(display, 0, NULL);
+
+	igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc);
+
+	igt_assert_crc_equal(&ref_crc, &new_crc);
+
+	test_fini(data);
+	igt_remove_fb(data->fd, &o_fb);
+	igt_remove_fb(data->fd, &p_fb);
+	igt_remove_fb(data->fd, &r_fb);
+}
+
+igt_main
+{
+	data_t data;
+
+	igt_skip_on_simulation();
+
+	memset(&data, 0, sizeof(data));
+
+	igt_fixture
+	{
+		data.fd = drm_open_driver_master(DRIVER_AMDGPU);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&data.display, data.fd);
+		igt_require(data.display.is_atomic);
+		igt_display_require_output(&data.display);
+	}
+
+	igt_subtest("test-mpo-4k") test_mpo_4k(&data);
+
+	igt_fixture
+	{
+		igt_display_fini(&data.display);
+	}
+}
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
index 5216e194..3531151b 100644
--- a/tests/amdgpu/meson.build
+++ b/tests/amdgpu/meson.build
@@ -17,6 +17,7 @@ if libdrm_amdgpu.found()
 			  'amd_link_settings',
 			  'amd_vrr_range',
 			  'amd_mode_switch',
+			  'amd_plane',
 			]
 	amdgpu_deps += libdrm_amdgpu
 endif
-- 
2.33.1

  reply	other threads:[~2021-12-01  6:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30  8:34 [igt-dev] [PATCH i-g-t 00/11] Create tests for multi-plane overlay Stylon Wang
2021-11-30  8:34 ` [igt-dev] [PATCH i-g-t 01/11] tests/amdgpu/amd_plane: Introduced 4K MPO test Stylon Wang
2021-11-30  8:34 ` [igt-dev] [PATCH i-g-t 02/11] tests/amdgpu/amd_plane: Add MPO swizzle mode toggle test Stylon Wang
2021-11-30  8:34 ` [igt-dev] [PATCH i-g-t 03/11] tests/amdgpu/amd_plane: fixes for test-4k-mpo Stylon Wang
2021-11-30  8:34 ` [igt-dev] [PATCH i-g-t 04/11] tests/amdgpu/amd_plane: Switch mpo-swizzle-toggle to single-head Stylon Wang
2021-11-30  8:34 ` [igt-dev] [PATCH i-g-t 05/11] tests/amdgpu/amd_plane: Create mpo panning test Stylon Wang
2021-11-30  8:34 ` [igt-dev] [PATCH i-g-t 06/11] tests/amdgpu/amd_plane: Create mpo swap between 2 displays test Stylon Wang
2021-11-30  8:34 ` [igt-dev] [PATCH i-g-t 07/11] tests/amdgpu/amd_plane: Create mpo scaling tests Stylon Wang
2021-11-30  8:35 ` [igt-dev] [PATCH i-g-t 08/11] tests/amdgpu/amd_plane: Add MPO scale and pan subtest single display option Stylon Wang
2021-11-30  8:35 ` [igt-dev] [PATCH i-g-t 09/11] tests/amdgpu/amd_plane: Add full screen scaling test case Stylon Wang
2021-11-30  8:35 ` [igt-dev] [PATCH i-g-t 10/11] tests/amdgpu/amd_plane: Ensure pipes are enabled before accessing Stylon Wang
2021-11-30  8:35 ` [igt-dev] [PATCH i-g-t 11/11] tests/amdgpu/amd_plane: Add P010 format to MPO tests and add test descriptions Stylon Wang
2021-11-30 11:10 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Create tests for multi-plane overlay Patchwork
2021-12-01  6:54 ` [igt-dev] [PATCH i-g-t v2 00/11] " Stylon Wang
2021-12-01  6:54   ` Stylon Wang [this message]
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 02/11] tests/amdgpu/amd_plane: Add MPO swizzle mode toggle test Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 03/11] tests/amdgpu/amd_plane: fixes for test-4k-mpo Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 04/11] tests/amdgpu/amd_plane: Switch mpo-swizzle-toggle to single-head Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 05/11] tests/amdgpu/amd_plane: Create mpo panning test Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 06/11] tests/amdgpu/amd_plane: Create mpo swap between 2 displays test Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 07/11] tests/amdgpu/amd_plane: Create mpo scaling tests Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 08/11] tests/amdgpu/amd_plane: Add MPO scale and pan subtest single display option Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 09/11] tests/amdgpu/amd_plane: Add full screen scaling test case Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 10/11] tests/amdgpu/amd_plane: Ensure pipes are enabled before accessing Stylon Wang
2021-12-01  6:54   ` [igt-dev] [PATCH i-g-t v2 11/11] tests/amdgpu/amd_plane: Add P010 format to MPO tests and add test descriptions Stylon Wang
2021-12-01 22:09 ` [igt-dev] [PATCH i-g-t 00/11] Create tests for multi-plane overlay Rodrigo Siqueira Jordao

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=20211201065434.48827-2-stylon.wang@amd.com \
    --to=stylon.wang@amd.com \
    --cc=Ahmad.Othman@amd.com \
    --cc=Bhawanpreet.Lakha@amd.com \
    --cc=Hayden.Goodfellow@amd.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=victorchengchi.lu@amd.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.