<div dir="ltr"><div dir="ltr"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 31, 2023 at 9:30 AM Modem, Bhanuprakash <<a href="mailto:bhanuprakash.modem@intel.com">bhanuprakash.modem@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
On Fri-28-07-2023 08:07 pm, Albert Esteve wrote:<br>
> Add a test for modesetting an atomic cursor plane<br>
> hotspot property. Test added to verify the kernel<br>
> patch at [1]. The test first checks if the<br>
> plane is atomic and has the hotspot property.<br>
> and if it does, it sets different random hot_x<br>
> and hot_y values and checks that it is updated<br>
> correctly after an atomic commit.<br>
> <br>
> [1] <a href="https://lists.freedesktop.org/archives/dri-devel/2023-July/414509.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/archives/dri-devel/2023-July/414509.html</a><br>
> <br>
> Signed-off-by: Albert Esteve <<a href="mailto:aesteve@redhat.com" target="_blank">aesteve@redhat.com</a>><br>
> ---<br>
>   tests/kms_cursor_legacy.c | 76 +++++++++++++++++++++++++++++++++++++++<br>
>   1 file changed, 76 insertions(+)<br>
> <br>
> diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c<br>
> index 1ebac9d31..ba68dc481 100644<br>
> --- a/tests/kms_cursor_legacy.c<br>
> +++ b/tests/kms_cursor_legacy.c<br>
> @@ -1607,6 +1607,71 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic)<br>
>       put_ahnd(ahnd);<br>
>   }<br>
>   <br>
> +static void modeset_atomic_cursor_hotspot(igt_display_t *display)<br>
> +{<br>
> +     struct igt_fb cursor_fb;<br>
> +     igt_output_t *output;<br>
> +     enum pipe pipe;<br>
> +     igt_plane_t *cursor = NULL;<br>
> +     bool has_hotspot_prop;<br>
> +     uint64_t cursor_width, cursor_height;<br>
> +     uint32_t hot_x, hot_y, prev_hot_x, prev_hot_y;<br>
> +<br>
> +     igt_require(display->is_atomic);<br>
> +     igt_require(display->set_hotspots);<br>
> +     pipe = find_connected_pipe(display, false, &output);<br>
> +     igt_require(output);<br>
> +<br>
> +     igt_info("Using pipe %s & %s\n",<br>
> +              kmstest_pipe_name(pipe), igt_output_name(output));<br>
> +<br>
> +     cursor_width = cursor_height = 64;<br>
> +     igt_create_color_fb(display->drm_fd, cursor_width, cursor_height, DRM_FORMAT_ARGB8888,<br>
> +                         DRM_FORMAT_MOD_LINEAR, 1., 1., 1., &cursor_fb);<br>
> +<br>
> +     igt_display_commit2(display, COMMIT_ATOMIC);<br>
> +<br>
> +     cursor = set_cursor_on_pipe(display, pipe, &cursor_fb);<br>
> +<br>
> +     has_hotspot_prop = cursor->props[IGT_PLANE_HOTSPOT_X] ||<br>
> +             cursor->props[IGT_PLANE_HOTSPOT_Y];<br>
> +     igt_require_f(has_hotspot_prop, "Cursor plane lacks the hotspot property");<br>
> +<br>
> +     /*<br>
> +      * Change the hotspot coordinates randomly and check that the property<br>
> +      * is updated accordingly.<br>
> +      */<br>
> +     srand(time(NULL));<br>
> +     for (int i = 0; i < 20; i++) {<br>
> +             hot_x = rand() % cursor_width;<br>
> +             hot_y = rand() % cursor_height;<br>
> +             prev_hot_x = igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_X);<br>
> +             prev_hot_y = igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_Y);<br>
> +             igt_debug("Update cursor hotspot: (%d, %d)\n", hot_x, hot_y);<br>
> +             <br>
> +             /* Set cursor hotspot property values */<br>
> +             igt_output_set_prop_value(cursor, IGT_PLANE_HOTSPOT_X, hot_x);<br>
> +             igt_output_set_prop_value(cursor, IGT_PLANE_HOTSPOT_Y, hot_y);<br>
> +<br>
> +             /* Properties are not updated until the commit */<br>
> +             igt_assert_eq(igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_X), prev_hot_x);<br>
> +             igt_assert_eq(igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_Y), prev_hot_y);<br>
<br>
I think, this check is not required since it is an obvious.<br></blockquote><div><br></div><div>It is indeed a bit redundant, and probably out of the scope of the hotspot setting.</div><div>But it was low effort and adds a layer that helps to understand what the</div><div>test is doing, and how the properties are updated.</div><div>That said, I am ok with removing this. Actually, I added these checks only in a</div><div>later step of the development.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> +<br>
> +             igt_display_commit2(display, COMMIT_ATOMIC);<br>
> +<br>
> +             /* After the commit, the cursor hotspot property values are updated */<br>
> +             igt_assert_eq(igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_X), hot_x);<br>
> +             igt_assert_eq(igt_plane_get_prop(cursor, IGT_PLANE_HOTSPOT_Y), hot_y);<br>
> +     }<br>
> +<br>
> +     /* Clean-up */<br>
> +     igt_plane_set_fb(cursor, NULL);<br>
> +     igt_output_set_pipe(output, PIPE_NONE);<br>
<br>
We need to cleanup/set to default hotspot before exiting the subtest.<br></blockquote><div><br></div><div>Sure, will do!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
- Bhanu<br>
<br>
> +     igt_display_commit2(display, COMMIT_ATOMIC);<br>
> +<br>
> +     igt_remove_fb(display->drm_fd, &cursor_fb);<br>
> +}<br>
> +<br>
>   igt_main<br>
>   {<br>
>       const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);<br>
> @@ -1681,6 +1746,17 @@ igt_main<br>
>                       nonblocking_modeset_vs_cursor(&display, 16);<br>
>       }<br>
>   <br>
> +     igt_describe("Test changes the cursor hotspot and checks that the "<br>
> +                   "property is updated accordignly");<br>
> +     igt_subtest_group {<br>
> +             igt_fixture {<br>
> +                     igt_display_require_output(&display);<br>
> +             }<br>
> +<br>
> +             igt_subtest("modeset-atomic-cursor-hotspot")<br>
> +                     modeset_atomic_cursor_hotspot(&display);<br>
> +     }<br>
> +<br>
>       igt_describe("This test executes flips on both CRTCs "<br>
>                    "while running cursor updates in parallel");<br>
>       igt_subtest_group {<br>
<br>
</blockquote></div></div>