[PATCH i-g-t] tests/kms_async_flips: Create subtest for overlay planes

André Almeida andrealmeid at igalia.com
Wed Dec 11 03:18:20 UTC 2024


amdgpu can perform async flips in overlay planes as well, so create a
test for that.

Signed-off-by: André Almeida <andrealmeid at igalia.com>
---
 tests/kms_async_flips.c | 42 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index 6e00be3de..10a416cfb 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c
@@ -109,12 +109,14 @@ typedef struct {
 	uint32_t crtc_id;
 	uint32_t refresh_rate;
 	struct igt_fb bufs[NUM_FBS];
+	struct igt_fb bufs_overlay[NUM_FBS];
 	igt_display_t display;
 	igt_output_t *output;
 	unsigned long flip_timestamp_us;
 	double flip_interval;
 	uint64_t modifier;
 	igt_plane_t *plane;
+	igt_plane_t *overlay_plane;
 	igt_pipe_crc_t *pipe_crc;
 	igt_crc_t ref_crc;
 	int flip_count;
@@ -126,6 +128,7 @@ typedef struct {
 	bool allow_fail;
 	struct buf_ops *bops;
 	bool atomic_path;
+	bool overlay_path;
 } data_t;
 
 static void flip_handler(int fd_, unsigned int sequence, unsigned int tv_sec,
@@ -226,6 +229,8 @@ static void test_init(data_t *data)
 	igt_output_set_pipe(data->output, data->pipe);
 
 	data->plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
+	if (data->overlay_path)
+		data->overlay_plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_OVERLAY);
 }
 
 static void test_init_fbs(data_t *data)
@@ -246,16 +251,27 @@ static void test_init_fbs(data_t *data)
 		prev_modifier = data->modifier;
 
 		if (data->bufs[0].fb_id) {
-			for (i = 0; i < NUM_FBS; i++)
+			for (i = 0; i < NUM_FBS; i++) {
 				igt_remove_fb(data->drm_fd, &data->bufs[i]);
+				if (data->overlay_path)
+					igt_remove_fb(data->drm_fd, &data->bufs_overlay[i]);
+			}
 		}
 
-		for (i = 0; i < NUM_FBS; i++)
+		for (i = 0; i < NUM_FBS; i++) {
 			make_fb(data, &data->bufs[i], width, height, i);
+			if (data->overlay_path)
+				make_fb(data, &data->bufs_overlay[i], width, height, i);
+		}
 	}
 
 	igt_plane_set_fb(data->plane, &data->bufs[0]);
 	igt_plane_set_size(data->plane, width, height);
+
+	if (data->overlay_path) {
+		igt_plane_set_fb(data->overlay_plane, &data->bufs[0]);
+		igt_plane_set_size(data->overlay_plane, width, height);
+	}
 }
 
 static bool async_flip_needs_extra_frame(data_t *data)
@@ -283,12 +299,17 @@ static bool async_flip_needs_extra_frame(data_t *data)
 static int perform_flip(data_t *data, int frame, int flags)
 {
 	int ret;
+	igt_plane_t *plane;
+	struct igt_fb *bufs;
+
+	plane = data->overlay_path ? data->overlay_plane : data->plane;
+	bufs = data->overlay_path ? data->bufs_overlay : data->bufs;
 
 	if (!data->atomic_path) {
 		ret = drmModePageFlip(data->drm_fd, data->crtc_id,
-				      data->bufs[frame % NUM_FBS].fb_id, flags, data);
+				     bufs[frame % NUM_FBS].fb_id, flags, data);
 	} else {
-		igt_plane_set_fb(data->plane, &data->bufs[frame % NUM_FBS]);
+		igt_plane_set_fb(plane, &data->bufs[frame % NUM_FBS]);
 		ret = igt_display_try_commit_atomic(&data->display, flags, data);
 	}
 
@@ -758,6 +779,7 @@ igt_main
 		igt_subtest_with_dynamic("async-flip-with-page-flip-events") {
 			data.alternate_sync_async = false;
 			data.atomic_path = false;
+			data.overlay_path = false;
 			if (is_intel_device(data.drm_fd))
 				run_test_with_modifiers(&data, test_async_flip);
 			else
@@ -769,6 +791,7 @@ igt_main
 		igt_subtest_with_dynamic("async-flip-with-page-flip-events-atomic") {
 			data.alternate_sync_async = false;
 			data.atomic_path = true;
+			data.overlay_path = false;
 			if (is_intel_device(data.drm_fd))
 				run_test_with_modifiers(&data, test_async_flip);
 			else
@@ -779,6 +802,7 @@ igt_main
 		igt_subtest_with_dynamic("alternate-sync-async-flip") {
 			data.alternate_sync_async = true;
 			data.atomic_path = false;
+			data.overlay_path = false;
 			run_test(&data, test_async_flip);
 		}
 
@@ -786,7 +810,17 @@ igt_main
 		igt_subtest_with_dynamic("alternate-sync-async-flip-atomic") {
 			data.alternate_sync_async = true;
 			data.atomic_path = true;
+			data.overlay_path = false;
+			run_test(&data, test_async_flip);
+		}
+
+		igt_describe("Verify overlay planes with async flips in atomic API");
+		igt_subtest_with_dynamic("overlay-atomic") {
+			igt_require(is_amdgpu_device(data.drm_fd));
+			data.atomic_path = true;
+			data.overlay_path = true;
 			run_test(&data, test_async_flip);
+			data.overlay_path = false;
 		}
 
 		igt_describe("Verify that the async flip timestamp does not "
-- 
2.47.1



More information about the igt-dev mailing list