Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Aurabindo Pillai <aurabindo.pillai@amd.com>
To: <igt-dev@lists.freedesktop.org>
Subject: [igt-dev] [PATCH i-g-t 4/4] test/amdgpu: Add test for Sub-viewport
Date: Thu, 2 Nov 2023 16:00:00 -0400	[thread overview]
Message-ID: <20231102200000.969208-4-aurabindo.pillai@amd.com> (raw)
In-Reply-To: <20231102200000.969208-1-aurabindo.pillai@amd.com>

Sub-viewport is a power saving feature found on DCN32/DCN321 and newer dGPUs.

Add a test that commit a high resolution test pattern on multiple displays
and checks whether Sub-viewport feature is engaged.

Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
---
 tests/amdgpu/amd_subvp.c | 194 +++++++++++++++++++++++++++++++++++++++
 tests/amdgpu/meson.build |   1 +
 2 files changed, 195 insertions(+)
 create mode 100644 tests/amdgpu/amd_subvp.c

diff --git a/tests/amdgpu/amd_subvp.c b/tests/amdgpu/amd_subvp.c
new file mode 100644
index 000000000..110ae31a5
--- /dev/null
+++ b/tests/amdgpu/amd_subvp.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2023 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"
+#include "igt_amd.h"
+#include "igt_core.h"
+#include <fcntl.h>
+
+IGT_TEST_DESCRIPTION("Test enabling sub-viewport feature");
+
+/* Common test data. */
+typedef struct data {
+	igt_display_t display;
+	igt_plane_t *primary[IGT_MAX_PIPES];
+	igt_output_t *output[IGT_MAX_PIPES];
+	igt_pipe_t *pipe[IGT_MAX_PIPES];
+	igt_pipe_crc_t *pipe_crc[IGT_MAX_PIPES];
+	drmModeModeInfo mode[IGT_MAX_PIPES];
+	enum pipe pipe_id[IGT_MAX_PIPES];
+	int fd;
+} data_t;
+
+struct line_check {
+	int found;
+	const char *substr;
+};
+
+static const drmModeModeInfo test_mode[] = {
+	{ 533250,
+	3840, 3888, 3920, 4000, 0,
+	2160, 2214, 2219, 2222, 0,
+	60,
+	DRM_MODE_FLAG_NHSYNC,
+	0x48,
+	"4k60\0",
+	}, /* from LG Ultra HD, product_id = 5B09, serial_number = 1010101 */
+};
+
+/* Forces a mode for a connector. */
+static void force_output_mode(struct data *d, igt_output_t *output,
+			      const drmModeModeInfo *mode)
+{
+	/* This allows us to create a virtual sink. */
+	if (!igt_output_is_connected(output)) {
+		kmstest_force_edid(d->fd, output->config.connector,
+				   igt_kms_get_4k_edid());
+
+		kmstest_force_connector(d->fd, output->config.connector,
+					FORCE_CONNECTOR_DIGITAL);
+	}
+
+	igt_output_override_mode(output, mode);
+}
+
+/* Common test setup. */
+static void test_init(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	int i, n;
+	bool subvp_capable = false;
+	bool subvp_en = false;
+
+	for_each_pipe(display, i) {
+		data->pipe_id[i] = PIPE_A + i;
+		data->pipe[i] = &data->display.pipes[data->pipe_id[i]];
+		data->primary[i] = igt_pipe_get_plane_type(data->pipe[i], DRM_PLANE_TYPE_PRIMARY);
+		data->pipe_crc[i] = igt_pipe_crc_new(data->fd, data->pipe_id[i], IGT_PIPE_CRC_SOURCE_AUTO);
+	}
+
+	for (i = 0, n = 0; i < display->n_outputs && n < display->n_pipes; ++i) {
+		igt_output_t *output = &display->outputs[i];
+		data->output[n] = output;
+
+		/* Only allow physically connected displays for the tests. */
+		if (!igt_output_is_connected(output))
+				continue;
+
+		/* SubVP is only enabled on DP */
+		if (output->config.connector->connector_type !=
+			DRM_MODE_CONNECTOR_DisplayPort)
+			continue;
+
+		igt_assert(kmstest_get_connector_default_mode(
+				data->fd, output->config.connector, &data->mode[n]));
+
+		force_output_mode(data, data->output[n], &test_mode[0]);
+
+		n += 1;
+	}
+
+	igt_require_f(n >= 2, "Requires at least two connected display\n");\
+
+	igt_amd_get_subvp_status(data->fd, &subvp_capable, &subvp_en);
+	igt_require_f(subvp_capable, "Requires hardware that supports Sub-viewport\n");
+
+	igt_display_reset(display);
+}
+
+/* Common test cleanup. */
+static void test_fini(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	int i;
+
+	for_each_pipe(display, i) {
+		igt_pipe_crc_free(data->pipe_crc[i]);
+	}
+
+	igt_display_reset(display);
+	igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, 0);
+}
+
+static void test_subvp(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_fb_t rfb;
+	bool subvp_supp, subvp_en;
+	igt_output_t *output;
+	int i;
+
+	test_init(data);
+	igt_enable_connectors(data->fd);
+
+	for_each_pipe(&data->display, i) {
+		/* Setup the output */
+		output = data->output[i];
+		if (!output || !igt_output_is_connected(output))
+			continue;
+
+		igt_create_pattern_fb(data->fd,
+					test_mode[0].hdisplay,
+					test_mode[0].vdisplay,
+					DRM_FORMAT_XRGB8888,
+					0,
+					&rfb);
+
+		igt_output_set_pipe(output, data->pipe_id[i]);
+		igt_plane_set_fb(data->primary[i], &rfb);
+		igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, 0);
+	}
+
+
+	igt_amd_get_subvp_status(data->fd, &subvp_supp, &subvp_en);
+	igt_fail_on_f(!(subvp_supp && subvp_en), "SUBVP did not get enabled\n");
+
+	igt_remove_fb(data->fd, &rfb);
+	test_fini(data);
+}
+
+igt_main
+{
+	data_t data;
+
+	igt_skip_on_simulation();
+
+	memset(&data, 0, sizeof(data));
+
+	igt_fixture
+	{
+		data.fd = drm_open_driver_master(DRIVER_AMDGPU);
+		igt_display_require(&data.display, data.fd);
+		igt_display_require_output(&data.display);
+		igt_require(data.display.is_atomic);
+
+		kmstest_set_vt_graphics_mode();
+	}
+
+	igt_describe("Tests whether system enables sub-viewport when a specific mode is commited");
+	igt_subtest("dual-4k60") test_subvp(&data);
+
+	igt_fixture
+	{
+		igt_display_fini(&data.display);
+	}
+}
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
index f52fc3645..efd911fab 100644
--- a/tests/amdgpu/meson.build
+++ b/tests/amdgpu/meson.build
@@ -36,6 +36,7 @@ if libdrm_amdgpu.found()
 			  'amd_vrr_range',
 			  'amd_mall',
 			  'amd_odm',
+			  'amd_subvp',
 			]
 	if libdrm_amdgpu.version().version_compare('> 2.4.97')
 		amdgpu_progs +=[ 'amd_syncobj', ]
-- 
2.39.2

  parent reply	other threads:[~2023-11-02 20:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 19:59 [igt-dev] [PATCH i-g-t 1/4] lib/amd: improve MALL capabilities checking logic Aurabindo Pillai
2023-11-02 19:59 ` [igt-dev] [PATCH i-g-t 2/4] lib/amd: Add check for SubVP feature status Aurabindo Pillai
2023-11-02 19:59 ` [igt-dev] [PATCH i-g-t 3/4] lib/amd: Update function documentation Aurabindo Pillai
2023-11-02 20:00 ` Aurabindo Pillai [this message]
2023-11-03  9:21   ` [igt-dev] [PATCH i-g-t 4/4] test/amdgpu: Add test for Sub-viewport Kamil Konieczny
2023-11-03 18:23     ` Aurabindo Pillai
2023-11-02 20:55 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/amd: improve MALL capabilities checking logic Patchwork
2023-11-02 21:32 ` [igt-dev] ✓ CI.xeBAT: " Patchwork
2023-11-03 17:11 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

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=20231102200000.969208-4-aurabindo.pillai@amd.com \
    --to=aurabindo.pillai@amd.com \
    --cc=igt-dev@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