All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Dafna Hirschfeld <dafna3@gmail.com>,
	linux-media@vger.kernel.org, helen.koike@collabora.com,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>
Subject: Re: [PATCH v5 02/23] videodev2.h: add V4L2_BUF_CAP_REQUIRES_REQUESTS
Date: Wed, 20 Mar 2019 10:09:58 -0300	[thread overview]
Message-ID: <20190320100958.019fb382@coco.lan> (raw)
In-Reply-To: <10b33081-7b79-bae9-6325-1904d76f3717@xs4all.nl>

Em Wed, 20 Mar 2019 13:41:42 +0100
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 3/20/19 1:37 PM, Mauro Carvalho Chehab wrote:
> > Em Wed, 20 Mar 2019 13:20:07 +0100
> > Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> >   
> >>>> The only affected driver is the staging cedrus driver. And that will
> >>>> actually crash if you try to use it without requests.
> >>>>
> >>>> If you look at patch 3 you'll see that it just sets the flag and doesn't
> >>>> remove any code that was supposed to check for use-without-requests.
> >>>> That's because there never was a check and the driver would just crash.
> >>>>
> >>>> So we're safe here.    
> >>>
> >>> Making it mandatory for the cedrus driver makes sense, but no other
> >>> current driver should ever use it.     
> >>
> >> The only other drivers that implement the request API are vivid and vim2m.
> >>
> >> For both the request API is optional.
> >>
> >> And of course this patch series that adds the stateless decoder support to
> >> vicodec, so vicodec is the only other driver besides the cedrus driver that
> >> sets this flag.  
> > 
> > The current vicodec implementation is only stateless?  
> 
> vicodec before this series is only stateful. After this series a new video node
> is added which is for the stateless decoder. And that device will require
> requests.

I see. see below.

> 
> >   
> >>> The problem I see is that, as we advance on improving the requests API,
> >>> non-stateless-codec drivers may end supporting the request API. 
> >>> That's perfectly fine, but such other drivers should *never* be
> >>> changed to use V4L2_BUF_CAP_REQUIRES_REQUESTS. This also applies to any
> >>> new driver that it is not implementing a stateless codec.
> >>>
> >>> Btw, as this seems to be a requirement only for stateless codec drivers,
> >>> perhaps we should (at least in Kernelspace) to use, instead, a
> >>> V4L2_BUF_CAP_STATELESS_CODEC_ONLY flag, with the V4L2 core would
> >>> translate it to V4L2_BUF_CAP_REQUIRES_REQUESTS before returning it to
> >>> userspace, and have a special #ifdef at the userspace header, in order
> >>> to prevent this flag to be set directly by a random driver.    
> >>
> >> I don't think this makes sense. Requiring requests is not something you
> >> can miss since you have to code for it.
> >>
> >> However, there is something else that we need to think about and that is
> >> that V4L2_BUF_CAP_REQUIRES_REQUESTS can be format specific. E.g. a stateless
> >> codec driver can also support a JPEG codec, and for that format requests
> >> are most likely not required at all. So this capability might actually be
> >> format-specific.  
> > 
> > Yes, on formats that don't have temporal compression, there's no sense
> > to make request API mandatory.
> > 
> > For formats that have temporal compression, the codec driver can either 
> > be stateless or stateful (or even support both modes).
> > 
> > It sounds to me that a flag like that should be returned by S_FMT and
> > TRY_FMT or on a separate ioctl.
> > 
> > It also seems to make sense if userspace could select between stateless
> > and stateful modes, if the driver supports both modes for the same
> > fourcc.  
> 
> That can't happen. The stateless formats have their own fourcc. It really
> is a different format.

Well, if we're already defining different fourcc for the stateless
codecs, then I think that your proposed patch:

	[PATCH v5.1 2/2] cedrus: set requires_requests

Is not the best way to implement it.

	Instead, I would have a helper function like:

static int v4l2_format_requires_request_api(uint32 fourcc)
{
	switch(fourcc) {
	case V4L2_PIX_FMT_MPEG2_SLICE:
		return 1;
	default:
		return 0;
	}
}

called by V4L2 core at S_FMT handler in order to set vq->requires_requests.

Also, in this case, I would add a V4L2_FMT_FLAG_REQUIRE_REQUEST_API or
V4L2_FMT_FLAG_STATELESS_CODEC flag at VIDIOC_ENUM_FMT in order to
indicate it.

Thanks,
Mauro

  reply	other threads:[~2019-03-20 13:10 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06 21:13 [PATCH v5 00/23] support for stateless decoder Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 01/23] vb2: add requires_requests bit for stateless codecs Dafna Hirschfeld
2019-03-12 15:29   ` Paul Kocialkowski
2019-03-20 10:21   ` Mauro Carvalho Chehab
2019-03-20 10:45     ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 02/23] videodev2.h: add V4L2_BUF_CAP_REQUIRES_REQUESTS Dafna Hirschfeld
2019-03-12 15:29   ` Paul Kocialkowski
2019-03-20 10:11   ` Mauro Carvalho Chehab
2019-03-20 10:39     ` Hans Verkuil
2019-03-20 11:42       ` Mauro Carvalho Chehab
2019-03-20 12:20         ` Hans Verkuil
2019-03-20 12:37           ` Mauro Carvalho Chehab
2019-03-20 12:41             ` Hans Verkuil
2019-03-20 13:09               ` Mauro Carvalho Chehab [this message]
2019-03-06 21:13 ` [PATCH v5 03/23] cedrus: set requires_requests Dafna Hirschfeld
2019-03-12 15:32   ` Paul Kocialkowski
2019-03-13 14:59     ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 04/23] media: vicodec: selection api should only check single buffer types Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 05/23] media: vicodec: upon release, call m2m release before freeing ctrl handler Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 06/23] media: v4l2-ctrl: v4l2_ctrl_request_setup returns with error upon failure Dafna Hirschfeld
2019-03-12 15:40   ` Paul Kocialkowski
2019-03-06 21:13 ` [PATCH v5 07/23] media: vicodec: change variable name for the return value of v4l2_fwht_encode Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 08/23] media: vicodec: bugfix - call v4l2_m2m_buf_copy_metadata also if decoding fails Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 09/23] media: vicodec: bugfix: free compressed_frame upon device release Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 10/23] media: vicodec: Move raw frame preparation code to a function Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 11/23] media: vicodec: add field 'buf' to fwht_raw_frame Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 12/23] media: vicodec: keep the ref frame according to the format in decoder Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 13/23] media: vicodec: Validate version dependent header values in a separate function Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 14/23] media: vicodec: rename v4l2_fwht_default_fmt to v4l2_fwht_find_nth_fmt Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 15/23] media: vicodec: Handle the case that the reference buffer is NULL Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 16/23] media: vicodec: add struct for encoder/decoder instance Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 17/23] media: vicodec: add documentation to V4L2_CID_FWHT_I/P_FRAME_QP Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 18/23] media: vicodec: add documentation to V4L2_CID_MPEG_VIDEO_FWHT_PARAMS Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 19/23] media: vicodec: add documentation to V4L2_PIX_FMT_FWHT_STATELESS Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 20/23] media: vicodec: Introducing stateless fwht defs and structs Dafna Hirschfeld
2019-03-13 14:42   ` [PATCH v5 24/23] v4l2-ioctl.c: add V4L2_PIX_FMT_FWHT_STATELESS to v4l_fill_fmtdesc Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 21/23] media: vicodec: Register another node for stateless decoder Dafna Hirschfeld
2019-03-13 14:38   ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 22/23] media: vicodec: Add support " Dafna Hirschfeld
2019-03-13 14:37   ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 23/23] media: vicodec: set pixelformat to V4L2_PIX_FMT_FWHT_STATELESS " Dafna Hirschfeld

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=20190320100958.019fb382@coco.lan \
    --to=mchehab+samsung@kernel.org \
    --cc=dafna3@gmail.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.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.