drm/format-helper: Use drm_format_info_min_pitch() in tests helper

There's a nice macro to calculate the destination pitch that already takes
into account sub-byte pixel formats. Use that instead of open coding it.
Suggested-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230316223404.102806-1-javierm@redhat.com
parent 06bc8c80
...@@ -440,15 +440,12 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch, ...@@ -440,15 +440,12 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
const struct drm_rect *clip) const struct drm_rect *clip)
{ {
const struct drm_format_info *dst_fi = drm_format_info(dst_format); const struct drm_format_info *dst_fi = drm_format_info(dst_format);
unsigned int bpp;
if (!dst_fi) if (!dst_fi)
return -EINVAL; return -EINVAL;
if (!dst_pitch) { if (!dst_pitch)
bpp = drm_format_info_bpp(dst_fi, 0); dst_pitch = drm_format_info_min_pitch(dst_fi, 0, drm_rect_width(clip));
dst_pitch = DIV_ROUND_UP(drm_rect_width(clip) * bpp, 8);
}
return dst_pitch * drm_rect_height(clip); return dst_pitch * drm_rect_height(clip);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment