mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/format-helper: Use drm_format_info_min_pitch() in tests helper
@ 2023-03-16 22:34 Javier Martinez Canillas
  2023-03-17  8:08 ` Thomas Zimmermann
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2023-03-16 22:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Geert Uytterhoeven, Arthur Grillo,
	Daniel Vetter, David Airlie, David Gow, José Expósito,
	Maíra Canal, Thomas Zimmermann, dri-devel

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: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/gpu/drm/tests/drm_format_helper_test.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index bfa47f8ffd09..474bb7a1c4ee 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -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_format_info *dst_fi = drm_format_info(dst_format);
-	unsigned int bpp;
 
 	if (!dst_fi)
 		return -EINVAL;
 
-	if (!dst_pitch) {
-		bpp = drm_format_info_bpp(dst_fi, 0);
-		dst_pitch = DIV_ROUND_UP(drm_rect_width(clip) * bpp, 8);
-	}
+	if (!dst_pitch)
+		dst_pitch = drm_format_info_min_pitch(dst_fi, 0, drm_rect_width(clip));
 
 	return dst_pitch * drm_rect_height(clip);
 }

base-commit: 165d5133731a2e045abdd6d9d3c9221fdc2a556e
-- 
2.39.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-17 17:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16 22:34 [PATCH] drm/format-helper: Use drm_format_info_min_pitch() in tests helper Javier Martinez Canillas
2023-03-17  8:08 ` Thomas Zimmermann
2023-03-17 17:38   ` Javier Martinez Canillas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®