aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/DocBook
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2013-01-25 13:00:07 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-05 14:20:28 -0500
commitc6c092135d4f61b038a41685147c79e966c2399c (patch)
treed93179b278d936dacaec7178939465d2f16585b3 /Documentation/DocBook
parentf1343281d829d920d4158827bb420a24afe905f7 (diff)
[media] v4l: Document timestamp behaviour to correspond to reality
Document that monotonic timestamps are taken after the corresponding frame has been received, not when the reception has begun. This corresponds to the reality of current drivers: the timestamp is naturally taken when the hardware triggers an interrupt to tell the driver to handle the received frame. Remove the note on timestamp accuracy as it is fairly subjective what is actually an unstable timestamp. Also remove explanation that output buffer timestamps can be used to delay outputting a frame. Remove the footnote saying we always use realtime clock. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'Documentation/DocBook')
-rw-r--r--Documentation/DocBook/media/v4l/io.xml56
1 files changed, 12 insertions, 44 deletions
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index 1fb11e8d2a26..89544e4495a9 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -339,8 +339,8 @@ returns immediately with an &EAGAIN; when no buffer is available. The
339queues as a side effect. Since there is no notion of doing anything 339queues as a side effect. Since there is no notion of doing anything
340"now" on a multitasking system, if an application needs to synchronize 340"now" on a multitasking system, if an application needs to synchronize
341with another event it should examine the &v4l2-buffer; 341with another event it should examine the &v4l2-buffer;
342<structfield>timestamp</structfield> of captured buffers, or set the 342<structfield>timestamp</structfield> of captured or outputted buffers.
343field before enqueuing buffers for output.</para> 343</para>
344 344
345 <para>Drivers implementing memory mapping I/O must 345 <para>Drivers implementing memory mapping I/O must
346support the <constant>VIDIOC_REQBUFS</constant>, 346support the <constant>VIDIOC_REQBUFS</constant>,
@@ -457,7 +457,7 @@ queues and unlocks all buffers as a side effect. Since there is no
457notion of doing anything "now" on a multitasking system, if an 457notion of doing anything "now" on a multitasking system, if an
458application needs to synchronize with another event it should examine 458application needs to synchronize with another event it should examine
459the &v4l2-buffer; <structfield>timestamp</structfield> of captured 459the &v4l2-buffer; <structfield>timestamp</structfield> of captured
460buffers, or set the field before enqueuing buffers for output.</para> 460or outputted buffers.</para>
461 461
462 <para>Drivers implementing user pointer I/O must 462 <para>Drivers implementing user pointer I/O must
463support the <constant>VIDIOC_REQBUFS</constant>, 463support the <constant>VIDIOC_REQBUFS</constant>,
@@ -620,8 +620,7 @@ returns immediately with an &EAGAIN; when no buffer is available. The
620unlocks all buffers as a side effect. Since there is no notion of doing 620unlocks all buffers as a side effect. Since there is no notion of doing
621anything "now" on a multitasking system, if an application needs to synchronize 621anything "now" on a multitasking system, if an application needs to synchronize
622with another event it should examine the &v4l2-buffer; 622with another event it should examine the &v4l2-buffer;
623<structfield>timestamp</structfield> of captured buffers, or set the field 623<structfield>timestamp</structfield> of captured or outputted buffers.</para>
624before enqueuing buffers for output.</para>
625 624
626 <para>Drivers implementing DMABUF importing I/O must support the 625 <para>Drivers implementing DMABUF importing I/O must support the
627<constant>VIDIOC_REQBUFS</constant>, <constant>VIDIOC_QBUF</constant>, 626<constant>VIDIOC_REQBUFS</constant>, <constant>VIDIOC_QBUF</constant>,
@@ -654,38 +653,11 @@ plane, are stored in struct <structname>v4l2_plane</structname> instead.
654In that case, struct <structname>v4l2_buffer</structname> contains an array of 653In that case, struct <structname>v4l2_buffer</structname> contains an array of
655plane structures.</para> 654plane structures.</para>
656 655
657 <para>Nominally timestamps refer to the first data byte transmitted. 656 <para>For timestamp types that are sampled from the system clock
658In practice however the wide range of hardware covered by the V4L2 API 657(V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) it is guaranteed that the timestamp is
659limits timestamp accuracy. Often an interrupt routine will 658taken after the complete frame has been received (or transmitted in
660sample the system clock shortly after the field or frame was stored 659case of video output devices). For other kinds of
661completely in memory. So applications must expect a constant 660timestamps this may vary depending on the driver.</para>
662difference up to one field or frame period plus a small (few scan
663lines) random error. The delay and error can be much
664larger due to compression or transmission over an external bus when
665the frames are not properly stamped by the sender. This is frequently
666the case with USB cameras. Here timestamps refer to the instant the
667field or frame was received by the driver, not the capture time. These
668devices identify by not enumerating any video standards, see <xref
669linkend="standard" />.</para>
670
671 <para>Similar limitations apply to output timestamps. Typically
672the video hardware locks to a clock controlling the video timing, the
673horizontal and vertical synchronization pulses. At some point in the
674line sequence, possibly the vertical blanking, an interrupt routine
675samples the system clock, compares against the timestamp and programs
676the hardware to repeat the previous field or frame, or to display the
677buffer contents.</para>
678
679 <para>Apart of limitations of the video device and natural
680inaccuracies of all clocks, it should be noted system time itself is
681not perfectly stable. It can be affected by power saving cycles,
682warped to insert leap seconds, or even turned back or forth by the
683system administrator affecting long term measurements. <footnote>
684 <para>Since no other Linux multimedia
685API supports unadjusted time it would be foolish to introduce here. We
686must use a universally supported clock to synchronize different media,
687hence time of day.</para>
688 </footnote></para>
689 661
690 <table frame="none" pgwide="1" id="v4l2-buffer"> 662 <table frame="none" pgwide="1" id="v4l2-buffer">
691 <title>struct <structname>v4l2_buffer</structname></title> 663 <title>struct <structname>v4l2_buffer</structname></title>
@@ -745,13 +717,9 @@ applications when an output stream.</entry>
745 byte was captured, as returned by the 717 byte was captured, as returned by the
746 <function>clock_gettime()</function> function for the relevant 718 <function>clock_gettime()</function> function for the relevant
747 clock id; see <constant>V4L2_BUF_FLAG_TIMESTAMP_*</constant> in 719 clock id; see <constant>V4L2_BUF_FLAG_TIMESTAMP_*</constant> in
748 <xref linkend="buffer-flags" />. For output streams the data 720 <xref linkend="buffer-flags" />. For output streams the driver
749 will not be displayed before this time, secondary to the nominal 721 stores the time at which the last data byte was actually sent out
750 frame rate determined by the current video standard in enqueued 722 in the <structfield>timestamp</structfield> field. This permits
751 order. Applications can for example zero this field to display
752 frames as soon as possible. The driver stores the time at which
753 the first data byte was actually sent out in the
754 <structfield>timestamp</structfield> field. This permits
755 applications to monitor the drift between the video and system 723 applications to monitor the drift between the video and system
756 clock.</para></entry> 724 clock.</para></entry>
757 </row> 725 </row>