linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
	linux-media@vger.kernel.org, remi@remlab.net, daniel-gl@gmx.net,
	sylwester.nawrocki@gmail.com
Subject: Re: [RFC] Timestamps and V4L2
Date: Thu, 27 Sep 2012 12:55:31 +0200	[thread overview]
Message-ID: <2042961.UTB0pRMYu0@avalon> (raw)
In-Reply-To: <506354C2.1030805@iki.fi>

Hi Sakari,

On Wednesday 26 September 2012 22:17:22 Sakari Ailus wrote:
> Laurent Pinchart wrote:
> > On Tuesday 25 September 2012 23:12:00 Sakari Ailus wrote:
> >> Hans Verkuil wrote:
> >>> On Tue 25 September 2012 12:48:01 Laurent Pinchart wrote:
> >>>> On Tuesday 25 September 2012 08:47:45 Hans Verkuil wrote:
> >>>>> On Tue September 25 2012 02:00:55 Laurent Pinchart wrote:
> >>>>> BTW, I think we should also fix the description of the timestamp in
> >>>>> the spec. Currently it says:
> >>>>> 
> >>>>> "For input streams this is the system time (as returned by the
> >>>>> gettimeofday() function) when the first data byte was captured. For
> >>>>> output streams the data will not be displayed before this time,
> >>>>> secondary to the nominal frame rate determined by the current video
> >>>>> standard in enqueued order. Applications can for example zero this
> >>>>> field to display frames as soon as possible. The driver stores the
> >>>>> time at which the first data byte was actually sent out in the
> >>>>> timestamp field. This permits applications to monitor the drift
> >>>>> between the video and system clock."
> >>>>> 
> >>>>> To my knowledge all capture drivers set the timestamp to the time the
> >>>>> *last* data byte was captured, not the first.
> >>>> 
> >>>> The uvcvideo driver uses the time the first image packet is received
> >>>> :-)
> >>>> Most other drivers use the time the last byte was *received*, not
> >>>> captured.
> >>> 
> >>> Unless the hardware buffers more than a few lines there is very little
> >>> difference between the time the last byte was received and when it was
> >>> captured.
> >>> 
> >>> But you are correct, it is typically the time the last byte was
> >>> received.
> >>> 
> >>> Should we signal this as well? First vs last byte? Or shall we
> >>> standardize?
> >> 
> >> My personal opinion would be to change the spec to say what almost every
> >> driver does: it's the timestamp from the moment the last pixel has been
> >> received. We have the frame sync event for telling when the frame starts
> >> btw. The same event could be used for signalling whenever a given line
> >> starts. I don't see frame end fitting to that quite as nicely but I
> >> guess it could be possible.
> > 
> > The uvcvideo driver can timestamp the buffers with the system time at
> > which the first packet in the frame is received, but has no way to
> > generate a frame start event: the frame start event should correspond to
> > the time the frame starts, not to the time the first packet in the frame
> > is received. That information isn't available to the driver.
> 
> Aren't the two about equal, apart from the possible delays caused by the
> USB bus?

Apart from the possible delays caused by buffering on the device side, by 
transfers and by interrupt latency. For some applications that can matter. 
That's why we need support for device timestamps in the first place.

> The spec says about the frame sync event that it's "Triggered immediately
> when the reception of a frame has begun."

Then the OMAP3 ISP driver got it wrong, as we send the event when the hardware 
detects a vertical sync pulse :-)

We will never be able to implement the exact same behaviour for all devices. 
USB drivers typically don't receive VS events from the devices but can 
generate an event when they receive the first packet of a frame. On the other 
hand, DMA-based devices (PCI, SoC) usually only get notified of the end of the 
transfer (as opposed to the beginning of the transfer), and often (?) support 
generating an interrupt on VS detection. I think the best we can do is 
document in the spec that those different behaviours exist. We could add a 
capability flag to inform applications of the exact behaviour, but I don't 
think that's really worth it.

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2012-09-27 10:54 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 [this message]
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
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=2042961.UTB0pRMYu0@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=daniel-gl@gmx.net \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=remi@remlab.net \
    --cc=sakari.ailus@iki.fi \
    --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 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).