Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@igalia.com>
To: igt-dev@lists.freedesktop.org, "Simon Ser" <contact@emersion.fr>,
	kernel-dev@igalia.com,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: "André Almeida" <andrealmeid@igalia.com>
Subject: [PATCH 1/1] tests/kms_async_flips: add atomic test
Date: Sun,  1 Dec 2024 15:38:41 -0300	[thread overview]
Message-ID: <20241201183841.71046-2-andrealmeid@igalia.com> (raw)
In-Reply-To: <20241201183841.71046-1-andrealmeid@igalia.com>

From: Simon Ser <contact@emersion.fr>

This adds a simple test for DRM_MODE_PAGE_FLIP_ASYNC with the
atomic uAPI.

Signed-off-by: Simon Ser <contact@emersion.fr>
[Rebased and added modeset commit]
Signed-off-by: André Almeida <andrealmeid@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


  reply	other threads:[~2024-12-02  8:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-01 18:38 [PATCH 0/1] tests/kms_async_flips: add atomic test André Almeida
2024-12-01 18:38 ` André Almeida [this message]
2024-12-02 18:55 ` ✗ GitLab.Pipeline: warning for tests/kms_async_flips: add atomic test (rev3) Patchwork
2024-12-05 15:28 ` [PATCH 0/1] tests/kms_async_flips: add atomic test André Almeida

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=20241201183841.71046-2-andrealmeid@igalia.com \
    --to=andrealmeid@igalia.com \
    --cc=contact@emersion.fr \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kernel-dev@igalia.com \
    --cc=ville.syrjala@linux.intel.com \
    /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