All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Figa <tfiga@chromium.org>
To: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Cc: Ezequiel Garcia <ezequiel@collabora.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>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Subject: Re: [RFC] Request API and V4L2 capabilities
Date: Wed, 29 Aug 2018 13:25:28 +0900	[thread overview]
Message-ID: <CAAFQd5AU0dEJSdj741qDR4pQf6d56t8R=tCYScrvG0+AcLK67g@mail.gmail.com> (raw)
In-Reply-To: <0f947768d8e982fcc591112c43cf40d618df2233.camel@bootlin.com>

On Thu, Aug 23, 2018 at 5:05 PM Paul Kocialkowski
<paul.kocialkowski@bootlin.com> wrote:
>
> Hi,
>
> On Wed, 2018-08-22 at 14:33 -0300, Ezequiel Garcia wrote:
> > On Wed, 2018-08-22 at 16:10 +0200, Paul Kocialkowski wrote:
> > > Hi,
> > >
> > > On Tue, 2018-08-21 at 17:52 +0900, Tomasz Figa wrote:
> > > > Hi Hans, Paul,
> > > >
> > > > On Mon, Aug 6, 2018 at 6:29 PM Paul Kocialkowski
> > > > <paul.kocialkowski@bootlin.com> wrote:
> > > > >
> > > > > On Mon, 2018-08-06 at 11:23 +0200, Hans Verkuil wrote:
> > > > > > On 08/06/2018 11:13 AM, Paul Kocialkowski wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > On Mon, 2018-08-06 at 10:32 +0200, Hans Verkuil wrote:
> > > > > > > > On 08/06/2018 10:16 AM, Paul Kocialkowski wrote:
> > > > > > > > > On Sat, 2018-08-04 at 15:50 +0200, Hans Verkuil wrote:
> > > > > > > > > > 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'm not sure this is entirely true. The hardware may need to be
> > > > explicitly told what profile the video is. It may even not be the
> > > > hardware, but the driver itself too, given that the profile may imply
> > > > the CAPTURE pixel format, e.g. for VP9 profiles:
> > > >
> > > > profile 0
> > > > color depth: 8 bit/sample, chroma subsampling: 4:2:0
> > > > profile 1
> > > > color depth: 8 bit, chroma subsampling: 4:2:0, 4:2:2, 4:4:4
> > > > profile 2
> > > > color depth: 10–12 bit, chroma subsampling: 4:2:0
> > > > profile 3
> > > > color depth: 10–12 bit, chroma subsampling: 4:2:0, 4:2:2, 4:4:4
> > > >
> > > > (reference: https://en.wikipedia.org/wiki/VP9#Profiles)
> > >
> > > I think it would be fair to expect userspace to select the right
> > > destination format (and maybe have the driver error if there's a
> > > mismatch with the meta-data) instead of having the driver somewhat
> > > expose what format should be used.
> > >
> > > But maybe this would be an API violation, since all the enumerated
> > > formats are probably supposed to be selectable?
> > >
> > > We could also look at it the other way round and consider that selecting
> > > an exposed format is always legit, but that it implies passing a
> > > bitstream that matches it or the driver will error (because of an
> > > invalid bitstream passed, not because of a "wrong" selected format).
> > >
> >
> > The API requires the user to negotiate via TRY_FMT/S_FMT. The driver
> > usually does not return error on invalid formats, and simply return
> > a format it can work with. I think the kernel-user contract has to
> > guarantee if the driver accepted a given format, it won't fail to
> > encoder or decode.
>
> Well, the issue here is that in order to correctly enumerate the
> formats, the driver needs to be aware of:
> 1. in what destination format the bitstream data is decoded to;
> 2. what format convesions the VPU can do.
>
> Step 1 is known by userspace but is only passed to the driver with the
> bitstream metadata from controls. This is much too late for trimming the
> list of supported formats.

That's not true. See my previous reply. The user space only knows the
physical representation of samples in the stream, i.e. YUV 4:2:0 or
4:2:2. It doesn't know anything about hardware constraints on the
memory representation.

>
> I'm not sure that passing an extra information to the driver early to
> trim the list would make sense, because it comes to down to telling the
> driver what format to target and then asking the driver was format it
> supports, which is rather redundant.
>
> I think the information we need to expose to userspace is whether the
> driver supports a destination format that does not match the bitstream
> format. We could make it part of the spec that, by lack of this
> indication, the provided bitstream is expected to match the format that
> was selected.
>
> > I think that's why it makes sense for stateless drivers to set the
> > profile/levels for a given job, in order to properly negotiate
> > the input and output formats (for both encoders and decoders).
>
> I still fail to follow this logic. As far as I understood, profile/level
> are indications of hardware capabilities required to decode the video,
> not an indication of the precise features selected for decoding,
> especially when it comes the format. As Tomasz mentionned in the
> previous email, various formats may be supported by the same profile, so
> setting the profile/level does not indicate which format is appropriate
> for decoding the bitstream.

Indeed, after thinking a bit more about this, profile/levels alone are
not a good indicator for this. I'm afraid we may need an
initialization sequence that involves user space providing to the
driver any necessary state needed for it to determine the exact set of
supported memory representations (pixel formats).

Best regards,
Tomasz

  parent reply	other threads:[~2018-08-29  8:20 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 [this message]
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
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='CAAFQd5AU0dEJSdj741qDR4pQf6d56t8R=tCYScrvG0+AcLK67g@mail.gmail.com' \
    --to=tfiga@chromium.org \
    --cc=ezequiel@collabora.com \
    --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 \
    /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.