All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Zhang <dingchen.zhang@amd.com>
To: <igt-dev@lists.freedesktop.org>
Subject: [igt-dev] [PATCH v4 3/4] tests/amdgpu/amd_psr: add PSR-SU cursor movement test case
Date: Mon, 25 Apr 2022 14:45:55 -0400	[thread overview]
Message-ID: <20220425184556.771707-4-dingchen.zhang@amd.com> (raw)
In-Reply-To: <20220425184556.771707-1-dingchen.zhang@amd.com>

[why]
We'd have a test case to validate PSR-SU enablement and selective
region update when cursor movement occurs by visual confirm. This
is to emulate the scenario of usermode behavior that only the
cursor is moving on top of the static screen.

[how]
create overlay plane w/ screen size and primary plane w/ quarter
of screen size and positioned at the top-left of screen. create
a cursor plane w/ size of (currently set to) 128 pixels.

move the cursor plane along horizonal/vertical/diagonal three
directions w/ the incremental step of 16 pixels for a couple of
seconds to allow visual confirm of PSR-SU update.

changes in v2:
-------------------
- use multi-level comment to replace the '//' as per the Linux
  coding rule

Cc: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Jay Pillai <aurabindo.pillai@amd.com>
Cc: Wayne Lin <wayne.lin@amd.com>

Signed-off-by: David Zhang <dingchen.zhang@amd.com>
Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
---
 tests/amdgpu/amd_psr.c | 116 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 111 insertions(+), 5 deletions(-)

diff --git a/tests/amdgpu/amd_psr.c b/tests/amdgpu/amd_psr.c
index 8f47e816..dbcb80b7 100644
--- a/tests/amdgpu/amd_psr.c
+++ b/tests/amdgpu/amd_psr.c
@@ -63,6 +63,13 @@ typedef struct data {
 	int h;
 } data_t;
 
+enum cursor_move {
+	HORIZONTAL,
+	VERTICAL,
+	DIAGONAL,
+	INVALID
+};
+
 struct {
 	bool visual_confirm;
 } opt = {
@@ -290,9 +297,9 @@ static void run_check_psr(data_t *data, bool test_null_crtc) {
 static void run_check_psr_su_mpo(data_t *data)
 {
 	int edp_idx = check_conn_type(data, DRM_MODE_CONNECTOR_eDP);
-	igt_fb_t ov_fb;		// fb for overlay
-	igt_fb_t rect_fb[N_MPO_TEST_RECT_FB]; 	// rectangle fbs for primary, emulate as video playback region
-	igt_fb_t ref_fb;	// reference fb
+	igt_fb_t ov_fb;		/* fb for overlay */
+	igt_fb_t rect_fb[N_MPO_TEST_RECT_FB]; 	/* rectangle fbs for primary, emulate as video playback region */
+	igt_fb_t ref_fb;	/* reference fb */
 	igt_fb_t *flip_fb;
 	int ret;
 	const int run_sec = 5;
@@ -410,8 +417,8 @@ static void panning_rect_fb(data_t *data, igt_fb_t *rect_fb, int rect_w, int rec
 static void run_check_psr_su_ffu(data_t *data)
 {
 	int edp_idx = check_conn_type(data, DRM_MODE_CONNECTOR_eDP);
-	igt_fb_t rect_fb; 	// rectangle fbs for primary
-	igt_fb_t ref_fb;	// reference fb
+	igt_fb_t rect_fb; 	/* rectangle fbs for primary */
+	igt_fb_t ref_fb;	/* reference fb */
 	int pb_w, pb_h;
 
 	/* skip the test run if no eDP sink detected */
@@ -487,6 +494,101 @@ static void run_check_psr_su_ffu(data_t *data)
 	test_fini(data);
 }
 
+static void test_cursor_movement(data_t *data, int iters, igt_fb_t * pfb, int cs_size, enum cursor_move move_type)
+{
+	int i, pos_x, pos_y;
+	int ret;
+
+	/* incremental step == cursor size / 16 */
+	for (i = 0, pos_y = 0, pos_x = 0; i < iters; ++i) {
+		if (move_type == HORIZONTAL && (pos_x + cs_size > data->w))
+			pos_x = 0;
+		else if (move_type == VERTICAL && (pos_y + cs_size > data->h))
+			pos_y = 0;
+		else if (move_type == DIAGONAL && ((pos_y + cs_size > data->h) || (pos_x + cs_size > data->w)))
+			pos_x = pos_y = 0;
+
+		igt_plane_set_position(data->cursor, pos_x, pos_y);
+		igt_plane_set_fb(data->primary, pfb);
+
+		ret = igt_display_try_commit_atomic(&data->display, DRM_MODE_PAGE_FLIP_EVENT, NULL);
+		igt_require(ret == 0);
+		kmstest_wait_for_pageflip(data->fd);
+
+		/* update position */
+		if (move_type == HORIZONTAL)
+			pos_x += cs_size / 16;
+		else if (move_type == VERTICAL)
+			pos_y += cs_size / 16;
+		else if (move_type == DIAGONAL) {
+			pos_x += cs_size / 16;
+			pos_y += cs_size / 16;
+		}
+	}
+}
+
+static void run_check_psr_su_cursor(data_t *data)
+{
+	int edp_idx = check_conn_type(data, DRM_MODE_CONNECTOR_eDP);
+	igt_fb_t rect_fb;	/* primary FB */
+	igt_fb_t cs_fb;		/* cursor FB */
+	const int cs_size = 128;
+	const int delay_sec = 5; /* seconds */
+	int frame_rate = 0;
+	int pb_w, pb_h, ob_w, ob_h;
+
+	igt_skip_on_f(edp_idx == -1, "no eDP connector found\n");
+
+	test_init(data);
+	igt_skip_on(!psr_su_supported(data));
+
+	ob_w = data->w;
+	ob_h = data->h;
+	pb_w = data->w / 2;
+	pb_h = data->h / 2;
+	frame_rate = data->mode->vrefresh;
+
+	/* primary & overlay FB creation and set alpha region of overlay to show */
+	igt_create_color_fb(data->fd, pb_w, pb_h, DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR,
+			    .0, .0, 1.0, &rect_fb);
+	igt_create_color_fb(data->fd, ob_w, ob_h, DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_LINEAR,
+			    1.0, 1.0, 1.0, &data->ov_fb[0]);
+	draw_color_alpha(&data->ov_fb[0], 0, 0, pb_w, pb_h, 1.0, 1.0, 1.0, .0);
+
+	/* cursor FB creation, draw cursor pattern/set alpha regions */
+	igt_create_fb(data->fd, cs_size, cs_size, DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_LINEAR, &cs_fb);
+	draw_color_cursor(&cs_fb, cs_size, 1.0, .0, 1.0);
+
+	igt_plane_set_fb(data->primary, &rect_fb);
+	igt_plane_set_fb(data->overlay, &data->ov_fb[0]);
+	igt_plane_set_fb(data->cursor, &cs_fb);
+	igt_plane_set_position(data->cursor, 0, 0);
+
+	igt_output_set_pipe(data->output, data->pipe_id);
+	igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+
+	/*
+	 * test by setting different cursor position in screen
+	 * - horizontal movement
+	 * - vertial movement
+	 * - diagonal movement
+	 */
+
+	/* horizontal */
+	test_cursor_movement(data, frame_rate * delay_sec, &rect_fb, cs_size, HORIZONTAL);
+
+	/* vertical */
+	test_cursor_movement(data, frame_rate * delay_sec, &rect_fb, cs_size, VERTICAL);
+
+	/* diagonal */
+	test_cursor_movement(data, frame_rate * delay_sec, &rect_fb, cs_size, DIAGONAL);
+
+	igt_remove_fb(data->fd, &rect_fb);
+	igt_remove_fb(data->fd, &cs_fb);
+	igt_remove_fb(data->fd, &data->ov_fb[0]);
+	test_fini(data);
+}
+
 const char *help_str =
 "  --visual-confirm           PSR visual confirm debug option enable\n";
 
@@ -550,6 +652,10 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 		     "and to validate Full Frame Update scenario");
 	igt_subtest("psr_su_ffu") run_check_psr_su_ffu(&data);
 
+	igt_describe("Test to validate PSR SU enablement with Visual Confirm "
+		     "and to validate cursor movement + static background scenario");
+	igt_subtest("psr_su_cursor") run_check_psr_su_cursor(&data);
+
 	igt_fixture
 	{
 		if (opt.visual_confirm) {
-- 
2.25.1

  parent reply	other threads:[~2022-04-25 18:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25 18:45 [igt-dev] [PATCH v4 0/4] amdgpu PSR-SU cursor move test cases David Zhang
2022-04-25 18:45 ` [igt-dev] [PATCH v4 1/4] tests/amdgpu/amd_psr: add helper to draw cursor pattern David Zhang
2022-04-25 18:45 ` [igt-dev] [PATCH v4 2/4] tests/amdgpu/amd_psr: set visual-confirm default to disabled David Zhang
2022-04-25 18:45 ` David Zhang [this message]
2022-04-25 18:45 ` [igt-dev] [PATCH v4 4/4] tests/amdgpu/amd_psr: add PSR-SU test case for cursor move + MPO scenario David Zhang
2022-04-25 19:54 ` [igt-dev] ✗ GitLab.Pipeline: warning for amdgpu PSR-SU cursor move test cases (rev4) Patchwork
2022-04-25 20:17 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2022-04-25 21:43 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-04-26 15:30 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork

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=20220425184556.771707-4-dingchen.zhang@amd.com \
    --to=dingchen.zhang@amd.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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.