[PATCH 1/1] tests/kms_async_flips: add atomic test
André Almeida
andrealmeid at igalia.com
Sun Dec 1 18:38:41 UTC 2024
From: Simon Ser <contact at emersion.fr>
This adds a simple test for DRM_MODE_PAGE_FLIP_ASYNC with the
atomic uAPI.
Signed-off-by: Simon Ser <contact at emersion.fr>
[Rebased and added modeset commit]
Signed-off-by: André Almeida <andrealmeid at igalia.com>
---
tests/kms_async_flips.c | 44 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index 5dec71291..ce02db8e7 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c
@@ -331,6 +331,42 @@ static void test_async_flip(data_t *data)
}
}
+static void test_async_flip_atomic(data_t *data)
+{
+ int frame;
+ long long int fps;
+ struct timeval start, end, diff;
+
+ test_init(data);
+
+ /*
+ * Async flips doesn't allow mode sets, so do a initial sync flip
+ * setting this mode
+ */
+ igt_plane_set_fb(data->plane, &data->bufs[0]);
+ igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, data);
+
+ gettimeofday(&start, NULL);
+ frame = 1;
+ do {
+ uint32_t flags = DRM_MODE_PAGE_FLIP_ASYNC | DRM_MODE_PAGE_FLIP_EVENT;
+
+ igt_plane_set_fb(data->plane, &data->bufs[frame % 4]);
+ igt_display_commit_atomic(&data->display, flags, data);
+
+ wait_flip_event(data);
+
+ gettimeofday(&end, NULL);
+ timersub(&end, &start, &diff);
+
+ frame++;
+ } while (diff.tv_sec < RUN_TIME);
+
+ fps = frame * 1000 / RUN_TIME;
+ igt_assert_f((fps / 1000) > (data->refresh_rate * MIN_FLIPS_PER_FRAME),
+ "FPS should be significantly higher than the refresh rate\n");
+}
+
static void wait_for_vblank(data_t *data, unsigned long *vbl_time, unsigned int *seq)
{
drmVBlank wait_vbl;
@@ -765,6 +801,14 @@ igt_main
run_test(&data, test_async_flip);
}
+ igt_describe("Verify the async flip functionality and the fps during atomic async flips");
+ igt_subtest_with_dynamic("atomic-async-flip") {
+ require_monotonic_timestamp(data.drm_fd);
+ igt_require_f(igt_has_drm_cap(data.drm_fd, DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP),
+ "Atomic async page-flips are not supported\n");
+ run_test(&data, test_async_flip_atomic);
+ }
+
igt_fixture {
for (i = 0; i < NUM_FBS; i++)
igt_remove_fb(data.drm_fd, &data.bufs[i]);
--
2.47.0
More information about the igt-dev
mailing list