Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Albert Esteve <aesteve@redhat.com>
To: igt-dev@lists.freedesktop.org
Cc: belmouss@redhat.com, Albert Esteve <aesteve@redhat.com>,
	javierm@redhat.com
Subject: [igt-dev] [PATCH 3/3] kms_cursor_legacy: modeset-atomic-cursor-hotspot
Date: Fri, 21 Jul 2023 15:04:58 +0200	[thread overview]
Message-ID: <20230721130458.64856-4-aesteve@redhat.com> (raw)
In-Reply-To: <20230721130458.64856-1-aesteve@redhat.com>

Add a test for modesetting an atomic cursor plane
hotspot property. The test first checks if the
plane is atomic and has the hotspot property.
and if it does, it sets different random hot_x
and hot_y values and checks that it is updated
correctly after an atomic commit.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
---
 tests/kms_cursor_legacy.c | 75 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index 1ebac9d31..38258ed8d 100644
--- a/tests/kms_cursor_legacy.c
+++ b/tests/kms_cursor_legacy.c
@@ -1607,6 +1607,70 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic)
 	put_ahnd(ahnd);
 }
 
+static void modeset_atomic_cursot_hotspot(igt_display_t *display)
+{
+	struct igt_fb cursor_fb;
+	igt_output_t *output;
+	enum pipe pipe;
+	igt_plane_t *cursor = NULL;
+	bool has_hotspot_prop;
+	uint64_t width, height;
+	uint32_t hot_x, hot_y, prev_hot_x, prev_hot_y;
+
+	igt_require(display->is_atomic);
+	pipe = find_connected_pipe(display, false, &output);
+	igt_require(output);
+
+	igt_info("Using pipe %s & %s\n",
+		 kmstest_pipe_name(pipe), igt_output_name(output));
+
+	width = height = 64;
+	igt_create_color_fb(display->drm_fd, width, height, DRM_FORMAT_ARGB8888,
+			    DRM_FORMAT_MOD_LINEAR, 1., 1., 1., &cursor_fb);
+
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	cursor = set_cursor_on_pipe(display, pipe, &cursor_fb);
+
+	has_hotspot_prop = cursor->props[IGT_PLANE_HOTSPOT_X] ||
+		cursor->props[IGT_PLANE_HOTSPOT_Y];
+	igt_require_f(has_hotspot_prop, "Cursor plane lacks the hotspot property");
+
+	/*
+	 * Change the hotspot coordinates randomly and check that the property
+	 * is updated accordingly.
+	 */
+	srand(time(NULL));
+	for (int i = 0; i < 20; i++) {
+		hot_x = rand() % width;
+		hot_y = rand() % height;
+		prev_hot_x = igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_X);
+		prev_hot_y = igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_Y);
+		igt_debug("Update cursor hotspot: (%d, %d)\n", hot_x, hot_y);
+		
+		/* Set cursor hotspot property values */
+		igt_output_set_prop_value(cursor, IGT_PLANE_HOTSPOT_X, hot_x);
+		igt_output_set_prop_value(cursor, IGT_PLANE_HOTSPOT_Y, hot_y);
+
+		/* Properties are not updated until the commit */
+		igt_assert_eq(igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_X), prev_hot_x);
+		igt_assert_eq(igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_Y), prev_hot_y);
+
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		/* After the commit, the cursor hotspot property values are updated */
+		igt_assert_eq(igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_X), hot_x);
+		igt_assert_eq(igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_Y), hot_y);
+	}
+
+	/* Clean-up */
+	igt_plane_set_fb(cursor, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_remove_fb(display->drm_fd, &cursor_fb);
+}
+
 igt_main
 {
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
@@ -1681,6 +1745,17 @@ igt_main
 			nonblocking_modeset_vs_cursor(&display, 16);
 	}
 
+	igt_describe("Test changes the cursor hotspot and checks that the "
+		      "property is updated accordignly");
+	igt_subtest_group {
+		igt_fixture {
+			igt_display_require_output(&display);
+		}
+
+		igt_subtest("modeset-atomic-cursor-hotspot")
+			modeset_atomic_cursot_hotspot(&display);
+	}
+
 	igt_describe("This test executes flips on both CRTCs "
 		     "while running cursor updates in parallel");
 	igt_subtest_group {
-- 
2.40.0

  parent reply	other threads:[~2023-07-21 13:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 13:04 [igt-dev] [PATCH 0/3] Add atomic DRM cursor hotspot test Albert Esteve
2023-07-21 13:04 ` [igt-dev] [PATCH 1/3] drm header update: temp commit Albert Esteve
2023-07-28  7:41   ` Zbigniew Kempczyński
2023-07-28  7:57     ` Albert Esteve
2023-07-28  8:31       ` Zbigniew Kempczyński
2023-07-21 13:04 ` [igt-dev] [PATCH 2/3] igt_kms: add hotspot plane property Albert Esteve
2023-07-25 13:40   ` Javier Martinez Canillas
2023-07-26 14:42     ` Albert Esteve
2023-07-21 13:04 ` Albert Esteve [this message]
2023-07-25 14:26   ` [igt-dev] [PATCH 3/3] kms_cursor_legacy: modeset-atomic-cursor-hotspot Javier Martinez Canillas
2023-07-26 14:50     ` Albert Esteve
2023-07-26 14:53       ` Javier Martinez Canillas
2023-07-24 12:22 ` [igt-dev] ✓ Fi.CI.BAT: success for Add atomic DRM cursor hotspot test Patchwork
2023-07-24 17:02 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-07-25 15:51 ` [igt-dev] [PATCH 0/3] " Kamil Konieczny
2023-07-26 14:52   ` Albert Esteve

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=20230721130458.64856-4-aesteve@redhat.com \
    --to=aesteve@redhat.com \
    --cc=belmouss@redhat.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=javierm@redhat.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