From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Vishal Sagar <vishal.sagar@amd.com>,
Anatoliy Klymenko <anatoliy.klymenko@amd.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Michal Simek <michal.simek@amd.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH v3 01/11] drm/fourcc: Add warning for bad bpp
Date: Thu, 13 Feb 2025 22:41:40 +0200 [thread overview]
Message-ID: <20250213204140.GB22998@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20250212-xilinx-formats-v3-1-90d0fe106995@ideasonboard.com>
Hi Tomi,
Thank you for the patch.
On Wed, Feb 12, 2025 at 04:56:05PM +0200, Tomi Valkeinen wrote:
> drm_format_info_bpp() cannot be used for formats which do not have an
> integer bits-per-pixel in a pixel block.
>
> E.g. DRM_FORMAT_XV15's (not yet in upstream) plane 0 has three 10-bit
> pixels (Y components), and two padding bits, in a 4 byte block. That is
> 10.666... bits per pixel when considering the whole 4 byte block, which
> is what drm_format_info_bpp() does. Thus a driver that supports such
> formats cannot use drm_format_info_bpp(),
>
> It is a driver bug if this happens, but so handle wrong calls by
> printing a warning and returning 0.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@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 3a94ca211f9c..1e9afbf6ef99 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
> @@ -457,6 +457,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))) {
Can you cache
drm_format_info_block_width(info, plane) *
drm_format_info_block_height(info, plane)
in a local variable to avoid computing it twice ?
> + pr_warn("unable to return an integer bpp\n");
It would be nice to print the warning in the context of the drm device,
but we don't have the required structure here.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> + return 0;
> + }
> +
> return info->char_per_block[plane] * 8 /
> (drm_format_info_block_width(info, plane) *
> drm_format_info_block_height(info, plane));
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2025-02-13 20:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-12 14:56 [PATCH v3 00/11] drm: Add new pixel formats for Xilinx Zynqmp Tomi Valkeinen
2025-02-12 14:56 ` [PATCH v3 01/11] drm/fourcc: Add warning for bad bpp Tomi Valkeinen
2025-02-13 20:41 ` Laurent Pinchart [this message]
2025-02-12 14:56 ` [PATCH v3 02/11] drm/fourcc: Add DRM_FORMAT_XV15/XV20 Tomi Valkeinen
2025-02-17 20:00 ` Dmitry Baryshkov
2025-03-26 13:02 ` Tomi Valkeinen
2025-02-12 14:56 ` [PATCH v3 03/11] drm/fourcc: Add DRM_FORMAT_Y8 Tomi Valkeinen
2025-02-17 19:58 ` Dmitry Baryshkov
2025-02-12 14:56 ` [PATCH v3 04/11] drm/fourcc: Add DRM_FORMAT_Y10_P32 Tomi Valkeinen
2025-02-12 14:56 ` [PATCH v3 05/11] drm/fourcc: Add DRM_FORMAT_X403 Tomi Valkeinen
2025-02-17 20:16 ` Dmitry Baryshkov
2025-02-12 14:56 ` [PATCH v3 06/11] drm/fourcc: Add DRM_FORMAT_XVUY2101010 Tomi Valkeinen
2025-02-17 20:15 ` Dmitry Baryshkov
2025-02-17 20:27 ` Tomi Valkeinen
2025-02-18 3:26 ` Dmitry Baryshkov
2025-02-19 14:47 ` Tomi Valkeinen
2025-02-19 15:08 ` Laurent Pinchart
2025-02-19 17:28 ` Dmitry Baryshkov
2025-02-19 17:49 ` Laurent Pinchart
2025-02-12 14:56 ` [PATCH v3 07/11] drm: xlnx: zynqmp: Use drm helpers when calculating buffer sizes Tomi Valkeinen
2025-02-13 20:45 ` Laurent Pinchart
2025-02-12 14:56 ` [PATCH v3 08/11] drm: xlnx: zynqmp: Add support for XV15 & XV20 Tomi Valkeinen
2025-02-12 14:56 ` [PATCH v3 09/11] drm: xlnx: zynqmp: Add support for Y8 and Y10_LE32 Tomi Valkeinen
2025-02-12 14:56 ` [PATCH v3 10/11] drm: xlnx: zynqmp: Add support for X403 Tomi Valkeinen
2025-02-12 14:56 ` [PATCH v3 11/11] drm: xlnx: zynqmp: Add support for XVUY2101010 Tomi Valkeinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250213204140.GB22998@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=anatoliy.klymenko@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert@linux-m68k.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=michal.simek@amd.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=tzimmermann@suse.de \
--cc=vishal.sagar@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox