Commit 96dc635d authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Sam Ravnborg
Browse files

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: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1cae5ebc28513ec1c91c66b00647ce3ca23bfba7.1657294931.git.geert@linux-m68k.org
parent 79abca2b
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -370,6 +370,25 @@ unsigned int drm_format_info_block_height(const struct drm_format_info *info,
}
}
EXPORT_SYMBOL(drm_format_info_block_height);
EXPORT_SYMBOL(drm_format_info_block_height);


/**
 * drm_format_info_bpp - number of bits per pixel
 * @info: pixel format info
 * @plane: plane index
 *
 * Returns:
 * The actual number of bits per pixel, depending on the plane index.
 */
unsigned int drm_format_info_bpp(const struct drm_format_info *info, int plane)
{
	if (!info || plane < 0 || plane >= info->num_planes)
		return 0;

	return info->char_per_block[plane] * 8 /
	       (drm_format_info_block_width(info, plane) *
		drm_format_info_block_height(info, plane));
}
EXPORT_SYMBOL(drm_format_info_bpp);

/**
/**
 * drm_format_info_min_pitch - computes the minimum required pitch in bytes
 * drm_format_info_min_pitch - computes the minimum required pitch in bytes
 * @info: pixel format info
 * @info: pixel format info
+1 −0
Original line number Original line Diff line number Diff line
@@ -313,6 +313,7 @@ unsigned int drm_format_info_block_width(const struct drm_format_info *info,
					 int plane);
					 int plane);
unsigned int drm_format_info_block_height(const struct drm_format_info *info,
unsigned int drm_format_info_block_height(const struct drm_format_info *info,
					  int plane);
					  int plane);
unsigned int drm_format_info_bpp(const struct drm_format_info *info, int plane);
uint64_t drm_format_info_min_pitch(const struct drm_format_info *info,
uint64_t drm_format_info_min_pitch(const struct drm_format_info *info,
				   int plane, unsigned int buffer_width);
				   int plane, unsigned int buffer_width);