Re: [PATCH] media: cedrus: Convert to MPLANE uAPI
From: Nicolas Dufresne
Date: Tue Dec 06 2022 - 14:15:45 EST
Le mardi 06 décembre 2022 à 20:23 +0800, Chen-Yu Tsai a écrit :
> On Tue, Dec 6, 2022 at 4:35 PM Hans Verkuil <hverkuil-cisco@xxxxxxxxx> wrote:
> >
> > On 05/12/2022 22:01, Jernej Škrabec wrote:
> > > Hi Chen-Yu!
> > >
> > > Dne torek, 29. november 2022 ob 08:45:30 CET je Chen-Yu Tsai napisal(a):
> > > > The majority of the V4L2 stateless video decoder drivers use the MPLANE
> > > > interface.
> > > >
> > > > On the userspace side, Gstreamer supports non-MPLANE and MPLANE
> > > > interfaces. Chromium only supports the MPLANE interface, and is not yet
> > > > usable with standard desktop Linux. FFmpeg support for either has not
> > > > landed.
> > >
> > > I don't like fixing userspace issues in kernel, if kernel side works fine.
> > > Implementing missing non-MPLANE support in Chromium will also allow it to work
> > > with older kernels.
> > >
> > > Hans, what's linux-media politics about such changes?
> >
> > Not keen on this. Does the cedrus HW even have support for multiple planes?
> > I suspect not, in which case the driver shouldn't suggest that it can do that.
Hi Hans,
> >
> > Now, if the hardware *can* support this, then there is an argument to be made
> > for the cedrus driver to move to the multiplanar API before moving it out
> > of staging to allow such future enhancements.
>
> AFAIK it can, but has some limitations on how far apart the buffers for
> the separate planes can be. Nicolas mentioned that I could support the
> multiplanar API, but only allow the contiguous single planar formats,
> so NV12 instead of NV12M.
indeed, MPLANE buffer API is not an advertisement for MPLANE support. The pixel
formats exposed through ENUM_FMT are the only possible advertisement, and only
single allocation format (NV12) remains exposed.
Putting my userspace hat on, I see see an effort by the author of MPLANE API to
make it so it would completely replaced the older API. The effort have imho very
bad consequences (duplication of pixel formats), but if we also don't enforce
porting existing drivers to the new API, we add yet another consequence, but
this time on userspace, which must handle both C structures to actually work
generically. I totally understand that from driver maintainer point of view,
this change have absolutely no value, but we force userspace complexity simply
because we leave it to driver author to pick older or newer (totally equivalent)
APIs. To me, the problem is that V4L2 API maintainers didn't adopt the new API
despite merging it. The adoption should have deprecated usage of the old API, at
least in new drivers (since 2011). This should also have been an unstaging
requirement.
regards,
Nicolas
>
> And I suspect that reference frames have to be contiguous as well.
> So I guess the overall answer is that it can't. But the same goes for
> Hantro or rkvdec, which both use the multiplanar API.
>
> This conversion was done so that I could use Cedrus as a testbed for
> developing new codec support, as I already own an H6 device. Added
> bonus is trying to get V4L2 decoder support to work for desktop Linux,
> without the libraries that ChromeOS ships.
>
> > Note that you have to choose whether to support single or multiplanar, you
> > can't support both at the same time.
> >
> > So the decision to move to multiplanar should be led by the HW capabilities.
> >
> > And Chromium really needs to support non-multiplanar formats as well. I'm
> > really surprised to hear that it doesn't, to be honest.
>
> Chromium does support non-multiplanar formats, such as NV12. In fact
> this is the preferred format, unless it's on MediaTek, in which it
> switches to MM21 as the capture format, and does untiling in software.
> This support for formats is separate from using the multiplanar API.
>
> Support for video decoders is mostly driven by ChromeOS. Currently all the
> hardware ChromeOS supports, be it stateful or stateless, use the multiplanar
> API, so there hasn't been a real need to support it yet.
>
>
> Regards
> ChenYu
>
> > Regards,
> >
> > Hans
> >
> > >
> > > Best regards,
> > > Jernej
> > >
> > > >
> > > > A fallback route using libv4l is also available. The library translates
> > > > MPLANE interface ioctl calls to non-MPLANE ones, provided that the pixel
> > > > format used is single plane.
> > > >
> > > > Convert the Cedrus driver to the MPLANE interface, while keeping the
> > > > supported formats single plane. Besides backward compatibility through
> > > > the plugin, the hardware requires that different planes not be located
> > > > too far apart in memory. Keeping the single plane pixel format makes
> > > > this easy to enforce.
> > > >
> > > > Signed-off-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>
> > > > ---
> > > >
> > > > This has been tested with Fluster. The score remained the same with or
> > > > without the patch. This also helps with getting VP8 decoding working
> > > > with Chromium's in-tree test program "video_decode_accelerator_tests",
> > > > though Chromium requires other changes regarding buffer allocation and
> > > > management.
> > >
> > >
> >