[PATCH 01/10] drm/fourcc: Add warning for bad bpp

Sagar, Vishal vishal.sagar at amd.com
Wed Dec 4 08:26:41 PST 2024


[AMD Official Use Only - AMD Internal Distribution Only]

Hi Tomi,

Thanks for the patch.

> -----Original Message-----
> From: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> Sent: Wednesday, December 4, 2024 10:31 AM
> To: Sagar, Vishal <vishal.sagar at amd.com>; Klymenko, Anatoliy
> <Anatoliy.Klymenko at amd.com>; Maarten Lankhorst
> <maarten.lankhorst at linux.intel.com>; Maxime Ripard <mripard at kernel.org>;
> Thomas Zimmermann <tzimmermann at suse.de>; David Airlie
> <airlied at gmail.com>; Simona Vetter <simona at ffwll.ch>; Laurent Pinchart
> <laurent.pinchart at ideasonboard.com>; Simek, Michal <michal.simek at amd.com>
> Cc: dri-devel at lists.freedesktop.org; linux-kernel at vger.kernel.org; linux-arm-
> kernel at lists.infradead.org; Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> Subject: [PATCH 01/10] drm/fourcc: Add warning for bad bpp
>
> drm_format_info_bpp() cannot be used for formats which do not have an
> integer bits-per-pixel. Handle wrong calls by printing a warning and
> returning 0.

It would be good to add an example of pixel format that may cause this issue.

>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> ---
>  drivers/gpu/drm/drm_fourcc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> index 193cf8ed7912..e84c4ed6928c 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
> @@ -429,6 +429,13 @@ unsigned int drm_format_info_bpp(const struct
> drm_format_info *info, int plane)
>       if (!info || plane < 0 || plane >= info->num_planes)
>               return 0;
>
> +     if (info->char_per_block[plane] * 8 %
> +         (drm_format_info_block_width(info, plane) *
> +          drm_format_info_block_height(info, plane))) {
> +             pr_warn("unable to return an integer bpp\n");
> +             return 0;
> +     }
> +
>       return info->char_per_block[plane] * 8 /
>              (drm_format_info_block_width(info, plane) *
>               drm_format_info_block_height(info, plane));
>
> --
> 2.43.0

Regards
Vishal Sagar


More information about the linux-arm-kernel mailing list