Re: [PATCH v2 3/4] drm/format-helper: Support multiple target formats results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 9, 2022 at 7:58 PM José Expósito <jose.exposito89@xxxxxxxxx> wrote:
>
> In order to support multiple destination format conversions, store the
> destination pitch and the expected result in its own structure.
>
> Tested-by: Tales L. Aparecida <tales.aparecida@xxxxxxxxx>
> Acked-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
> Signed-off-by: José Expósito <jose.exposito89@xxxxxxxxx>
> ---

Looks good to me. You could probably merge this with the previous
patch if you wanted to, IMO, but it's also fine like this.

Reviewed-by: David Gow <davidgow@xxxxxxxxxx>

Cheers,
-- David


>  .../gpu/drm/tests/drm_format_helper_test.c    | 53 ++++++++++++-------
>  1 file changed, 33 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
> index f66aaa0e52c9..0a490ad4fd32 100644
> --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> @@ -16,34 +16,42 @@
>
>  #define TEST_BUF_SIZE 50
>
> +struct convert_to_rgb332_result {
> +       unsigned int dst_pitch;
> +       const u8 expected[TEST_BUF_SIZE];
> +};
> +
>  struct convert_xrgb8888_case {
>         const char *name;
>         unsigned int pitch;
> -       unsigned int dst_pitch;
>         struct drm_rect clip;
>         const u32 xrgb8888[TEST_BUF_SIZE];
> -       const u8 expected[4 * TEST_BUF_SIZE];
> +       struct convert_to_rgb332_result rgb332_result;
>  };
>
>  static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
>         {
>                 .name = "single_pixel_source_buffer",
>                 .pitch = 1 * 4,
> -               .dst_pitch = 0,
>                 .clip = DRM_RECT_INIT(0, 0, 1, 1),
>                 .xrgb8888 = { 0x01FF0000 },
> -               .expected = { 0xE0 },
> +               .rgb332_result = {
> +                       .dst_pitch = 0,
> +                       .expected = { 0xE0 },
> +               },
>         },
>         {
>                 .name = "single_pixel_clip_rectangle",
>                 .pitch = 2 * 4,
> -               .dst_pitch = 0,
>                 .clip = DRM_RECT_INIT(1, 1, 1, 1),
>                 .xrgb8888 = {
>                         0x00000000, 0x00000000,
>                         0x00000000, 0x10FF0000,
>                 },
> -               .expected = { 0xE0 },
> +               .rgb332_result = {
> +                       .dst_pitch = 0,
> +                       .expected = { 0xE0 },
> +               },
>         },
>         {
>                 /* Well known colors: White, black, red, green, blue, magenta,
> @@ -52,7 +60,6 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
>                  */
>                 .name = "well_known_colors",
>                 .pitch = 4 * 4,
> -               .dst_pitch = 0,
>                 .clip = DRM_RECT_INIT(1, 1, 2, 4),
>                 .xrgb8888 = {
>                         0x00000000, 0x00000000, 0x00000000, 0x00000000,
> @@ -61,28 +68,33 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
>                         0x00000000, 0x550000FF, 0x66FF00FF, 0x00000000,
>                         0x00000000, 0x77FFFF00, 0x8800FFFF, 0x00000000,
>                 },
> -               .expected = {
> -                       0xFF, 0x00,
> -                       0xE0, 0x1C,
> -                       0x03, 0xE3,
> -                       0xFC, 0x1F,
> +               .rgb332_result = {
> +                       .dst_pitch = 0,
> +                       .expected = {
> +                               0xFF, 0x00,
> +                               0xE0, 0x1C,
> +                               0x03, 0xE3,
> +                               0xFC, 0x1F,
> +                       },
>                 },
>         },
>         {
>                 /* Randomly picked colors. Full buffer within the clip area. */
>                 .name = "destination_pitch",
>                 .pitch = 3 * 4,
> -               .dst_pitch = 5,
>                 .clip = DRM_RECT_INIT(0, 0, 3, 3),
>                 .xrgb8888 = {
>                         0xA10E449C, 0xB1114D05, 0xC1A80303,
>                         0xD16C7073, 0xA20E449C, 0xB2114D05,
>                         0xC2A80303, 0xD26C7073, 0xA30E449C,
>                 },
> -               .expected = {
> -                       0x0A, 0x08, 0xA0, 0x00, 0x00,
> -                       0x6D, 0x0A, 0x08, 0x00, 0x00,
> -                       0xA0, 0x6D, 0x0A, 0x00, 0x00,
> +               .rgb332_result = {
> +                       .dst_pitch = 5,
> +                       .expected = {
> +                               0x0A, 0x08, 0xA0, 0x00, 0x00,
> +                               0x6D, 0x0A, 0x08, 0x00, 0x00,
> +                               0xA0, 0x6D, 0x0A, 0x00, 0x00,
> +                       },
>                 },
>         },
>  };
> @@ -138,6 +150,7 @@ KUNIT_ARRAY_PARAM(convert_xrgb8888, convert_xrgb8888_cases,
>  static void xrgb8888_to_rgb332_test(struct kunit *test)
>  {
>         const struct convert_xrgb8888_case *params = test->param_value;
> +       const struct convert_to_rgb332_result *result = &params->rgb332_result;
>         size_t dst_size;
>         __u8 *dst = NULL;
>         __u32 *src = NULL;
> @@ -147,7 +160,7 @@ static void xrgb8888_to_rgb332_test(struct kunit *test)
>                 .pitches = { params->pitch, 0, 0 },
>         };
>
> -       dst_size = conversion_buf_size(DRM_FORMAT_RGB332, params->dst_pitch,
> +       dst_size = conversion_buf_size(DRM_FORMAT_RGB332, result->dst_pitch,
>                                        &params->clip);
>         KUNIT_ASSERT_GT(test, dst_size, 0);
>
> @@ -157,9 +170,9 @@ static void xrgb8888_to_rgb332_test(struct kunit *test)
>         src = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE);
>         KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src);
>
> -       drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, src, &fb,
> +       drm_fb_xrgb8888_to_rgb332(dst, result->dst_pitch, src, &fb,
>                                   &params->clip);
> -       KUNIT_EXPECT_EQ(test, memcmp(dst, params->expected, dst_size), 0);
> +       KUNIT_EXPECT_EQ(test, memcmp(dst, result->expected, dst_size), 0);
>  }
>
>  static struct kunit_case drm_format_helper_test_cases[] = {
> --
> 2.25.1
>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux