Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t][V2] tests/amdgpu: Add amd_hdr_visual for manual HDR verification
@ 2026-05-05 20:57 Alex Hung
  2026-05-05 22:10 ` ✓ Xe.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Alex Hung @ 2026-05-05 20:57 UTC (permalink / raw)
  To: igt-dev
  Cc: alex.hung, Mark.Broadworth, vitaly.prosyak, swati2.sharma,
	kamil.konieczny, jani.nikula, Wayne Lin

From: Wayne Lin <wayne.lin@amd.com>

Add a visual verification test for AMD HDR display output. This test
displays HDR test patterns with different metadata types and waits for
user confirmation, enabling manual inspection of HDR output quality.

Subtests:
- static-swap-smpte2084: Display with SMPTE ST2084 (PQ) HDR metadata
- static-swap-traditional-sdr: Display with traditional SDR gamma metadata

Co-developed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Wayne Lin <wayne.lin@amd.com>
---
 tests/amdgpu/amd_hdr_visual.c | 176 ++++++++++++++++++++++++++++++++++
 tests/amdgpu/meson.build      |   7 ++
 2 files changed, 183 insertions(+)
 create mode 100644 tests/amdgpu/amd_hdr_visual.c

diff --git a/tests/amdgpu/amd_hdr_visual.c b/tests/amdgpu/amd_hdr_visual.c
new file mode 100644
index 000000000..63eed937c
--- /dev/null
+++ b/tests/amdgpu/amd_hdr_visual.c
@@ -0,0 +1,176 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ */
+
+#include "igt.h"
+#include "igt_hdr.h"
+
+/**
+ * TEST: AMD manual HDR visual tests
+ * Description: Test HDR metadata interfaces by showing visual HDR patterns
+ * Driver requirement: amdgpu
+ * Mega-feature: Display
+ * Sub-category: HDR
+ *
+ * SUBTEST: static-swap-smpte2084
+ * Description: Show a visual HDR pattern with SMPTE ST2084 metadata and
+ * require user confirmation.
+ *
+ * SUBTEST: static-swap-traditional-sdr
+ * Description: Show a visual HDR pattern with traditional SDR gamma metadata
+ * and require user confirmation.
+ */
+IGT_TEST_DESCRIPTION("Test HDR output metadata visual verification");
+
+/* Common test data. */
+typedef struct data {
+	igt_display_t display;
+	igt_plane_t *primary;
+	igt_output_t *output;
+	igt_crtc_t *crtc;
+	drmModeModeInfo *mode;
+	int fd;
+	int w;
+	int h;
+} data_t;
+
+/* Fills the FB with a test HDR pattern. */
+static void draw_hdr_pattern(igt_fb_t *fb)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	igt_paint_color(cr, 0, 0, fb->width, fb->height, 1.0, 1.0, 1.0);
+	igt_paint_test_pattern(cr, fb->width, fb->height);
+
+	igt_put_cairo_ctx(cr);
+}
+
+/* Prepare test data. */
+static void prepare_test(data_t *data, igt_output_t *output, igt_crtc_t *crtc)
+{
+	igt_display_t *display = &data->display;
+
+	data->crtc = crtc;
+	igt_assert(data->crtc);
+
+	igt_display_reset(display);
+
+	data->output = output;
+	igt_assert(data->output);
+
+	data->mode = igt_output_get_mode(data->output);
+	igt_assert(data->mode);
+
+	data->primary =
+		igt_crtc_get_plane_type(data->crtc, DRM_PLANE_TYPE_PRIMARY);
+
+	igt_output_set_crtc(data->output, crtc);
+
+	data->w = data->mode->hdisplay;
+	data->h = data->mode->vdisplay;
+}
+
+/* Returns true if an output supports max bpc property. */
+static bool has_max_bpc(igt_output_t *output)
+{
+	return igt_output_has_prop(output, IGT_CONNECTOR_MAX_BPC) &&
+	       igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC);
+}
+
+static void test_static_swap(data_t *data,
+			     void (*fill_metadata)(struct hdr_output_metadata *),
+			     const char *mode_name)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	igt_crtc_t *crtc;
+	igt_fb_t afb;
+	int afb_id;
+	bool found = false;
+	struct hdr_output_metadata hdr;
+
+	for_each_connected_output(display, output) {
+		if (!has_max_bpc(output) || !igt_output_supports_hdr(output)) {
+			igt_info("%s connector not found with HDR metadata/max_bpc connector property\n", output->name);
+			continue;
+		}
+
+		if (!igt_is_panel_hdr(data->fd, output)) {
+			igt_info("Panel attached via %s connector is non-HDR\n", output->name);
+			continue;
+		}
+
+		for_each_crtc(display, crtc) {
+			if (!igt_crtc_connector_valid(crtc, output))
+				continue;
+
+			prepare_test(data, output, crtc);
+
+			/* 10-bit formats are slow, so limit the size. */
+			afb_id = igt_create_fb(data->fd, 512, 512,
+					       DRM_FORMAT_XRGB2101010, 0, &afb);
+			igt_assert(afb_id);
+
+			draw_hdr_pattern(&afb);
+
+			/* Start in the specified HDR mode. */
+			igt_plane_set_fb(data->primary, &afb);
+			igt_plane_set_size(data->primary, data->w, data->h);
+			fill_metadata(&hdr);
+			igt_hdr_set_metadata(data->output, &hdr);
+			igt_output_set_prop_value(data->output,
+						  IGT_CONNECTOR_MAX_BPC, 10);
+			igt_display_commit_atomic(display,
+						  DRM_MODE_ATOMIC_ALLOW_MODESET,
+						  NULL);
+
+			igt_info("wait %s!\n", mode_name);
+			igt_debug_wait_for_keypress(mode_name);
+
+			/* Exit HDR mode and enter 8bpc, cleanup. */
+			igt_hdr_set_metadata(data->output, NULL);
+			igt_output_set_prop_value(data->output,
+						  IGT_CONNECTOR_MAX_BPC, 8);
+			igt_display_commit_atomic(display,
+						  DRM_MODE_ATOMIC_ALLOW_MODESET,
+						  NULL);
+
+			igt_display_reset(display);
+			igt_remove_fb(data->fd, &afb);
+
+			found = true;
+			break;
+		}
+	}
+
+	igt_require_f(found, "No connector found with HDR metadata/max_bpc connector property (or) panel is non-HDR\n");
+}
+
+int igt_main()
+{
+	data_t data = { 0 };
+
+	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_describe("Tests swapping to SMPTE ST2084 HDR metadata");
+	igt_subtest("static-swap-smpte2084")
+		test_static_swap(&data, igt_hdr_fill_st2084, "smpte2084");
+
+	igt_describe("Tests swapping to traditional SDR gamma HDR metadata");
+	igt_subtest("static-swap-traditional-sdr")
+		test_static_swap(&data, igt_hdr_fill_sdr, "traditional-sdr");
+
+	igt_fixture() {
+		igt_display_fini(&data.display);
+	}
+}
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
index d5a4820e3..7db1e2d9e 100644
--- a/tests/amdgpu/meson.build
+++ b/tests/amdgpu/meson.build
@@ -90,3 +90,10 @@ foreach prog : amdgpu_progs
 				       install : true)
 	test_list += join_paths('amdgpu', prog)
 endforeach
+
+test_executables += executable('amd_hdr_visual', 'amd_hdr_visual.c',
+			       dependencies : test_deps,
+			       install_dir : amdgpudir,
+			       install_rpath : amdgpudir_rpathdir,
+			       install : true)
+test_list += join_paths('amdgpu', 'amd_hdr_visual')
--
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-05-06 19:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 20:57 [PATCH i-g-t][V2] tests/amdgpu: Add amd_hdr_visual for manual HDR verification Alex Hung
2026-05-05 22:10 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-05-05 22:11 ` ✗ i915.CI.BAT: failure " Patchwork
2026-05-06  4:48 ` ✗ Xe.CI.FULL: " Patchwork
2026-05-06 11:43 ` [PATCH i-g-t][V2] " Sharma, Swati2
2026-05-06 15:40   ` Alex Hung
2026-05-06 19:23     ` Sharma, Swati2

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox