mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: "Sagar, Vishal" <vishal.sagar@amd.com>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"Klymenko, Anatoliy" <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>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	"Simek, Michal" <michal.simek@amd.com>
Subject: Re: [PATCH 01/10] drm/fourcc: Add warning for bad bpp
Date: Wed, 18 Dec 2024 13:49:01 +0200	[thread overview]
Message-ID: <02da12fe-4d94-4a40-86b6-6dad28588843@ideasonboard.com> (raw)
In-Reply-To: <BL1PR12MB596954886CC5E28EC8E735BA9C372@BL1PR12MB5969.namprd12.prod.outlook.com>

Hi Vishal,

On 04/12/2024 18:26, Sagar, Vishal wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
> 
> Hi Tomi,
> 
> Thanks for the patch.
> 
>> -----Original Message-----
>> From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>> Sent: Wednesday, December 4, 2024 10:31 AM
>> To: Sagar, Vishal <vishal.sagar@amd.com>; Klymenko, Anatoliy
>> <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>; Laurent Pinchart
>> <laurent.pinchart@ideasonboard.com>; Simek, Michal <michal.simek@amd.com>
>> Cc: dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; linux-arm-
>> kernel@lists.infradead.org; Tomi Valkeinen <tomi.valkeinen@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.

Indeed, the description is perhaps a bit lacking. I'll change it to:

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.

  Tomi

>>
>> 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 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


  reply	other threads:[~2024-12-18 11:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04  9:31 [PATCH 00/10] drm: Add new pixel formats for Xilinx Zynqmp Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 01/10] drm/fourcc: Add warning for bad bpp Tomi Valkeinen
2024-12-04 16:26   ` Sagar, Vishal
2024-12-18 11:49     ` Tomi Valkeinen [this message]
2024-12-18 14:35       ` Sagar, Vishal
2024-12-04  9:31 ` [PATCH 02/10] drm/fourcc: Add DRM_FORMAT_XV15/XV20 Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 03/10] drm/fourcc: Add DRM_FORMAT_Y8 Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 04/10] drm/fourcc: Add DRM_FORMAT_Y10_LE32 Tomi Valkeinen
2024-12-18 12:03   ` Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 05/10] drm/fourcc: Add DRM_FORMAT_X403 Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 06/10] drm: xlnx: zynqmp: Use drm helpers when calculating buffer sizes Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 07/10] drm: xlnx: zynqmp: Add support for XV15 & XV20 Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 08/10] drm: xlnx: zynqmp: Add support for Y8 and Y10_LE32 Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 09/10] drm: xlnx: zynqmp: Add support for X403 Tomi Valkeinen
2024-12-04  9:31 ` [PATCH 10/10] drm: xlnx: zynqmp: Fix max dma segment size Tomi Valkeinen
2025-01-10 18:10   ` Sean Anderson

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=02da12fe-4d94-4a40-86b6-6dad28588843@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=Anatoliy.Klymenko@amd.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --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=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

all inboxes | Powered by JetHome®