All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: "Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"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: Sat, 15 Sep 2012 13:37:58 +0300	[thread overview]
Message-ID: <50545A86.3050904@iki.fi> (raw)
In-Reply-To: <201209151205.20981.hverkuil@xs4all.nl>

Hi Hans and Laurent,

Hans Verkuil wrote:
> On Sat September 15 2012 11:31:29 Laurent Pinchart wrote:
>> Hi Hans,
>>
>> On Saturday 15 September 2012 09:41:59 Hans Verkuil wrote:
>>> On Fri September 14 2012 23:05:45 Sakari Ailus wrote:
>>>> Rémi Denis-Courmont wrote:
>>>>> Le vendredi 14 septembre 2012 23:25:01, Sakari Ailus a écrit :
>>>>>> I had a quick discussion with Laurent, and what he suggested was to use
>>>>>> the kernel version to figure out the type of the timestamp. The drivers
>>>>>> that use the monotonic time right now wouldn't be affected by the new
>>>>>> flag on older kernels. If we've decided we're going to switch to
>>>>>> monotonic time anyway, why not just change all the drivers now and
>>>>>> forget the capability flag.
>>>>>
>>>>> That does not work In Real Life.
>>>>>
>>>>> People do port old drivers forward to new kernels.
>>>>> People do port new drivers back to old kernels
>>>>
>>>> Why would you port a driver from an old kernel to a new kernel? Or are
>>>> you talking about out-of-tree drivers?
>>>
>>> More likely the latter.
>>>
>>>> If you do port drivers across different kernel versions I guess you're
>>>> supposed to use the appropriate interfaces for those kernels, too. Using
>>>> a helper function helps here, so compiling a backported driver would
>>>> fail w/o the helper function that produces the timestamp, forcing the
>>>> backporter to notice the situation.
>>>>
>>>> Anyway, I don't have a very strict opinion on this, so I'm okay with the
>>>> flag, too, but I personally simply don't think it's the best choice we
>>>> can make now. Also, without converting the drivers now the user space
>>>> must live with different kinds of timestamps much longer.
>>>
>>> There are a number of reasons why I want to go with a flag:
>>>
>>> - Out-of-tree drivers which are unlikely to switch to monotonic in practice
>>> - Backporting drivers
>>> - It makes it easy to verify in v4l2-compliance and enforce the use of
>>>    the monotonic clock.
>>> - It's easy for apps to check.
>>>
>>> The third reason is probably the most important one for me. There tends to
>>> be a great deal of inertia before changes like this are applied to new
>>> drivers, and without being able to (easily) check this in v4l2-compliance
>>> more drivers will be merged that keep using gettimeofday. It's all too easy
>>> to miss in a review.
>>
>> If we switch all existing drivers to monotonic timestamps in kernel release
>> 3.x, v4l2-compliance can just use the version it gets from VIDIOC_QUERYCAP and
>> enforce monotonic timestamps verification if the version is >= 3.x. This isn't
>> more difficult for apps to check than a dedicated flag (although it's less
>> explicit).
>
> I think that checking for the driver (kernel) version is a very poor substitute
> for testing against a proper flag.

That flag should be the default in this case. The flag should be set by 
the framework instead giving every driver the job of setting it.

> 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
> V4L2_BUF_FLAG_CLOCK_MONOTONIC	0x1000

There are three clocks defined in clock_gettime (2) man page. It'd 
indeed be good that the timestamp was selectable, but this really 
depends on the user rather than the driver. As you suggested earlier on, 
I agree that only monotonic timestamps are seen necessary right now.

It might be that raw monotonic timestamps could have some potential use 
(albeit I don't know a use case right now) but I still wouldn't think 
users would change the type of the timestamp that often. So I don't see 
a need for the buffer flag, but I still think it's better than a device 
capability flag.

If we gave the user the ability to pick the type of the timestamp we 
should move to use timespec at the same time.

>> My concern is identical to Sakari's, I'm not very keen on introducing a flag
>> that all drivers will set in the very near future and that we will have to
>> keep around forever.
>>
>>> That doesn't mean that it isn't a good idea to convert existing drivers
>>> asap. But it's not something I'm likely to take up myself.
>>
>> Sakari, are you volunteering for that ? ;-)

I'd be happy to do that. As the changes are mostly mechanical, it won't 
really take much time to do that.

What comes to new drivers --- I think it's wrong to assume every new 
driver would have been written wrong kind of timestamps in mind. I mean, 
what do you think would be the reasons why a driver writer would pick 
do_gettimeofday() instead of ktime_get_ts() if every driver in the tree 
already uses ktime_get_ts()?

Kind regards.

-- 
Sakari Ailus
sakari.ailus@iki.fi

  reply	other threads:[~2012-09-15 10:36 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 [this message]
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
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=50545A86.3050904@iki.fi \
    --to=sakari.ailus@iki.fi \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=remi@remlab.net \
    /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.