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>
Cc: hersenxs.wu@amd.com
Subject: [igt-dev] [PATCH v4 2/2] tests/amdgpu: Add test for ODM combine
Date: Mon, 21 Aug 2023 10:07:12 -0400	[thread overview]
Message-ID: <20230821140712.1034591-2-aurabindo.pillai@amd.com> (raw)
In-Reply-To: <20230821140712.1034591-1-aurabindo.pillai@amd.com>

Add a test that checks whether ODM Combine mode is triggered when high
refresh rate timing is committed on hardware it supports. This test
requires a DSC capable monitor.

Changes in V2: Added check to skip test on hardware that does not have
ODM combine segments debugfs endpoint exposed

Changes in V3: Removed data->w,h since its not used; Removed license
text and use SPDX identifier instead.

Changes in V4: Checkpatch.pl style fixes

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

diff --git a/tests/amdgpu/amd_odm.c b/tests/amdgpu/amd_odm.c
new file mode 100644
index 000000000..2781ad1c2
--- /dev/null
+++ b/tests/amdgpu/amd_odm.c
@@ -0,0 +1,189 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyrights 2023 Advanced Micro Devices, Inc.
+ */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <xf86drmMode.h>
+
+#include "igt.h"
+#include "igt_amd.h"
+#include "igt_edid.h"
+
+IGT_TEST_DESCRIPTION("Test whether ODM Combine mode is triggered when timings with high refresh "
+		     "rate is committed");
+
+enum odmc_mode {
+	ODMC_2_TO_1,
+	ODMC_4_TO_1,
+};
+
+/* Common test data. */
+struct data {
+	igt_display_t display;
+	igt_plane_t *primary;
+	igt_output_t *output;
+	igt_pipe_t *pipe;
+	drmModeModeInfoPtr mode;
+	enum pipe pipe_id;
+	int fd;
+};
+
+static const drmModeModeInfo test_mode[] = {
+	{ 1278720,
+	3840, 3952, 3984, 4000, 0,
+	2160, 2210, 2215, 2220, 0,
+	30,
+	DRM_MODE_FLAG_NHSYNC,
+	0x40,
+	"4k144\0",
+	}, /* from HP Omen 27c */
+
+};
+
+#define TEST_MODE_IDX_ODMC_2_TO_1 0
+
+static void test_init(struct data *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);
+
+	/* find a connected non-HDMI output */
+	data->output = NULL;
+	for (int i = 0; i < data->display.n_outputs; ++i) {
+		drmModeConnector *connector = data->display.outputs[i].config.connector;
+
+		if (connector->connection == DRM_MODE_CONNECTED)
+			data->output = &data->display.outputs[i];
+	}
+	igt_require_f(data->output, "Requires a connected output\n");
+
+	data->mode = igt_output_get_mode(data->output);
+	igt_assert(data->mode);
+
+	igt_skip_on_f(!igt_amd_output_has_odm_combine_segments(data->fd, data->output->name),
+		      "ASIC does not support reading ODM combine segments\n");
+
+	igt_skip_on_f(!is_dp_dsc_supported(data->fd, data->output->name),
+		      "The monitor must be DSC capable\n");
+
+	igt_skip_on_f(data->output->config.connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+		      data->output->config.connector->connector_type == DRM_MODE_CONNECTOR_HDMIB,
+		      "ODM Combine isn't supported on HDMI 1.x\n");
+
+	data->primary = igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY);
+	igt_output_set_pipe(data->output, data->pipe_id);
+
+	igt_display_reset(display);
+}
+
+static void test_fini(struct data *data)
+{
+	igt_display_reset(&data->display);
+	igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, 0);
+}
+
+/* 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);
+}
+
+static void run_test_odmc(struct data *data, enum odmc_mode m, const drmModeModeInfo *mode)
+{
+	igt_display_t *display = &data->display;
+	struct igt_fb buffer;
+	char buf[256];
+	int ret, seg, fd;
+	int i = 0;
+
+	test_init(data);
+
+	force_output_mode(data, data->output, mode);
+
+	igt_create_color_fb(display->drm_fd, mode->hdisplay,
+			    mode->vdisplay, DRM_FORMAT_XRGB8888,
+			    DRM_FORMAT_MOD_LINEAR, 1.f, 0.f, 0.f,
+			    &buffer);
+
+	igt_output_set_pipe(data->output, i);
+
+	igt_plane_set_fb(data->primary, &buffer);
+
+	ret = igt_display_try_commit_atomic(display,
+					    DRM_MODE_ATOMIC_ALLOW_MODESET |
+					    DRM_MODE_ATOMIC_TEST_ONLY,
+					    NULL);
+	igt_skip_on_f(ret != 0, "Unsupported mode\n");
+
+	igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+
+	fd = igt_debugfs_connector_dir(data->fd, data->output->name, O_RDONLY);
+	igt_assert(fd >= 0);
+
+	ret = igt_debugfs_simple_read(fd, "odm_combine_segments", buf, sizeof(buf));
+	close(fd);
+	igt_require(ret > 0);
+
+	seg = strtol(buf, NULL, 0);
+
+	switch (m) {
+	case ODMC_2_TO_1:
+		igt_assert_f(seg == 2,
+			     "ODM Combine uses %d segments for connector %s, expected 2\n",
+			     seg, data->output->name);
+		break;
+	case ODMC_4_TO_1:
+		igt_assert_f(seg == 4,
+			     "ODM Combine uses %d segments for connector %s, expected 4\n",
+			     seg, data->output->name);
+		break;
+	}
+
+	igt_remove_fb(display->drm_fd, &buffer);
+
+	test_fini(data);
+}
+
+igt_main
+{
+	struct data data;
+
+	memset(&data, 0, sizeof(data));
+
+	igt_fixture
+	{
+		data.fd = drm_open_driver_master(DRIVER_ANY);
+
+		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_f("odm-combine-2-to-1-%s", test_mode[TEST_MODE_IDX_ODMC_2_TO_1].name)
+		run_test_odmc(&data, ODMC_2_TO_1, &test_mode[TEST_MODE_IDX_ODMC_2_TO_1]);
+
+	igt_fixture
+	{
+		igt_display_fini(&data.display);
+	}
+}
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
index 6c6166167..6032a38e8 100644
--- a/tests/amdgpu/meson.build
+++ b/tests/amdgpu/meson.build
@@ -35,6 +35,7 @@ if libdrm_amdgpu.found()
 			  'amd_vm',
 			  'amd_vrr_range',
 			  'amd_mall',
+			  'amd_odm',
 			]
 	amdgpu_deps += libdrm_amdgpu
 endif
-- 
2.41.0

  reply	other threads:[~2023-08-21 14:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21 14:07 [igt-dev] [PATCH v4 1/2] lib/amdgpu: Add check for ODM combine segments debugfs endpoint Aurabindo Pillai
2023-08-21 14:07 ` Aurabindo Pillai [this message]
2023-08-21 15:39   ` [igt-dev] [PATCH v4 2/2] tests/amdgpu: Add test for ODM combine Alex Hung
2023-08-21 20:18     ` Aurabindo Pillai
2023-08-22 19:45       ` Kamil Konieczny
2023-08-22 20:18         ` Aurabindo Pillai
2023-08-23  8:02           ` Kamil Konieczny
2023-08-23 13:38             ` Aurabindo Pillai
2023-08-21 15:38 ` [igt-dev] [PATCH v4 1/2] lib/amdgpu: Add check for ODM combine segments debugfs endpoint Alex Hung
2023-08-21 17:58 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [v4,1/2] " Patchwork
2023-08-21 18:23 ` [igt-dev] ○ CI.xeBAT: info " Patchwork
2023-08-21 18:40 ` [igt-dev] ✗ Fi.CI.BAT: failure " Patchwork
2023-08-22 18:17 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [v4,1/2] lib/amdgpu: Add check for ODM combine segments debugfs endpoint (rev4) Patchwork
2023-08-22 18:46 ` [igt-dev] ○ CI.xeBAT: info " Patchwork
2023-08-22 18:55 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-08-22 23:29 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-08-23  8:05   ` Kamil Konieczny
2023-08-23 10:26     ` Yedireswarapu, SaiX Nandan
2023-08-23 10:07 ` [igt-dev] ✓ Fi.CI.IGT: success " 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=20230821140712.1034591-2-aurabindo.pillai@amd.com \
    --to=aurabindo.pillai@amd.com \
    --cc=hersenxs.wu@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