<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 2023-02-17 15:24, Leo Li wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:9212eb43-3204-79f1-c507-01c1824cebe9@amd.com">
      <br>
      <br>
      <br>
      On 2/13/23 13:16, Bhawanpreet Lakha wrote:
      <br>
      <blockquote type="cite">[Why]
        <br>
        Some of our ASICs  support multiple overlay planes, so create
        <br>
        a test to test them
        <br>
        <br>
        [How]
        <br>
        Create a plane with two holes and fill them up with 2 overlay
        planes
        <br>
        <br>
        Signed-off-by: Bhawanpreet Lakha
        <a class="moz-txt-link-rfc2396E" href="mailto:Bhawanpreet.Lakha@amd.com"><Bhawanpreet.Lakha@amd.com></a>
        <br>
        Change-Id: If527d67ead59f64906a97c340845ac423d93a0aa
        <br>
        ---
        <br>
          tests/amdgpu/amd_plane.c | 128
        ++++++++++++++++++++++++++++++++++++++-
        <br>
          1 file changed, 127 insertions(+), 1 deletion(-)
        <br>
        <br>
        diff --git a/tests/amdgpu/amd_plane.c b/tests/amdgpu/amd_plane.c
        <br>
        index b9eec677..d34cd1d9 100644
        <br>
        --- a/tests/amdgpu/amd_plane.c
        <br>
        +++ b/tests/amdgpu/amd_plane.c
        <br>
        @@ -42,6 +42,7 @@ typedef struct data {
        <br>
                  igt_plane_t *primary[MAX_PIPES];
        <br>
                  igt_plane_t *cursor[MAX_PIPES];
        <br>
              igt_plane_t *overlay[MAX_PIPES];
        <br>
        +    igt_plane_t *overlay2[MAX_PIPES];
        <br>
                  igt_output_t *output[MAX_PIPES];
        <br>
                  igt_pipe_t *pipe[MAX_PIPES];
        <br>
                  igt_pipe_crc_t *pipe_crc[MAX_PIPES];
        <br>
        @@ -144,7 +145,8 @@ static void lut_free(lut_t *lut)
        <br>
          enum test {
        <br>
              MPO_SINGLE_PAN,
        <br>
              MPO_MULTI_PAN,
        <br>
        -    MPO_SCALE
        <br>
        +    MPO_SCALE,
        <br>
        +    MPO_MULTI_OVERLAY
        <br>
          };
        <br>
            static void test_init(data_t *data)
        <br>
        @@ -159,6 +161,8 @@ static void test_init(data_t *data)
        <br>
                      data->pipe[i], DRM_PLANE_TYPE_PRIMARY);
        <br>
                  data->overlay[i] = igt_pipe_get_plane_type_index(
        <br>
                      data->pipe[i], DRM_PLANE_TYPE_OVERLAY, 0);
        <br>
        +        data->overlay2[i] = igt_pipe_get_plane_type_index(
        <br>
        +            data->pipe[i], DRM_PLANE_TYPE_OVERLAY, 1);
        <br>
                  data->cursor[i] = igt_pipe_get_plane_type(
        <br>
                      data->pipe[i], DRM_PLANE_TYPE_CURSOR);
        <br>
                  data->pipe_crc[i] =
        <br>
        @@ -252,6 +256,7 @@ struct fbc {
        <br>
              igt_fb_t ref_primary;
        <br>
              igt_fb_t test_primary;
        <br>
              igt_fb_t test_overlay;
        <br>
        +    igt_fb_t test_overlay2;
        <br>
              igt_crc_t ref_crc;
        <br>
          };
        <br>
          @@ -264,6 +269,115 @@ static void set_regamma_lut(data_t
        *data, lut_t const *lut, int n)
        <br>
                                 size);
        <br>
          }
        <br>
          +/*
        <br>
        + * Compares the result of white backgroud with white window
        with and without MPO
        <br>
        + *
        <br>
        + * Reference crc:
        <br>
        + * Draws a White background of size (pw,ph).
        <br>
        + *
        <br>
        + * Test crc:
        <br>
        + * Draws a White Overlay of size (pw,ph) then creates a cutout
        of size (w,h) at location (x1, y1) and (x2, y2)
        <br>
        + * Draws a White Primary plane of size (w, h) at location
        (x1,y1) (under the overlay)
        <br>
        + * Draws a White Overlay of size (w, h) at location (x2,y2)
        <br>
        + *
        <br>
        + * NOTE: The reason for using White+White is to speed up the
        crc (reuse the ref crc for all cases vs taking
        <br>
        + * a ref crc per flip)
        <br>
        + */
        <br>
        +static void test_plane2(data_t *data, int n, int x1, int y1,
        int x2, int y2, int w, int h, int pw, int ph, struct fbc *fbc){
        <br>
        +
        <br>
        +    igt_crc_t test_crc;
        <br>
        +    igt_display_t *display = &data->display;
        <br>
        +
        <br>
        +    /* Reference: */
        <br>
        +
        <br>
        +    igt_plane_set_fb(data->primary[n],
        &fbc[n].ref_primary);
        <br>
        +
        <br>
        +    igt_plane_set_position(data->primary[n], 0, 0);
        <br>
        +    igt_plane_set_size(data->primary[n], pw, ph);
        <br>
        +
        <br>
        +    igt_display_commit_atomic(display, 0, 0);
        <br>
        +
        <br>
      </blockquote>
      <br>
      Should ref_crc be collected here?
      <br>
    </blockquote>
    <p><font size="2"><span style="font-size:11pt;">reference is stored
          in &fbc[n].ref_crc inside the main function </span></font><font size="2"><span style="font-size:11pt;">test_display_mpo(). The
          Other MPO tests had alot of iterations so the reference crc
          was saved before starting the tests. Since the setup code is
          the same for this test, its using the same logic. <br>
        </span></font></p>
    <blockquote type="cite" cite="mid:9212eb43-3204-79f1-c507-01c1824cebe9@amd.com">
      <br>
      <blockquote type="cite">+    /* Test: */
        <br>
        +    /* Draw a white overlay with two cutouts at (x1,y1) and
        (x2,y2) */
        <br>
        +    draw_color_alpha(&fbc[n].test_overlay2, 0, 0, pw, ph,
        1.0, 1.0, 1.0, 1.0);
        <br>
        +    draw_color_alpha(&fbc[n].test_overlay2, x1, y1, w, h,
        0.0, 0.0, 0.0, 0.0);
        <br>
        +    draw_color_alpha(&fbc[n].test_overlay2, x2, y2, w, h,
        0.0, 0.0, 0.0, 0.0);
        <br>
        +
        <br>
        +    /* Draw a overlay to cover up one hole */
        <br>
        +    draw_color_alpha(&fbc[n].test_overlay, 0, 0, pw, ph,
        0.0, 0.0, 0.0, 0.0);
        <br>
        +    draw_color_alpha(&fbc[n].test_overlay, x2, y2, w, h,
        1.0, 1.0, 1.0, 1.0);
        <br>
        +
        <br>
        +    /* Draw a primary to cover up the other hole */
        <br>
        +    draw_color_alpha(&fbc[n].test_primary, 0, 0, w, h, 0.0,
        0.0, 0.0, 0.0);
        <br>
        +    draw_color_alpha(&fbc[n].test_primary, 0, 0, w, h, 1.0,
        1.0, 1.0, 1.0);
        <br>
        +
        <br>
        +    igt_plane_set_fb(data->primary[n],
        &fbc[n].test_primary);
        <br>
        +    igt_plane_set_fb(data->overlay[n],
        &fbc[n].test_overlay);
        <br>
        +    igt_plane_set_fb(data->overlay2[n],
        &fbc[n].test_overlay2);
        <br>
        +
        <br>
        +    /* Move the primary to cover one of the holes*/
        <br>
        +    igt_plane_set_position(data->primary[n], x1, y1);
        <br>
        +    igt_plane_set_size(data->primary[n], w, h);
        <br>
        +
        <br>
        +
        <br>
        +    igt_display_commit_atomic(display, 0, 0);
        <br>
        +    igt_pipe_crc_collect_crc(data->pipe_crc[n],
        &test_crc);
        <br>
        +    igt_plane_set_fb(data->overlay[n], NULL);
        <br>
        +    igt_plane_set_fb(data->overlay2[n], NULL);
        <br>
        +
        <br>
        +    igt_assert_crc_equal(&fbc[n].ref_crc, &test_crc);
        <br>
        +
        <br>
        +    /* Set window to white, this is to avoid flashing between
        black/white after each flip */
        <br>
        +    draw_color_alpha(&fbc[n].ref_primary, 0, 0, w, h, 1.0,
        1.0, 1.0, 1.00);
        <br>
        +    igt_plane_set_fb(data->primary[n],
        &fbc[n].ref_primary);
        <br>
        +    igt_plane_set_position(data->primary[n], 0, 0);
        <br>
        +    igt_plane_set_size(data->primary[n], pw, ph);
        <br>
        +    igt_display_commit_atomic(display, 0, 0);
        <br>
        +
        <br>
        +
        <br>
        +}
        <br>
        +
        <br>
        +/*
        <br>
        + * MPO_MULTI_OVERLAY: This test takes the plane sizes and
        assigns random position within the screen
        <br>
        + *
        <br>
        + * The test creates a white screen with 2 cutouts which are to
        be filled with 2 overlay planes.
        <br>
        + * Testing multiple overlay planes
        <br>
        + */
        <br>
        +static void test_multi_overlay(data_t *data, int display_count,
        int w, int h, struct fbc *fb)
        <br>
        +{
        <br>
        +
        <br>
        +    int x1,x2,y1,y2;
        <br>
        +
        <br>
        +    for (int n = 0; n < display_count; n++) {
        <br>
        +
        <br>
        +        int pw = data->w[n];
        <br>
        +        int ph = data->h[n];
        <br>
        +
        <br>
        +        for (int i = 0; i < 1; i++){
        <br>
        +
        <br>
        +            if (pw <= w && ph <= h)
        <br>
        +                break;
        <br>
        +
        <br>
        +            srand(time(NULL));
        <br>
        +
        <br>
        +            /* Generate random x,y positions for two cutouts*/
        <br>
        +            x1 = (rand() % (pw-w));
        <br>
        +            y1 = (rand() % (ph-h));
        <br>
        +
        <br>
        +            x2 = (rand() % (pw-w));
        <br>
        +            y2 = (rand() % (ph-h));
        <br>
        +
        <br>
      </blockquote>
      <br>
      I wonder if using random positions can cause hard-to-reproduce
      failures.
      <br>
      Is there something in particular being tested via rand, or can we
      use a
      <br>
      fixed set of positions similar to test_cursor_spots() in
      <br>
      kms_plane_cursor?
      <br>
    </blockquote>
    <blockquote type="cite" cite="mid:9212eb43-3204-79f1-c507-01c1824cebe9@amd.com">Thanks,
      <br>
      Leo
      <br>
    </blockquote>
    <p><br>
      No particular reason for using random positions, I will take a
      look at test_cursor_spots(). Thanks<br>
    </p>
    <blockquote type="cite" cite="mid:9212eb43-3204-79f1-c507-01c1824cebe9@amd.com">
      <br>
      <blockquote type="cite">+
        <br>
        +            test_plane2(data, n, x1, y1, x2, y2, w,h, pw, ph,
        fb);
        <br>
        +
        <br>
        +        }
        <br>
        +    }
        <br>
        +
        <br>
        +    return;
        <br>
        +
        <br>
        +
        <br>
        +}
        <br>
        +
        <br>
          /*
        <br>
           * Compares the result of white backgroud with white window
        with and without MPO
        <br>
           *
        <br>
        @@ -467,6 +581,10 @@ static void test_display_mpo(data_t *data,
        enum test test, uint32_t format, int
        <br>
                test_init(data);
        <br>
          +    /* Skip test if we don't have 2 overlay planes */
        <br>
        +    if (test == MPO_MULTI_OVERLAY)
        <br>
        +        igt_skip_on(!data->overlay2[0]);
        <br>
        +
        <br>
              /* Skip if there is less valid outputs than the required.
        */
        <br>
              for_each_connected_output(display, output)
        <br>
                  valid_outputs++;
        <br>
        @@ -494,6 +612,7 @@ static void test_display_mpo(data_t *data,
        enum test test, uint32_t format, int
        <br>
                  igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888,
        0, &fb[n].ref_primary);
        <br>
                  igt_create_color_fb(data->fd, w, h,
        DRM_FORMAT_XRGB8888, 0, 1.0, 1.0, 1.0, &fb[n].ref_primary);
        <br>
                  igt_create_fb(data->fd, w, h, DRM_FORMAT_ARGB8888,
        0, &fb[n].test_overlay);
        <br>
        +        igt_create_fb(data->fd, w, h, DRM_FORMAT_ARGB8888,
        0, &fb[n].test_overlay2);
        <br>
                    igt_plane_set_fb(data->primary[n],
        &fb[n].ref_primary);
        <br>
          @@ -520,6 +639,8 @@ static void test_display_mpo(data_t *data,
        enum test test, uint32_t format, int
        <br>
                    if (test == MPO_SINGLE_PAN)
        <br>
                      test_panning_1_display(data, display_count,
        videos[i][0], videos[i][1], fb);
        <br>
        +        if (test == MPO_MULTI_OVERLAY)
        <br>
        +            test_multi_overlay(data, display_count,
        videos[i][0], videos[i][1], fb);
        <br>
                  if (test == MPO_MULTI_PAN)
        <br>
                      test_panning_2_display(data, videos[i][0],
        videos[i][1], fb);
        <br>
                  if(test == MPO_SCALE)
        <br>
        @@ -536,6 +657,7 @@ static void test_display_mpo(data_t *data,
        enum test test, uint32_t format, int
        <br>
              for (int n = 0; n < display_count; n++) {
        <br>
                  igt_remove_fb(data->fd, &fb[n].ref_primary);
        <br>
                  igt_remove_fb(data->fd, &fb[n].test_overlay);
        <br>
        +        igt_remove_fb(data->fd, &fb[n].test_overlay2);
        <br>
              }
        <br>
          }
        <br>
          /*
        <br>
        @@ -798,6 +920,10 @@ igt_main
        <br>
              igt_subtest("mpo-pan-multi-p010")
        <br>
                  test_display_mpo(&data, MPO_MULTI_PAN,
        DRM_FORMAT_P010, DISPLAYS_TO_TEST);
        <br>
          +    igt_describe("Multi MPO");
        <br>
        +    igt_subtest("multi-mpo")
        <br>
        +        test_display_mpo(&data, MPO_MULTI_OVERLAY,
        DRM_FORMAT_NV12, 1);
        <br>
        +
        <br>
              igt_describe("MPO and scaling RGB primary plane");
        <br>
              igt_subtest("mpo-scale-rgb")
        <br>
                  test_display_mpo(&data, MPO_SCALE,
        DRM_FORMAT_XRGB8888, 1);
        <br>
      </blockquote>
    </blockquote>
  </body>
</html>