All of lore.kernel.org
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@igalia.com>
To: igt-dev@lists.freedesktop.org
Cc: petri.latvala@intel.com, kernel-dev@igalia.com, markyacoub@google.com
Subject: [igt-dev] [PATCH i-g-t v2 2/2] tests/kms_async_flips: Support more vendors
Date: Fri, 20 May 2022 17:35:31 -0300	[thread overview]
Message-ID: <20220520203531.14394-3-andrealmeid@igalia.com> (raw)
In-Reply-To: <20220520203531.14394-1-andrealmeid@igalia.com>

kms_async_flips uses igt_draw_ and i915 modifiers, which make this test
fails for other vendors that are not Intel. Use more generic functions
and modifiers so other devices can be tested.

Since i915's "Linear memory does not support async flips", we can't use
DRM_FORMAT_MOD_LINEAR and need to keep using I915_FORMAT_MOD_X_TILED.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
---
 tests/kms_async_flips.c | 47 ++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index 5e11cd43..1701883b 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c
@@ -133,19 +133,24 @@ static void make_fb(data_t *data, struct igt_fb *fb,
 {
 	uint32_t width, height;
 	int rec_width;
+	cairo_t *cr;
 
 	width = connector->modes[0].hdisplay;
 	height = connector->modes[0].vdisplay;
 
 	rec_width = width / (ARRAY_SIZE(data->bufs) * 2);
 
-	igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888,
-		      I915_FORMAT_MOD_X_TILED, fb);
-	igt_draw_fill_fb(data->drm_fd, fb, 0x88);
-	igt_draw_rect_fb(data->drm_fd, NULL, 0, fb, IGT_DRAW_MMAP_CPU,
-			 rec_width * 2 + rec_width * index,
-			 height / 4, rec_width,
-			 height / 2, rand());
+	if (is_i915_device(data->drm_fd)) {
+		igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888,
+			      I915_FORMAT_MOD_X_TILED, fb);
+		igt_draw_fill_fb(data->drm_fd, fb, 0x88);
+	} else {
+		igt_create_color_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888,
+				    DRM_FORMAT_MOD_LINEAR, 0.0, 0.0, 0.5, fb);
+	}
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+	igt_paint_color_rand(cr, rec_width * 2 + rec_width * index, height / 4, rec_width, height / 2);
 }
 
 static void require_monotonic_timestamp(int fd)
@@ -347,6 +352,9 @@ static void test_invalid(data_t *data)
 	uint32_t width, height;
 	struct igt_fb fb;
 
+	/* TODO: support more vendors */
+	igt_require(is_i915_device(data->drm_fd));
+
 	width = data->connector->modes[0].hdisplay;
 	height = data->connector->modes[0].vdisplay;
 
@@ -472,26 +480,25 @@ static unsigned int clock_ms(void)
 	return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
 }
 
-static void paint_fb(int fd, struct igt_fb *fb, uint32_t color)
-{
-	igt_draw_rect_fb(fd, NULL, 0, fb,
-			 gem_has_mappable_ggtt(fd) ?
-			 IGT_DRAW_MMAP_GTT : IGT_DRAW_MMAP_WC,
-			 0, 0, 1, fb->height, color);
-}
-
 static void test_crc(data_t *data)
 {
 	unsigned int frame = 0;
 	unsigned int start;
+	cairo_t *cr;
 	int ret;
 
+	/* Devices without CRC can't run this test */
+	igt_require_pipe_crc(data->drm_fd);
+
 	data->flip_count = 0;
 	data->frame_count = 0;
 	data->flip_pending = false;
 
-	igt_draw_fill_fb(data->drm_fd, &data->bufs[frame], 0xff0000ff);
-	igt_draw_fill_fb(data->drm_fd, &data->bufs[!frame], 0xff0000ff);
+	cr = igt_get_cairo_ctx(data->drm_fd, &data->bufs[frame]);
+	igt_paint_color(cr, 0, 0, data->bufs[frame].width, data->bufs[frame].height, 1.0, 0.0, 0.0);
+
+	cr = igt_get_cairo_ctx(data->drm_fd, &data->bufs[!frame]);
+	igt_paint_color(cr, 0, 0, data->bufs[!frame].width, data->bufs[!frame].height, 1.0, 0.0, 0.0);
 
 	ret = drmModeSetCrtc(data->drm_fd, data->crtc_id, data->bufs[frame].fb_id, 0, 0,
 			     &data->connector->connector_id, 1, &data->connector->modes[0]);
@@ -510,7 +517,8 @@ static void test_crc(data_t *data)
 
 	while (clock_ms() - start < 2000) {
 		/* fill the next fb with the expected color */
-		paint_fb(data->drm_fd, &data->bufs[frame], 0xff0000ff);
+		cr = igt_get_cairo_ctx(data->drm_fd, &data->bufs[frame]);
+		igt_paint_color(cr, 0, 0, 1, data->bufs[frame].height, 1.0, 0.0, 0.0);
 
 		data->flip_pending = true;
 		ret = drmModePageFlip(data->drm_fd, data->crtc_id, data->bufs[frame].fb_id,
@@ -521,7 +529,8 @@ static void test_crc(data_t *data)
 
 		/* clobber the previous fb which should no longer be scanned out */
 		frame = !frame;
-		paint_fb(data->drm_fd, &data->bufs[frame], rand());
+		cr = igt_get_cairo_ctx(data->drm_fd, &data->bufs[frame]);
+		igt_paint_color_rand(cr, 0, 0, 1, data->bufs[frame].height);
 	}
 
 	igt_pipe_crc_stop(data->pipe_crc);
-- 
2.36.0

  parent reply	other threads:[~2022-05-20 20:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20 20:35 [igt-dev] [PATCH i-g-t v2 0/2] tests/kms_async_flips: Expand test André Almeida
2022-05-20 20:35 ` [igt-dev] [PATCH i-g-t v2 1/2] lib/igt_fb: Add support for drawing rectangles with random colors André Almeida
2022-05-20 20:35 ` André Almeida [this message]
2022-05-20 21:30 ` [igt-dev] ✗ GitLab.Pipeline: warning for tests/kms_async_flips: Expand test (rev4) Patchwork
2022-05-20 21:52 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2022-05-20 23:24 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2022-05-24 13:14 ` [igt-dev] [PATCH i-g-t v2 0/2] tests/kms_async_flips: Expand test Rodrigo Siqueira Jordao
2022-05-24 13:21   ` André Almeida
2022-05-24 15:48   ` Vudum, Lakshminarayana
2022-05-24 16:01     ` Rodrigo Siqueira Jordao

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=20220520203531.14394-3-andrealmeid@igalia.com \
    --to=andrealmeid@igalia.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kernel-dev@igalia.com \
    --cc=markyacoub@google.com \
    --cc=petri.latvala@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.