LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Ezequiel Garcia <ezequiel@collabora.com>, linux-media@vger.kernel.org
Cc: kernel@collabora.com,
Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
Shuah Khan <shuahkh@osg.samsung.com>,
Pawel Osciak <pawel@osciak.com>,
Alexandre Courbot <acourbot@chromium.org>,
Sakari Ailus <sakari.ailus@iki.fi>,
Brian Starkey <brian.starkey@arm.com>,
linux-kernel@vger.kernel.org,
Gustavo Padovan <gustavo.padovan@collabora.com>
Subject: Re: [PATCH v10 08/16] v4l: mark unordered formats
Date: Wed, 23 May 2018 13:29:01 +0200 [thread overview]
Message-ID: <db537395-836a-3f6c-0039-1f4ed957f126@xs4all.nl> (raw)
In-Reply-To: <70b7ddaf685c2fc08dfd1caaab45bb0cc9c99a21.camel@collabora.com>
On 23/05/18 12:30, Ezequiel Garcia wrote:
> On Tue, 2018-05-22 at 13:55 +0200, Hans Verkuil wrote:
>> On 21/05/18 18:59, Ezequiel Garcia wrote:
>>> From: Gustavo Padovan <gustavo.padovan@collabora.com>
>>>
>>> Now that we've introduced the V4L2_FMT_FLAG_UNORDERED flag,
>>> mark the appropriate formats.
>>>
>>> v2: Set unordered flag before calling the driver callback.
>>>
>>> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
>>> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
>>> ---
>>> drivers/media/v4l2-core/v4l2-ioctl.c | 74 +++++++++++++++++++++++++++---------
>>> 1 file changed, 57 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
>>> index f48c505550e0..2135ac235a96 100644
>>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>>> @@ -1102,6 +1102,27 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
>>> return ops->vidioc_enum_output(file, fh, p);
>>> }
>>>
>>> +static void v4l_fill_unordered_fmtdesc(struct v4l2_fmtdesc *fmt)
>>> +{
>>> + switch (fmt->pixelformat) {
>>> + case V4L2_PIX_FMT_MPEG:
>>> + case V4L2_PIX_FMT_H264:
>>> + case V4L2_PIX_FMT_H264_NO_SC:
>>> + case V4L2_PIX_FMT_H264_MVC:
>>> + case V4L2_PIX_FMT_H263:
>>> + case V4L2_PIX_FMT_MPEG1:
>>> + case V4L2_PIX_FMT_MPEG2:
>>> + case V4L2_PIX_FMT_MPEG4:
>>> + case V4L2_PIX_FMT_XVID:
>>> + case V4L2_PIX_FMT_VC1_ANNEX_G:
>>> + case V4L2_PIX_FMT_VC1_ANNEX_L:
>>> + case V4L2_PIX_FMT_VP8:
>>> + case V4L2_PIX_FMT_VP9:
>>> + case V4L2_PIX_FMT_HEVC:
>>> + fmt->flags |= V4L2_FMT_FLAG_UNORDERED;
>>
>> Please add a break here. This prevents potential future errors if new cases
>> are added below this line.
>>
>
> Sure.
>
>>> + }
>>> +}
>>> +
>>> static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
>>> {
>>> const unsigned sz = sizeof(fmt->description);
>>> @@ -1310,61 +1331,80 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
>>>
>>> if (descr)
>>> WARN_ON(strlcpy(fmt->description, descr, sz) >= sz);
>>> - fmt->flags = flags;
>>> + fmt->flags |= flags;
>>> }
>>>
>>> -static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
>>> - struct file *file, void *fh, void *arg)
>>> -{
>>> - struct v4l2_fmtdesc *p = arg;
>>> - int ret = check_fmt(file, p->type);
>>>
>>> - if (ret)
>>> - return ret;
>>> - ret = -EINVAL;
>>> +static int __vidioc_enum_fmt(const struct v4l2_ioctl_ops *ops,
>>> + struct v4l2_fmtdesc *p,
>>> + struct file *file, void *fh)
>>> +{
>>> + int ret = 0;
>>>
>>> switch (p->type) {
>>> case V4L2_BUF_TYPE_VIDEO_CAPTURE:
>>> if (unlikely(!ops->vidioc_enum_fmt_vid_cap))
>>> break;
>>> - ret = ops->vidioc_enum_fmt_vid_cap(file, fh, arg);
>>> + ret = ops->vidioc_enum_fmt_vid_cap(file, fh, p);
>>> break;
>>> case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
>>> if (unlikely(!ops->vidioc_enum_fmt_vid_cap_mplane))
>>> break;
>>> - ret = ops->vidioc_enum_fmt_vid_cap_mplane(file, fh, arg);
>>> + ret = ops->vidioc_enum_fmt_vid_cap_mplane(file, fh, p);
>>> break;
>>> case V4L2_BUF_TYPE_VIDEO_OVERLAY:
>>> if (unlikely(!ops->vidioc_enum_fmt_vid_overlay))
>>> break;
>>> - ret = ops->vidioc_enum_fmt_vid_overlay(file, fh, arg);
>>> + ret = ops->vidioc_enum_fmt_vid_overlay(file, fh, p);
>>> break;
>>> case V4L2_BUF_TYPE_VIDEO_OUTPUT:
>>> if (unlikely(!ops->vidioc_enum_fmt_vid_out))
>>> break;
>>> - ret = ops->vidioc_enum_fmt_vid_out(file, fh, arg);
>>> + ret = ops->vidioc_enum_fmt_vid_out(file, fh, p);
>>> break;
>>> case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
>>> if (unlikely(!ops->vidioc_enum_fmt_vid_out_mplane))
>>> break;
>>> - ret = ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg);
>>> + ret = ops->vidioc_enum_fmt_vid_out_mplane(file, fh, p);
>>> break;
>>> case V4L2_BUF_TYPE_SDR_CAPTURE:
>>> if (unlikely(!ops->vidioc_enum_fmt_sdr_cap))
>>> break;
>>> - ret = ops->vidioc_enum_fmt_sdr_cap(file, fh, arg);
>>> + ret = ops->vidioc_enum_fmt_sdr_cap(file, fh, p);
>>> break;
>>> case V4L2_BUF_TYPE_SDR_OUTPUT:
>>> if (unlikely(!ops->vidioc_enum_fmt_sdr_out))
>>> break;
>>> - ret = ops->vidioc_enum_fmt_sdr_out(file, fh, arg);
>>> + ret = ops->vidioc_enum_fmt_sdr_out(file, fh, p);
>>> break;
>>> case V4L2_BUF_TYPE_META_CAPTURE:
>>> if (unlikely(!ops->vidioc_enum_fmt_meta_cap))
>>> break;
>>> - ret = ops->vidioc_enum_fmt_meta_cap(file, fh, arg);
>>> + ret = ops->vidioc_enum_fmt_meta_cap(file, fh, p);
>>> break;
>>> }
>>> + return ret;
>>> +}
>>> +
>>> +static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
>>> + struct file *file, void *fh, void *arg)
>>> +{
>>> + struct v4l2_fmtdesc *p = arg;
>>> + int ret = check_fmt(file, p->type);
>>> +
>>> + if (ret)
>>> + return ret;
>>> + ret = -EINVAL;
>>
>> Why set ret when it is overwritten below?
>>
>
> Oops, seems to be some leftover code.
>
>>> +
>>> + ret = __vidioc_enum_fmt(ops, p, file, fh);
>>> + if (ret)
>>> + return ret;
>>
>> Huh? Why call the driver twice? As far as I can see you can just drop
>> these three lines above.
>>
>>
>
> Well, because I thought this was the outcome of v9 [1]. Let me quote you:
>
> ""
> I realized that this is a problem since this function is called *after*
> the driver. So the driver has no chance to clear this flag if it knows
> that the queue is always ordered.
> ""
>
> So, we first call the driver to get struct v4l2_fmtdesc pixelformat field
> filled by the driver, then we call v4l_fill_unordered_fmtdesc()
> to set FLAG_UNORDERED if needed, and finally we call the driver again
> so it can clear the FLAG_UNORDERED.
>
> Does that make sense?
Not what I meant. v4l_fill_unordered_fmtdesc() should be called first, then
the driver (which can now fiddle with the flag if it wants to) and finally
v4l_fill_fmtdesc(p) is called.
Drivers that support these compressed formats need to be checked though:
they shouldn't overwrite flags unconditionally.
Regards,
Hans
>
> [1] https://lkml.org/lkml/2018/5/7/349
>
next prev parent reply other threads:[~2018-05-23 11:29 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 16:59 [PATCH v10 00/16] V4L2 Explicit Synchronization Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 01/16] videobuf2: Make struct vb2_buffer refcounted Ezequiel Garcia
2018-05-25 6:41 ` sathyam panda
2018-05-29 13:17 ` Ezequiel Garcia
2018-05-29 15:11 ` sathyam panda
2018-05-21 16:59 ` [PATCH v10 02/16] xilinx: regroup caps on querycap Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 03/16] hackrf: group device capabilities Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 04/16] omap3isp: " Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 05/16] vb2: move vb2_ops functions to videobuf2-core.[ch] Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 06/16] vb2: add is_unordered callback for drivers Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 07/16] v4l: add unordered flag to format description ioctl Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 08/16] v4l: mark unordered formats Ezequiel Garcia
2018-05-22 11:55 ` Hans Verkuil
2018-05-23 10:30 ` Ezequiel Garcia
2018-05-23 11:29 ` Hans Verkuil [this message]
2018-05-21 16:59 ` [PATCH v10 09/16] cobalt: add .is_unordered() for cobalt Ezequiel Garcia
2018-05-22 11:57 ` Hans Verkuil
2018-05-21 16:59 ` [PATCH v10 10/16] vb2: mark codec drivers as unordered Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 11/16] vb2: add explicit fence user API Ezequiel Garcia
2018-05-22 12:05 ` Hans Verkuil
2018-05-22 15:51 ` Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 12/16] vb2: add in-fence support to QBUF Ezequiel Garcia
2018-05-22 12:37 ` Hans Verkuil
2018-05-22 16:22 ` Ezequiel Garcia
2018-05-22 16:48 ` Hans Verkuil
2018-05-22 17:41 ` Ezequiel Garcia
2018-05-25 6:12 ` sathyam panda
2018-05-21 16:59 ` [PATCH v10 13/16] vb2: add out-fence " Ezequiel Garcia
2018-05-22 12:41 ` Hans Verkuil
2018-05-25 16:36 ` Brian Starkey
2018-05-21 16:59 ` [PATCH v10 14/16] v4l: introduce the fences capability Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 15/16] v4l: Add V4L2_CAP_FENCES to drivers Ezequiel Garcia
2018-05-21 16:59 ` [PATCH v10 16/16] v4l: Document explicit synchronization behavior Ezequiel Garcia
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=db537395-836a-3f6c-0039-1f4ed957f126@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=acourbot@chromium.org \
--cc=brian.starkey@arm.com \
--cc=ezequiel@collabora.com \
--cc=gustavo.padovan@collabora.com \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
--cc=pawel@osciak.com \
--cc=sakari.ailus@iki.fi \
--cc=shuahkh@osg.samsung.com \
--subject='Re: [PATCH v10 08/16] v4l: mark unordered formats' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).