[igt-dev] [PATCH i-g-t] tests/atomic_vs_legacy_commit: check atomic vs legacy commit effect

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Tue Aug 17 17:36:59 UTC 2021


see both ways to reset display will reset plane alpha.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 tests/atomic_vs_legacy_commit.c | 112 ++++++++++++++++++++++++++++++++
 tests/meson.build               |   1 +
 2 files changed, 113 insertions(+)
 create mode 100644 tests/atomic_vs_legacy_commit.c

diff --git a/tests/atomic_vs_legacy_commit.c b/tests/atomic_vs_legacy_commit.c
new file mode 100644
index 000000000..bca78c928
--- /dev/null
+++ b/tests/atomic_vs_legacy_commit.c
@@ -0,0 +1,112 @@
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION( "Simple atomic vs legacy commit verification");
+
+struct {
+	int drm_fd;
+	igt_display_t display;
+	struct igt_fb fb;
+	igt_output_t *output;
+	igt_pipe_crc_t *pipe_crc;
+	igt_plane_t *primary;
+
+	igt_crc_t atomic_0xbeef_crc;
+	igt_crc_t legacy_clean_crc;
+	igt_crc_t atomic_clean_crc;
+} data;
+
+igt_main
+{
+	drmModeModeInfo *mode;
+	char *crcstr;
+	igt_crc_t mid_crc;
+
+	igt_fixture {
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+
+		kmstest_set_vt_graphics_mode();
+		igt_require_pipe_crc(data.drm_fd);
+		igt_display_require(&data.display, data.drm_fd);
+		igt_require(data.display.is_atomic);
+		igt_display_commit2(&data.display, COMMIT_ATOMIC);
+	}
+
+	igt_describe("Simple atomic vs legacy commit verification");
+	igt_subtest_f("legacy-vs-atomic-commit-reset-alpha") {
+		data.output = igt_get_single_output_for_pipe(&data.display, PIPE_A);
+		igt_require(data.output);
+		igt_output_set_pipe(data.output, PIPE_A);
+		igt_display_commit2(&data.display, COMMIT_ATOMIC);
+
+		mode = igt_output_get_mode(data.output);
+
+		igt_create_color_fb(data.drm_fd, mode->hdisplay, mode->vdisplay,
+			DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
+			1.0, 1.0, 1.0, &data.fb);
+
+		data.pipe_crc = igt_pipe_crc_new(data.drm_fd, PIPE_A, INTEL_PIPE_CRC_SOURCE_AUTO);
+		data.primary = igt_output_get_plane_type(data.output, DRM_PLANE_TYPE_PRIMARY);
+
+		// get 'non reset crc'
+		igt_plane_set_fb(data.primary, &data.fb);
+		igt_plane_set_prop_value(data.primary, IGT_PLANE_ALPHA, 0xbeef);
+		igt_display_commit2(&data.display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_start(data.pipe_crc);
+		igt_pipe_crc_get_current(data.drm_fd, data.pipe_crc, &data.atomic_0xbeef_crc);
+		igt_pipe_crc_stop(data.pipe_crc);
+		crcstr = igt_crc_to_string(&data.atomic_0xbeef_crc);
+		igt_info("non-reset 0xbeef crc %s\n", crcstr);
+		free(crcstr);
+
+		// get legacy reset crc
+		igt_display_reset(&data.display);
+		igt_output_set_pipe(data.output, PIPE_A);
+		igt_display_commit2(&data.display, COMMIT_LEGACY);
+		igt_plane_set_fb(data.primary, &data.fb);
+		igt_display_commit2(&data.display, COMMIT_LEGACY);
+
+		igt_pipe_crc_start(data.pipe_crc);
+		igt_pipe_crc_get_current(data.drm_fd, data.pipe_crc, &data.legacy_clean_crc);
+		igt_pipe_crc_stop(data.pipe_crc);
+		crcstr = igt_crc_to_string(&data.legacy_clean_crc);
+		igt_info("legacy commit reset crc %s\n", crcstr);
+		free(crcstr);
+
+
+		// get atomic reset crc, first set 0xbeef in place and check we got it.
+		igt_plane_set_prop_value(data.primary, IGT_PLANE_ALPHA, 0xbeef);
+		igt_display_commit2(&data.display, COMMIT_ATOMIC);
+		igt_pipe_crc_start(data.pipe_crc);
+		igt_pipe_crc_get_current(data.drm_fd, data.pipe_crc, &mid_crc);
+		igt_pipe_crc_stop(data.pipe_crc);
+
+		igt_assert_f(igt_check_crc_equal(&mid_crc, &data.atomic_0xbeef_crc), "test error! something weird!\n");
+		crcstr = igt_crc_to_string(&mid_crc);
+		igt_info("mid crc should match 0xbeef crc %s\n", crcstr);
+		free(crcstr);
+
+		igt_display_reset(&data.display);
+		igt_output_set_pipe(data.output, PIPE_A);
+		igt_plane_set_fb(data.primary, &data.fb);
+		igt_display_commit2(&data.display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_start(data.pipe_crc);
+		igt_pipe_crc_get_current(data.drm_fd, data.pipe_crc, &data.atomic_clean_crc);
+		igt_pipe_crc_stop(data.pipe_crc);
+		crcstr = igt_crc_to_string(&data.atomic_clean_crc);
+		igt_info("atomic commit reset crc %s\n", crcstr);
+		free(crcstr);
+
+		// aftermath 
+		igt_pipe_crc_free(data.pipe_crc);
+		igt_assert_crc_equal(&data.legacy_clean_crc, &data.atomic_clean_crc);		
+	}
+
+	igt_fixture {
+		igt_display_reset(&data.display);
+		igt_display_commit2(&data.display, COMMIT_ATOMIC);
+		kmstest_restore_vt_mode();
+		igt_display_fini(&data.display);
+	}
+}
diff --git a/tests/meson.build b/tests/meson.build
index 1bdfddbb2..b03d392a1 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,4 +1,5 @@
 test_progs = [
+	'atomic_vs_legacy_commit',
 	'core_auth',
 	'core_getclient',
 	'core_getstats',
-- 
2.28.0



More information about the igt-dev mailing list