Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/fourcc: Add drm_format_info_bpp() helper

Add a helper to retrieve the actual number of bits per pixel for a
plane, taking into account the number of characters and pixels per
block for tiled formats.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1cae5ebc28513ec1c91c66b00647ce3ca23bfba7.1657294931.git.geert@linux-m68k.org

authored by

Geert Uytterhoeven and committed by
Sam Ravnborg
96dc635d 79abca2b

+20
+19
drivers/gpu/drm/drm_fourcc.c
··· 371 371 EXPORT_SYMBOL(drm_format_info_block_height); 372 372 373 373 /** 374 + * drm_format_info_bpp - number of bits per pixel 375 + * @info: pixel format info 376 + * @plane: plane index 377 + * 378 + * Returns: 379 + * The actual number of bits per pixel, depending on the plane index. 380 + */ 381 + unsigned int drm_format_info_bpp(const struct drm_format_info *info, int plane) 382 + { 383 + if (!info || plane < 0 || plane >= info->num_planes) 384 + return 0; 385 + 386 + return info->char_per_block[plane] * 8 / 387 + (drm_format_info_block_width(info, plane) * 388 + drm_format_info_block_height(info, plane)); 389 + } 390 + EXPORT_SYMBOL(drm_format_info_bpp); 391 + 392 + /** 374 393 * drm_format_info_min_pitch - computes the minimum required pitch in bytes 375 394 * @info: pixel format info 376 395 * @plane: plane index
+1
include/drm/drm_fourcc.h
··· 313 313 int plane); 314 314 unsigned int drm_format_info_block_height(const struct drm_format_info *info, 315 315 int plane); 316 + unsigned int drm_format_info_bpp(const struct drm_format_info *info, int plane); 316 317 uint64_t drm_format_info_min_pitch(const struct drm_format_info *info, 317 318 int plane, unsigned int buffer_width); 318 319