Re: [RFC PATCH v6 02/11] media: v4l2: Extend pixel formats to unify single/multi-planar handling (and more)

Nicolas Dufresne
2022-11-15T16:20:17Z

Le vendredi 11 novembre 2022 à 17:54 +0900, Tomasz Figa a écrit :
> > > I feel like this would be only useful in the MMAP mode. Looking at how
> > > the other UAPIs are evolving, things are going towards
> > > userspace-managed allocations, using, for example, DMA-buf heaps. I
> > > think we should follow the trend and keep the MMAP mode just at the
> > > same level of functionality as is today and focus on improvements and
> > > new functionality for the DMABUF mode.
> >
> > I agree, but we will need an API to expose the memory constraints of the
> > device, or userspace won't be able to allocate memory compatible with
> > the hardware or driver requirements.
>
> Yes, I fully agree and that's why I think we should rather focus our
> efforts in that direction rather than expanding the existing MMAP
> capabilities.

I was once told that MMAP was mandatory to support in v4l2 drivers. I'd like to
get some clarification on the subject for sure. We can't break compat, unless we
spin v4l3 here.

One thing that come to mind, is that its not true that a V4L2 driver can always
be importer only. For cards like Xplorer X1600P PCIe Accelerator [1] from Blaize
(they are using a modified, but still generic, Hantro Driver), the CODECs memory
should be allocated on the card for best performance. Only the driver is aware
that there is memory on that card, and so it must export the buffers.

In a DMABuf import only future, that basically means the driver must implement a
DMABuf HEAP driver, and to make this usable by generic software, the constraints
API need to support telling userspace that this Heap is to be used. This gap
easily extend to DRM, which have per driver API to allocate memory, and in some
cases these API must be used (they don't have heaps for on-card memory
allocation). When this is happening inside the GFX stack, it works very well,
but when you need to integrate this with some V4L2 driver, its not really
practical and requires something like minigbm/gralloc, which is non-generic.

[1] https://www.blaize.com/products/ai-edge-computing-platforms/