Re: [PATCH v2] drm/format-helper: Make conversion_buf_size() support sub-byte pixel fmts

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

 



Hi Javier,

On Tue, Mar 7, 2023 at 10:54 PM Javier Martinez Canillas
<javierm@xxxxxxxxxx> wrote:
> There are DRM fourcc formats that have pixels smaller than a byte, but the
> conversion_buf_size() function assumes that pixels are a multiple of bytes
> and use the struct drm_format_info .cpp field to calculate the dst_pitch.
>
> Instead, calculate it by using the bits per pixel (bpp) and divide it by 8
> to account for formats that have sub-byte pixels.
>
> Signed-off-by: Javier Martinez Canillas <javierm@xxxxxxxxxx>
> ---
> Tested by making sure that the following command still succeeds:
>
> ./tools/testing/kunit/kunit.py run \
> --kunitconfig=drivers/gpu/drm/tests/.kunitconfig
>
> Changes in v2:
> - Drop an unused variable, that was pointed out by the kernel robot.

Thanks for your patch!

> --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> @@ -409,12 +409,15 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
>                                   const struct drm_rect *clip)
>  {
>         const struct drm_format_info *dst_fi = drm_format_info(dst_format);
> +       unsigned int bpp;
>
>         if (!dst_fi)
>                 return -EINVAL;
>
> -       if (!dst_pitch)
> -               dst_pitch = drm_rect_width(clip) * dst_fi->cpp[0];
> +       if (!dst_pitch) {
> +               bpp = drm_format_info_bpp(dst_fi, 0);
> +               dst_pitch = DIV_ROUND_UP(drm_rect_width(clip) * bpp, 8);

I know I'm a bit late to the party,  but here's actually a helper for that:

    dst_pitch = drm_format_info_min_pitch(info, 0, drm_rect_width(clip));

> +       }
>
>         return dst_pitch * drm_rect_height(clip);
>  }

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds




[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