All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas@ndufresne.ca>
To: Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Tomasz Figa <tfiga@chromium.org>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Subject: Re: [RFC] Request API and V4L2 capabilities
Date: Wed, 22 Aug 2018 13:53:25 -0400	[thread overview]
Message-ID: <016dea64f7d373699b2c169e55219d2ba029ab16.camel@ndufresne.ca> (raw)
In-Reply-To: <1b16fd04fb9731b001353d58daa2d1050b02b1df.camel@bootlin.com>

[-- Attachment #1: Type: text/plain, Size: 8397 bytes --]

Le mercredi 22 août 2018 à 16:52 +0200, Paul Kocialkowski a écrit :
> Hi,
> 
> On Wed, 2018-08-15 at 09:57 -0400, Nicolas Dufresne wrote:
> > Le lundi 06 août 2018 à 10:16 +0200, Paul Kocialkowski a écrit :
> > > Hi Hans and all,
> > > 
> > > On Sat, 2018-08-04 at 15:50 +0200, Hans Verkuil wrote:
> > > > Hi all,
> > > > 
> > > > While the Request API patch series addresses all the core API issues, there
> > > > are some high-level considerations as well:
> > > > 
> > > > 1) How can the application tell that the Request API is supported and for
> > > >    which buffer types (capture/output) and pixel formats?
> > > > 
> > > > 2) How can the application tell if the Request API is required as opposed to being
> > > >    optional?
> > > > 
> > > > 3) Some controls may be required in each request, how to let userspace know this?
> > > >    Is it even necessary to inform userspace?
> > > > 
> > > > 4) (For bonus points): How to let the application know which streaming I/O modes
> > > >    are available? That's never been possible before, but it would be very nice
> > > >    indeed if that's made explicit.
> > > 
> > > Thanks for bringing up these considerations and questions, which perhaps
> > > cover the last missing bits for streamlined use of the request API by
> > > userspace. I would suggest another item, related to 3):
> > > 
> > > 5) How can applications tell whether the driver supports a specific
> > > codec profile/level, not only for encoding but also for decoding? It's
> > > common for low-end embedded hardware to not support the most advanced
> > > profiles (e.g. H264 high profile).
> > 
> > Hi Paul, after some discussion with Philip, he sent a proposal patch
> > that enables profile/level extended CID support to decoders too. The
> > control is made read-only, the point is not really the CID get/set but
> > that the controls allow enumerating the supported values. This seems
> > quite straightforward and easy to use.
> > 
> > This enumeration is already provided this way some of the existing
> > sate-full encoders. 
> 
> Sounds great, thanks for looking into it! I looked for the patch in the
> list, but couldn't find it off-hand. Do you have a link to it? I would
> like to bind it to the Cedrus VPU driver eventually.

I believe it is that one:
https://patchwork.kernel.org/patch/10494379/



> 
> Cheers,
> 
> Paul
> 
> > > > Since the Request API associates data with frame buffers it makes sense to expose
> > > > this as a new capability field in struct v4l2_requestbuffers and struct v4l2_create_buffers.
> > > > 
> > > > The first struct has 2 reserved fields, the second has 8, so it's not a problem to
> > > > take one for a capability field. Both structs also have a buffer type, so we know
> > > > if this is requested for a capture or output buffer type. The pixel format is known
> > > > in the driver, so HAS/REQUIRES_REQUESTS can be set based on that. I doubt we'll have
> > > > drivers where the request caps would actually depend on the pixel format, but it
> > > > theoretically possible. For both ioctls you can call them with count=0 at the start
> > > > of the application. REQBUFS has of course the side-effect of deleting all buffers,
> > > > but at the start of your application you don't have any yet. CREATE_BUFS has no
> > > > side-effects.
> > > 
> > > My initial thoughts on this point were to have flags exposed in
> > > v4l2_capability, but now that you're saying it, it does make sense for
> > > the flag to be associated with a buffer rather than the global device.
> > > 
> > > In addition, I've heard of cases (IIRC it was some Rockchip platforms)
> > > where the platform has both stateless and stateful VPUs (I think it was
> > > stateless up to H264 and stateful for H265). This would allow supporting
> > > these two hardware blocks under the same video device (if that makes
> > > sense anyway). And even if there's no immediate need, it's always good
> > > to have this level of granularity (with little drawbacks).
> > > 
> > > > I propose adding these capabilities:
> > > > 
> > > > #define V4L2_BUF_CAP_HAS_REQUESTS	0x00000001
> > > > #define V4L2_BUF_CAP_REQUIRES_REQUESTS	0x00000002
> > > > #define V4L2_BUF_CAP_HAS_MMAP		0x00000100
> > > > #define V4L2_BUF_CAP_HAS_USERPTR	0x00000200
> > > > #define V4L2_BUF_CAP_HAS_DMABUF		0x00000400
> > > > 
> > > > If REQUIRES_REQUESTS is set, then HAS_REQUESTS is also set.
> > > > 
> > > > At this time I think that REQUIRES_REQUESTS would only need to be set for the
> > > > output queue of stateless codecs.
> > > > 
> > > > If capabilities is 0, then it's from an old kernel and all you know is that
> > > > requests are certainly not supported, and that MMAP is supported. Whether USERPTR
> > > > or DMABUF are supported isn't known in that case (just try it :-) ).
> > > 
> > > Sounds good to me!
> > > 
> > > > Strictly speaking we do not need these HAS_MMAP/USERPTR/DMABUF caps, but it is very
> > > > easy to add if we create a new capability field anyway, and it has always annoyed
> > > > the hell out of me that we didn't have a good way to let userspace know what
> > > > streaming I/O modes we support. And with vb2 it's easy to implement.
> > > 
> > > I totally agree here, it would be very nice to take the occasion to
> > > expose to userspace what I/O modes are available. The current try-and-
> > > see approach works, but this feels much better indeed.
> > > 
> > > > Regarding point 3: I think this should be documented next to the pixel format. I.e.
> > > > the MPEG-2 Slice format used by the stateless cedrus codec requires the request API
> > > > and that two MPEG-2 controls (slice params and quantization matrices) must be present
> > > > in each request.
> > > > 
> > > > I am not sure a control flag (e.g. V4L2_CTRL_FLAG_REQUIRED_IN_REQ) is needed here.
> > > > It's really implied by the fact that you use a stateless codec. It doesn't help
> > > > generic applications like v4l2-ctl or qv4l2 either since in order to support
> > > > stateless codecs they will have to know about the details of these controls anyway.
> > > > 
> > > > So I am inclined to say that it is not necessary to expose this information in
> > > > the API, but it has to be documented together with the pixel format documentation.
> > > 
> > > I think this is affected by considerations about codec profile/level
> > > support. More specifically, some controls will only be required for
> > > supporting advanced codec profiles/levels, so they can only be
> > > explicitly marked with appropriate flags by the driver when the target
> > > profile/level is known. And I don't think it would be sane for userspace
> > > to explicitly set what profile/level it's aiming at. As a result, I
> > > don't think we can explicitly mark controls as required or optional.
> > > 
> > > I also like the idea that it should instead be implicit and that the
> > > documentation should detail which specific stateless metadata controls
> > > are required for a given profile/level.
> > > 
> > > As for controls validation, the approach followed in the Cedrus driver
> > > is to check that the most basic controls are filled and allow having
> > > missing controls for those that match advanced profiles.
> > > 
> > > Since this approach feels somewhat generic enough to be applied to all
> > > stateless VPU drivers, maybe this should be made a helper in the
> > > framework?
> > > 
> > > In addition, I see a need for exposing the maximum profile/level that
> > > the driver supports for decoding. I would suggest reusing the already-
> > > existing dedicated controls used for encoding for this purpose. For
> > > decoders, they would be used to expose the (read-only) maximum
> > > profile/level that is supported by the hardware and keep using them as a
> > > settable value in a range (matching the level of support) for encoders.
> > > 
> > > This is necessary for userspace to determine whether a given video can
> > > be decoded in hardware or not. Instead of half-way decoding the video
> > > (ending up in funky results), this would easily allow skipping hardware
> > > decoding and e.g. falling back on software decoding.
> > > 
> > > What do you think?
> > > 
> > > Cheers,
> > > 
> > > Paul
> > > 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2018-08-22 21:19 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04 13:50 [RFC] Request API and V4L2 capabilities Hans Verkuil
2018-08-06  8:16 ` Paul Kocialkowski
2018-08-06  8:32   ` Hans Verkuil
2018-08-06  9:13     ` Paul Kocialkowski
2018-08-06  9:23       ` Hans Verkuil
2018-08-06  9:29         ` Paul Kocialkowski
2018-08-21  8:52           ` Tomasz Figa
2018-08-22 14:10             ` Paul Kocialkowski
2018-08-22 17:33               ` Ezequiel Garcia
2018-08-23  8:05                 ` Paul Kocialkowski
2018-08-23 17:33                   ` Nicolas Dufresne
2018-08-29  4:30                     ` Tomasz Figa
2018-08-30  7:33                       ` Hans Verkuil
2018-08-29  4:25                   ` Tomasz Figa
2018-08-29  4:21               ` Tomasz Figa
2018-08-15 12:51       ` Maxime Jourdan
2018-08-22 13:21         ` Paul Kocialkowski
2018-08-22 13:53           ` Tomasz Figa
2018-08-21  9:34     ` Tomasz Figa
2018-08-15 13:57   ` Nicolas Dufresne
2018-08-22 14:52     ` Paul Kocialkowski
2018-08-22 17:53       ` Nicolas Dufresne [this message]
2018-08-15 14:03   ` Hans Verkuil
2018-08-07  4:05 ` Ezequiel Garcia
2018-08-15 12:11 ` Mauro Carvalho Chehab
2018-08-15 14:18   ` Hans Verkuil
2018-08-21  9:15     ` Tomasz Figa
2018-08-22  3:55       ` Alexandre Courbot
2018-08-15 14:37   ` Nicolas Dufresne
2018-08-15 14:27 ` Nicolas Dufresne
2018-08-23 14:31 ` Hans Verkuil
2018-08-23 17:37   ` Nicolas Dufresne
2018-08-24  7:29     ` Hans Verkuil
2018-08-24  9:00       ` Paul Kocialkowski
2018-08-29  4:31       ` Tomasz Figa

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=016dea64f7d373699b2c169e55219d2ba029ab16.camel@ndufresne.ca \
    --to=nicolas@ndufresne.ca \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=mchehab@kernel.org \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tfiga@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.