[igt-dev] [RFC PATCH] tests/kms_async_flips: add atomic test
Simon Ser
contact at emersion.fr
Wed Aug 24 14:58:44 UTC 2022
This adds a simple test for DRM_MODE_PAGE_FLIP_ASYNC with the
atomic uAPI.
Signed-off-by: Simon Ser <contact at emersion.fr>
Cc: Joshua Ashton <joshua at froggi.es>
Cc: Melissa Wen <mwen at igalia.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: Harry Wentland <hwentlan at amd.com>
Cc: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
---
This is sent as an RFC because the kernel patch is not yet merged.
include/drm-uapi/drm.h | 7 +++++++
tests/kms_async_flips.c | 45 +++++++++++++++++++++++++++++++++++++----
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/include/drm-uapi/drm.h b/include/drm-uapi/drm.h
index 5e54c3aa4c3a..77c258e4cbe7 100644
--- a/include/drm-uapi/drm.h
+++ b/include/drm-uapi/drm.h
@@ -761,6 +761,13 @@ struct drm_gem_open {
* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".
*/
#define DRM_CAP_SYNCOBJ_TIMELINE 0x14
+/**
+ * DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP
+ *
+ * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC for atomic
+ * commits.
+ */
+#define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP 0x15
/* DRM_IOCTL_GET_CAP ioctl argument type */
struct drm_get_cap {
diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index 695aea74d4f3..7173ca65a0b0 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c
@@ -51,6 +51,7 @@ typedef struct {
struct igt_fb bufs[4];
igt_display_t display;
igt_output_t *output;
+ igt_plane_t *plane;
unsigned long flip_timestamp_us;
double flip_interval;
igt_pipe_crc_t *pipe_crc;
@@ -146,7 +147,6 @@ static void test_init(data_t *data)
{
int i;
uint32_t width, height;
- igt_plane_t *plane;
static uint32_t prev_output_id;
drmModeModeInfo *mode;
@@ -161,7 +161,7 @@ static void test_init(data_t *data)
data->refresh_rate = mode->vrefresh;
igt_output_set_pipe(data->output, data->pipe);
- plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
+ data->plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
if (prev_output_id != data->output->id) {
prev_output_id = data->output->id;
@@ -175,8 +175,8 @@ static void test_init(data_t *data)
make_fb(data, &data->bufs[i], width, height, i);
}
- igt_plane_set_fb(plane, &data->bufs[0]);
- igt_plane_set_size(plane, width, height);
+ igt_plane_set_fb(data->plane, &data->bufs[0]);
+ igt_plane_set_size(data->plane, width, height);
igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
}
@@ -258,6 +258,35 @@ 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);
+
+ 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;
@@ -643,6 +672,14 @@ igt_main_args("e", NULL, help_str, opt_handler, &data)
run_test(&data, test_crc);
}
+ 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 < ARRAY_SIZE(data.bufs); i++)
igt_remove_fb(data.drm_fd, &data.bufs[i]);
--
2.37.2
More information about the igt-dev
mailing list