Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	airlied@gmail.com, simona@ffwll.ch
Cc: dri-devel@lists.freedesktop.org,
	linux-mediatek@lists.infradead.org,
	freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	imx@lists.linux.dev, linux-samsung-soc@vger.kernel.org,
	nouveau@lists.freedesktop.org, virtualization@lists.linux.dev,
	spice-devel@lists.freedesktop.org,
	linux-renesas-soc@vger.kernel.org,
	linux-rockchip@lists.infradead.org, linux-tegra@vger.kernel.org,
	intel-xe@lists.freedesktop.org, xen-devel@lists.xenproject.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Andy Yan <andyshrk@163.com>
Subject: Re: [PATCH v2 25/25] drm/xlnx: Compute dumb-buffer sizes with drm_mode_size_dumb()
Date: Wed, 15 Jan 2025 15:33:16 +0200	[thread overview]
Message-ID: <f35cb350-6be9-48ca-ad7e-e9dd418281d5@ideasonboard.com> (raw)
In-Reply-To: <0ea6be58-0e04-4172-87cd-064a3e4a43bc@suse.de>

Hi,

On 15/01/2025 14:34, Thomas Zimmermann wrote:
> Hi
> 
> 
> Am 15.01.25 um 13:06 schrieb Tomi Valkeinen:
>> Hi,
>>
>> On 15/01/2025 13:37, Thomas Zimmermann wrote:
>>> Hi
>>>
>>>
>>> Am 15.01.25 um 11:58 schrieb Tomi Valkeinen:
>>> [...]
>>>>> These are all good points. Did you read my discussion with Andy on 
>>>>> patch 2? I think it resolves all the points you have. The current 
>>>>> CREATE_DUMB 
>>>>
>>>> I had missed the discussion, and, indeed, the patch you attached 
>>>> fixes the problem on Xilinx.
>>>
>>> Great. Thanks for testing.
>>>
>>>>
>>>>> ioctl is unsuited for anything but the simple RGB formats. The bpp 
>>>>
>>>> It's a bit difficult to use, but is it really unsuited? 
>>>> bitsperpixel, width and height do give an exact pitch and size, do 
>>>> they not? It does require the userspace to handle the subsampling 
>>>> and planes, though, so far from perfect.
>>>
>>> The bpp value sets the number of bits per pixel; except for bpp==15 
>>> (XRGB1555), where it sets the color depth. OR bpp is the color depth; 
>>> except for bpp==32 (XRGB8888), where it is the number of bits per 
>>> pixel. It's therefore best to interpret it like a color-mode enum.
>>
>> Ah, right... That's horrible =).
>>
>> And I assume it's not really possible to define the bpp to mean bits 
>> per pixel, except for a few special cases like 15?
>>
>> Why do we even really care about color depth here? We're just 
>> allocating memory. Doesn't DIV_ROUND_UP(args->bpp, SZ_8) work fine for 
>> XRGB1555 too?
> 
> Drivers always did that, but it does not work correctly for (bpp < 8). 
> As we already have helpers to deal with bpp, it makes sense to use 
> them.  This also aligns dumb buffers with the kernel's video= parameter, 
> which as the same odd semantics. The fallback that uses bpp directly 
> will hopefully be the exception.

Hmm, well... If we had a 64-bit RGB format in the list of "legacy fb 
formats", I wouldn't have noticed anything. And if I would just use 32 
as the bpp, and adjust width accordingly, it would also have worked. So, 
I expect the fallback to be an exception,

And by working I mean that I can run my apps fine, but the internal 
operation would sure be odd: allocating any YUV buffer will cause 
drm_mode_size_dumb() to get an RGB format from 
drm_driver_color_mode_format(), and get a drm_format_info_min_pitch() 
for an RGB format.

>>>> So, I'm all for a new ioctl, but I don't right away see why the 
>>>> current ioctl couldn't be used. Which makes me wonder about the 
>>>> drm_warn() in your patch, and the "userspace throws in arbitrary 
>>>> values for bpp and relies on the kernel to figure it out". Maybe I'm 
>>>> missing something here.
>>>
>>> I was unsure about the drm_warn() as well. It's not really wrong to 
>>> have odd bpp values, but handing in an unknown bpp value might point 
>>> to a user-space error. At least there should be a drm_dbg().
>>>
>>>>
>>>>> parameter is not very precise. The solution would be a new ioctl 
>>>>> call that receives the DRM format and returns a buffer for each 
>>>>> individual plane.
>>>>
>>>> Yes, I think that makes sense. That's a long road, though =). So my 
>>>> question is, is CREATE_DUMB really unsuitable for other than simple 
>>>> RGB formats, or can it be suitable if we just define how the 
>>>> userspace should use it for multiplanar, subsampled formats?
>>>
>>> That would duplicate format and hardware information in user-space. Some 
>>
>> But we already have that, don't we? We have drivers and userspace that 
>> support, say, NV12 via dumb buffers. But (correct me if I'm wrong) we 
>> don't document how CREATE_DUMB has to be used to allocate multiplanar 
>> subsampled buffers, so the userspace devs have to "guess".
> 
> Yeah, there are constrains in the scanline and buffer alignments and 
> orientation. And if we say that bpp==12 means NV12, it will be a problem 
> for all other cases where bpp==12 makes sense.

I feel I still don't quite understand. Can't we define and document 
CREATE_DUMB like this:

If (bpp < 8 || is_power_of_two(bpp))
	bpp means bitsperpixel
	pitch is args->width * args->bpp / 8, aligned up to driver-specific-align
else
	bpp is a legacy parameter, and we deal with it case by case.
	list the cases and what they mean

And describe that when allocating subsampled buffers, the caller must 
adjust the width and height accordingly. And that the bpp and width can 
also refer to pixel groups.

Or if the currently existing code prevents the above for 16 and 32 bpps, 
how about defining that any non-RGB or not-simple buffer has to be 
allocated with bpp=8, and the userspace has to align the pitch correctly 
according to the format and platform's hw restrictions?

  Tomi


  reply	other threads:[~2025-01-15 13:33 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 14:56 [PATCH v2 00/25] drm/dumb-buffers: Fix and improve buffer-size calculation Thomas Zimmermann
2025-01-09 14:56 ` [PATCH v2 01/25] drm/dumb-buffers: Sanitize output on errors Thomas Zimmermann
2025-01-09 14:56 ` [PATCH v2 02/25] drm/dumb-buffers: Provide helper to set pitch and size Thomas Zimmermann
2025-01-10  1:49   ` Andy Yan
2025-01-10 13:23     ` [PATCH " Thomas Zimmermann
2025-01-13  3:53       ` Andy Yan
2025-01-13  7:52         ` Thomas Zimmermann
2025-01-09 14:56 ` [PATCH v2 03/25] drm/gem-dma: Compute dumb-buffer sizes with drm_mode_size_dumb() Thomas Zimmermann
2025-01-09 14:56 ` [PATCH v2 04/25] drm/gem-shmem: " Thomas Zimmermann
2025-01-09 14:56 ` [PATCH v2 05/25] drm/gem-vram: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 06/25] drm/armada: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 07/25] drm/exynos: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 08/25] drm/gma500: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 09/25] drm/hibmc: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 10/25] drm/imx/ipuv3: " Thomas Zimmermann
2025-01-10  8:06   ` Philipp Zabel
2025-01-09 14:57 ` [PATCH v2 11/25] drm/loongson: " Thomas Zimmermann
2025-01-15  3:50   ` Sui Jingfeng
2025-01-09 14:57 ` [PATCH v2 12/25] drm/mediatek: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 13/25] drm/msm: " Thomas Zimmermann
2025-01-13  8:25   ` Dmitry Baryshkov
2025-01-09 14:57 ` [PATCH v2 14/25] drm/nouveau: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 15/25] drm/omapdrm: " Thomas Zimmermann
2025-01-14 14:04   ` Tomi Valkeinen
2025-01-09 14:57 ` [PATCH v2 16/25] drm/qxl: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 17/25] drm/renesas/rcar-du: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 18/25] drm/renesas/rz-du: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 19/25] drm/rockchip: " Thomas Zimmermann
2025-01-09 22:59   ` Heiko Stübner
2025-01-09 14:57 ` [PATCH v2 20/25] drm/tegra: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 21/25] drm/virtio: " Thomas Zimmermann
2025-02-20 16:10   ` Dmitry Osipenko
2025-01-09 14:57 ` [PATCH v2 22/25] drm/vmwgfx: " Thomas Zimmermann
2025-01-10 18:18   ` Zack Rusin
2025-01-09 14:57 ` [PATCH v2 23/25] drm/xe: " Thomas Zimmermann
2025-01-09 16:05   ` Matthew Auld
2025-01-09 16:26     ` Thomas Zimmermann
2025-01-09 17:15       ` Matthew Auld
2025-01-09 14:57 ` [PATCH v2 24/25] drm/xen: " Thomas Zimmermann
2025-01-09 14:57 ` [PATCH v2 25/25] drm/xlnx: " Thomas Zimmermann
2025-01-15 10:13   ` Tomi Valkeinen
2025-01-15 10:26     ` Thomas Zimmermann
2025-01-15 10:58       ` Tomi Valkeinen
2025-01-15 11:37         ` Thomas Zimmermann
2025-01-15 12:06           ` Tomi Valkeinen
2025-01-15 12:34             ` Thomas Zimmermann
2025-01-15 13:33               ` Tomi Valkeinen [this message]
2025-01-15 13:45                 ` Thomas Zimmermann
2025-01-15 14:20                   ` Tomi Valkeinen
2025-01-15 14:34                     ` Daniel Stone
2025-01-16  8:43                       ` Laurent Pinchart
2025-01-16  9:38                         ` Laurent Pinchart
2025-01-16 10:07                           ` Tomi Valkeinen
2025-01-19 17:08                             ` Laurent Pinchart
2025-01-16  8:09                     ` Thomas Zimmermann
2025-01-16 10:03                       ` Tomi Valkeinen
2025-01-16 10:17                         ` Geert Uytterhoeven
2025-01-16 10:26                           ` Tomi Valkeinen
2025-01-16 10:35                           ` Dmitry Baryshkov
2025-01-16 12:24                             ` Daniel Stone
2025-01-19 11:29                             ` Sui Jingfeng
2025-01-19 12:18                               ` Tomi Valkeinen
2025-01-19 14:59                                 ` Sui Jingfeng
2025-01-19 15:22                                   ` Tomi Valkeinen
2025-01-19 16:26                                     ` Sui Jingfeng
2025-01-19 20:14                                       ` Laurent Pinchart
2025-01-20  7:04                                         ` Sui Jingfeng
2025-01-20  3:34                           ` Sui Jingfeng
2025-01-20  7:49                         ` Thomas Zimmermann
2025-01-20  8:51                           ` Tomi Valkeinen
2025-01-20  8:57                             ` Thomas Zimmermann
2025-01-20  7:54                         ` Thomas Zimmermann

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=f35cb350-6be9-48ca-ad7e-e9dd418281d5@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andyshrk@163.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=imx@lists.linux.dev \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=simona@ffwll.ch \
    --cc=spice-devel@lists.freedesktop.org \
    --cc=tzimmermann@suse.de \
    --cc=virtualization@lists.linux.dev \
    --cc=xen-devel@lists.xenproject.org \
    /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