Skip to contentSkip to conversation

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

PATCH In review Javier Martinez Canillas 2 participants 3 messages Mar 16, 2023 – Mar 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

 drivers/gpu/drm/tests/drm_format_helper_test.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/tests/drm_format_helper_test.c +2 -5
index bfa47f8ffd09..474bb7a1c4ee 100644
@@ -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

Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 16.03.23 um 23:34 schrieb Javier Martinez Canillas:

Quoted 5 lines

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.

Quoted 29 lines

---

  drivers/gpu/drm/tests/drm_format_helper_test.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/tests/drm_format_helper_test.c +2 -5
index bfa47f8ffd09..474bb7a1c4ee 100644
@@ -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

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
#2 lore raw
Quoted 9 lines · Thomas Zimmermann

Am 16.03.23 um 23:34 schrieb Javier Martinez Canillas:

Quoted 5 lines

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.

Pushed to drm-misc (drm-misc-next). Thanks!

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat