From: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: "Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
"Hans Verkuil" <hverkuil@xs4all.nl>,
"Rémi Denis-Courmont" <remi@remlab.net>,
linux-media@vger.kernel.org,
"Hans Verkuil" <hans.verkuil@cisco.com>
Subject: Re: [RFCv3 API PATCH 15/31] v4l2-core: Add new V4L2_CAP_MONOTONIC_TS capability.
Date: Mon, 17 Sep 2012 22:27:54 +0200 [thread overview]
Message-ID: <505787CA.6070409@gmail.com> (raw)
In-Reply-To: <50575BA1.8020600@iki.fi>
Hi Sakari,
On 09/17/2012 07:19 PM, Sakari Ailus wrote:
> Sylwester Nawrocki wrote:
>> On 09/16/2012 05:33 PM, Laurent Pinchart wrote:
>>> On Sunday 16 September 2012 15:57:14 Hans Verkuil wrote:
>>>> On Sat September 15 2012 22:16:24 Sylwester Nawrocki wrote:
>>>>> On 09/15/2012 02:35 PM, Hans Verkuil wrote:
>>>>>>>> One alternative might be to use a v4l2_buffer flag instead. That
>>>>>>>> does
>>>>>>>> have the advantage that in the future we can add additional flags
>>>>>>>> should we need to support different clocks. Should we ever add
>>>>>>>> support to switch clocks dynamically, then a buffer flag is more
>>>>>>>> suitable than a driver capability. In that scenario it does make
>>>>>>>> real
>>>>>>>> sense to have a flag (or really mask).
>>>>>>>>
>>>>>>>> Say something like this:
>>>>>>>>
>>>>>>>> /* Clock Mask */
>>>>>>>> V4L2_BUF_FLAG_CLOCK_MASK 0xf000
>>>>>>>> /* Possible Clocks */
>>>>>>>> V4L2_BUF_FLAG_CLOCK_SYSTEM 0x0000
>>>>>>
>>>>>> I realized that this should be called:
>>>>>>
>>>>>> V4L2_BUF_FLAG_CLOCK_UNKNOWN 0x0000
>>>>>>
>>>>>> With a comment saying that is clock is either the system clock or a
>>>>>> monotonic clock. That reflects the current situation correctly.
>>>>>>
>>>>>>>> V4L2_BUF_FLAG_CLOCK_MONOTONIC 0x1000
>>>>>
>>>>> There is already lots of overhead related to the buffers
>>>>> management, could
>>>>> we perhaps have the most common option defined in a way that
>>>>> drivers don't
>>>>> need to update each buffer's flags before dequeuing, only to
>>>>> indicate the
>>>>> timestamp type (other than flags being modified in videobuf) ?
>>>>
>>>> Well, if all vb2 drivers use the monotonic clock, then you could do
>>>> it in
>>>> __fill_v4l2_buffer: instead of clearing just the state flags you'd
>>>> clear
>>>> state + clock flags, and you OR in the monotonic flag in the case
>>>> statement
>>>> below (adding just a single b->flags |= line in the DEQUEUED case).
>>>>
>>>> So that wouldn't add any overhead. Not that I think setting a flag
>>>> will add
>>>> any measurable overhead in any case.
>>
>> Yes, that might be indeed negligible overhead, especially if it's done
>> well.
>> User space logic usually adds much more to complexity.
>>
>> Might be good idea to add some helpers to videobuf2, so handling
>> timestamps
>> is as simple as possible in drivers.
>
> Of the V4L2 core. Taking the timestamp has to be done usually at a very
> precise point in the code, and that's a decision I think is better done
> in the driver. Timestamps are also independent of the videobuf2.
Yes, good point. All in all videobuf2 belongs to v4l2-core, doesn't
it ? ;)
Taking a timestamp indeed needs some care and precision, but setting
a flag could be considered a sort of separate issue - it's more relaxed
and videobuf2 already handles the buffer flags.
>>>>> This buffer flags idea sounds to me worse than the capability flag.
>>>>> After
>>>>> all the drivers should use monotonic clock timestamps, shouldn't
>>>>> they ?
>>>>
>>>> Yes. But you have monotonic and raw monotonic clocks at the moment, and
>>>> perhaps others will be added in the future. You can't change clocks
>>>> if you
>>>> put this in the querycap capabilities.
>>
>> Fair enough. BTW, CLOCK_MONOTONIC_RAW is not defined in any POSIX
>> standard,
>> is it ?
>
> It's Linux-specific. Perhaps it's worth noting that both V4L2 and ALSA
> are Linux-specific, too. :-)
OK. I don't mind V4L2 and ALSA being Linux-specific...
:)
> Raw wonotonic time could be better in some use cases as it's not
> NTP-adjusted. Which one is better for the purpose might be
> system-specific, albeit I'm leaning on the side of the monotonic in a
> general case.
Yeah, I guess it's all determined by streams from what subsystems
we're trying to synchronize and what clocks are used there. If there
is a possibility to select from various clocks in at least one of
the subsystems then we're all set.
The main issue here is that we already have plenty of different
clocks and there is a need on the video side for at least:
1. reporting to user space what clock is used by a driver,
and optionally
2. selecting clock type on user request.
>>>> I'd really like to keep this door open. My experience is that if
>>>> something
>>>> is possible, then someone somewhere will want to use it.
>>
>> Indeed, caps flags approach might be too limited anyway. And a v4l2
>> control
>> might be not good for reporting things like these.
>
> Why not? Are there other mechanisms that are suitable for this than
> controls? If we end up using controls for this, then we should make it
> as easy as possible for the drivers.
Sorry, my concern here was that timestamps are needed by all video
devices and I wasn't sure if there are any video nodes that don't
implement the v4l2 control ioctls. I.e. we might be enforcing adding
controls support only for the purpose of being able to query the
timestamps type. That was my concern here about using controls. However
if all video devices implement the controls API then it's negligible.
Moreover some parts of such control implementation could likely be
a part v4l2-core.
I'm just wondering why we need a flag when a control is going to be
used anyway. It sounds like per-buffer controls/status but that's an
issue that was previously discussed and is still not really addressed
in V4L2 AFAICT.
Flags + a control is likely going to fulfil all (most of) possible
app requirements. Not sure if the applications really need to get
timestamp type from each v4l2 buffer and the drivers need to be setting
it. Rather than just using a control before starting/after stopping
streaming to select, and at any time to query, the clock type.
--
Regards,
Sylwester
next prev parent reply other threads:[~2012-09-17 20:28 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 10:57 [RFCv3 API PATCH 00/31] Full series of API fixes from the 2012 Media Workshop Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 01/31] v4l: Remove experimental tag from certain API elements Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 02/31] videodev2.h: split off controls into v4l2-controls.h Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 03/31] DocBook: improve STREAMON/OFF documentation Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 04/31] DocBook: make the G/S/TRY_FMT specification more strict Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 05/31] DocBook: bus_info can no longer be empty Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 06/31] vivi/mem2mem_testdev: update to latest bus_info specification Hans Verkuil
2012-09-14 17:34 ` Sylwester Nawrocki
2012-09-14 10:57 ` [RFCv3 API PATCH 07/31] v4l2-core: deprecate V4L2_BUF_TYPE_PRIVATE Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 08/31] DocBook: " Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 09/31] v4l2: remove experimental tag from a number of old drivers Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 10/31] DocBook: document when to return ENODATA Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 11/31] v4l2-core: tvnorms may be 0 for a given input, handle that case Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 12/31] Rename V4L2_(IN|OUT)_CAP_CUSTOM_TIMINGS Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 13/31] Feature removal: Remove CUSTOM_TIMINGS defines in 3.9 Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 14/31] DocBook: fix awkward language and fix the documented return value Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 15/31] v4l2-core: Add new V4L2_CAP_MONOTONIC_TS capability Hans Verkuil
2012-09-14 20:25 ` Sakari Ailus
2012-09-14 20:27 ` Rémi Denis-Courmont
2012-09-14 21:05 ` Sakari Ailus
2012-09-15 7:41 ` Hans Verkuil
2012-09-15 9:31 ` Laurent Pinchart
2012-09-15 10:05 ` Hans Verkuil
2012-09-15 10:37 ` Sakari Ailus
2012-09-15 12:35 ` Hans Verkuil
2012-09-15 20:16 ` Sylwester Nawrocki
2012-09-16 13:57 ` Hans Verkuil
2012-09-16 15:33 ` Laurent Pinchart
2012-09-16 21:59 ` Sylwester Nawrocki
2012-09-17 7:13 ` Daniel Glöckner
2012-09-17 9:18 ` Laurent Pinchart
2012-09-17 9:28 ` Hans Verkuil
2012-09-17 9:30 ` Daniel Glöckner
2012-09-17 17:19 ` Sakari Ailus
2012-09-17 20:27 ` Sylwester Nawrocki [this message]
2012-09-18 7:42 ` Sakari Ailus
2012-09-15 10:26 ` Sylwester Nawrocki
2012-09-14 10:57 ` [RFCv3 API PATCH 16/31] Add V4L2_CAP_MONOTONIC_TS where applicable Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 17/31] DocBook: clarify that sequence is also set for output devices Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 18/31] DocBook: Mark CROPCAP as optional instead of as compulsory Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 19/31] v4l2: make vidioc_s_fbuf const Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 20/31] v4l2: make vidioc_s_jpegcomp const Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 21/31] v4l2: make vidioc_s_freq_hw_seek const Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 22/31] v4l2: make vidioc_(un)subscribe_event const Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 23/31] v4l2: make vidioc_s_audio const Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 24/31] v4l2: make vidioc_s_audout const Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 25/31] v4l2: make vidioc_s_modulator const Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 26/31] v4l2: make vidioc_s_crop const Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 27/31] v4l2-dev: add new VFL_DIR_ defines Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 28/31] Set vfl_dir for all display or m2m drivers Hans Verkuil
2012-09-14 17:34 ` Sylwester Nawrocki
2012-09-14 10:57 ` [RFCv3 API PATCH 29/31] v4l2-dev: improve ioctl validity checks Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 30/31] v4l2-dev: reorder checks into blocks of ioctls with similar properties Hans Verkuil
2012-09-14 10:57 ` [RFCv3 API PATCH 31/31] Add vfl_dir field documentation Hans Verkuil
2012-09-14 17:34 ` Sylwester Nawrocki
2012-09-14 17:59 ` Hans Verkuil
2012-09-14 21:26 ` [RFCv3 API PATCH 00/31] Full series of API fixes from the 2012 Media Workshop Sakari Ailus
2012-09-15 7:33 ` Hans Verkuil
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=505787CA.6070409@gmail.com \
--to=sylvester.nawrocki@gmail.com \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=remi@remlab.net \
--cc=sakari.ailus@iki.fi \
/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 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).