All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Chris MacGregor <chris@cybermato.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org, hverkuil@xs4all.nl, remi@remlab.net,
	daniel-gl@gmx.net, sylwester.nawrocki@gmail.com
Subject: Re: [RFC] Timestamps and V4L2
Date: Mon, 15 Oct 2012 22:59:06 +0300	[thread overview]
Message-ID: <20121015195906.GG21261@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <507C5BC4.7060700@cybermato.com>

Hi Chris,

On Mon, Oct 15, 2012 at 11:53:56AM -0700, Chris MacGregor wrote:
> On 10/15/2012 11:45 AM, Laurent Pinchart wrote:
> >Hi Sakari,
> >
> >On Monday 15 October 2012 19:05:49 Sakari Ailus wrote:
> >>Hi all,
> >>
> >>As a summar from the discussion, I think we have reached the following
> >>conclusion. Please say if you agree or disagree with what's below. :-)
> >>
> >>- The drivers will be moved to use monotonic timestamps for video buffers.
> >>- The user space will learn about the type of the timestamp through buffer
> >>flags.
> >>- The timestamp source may be made selectable in the future, but buffer
> >>flags won't be the means for this, primarily since they're not available on
> >>subdevs. Possible way to do this include a new V4L2 control or a new IOCTL.
> >That's my understanding as well. For the concept,
> >
> >Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> I wasn't able to participate in the discussion that led to this, but
> I'd like to suggest and request now that an explicit requirement (of
> whatever scheme is selected) be that a userspace app have a
> reasonable and straightforward way to translate the timestamps to
> real wall-clock time, ideally with enough precision to allow
> synchronization of cameras across multiple computers.
> 
> In the systems I work on, for instance, we are recording real-world
> biological processes, some of which vary based on the time of day,
> and it is important to know when a given frame was captured so that
> information can be stored with the raw frame and the data derived
> from it. For many such purposes, an accuracy measured in multiple
> seconds (or even minutes) is fine.
> 
> However, when we are using multiple cameras on multiple computers
> (e.g., two or more BeagleBoard xM's, each with a camera connected),
> we would want to synchronize with an accuracy of less than 1 frame
> time - e.g. 10 ms or less.

I think you have two use cases actually: knowing when an image has been
taken, and synchronisation of images from multiple sources. The first one is
easy: you just call clock_gettime() for the realtime clock. The precision
will certainly be enough.

For the latter the realtime clock fits poorly to begin with: it jumps around
e.g. when the daylight saving time changes.

I think what I'd do is this: figure out the difference between the monotonic
clocks of your systems and use that as basis for synchronisation. I wonder
if there are existing solutions for this based e.g. on the NTP.

The pace of the monotonic clocks on different systems is the same as the
real-time ones; the same NTP adjustments are done to the monotonic clock as
well. As an added bonus you also won't be affected by daylight saving time
or someone setting the clock manually.

The conversion of the two clocks requires the knowledge of the values of
kernel internal variables, so performing the conversion in user space later
on is not an option.

Alternatively you could just call clock_gettime() after every DQBUF call,
but that's indeed less precise than if the driver would get the timestamp
for you.

How would this work for you?

Best regards,

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

  reply	other threads:[~2012-10-15 19:59 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-20 20:21 [RFC] Timestamps and V4L2 Sakari Ailus
2012-09-20 21:08 ` Rémi Denis-Courmont
2012-09-21  8:47 ` Christian Gmeiner
2012-09-21  9:33 ` Hans Verkuil
2012-09-22 12:38   ` Sakari Ailus
2012-09-22 17:12     ` Sylwester Nawrocki
2012-09-22 20:28       ` Daniel Glöckner
2012-09-23 18:40         ` Sylwester Nawrocki
2012-09-25  0:35           ` Laurent Pinchart
     [not found]             ` <5061DAE3.2080808@samsung.com>
2012-09-25 17:17               ` Kamil Debski
2012-09-26 22:30             ` Sylwester Nawrocki
2012-09-27 10:41               ` Laurent Pinchart
2012-09-23 11:43       ` Sakari Ailus
2012-09-24 20:11         ` Rémi Denis-Courmont
2012-09-25  6:50           ` Hans Verkuil
2012-09-25  0:34       ` Laurent Pinchart
2012-09-25 22:48         ` Sylwester Nawrocki
2012-09-23  9:18     ` Hans Verkuil
2012-09-23 13:07       ` Sakari Ailus
2012-09-24  8:30         ` Hans Verkuil
2012-09-25  0:21       ` Laurent Pinchart
2012-09-24 23:42   ` Laurent Pinchart
2012-09-25  0:00   ` Laurent Pinchart
2012-09-25  6:47     ` Hans Verkuil
2012-09-25 10:48       ` Laurent Pinchart
2012-09-25 10:54         ` Hans Verkuil
2012-09-25 11:09           ` Laurent Pinchart
2012-09-25 20:12           ` Sakari Ailus
2012-09-26  9:13             ` Laurent Pinchart
2012-09-26 19:17               ` Sakari Ailus
2012-09-27 10:55                 ` Laurent Pinchart
2012-09-25 20:05       ` Sakari Ailus
2012-10-15 16:05 ` Sakari Ailus
2012-10-15 18:45   ` Laurent Pinchart
2012-10-15 18:53     ` Chris MacGregor
2012-10-15 19:59       ` Sakari Ailus [this message]
2012-10-15 20:10         ` Rémi Denis-Courmont
2012-10-16  1:25         ` Chris MacGregor
2012-10-25  0:47           ` Laurent Pinchart
2012-10-16  6:13     ` 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=20121015195906.GG21261@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=chris@cybermato.com \
    --cc=daniel-gl@gmx.net \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=remi@remlab.net \
    --cc=sylwester.nawrocki@gmail.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.