* [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags
@ 2014-03-01 13:16 Sakari Ailus
2014-03-01 13:16 ` [PATH v6 01/10] vb2: fix timecode and flags handling for output buffers Sakari Ailus
` (9 more replies)
0 siblings, 10 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:16 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
Hi all,
This is the 6th and hopefully the final version of the set.
What has changed since v5.2:
- Got a patch from Hans to fix timestamp issues in vb2 (1st one). That's
unchanged.
- Renamed the vb2_queue.timestamp_type field as timestamp_flags (patch 4).
- Add a note that on mem-to-mem devices the timestamp source may vary from
buffer to buffer (patch 10).
- Copy timestamp source from source buffers to destination (patch 6).
Testing has been done on uvc and mem2mem_testdev.
Unless something serious is found I'll send a pull request tomorrow.
--
Kind regards,
Sakari
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATH v6 01/10] vb2: fix timecode and flags handling for output buffers
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
@ 2014-03-01 13:16 ` Sakari Ailus
2014-03-01 13:16 ` [PATH v6 02/10] v4l: Document timestamp behaviour to correspond to reality Sakari Ailus
` (8 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:16 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
From: Hans Verkuil <hans.verkuil@cisco.com>
When sending a buffer to a video output device some of the fields need
to be copied so they arrive in the driver. These are the KEY/P/BFRAME
flags and the TIMECODE flag, and, if that flag is set, the timecode field
itself.
There are a number of functions involved in this: the __fill_vb2_buffer()
is called while preparing a buffer. For output buffers the buffer contains
the video data, so any meta data associated with that (KEY/P/BFRAME and
the field information) should be stored at that point.
The timecode, timecode flag and timestamp information is not part of that,
that information will have to be set when vb2_internal_qbuf() is called to
actually queue the buffer to the driver. Usually VIDIOC_QBUF will do the
prepare as well, but you can call PREPARE_BUF first and only later VIDIOC_QBUF.
You most likely will want to set the timestamp and timecode when you actually
queue the buffer, not when you prepare it.
Finally, in buf_prepare() make sure the timestamp and sequence fields are
actually cleared so that when you do a QUERYBUF of a prepared-but-not-yet-queued
buffer you will not see stale timestamp/sequence data.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
drivers/media/v4l2-core/videobuf2-core.c | 35 ++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 5a5fb7f..edab3af 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -40,10 +40,14 @@ module_param(debug, int, 0644);
#define call_qop(q, op, args...) \
(((q)->ops->op) ? ((q)->ops->op(args)) : 0)
+/* Flags that are set by the vb2 core */
#define V4L2_BUFFER_MASK_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR | \
V4L2_BUF_FLAG_PREPARED | \
V4L2_BUF_FLAG_TIMESTAMP_MASK)
+/* Output buffer flags that should be passed on to the driver */
+#define V4L2_BUFFER_OUT_FLAGS (V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_BFRAME | \
+ V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_TIMECODE)
/**
* __vb2_buf_mem_alloc() - allocate video memory for the given buffer
@@ -1025,9 +1029,21 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
}
- vb->v4l2_buf.field = b->field;
- vb->v4l2_buf.timestamp = b->timestamp;
+ /* Zero flags that the vb2 core handles */
vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
+ if (V4L2_TYPE_IS_OUTPUT(b->type)) {
+ /*
+ * For output buffers mask out the timecode flag:
+ * this will be handled later in vb2_internal_qbuf().
+ * The 'field' is valid metadata for this output buffer
+ * and so that needs to be copied here.
+ */
+ vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TIMECODE;
+ vb->v4l2_buf.field = b->field;
+ } else {
+ /* Zero any output buffer flags as this is a capture buffer */
+ vb->v4l2_buf.flags &= ~V4L2_BUFFER_OUT_FLAGS;
+ }
}
/**
@@ -1261,6 +1277,10 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
}
vb->state = VB2_BUF_STATE_PREPARING;
+ vb->v4l2_buf.timestamp.tv_sec = 0;
+ vb->v4l2_buf.timestamp.tv_usec = 0;
+ vb->v4l2_buf.sequence = 0;
+
switch (q->memory) {
case V4L2_MEMORY_MMAP:
ret = __qbuf_mmap(vb, b);
@@ -1448,6 +1468,17 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
*/
list_add_tail(&vb->queued_entry, &q->queued_list);
vb->state = VB2_BUF_STATE_QUEUED;
+ if (V4L2_TYPE_IS_OUTPUT(q->type)) {
+ /*
+ * For output buffers copy the timestamp if needed,
+ * and the timecode field and flag if needed.
+ */
+ if (q->timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_COPY)
+ vb->v4l2_buf.timestamp = b->timestamp;
+ vb->v4l2_buf.flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;
+ if (b->flags & V4L2_BUF_FLAG_TIMECODE)
+ vb->v4l2_buf.timecode = b->timecode;
+ }
/*
* If already streaming, give the buffer to driver for processing.
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 02/10] v4l: Document timestamp behaviour to correspond to reality
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
2014-03-01 13:16 ` [PATH v6 01/10] vb2: fix timecode and flags handling for output buffers Sakari Ailus
@ 2014-03-01 13:16 ` Sakari Ailus
2014-03-01 13:17 ` [PATH v6 03/10] v4l: Use full 32 bits for buffer flags Sakari Ailus
` (7 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:16 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
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>
---
Documentation/DocBook/media/v4l/io.xml | 56 +++++++-------------------------
1 file changed, 12 insertions(+), 44 deletions(-)
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index 2c4c068..8facac4 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
queues as a side effect. Since there is no notion of doing anything
"now" on a multitasking system, if an application needs to synchronize
with another event it should examine the &v4l2-buffer;
-<structfield>timestamp</structfield> of captured buffers, or set the
-field before enqueuing buffers for output.</para>
+<structfield>timestamp</structfield> of captured or outputted buffers.
+</para>
<para>Drivers implementing memory mapping I/O must
support the <constant>VIDIOC_REQBUFS</constant>,
@@ -457,7 +457,7 @@ queues and unlocks all buffers as a side effect. Since there is no
notion of doing anything "now" on a multitasking system, if an
application needs to synchronize with another event it should examine
the &v4l2-buffer; <structfield>timestamp</structfield> of captured
-buffers, or set the field before enqueuing buffers for output.</para>
+or outputted buffers.</para>
<para>Drivers implementing user pointer I/O must
support the <constant>VIDIOC_REQBUFS</constant>,
@@ -620,8 +620,7 @@ returns immediately with an &EAGAIN; when no buffer is available. The
unlocks all buffers as a side effect. Since there is no notion of doing
anything "now" on a multitasking system, if an application needs to synchronize
with another event it should examine the &v4l2-buffer;
-<structfield>timestamp</structfield> of captured buffers, or set the field
-before enqueuing buffers for output.</para>
+<structfield>timestamp</structfield> of captured or outputted buffers.</para>
<para>Drivers implementing DMABUF importing I/O must support the
<constant>VIDIOC_REQBUFS</constant>, <constant>VIDIOC_QBUF</constant>,
@@ -654,38 +653,11 @@ plane, are stored in struct <structname>v4l2_plane</structname> instead.
In that case, struct <structname>v4l2_buffer</structname> contains an array of
plane structures.</para>
- <para>Nominally timestamps refer to the first data byte transmitted.
-In practice however the wide range of hardware covered by the V4L2 API
-limits timestamp accuracy. Often an interrupt routine will
-sample the system clock shortly after the field or frame was stored
-completely in memory. So applications must expect a constant
-difference up to one field or frame period plus a small (few scan
-lines) random error. The delay and error can be much
-larger due to compression or transmission over an external bus when
-the frames are not properly stamped by the sender. This is frequently
-the case with USB cameras. Here timestamps refer to the instant the
-field or frame was received by the driver, not the capture time. These
-devices identify by not enumerating any video standards, see <xref
-linkend="standard" />.</para>
-
- <para>Similar limitations apply to output timestamps. Typically
-the video hardware locks to a clock controlling the video timing, the
-horizontal and vertical synchronization pulses. At some point in the
-line sequence, possibly the vertical blanking, an interrupt routine
-samples the system clock, compares against the timestamp and programs
-the hardware to repeat the previous field or frame, or to display the
-buffer contents.</para>
-
- <para>Apart of limitations of the video device and natural
-inaccuracies of all clocks, it should be noted system time itself is
-not perfectly stable. It can be affected by power saving cycles,
-warped to insert leap seconds, or even turned back or forth by the
-system administrator affecting long term measurements. <footnote>
- <para>Since no other Linux multimedia
-API supports unadjusted time it would be foolish to introduce here. We
-must use a universally supported clock to synchronize different media,
-hence time of day.</para>
- </footnote></para>
+ <para>For timestamp types that are sampled from the system clock
+(V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) it is guaranteed that the timestamp is
+taken after the complete frame has been received (or transmitted in
+case of video output devices). For other kinds of
+timestamps this may vary depending on the driver.</para>
<table frame="none" pgwide="1" id="v4l2-buffer">
<title>struct <structname>v4l2_buffer</structname></title>
@@ -745,13 +717,9 @@ applications when an output stream.</entry>
byte was captured, as returned by the
<function>clock_gettime()</function> function for the relevant
clock id; see <constant>V4L2_BUF_FLAG_TIMESTAMP_*</constant> in
- <xref linkend="buffer-flags" />. 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
- <structfield>timestamp</structfield> field. This permits
+ <xref linkend="buffer-flags" />. For output streams the driver
+ stores the time at which the last data byte was actually sent out
+ in the <structfield>timestamp</structfield> field. This permits
applications to monitor the drift between the video and system
clock.</para></entry>
</row>
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 03/10] v4l: Use full 32 bits for buffer flags
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
2014-03-01 13:16 ` [PATH v6 01/10] vb2: fix timecode and flags handling for output buffers Sakari Ailus
2014-03-01 13:16 ` [PATH v6 02/10] v4l: Document timestamp behaviour to correspond to reality Sakari Ailus
@ 2014-03-01 13:17 ` Sakari Ailus
2014-03-01 13:17 ` [PATH v6 04/10] v4l: Rename vb2_queue.timestamp_type as timestamp_flags Sakari Ailus
` (6 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:17 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
The buffer flags field is 32 bits but the defined only used 16. This is
fine, but as more than 16 bits will be used in the very near future, define
them as 32-bit numbers for consistency.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
Documentation/DocBook/media/v4l/io.xml | 30 ++++++++++++-------------
include/uapi/linux/videodev2.h | 38 +++++++++++++++++++-------------
2 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index 8facac4..46d24b3 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -984,7 +984,7 @@ should set this to 0.</entry>
<tbody valign="top">
<row>
<entry><constant>V4L2_BUF_FLAG_MAPPED</constant></entry>
- <entry>0x0001</entry>
+ <entry>0x00000001</entry>
<entry>The buffer resides in device memory and has been mapped
into the application's address space, see <xref linkend="mmap" /> for details.
Drivers set or clear this flag when the
@@ -994,7 +994,7 @@ Drivers set or clear this flag when the
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_QUEUED</constant></entry>
- <entry>0x0002</entry>
+ <entry>0x00000002</entry>
<entry>Internally drivers maintain two buffer queues, an
incoming and outgoing queue. When this flag is set, the buffer is
currently on the incoming queue. It automatically moves to the
@@ -1007,7 +1007,7 @@ cleared.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_DONE</constant></entry>
- <entry>0x0004</entry>
+ <entry>0x00000004</entry>
<entry>When this flag is set, the buffer is currently on
the outgoing queue, ready to be dequeued from the driver. Drivers set
or clear this flag when the <constant>VIDIOC_QUERYBUF</constant> ioctl
@@ -1021,7 +1021,7 @@ state, in the application domain to say so.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_ERROR</constant></entry>
- <entry>0x0040</entry>
+ <entry>0x00000040</entry>
<entry>When this flag is set, the buffer has been dequeued
successfully, although the data might have been corrupted.
This is recoverable, streaming may continue as normal and
@@ -1031,7 +1031,7 @@ state, in the application domain to say so.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_KEYFRAME</constant></entry>
- <entry>0x0008</entry>
+ <entry>0x00000008</entry>
<entry>Drivers set or clear this flag when calling the
<constant>VIDIOC_DQBUF</constant> ioctl. It may be set by video
capture devices when the buffer contains a compressed image which is a
@@ -1039,27 +1039,27 @@ key frame (or field), &ie; can be decompressed on its own.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_PFRAME</constant></entry>
- <entry>0x0010</entry>
+ <entry>0x00000010</entry>
<entry>Similar to <constant>V4L2_BUF_FLAG_KEYFRAME</constant>
this flags predicted frames or fields which contain only differences to a
previous key frame.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_BFRAME</constant></entry>
- <entry>0x0020</entry>
+ <entry>0x00000020</entry>
<entry>Similar to <constant>V4L2_BUF_FLAG_PFRAME</constant>
this is a bidirectional predicted frame or field. [ooc tbd]</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_TIMECODE</constant></entry>
- <entry>0x0100</entry>
+ <entry>0x00000100</entry>
<entry>The <structfield>timecode</structfield> field is valid.
Drivers set or clear this flag when the <constant>VIDIOC_DQBUF</constant>
ioctl is called.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_PREPARED</constant></entry>
- <entry>0x0400</entry>
+ <entry>0x00000400</entry>
<entry>The buffer has been prepared for I/O and can be queued by the
application. Drivers set or clear this flag when the
<link linkend="vidioc-querybuf">VIDIOC_QUERYBUF</link>, <link
@@ -1069,7 +1069,7 @@ application. Drivers set or clear this flag when the
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_NO_CACHE_INVALIDATE</constant></entry>
- <entry>0x0800</entry>
+ <entry>0x00000800</entry>
<entry>Caches do not have to be invalidated for this buffer.
Typically applications shall use this flag if the data captured in the buffer
is not going to be touched by the CPU, instead the buffer will, probably, be
@@ -1078,7 +1078,7 @@ passed on to a DMA-capable hardware unit for further processing or output.
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_NO_CACHE_CLEAN</constant></entry>
- <entry>0x1000</entry>
+ <entry>0x00001000</entry>
<entry>Caches do not have to be cleaned for this buffer.
Typically applications shall use this flag for output buffers if the data
in this buffer has not been created by the CPU but by some DMA-capable unit,
@@ -1086,7 +1086,7 @@ in which case caches have not been used.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_TIMESTAMP_MASK</constant></entry>
- <entry>0xe000</entry>
+ <entry>0x0000e000</entry>
<entry>Mask for timestamp types below. To test the
timestamp type, mask out bits not belonging to timestamp
type by performing a logical and operation with buffer
@@ -1094,7 +1094,7 @@ in which case caches have not been used.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN</constant></entry>
- <entry>0x0000</entry>
+ <entry>0x00000000</entry>
<entry>Unknown timestamp type. This type is used by
drivers before Linux 3.9 and may be either monotonic (see
below) or realtime (wall clock). Monotonic clock has been
@@ -1107,7 +1107,7 @@ in which case caches have not been used.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC</constant></entry>
- <entry>0x2000</entry>
+ <entry>0x00002000</entry>
<entry>The buffer timestamp has been taken from the
<constant>CLOCK_MONOTONIC</constant> clock. To access the
same clock outside V4L2, use
@@ -1115,7 +1115,7 @@ in which case caches have not been used.</entry>
</row>
<row>
<entry><constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant></entry>
- <entry>0x4000</entry>
+ <entry>0x00004000</entry>
<entry>The CAPTURE buffer timestamp has been taken from the
corresponding OUTPUT buffer. This flag applies only to mem2mem devices.</entry>
</row>
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 6ae7bbe..e9ee444 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -669,24 +669,32 @@ struct v4l2_buffer {
};
/* Flags for 'flags' field */
-#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */
-#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */
-#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */
-#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */
-#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */
-#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */
+/* Buffer is mapped (flag) */
+#define V4L2_BUF_FLAG_MAPPED 0x00000001
+/* Buffer is queued for processing */
+#define V4L2_BUF_FLAG_QUEUED 0x00000002
+/* Buffer is ready */
+#define V4L2_BUF_FLAG_DONE 0x00000004
+/* Image is a keyframe (I-frame) */
+#define V4L2_BUF_FLAG_KEYFRAME 0x00000008
+/* Image is a P-frame */
+#define V4L2_BUF_FLAG_PFRAME 0x00000010
+/* Image is a B-frame */
+#define V4L2_BUF_FLAG_BFRAME 0x00000020
/* Buffer is ready, but the data contained within is corrupted. */
-#define V4L2_BUF_FLAG_ERROR 0x0040
-#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */
-#define V4L2_BUF_FLAG_PREPARED 0x0400 /* Buffer is prepared for queuing */
+#define V4L2_BUF_FLAG_ERROR 0x00000040
+/* timecode field is valid */
+#define V4L2_BUF_FLAG_TIMECODE 0x00000100
+/* Buffer is prepared for queuing */
+#define V4L2_BUF_FLAG_PREPARED 0x00000400
/* Cache handling flags */
-#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x0800
-#define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x1000
+#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x00000800
+#define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x00001000
/* Timestamp type */
-#define V4L2_BUF_FLAG_TIMESTAMP_MASK 0xe000
-#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 0x0000
-#define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x2000
-#define V4L2_BUF_FLAG_TIMESTAMP_COPY 0x4000
+#define V4L2_BUF_FLAG_TIMESTAMP_MASK 0x0000e000
+#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 0x00000000
+#define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x00002000
+#define V4L2_BUF_FLAG_TIMESTAMP_COPY 0x00004000
/**
* struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 04/10] v4l: Rename vb2_queue.timestamp_type as timestamp_flags
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
` (2 preceding siblings ...)
2014-03-01 13:17 ` [PATH v6 03/10] v4l: Use full 32 bits for buffer flags Sakari Ailus
@ 2014-03-01 13:17 ` Sakari Ailus
2014-03-01 13:43 ` Hans Verkuil
2014-03-01 13:17 ` [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them Sakari Ailus
` (5 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:17 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
The timestamp_type field used to contain only the timestamp type. Soon it
will be used for timestamp source flags as well. Rename the field
accordingly.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
drivers/media/parport/bw-qcam.c | 2 +-
drivers/media/platform/blackfin/bfin_capture.c | 2 +-
drivers/media/platform/coda.c | 4 ++--
drivers/media/platform/davinci/vpbe_display.c | 2 +-
drivers/media/platform/davinci/vpif_capture.c | 2 +-
drivers/media/platform/davinci/vpif_display.c | 2 +-
drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 ++--
drivers/media/platform/exynos4-is/fimc-capture.c | 2 +-
drivers/media/platform/exynos4-is/fimc-lite.c | 2 +-
drivers/media/platform/exynos4-is/fimc-m2m.c | 4 ++--
drivers/media/platform/m2m-deinterlace.c | 4 ++--
drivers/media/platform/mem2mem_testdev.c | 4 ++--
drivers/media/platform/mx2_emmaprp.c | 4 ++--
drivers/media/platform/s3c-camif/camif-capture.c | 2 +-
drivers/media/platform/s5p-g2d/g2d.c | 4 ++--
drivers/media/platform/s5p-jpeg/jpeg-core.c | 4 ++--
drivers/media/platform/s5p-mfc/s5p_mfc.c | 4 ++--
drivers/media/platform/soc_camera/atmel-isi.c | 2 +-
drivers/media/platform/soc_camera/mx2_camera.c | 2 +-
drivers/media/platform/soc_camera/mx3_camera.c | 2 +-
drivers/media/platform/soc_camera/rcar_vin.c | 2 +-
drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | 2 +-
drivers/media/platform/ti-vpe/vpe.c | 4 ++--
drivers/media/platform/vivi.c | 2 +-
drivers/media/platform/vsp1/vsp1_video.c | 2 +-
drivers/media/usb/em28xx/em28xx-video.c | 4 ++--
drivers/media/usb/pwc/pwc-if.c | 2 +-
drivers/media/usb/stk1160/stk1160-v4l.c | 2 +-
drivers/media/usb/usbtv/usbtv-video.c | 2 +-
drivers/media/usb/uvc/uvc_queue.c | 2 +-
drivers/media/v4l2-core/videobuf2-core.c | 8 ++++----
include/media/videobuf2-core.h | 2 +-
32 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/drivers/media/parport/bw-qcam.c b/drivers/media/parport/bw-qcam.c
index d12bd33..a0a6ee6 100644
--- a/drivers/media/parport/bw-qcam.c
+++ b/drivers/media/parport/bw-qcam.c
@@ -965,7 +965,7 @@ static struct qcam *qcam_init(struct parport *port)
q->drv_priv = qcam;
q->ops = &qcam_video_qops;
q->mem_ops = &vb2_vmalloc_memops;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
err = vb2_queue_init(q);
if (err < 0) {
v4l2_err(v4l2_dev, "couldn't init vb2_queue for %s.\n", port->name);
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 2819165..200bec9 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -997,7 +997,7 @@ static int bcap_probe(struct platform_device *pdev)
q->buf_struct_size = sizeof(struct bcap_buffer);
q->ops = &bcap_video_qops;
q->mem_ops = &vb2_dma_contig_memops;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
ret = vb2_queue_init(q);
if (ret)
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 61f3dbc..81b6f7b 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -2428,7 +2428,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->ops = &coda_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(src_vq);
if (ret)
@@ -2440,7 +2440,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->ops = &coda_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
return vb2_queue_init(dst_vq);
}
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index b02aba4..e512767 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1415,7 +1415,7 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
q->ops = &video_qops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct vpbe_disp_buffer);
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
ret = vb2_queue_init(q);
if (ret) {
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 735ec47..cd6da8b 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1023,7 +1023,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
q->ops = &video_qops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct vpif_cap_buffer);
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
ret = vb2_queue_init(q);
if (ret) {
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 9d115cd..fd68236 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -983,7 +983,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
q->ops = &video_qops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct vpif_disp_buffer);
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
ret = vb2_queue_init(q);
if (ret) {
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 810c3e1..6741025 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -590,7 +590,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->ops = &gsc_m2m_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(src_vq);
if (ret)
@@ -603,7 +603,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->ops = &gsc_m2m_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
return vb2_queue_init(dst_vq);
}
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
index 8a712ca..92ae812 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -1782,7 +1782,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
q->ops = &fimc_capture_qops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct fimc_vid_buffer);
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &fimc->lock;
ret = vb2_queue_init(q);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 1234734..2be4bb5 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -1313,7 +1313,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct flite_buffer);
q->drv_priv = fimc;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &fimc->lock;
ret = vb2_queue_init(q);
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index 9da95bd..bfc900d 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -557,7 +557,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->ops = &fimc_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->fimc_dev->lock;
ret = vb2_queue_init(src_vq);
@@ -570,7 +570,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->ops = &fimc_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->fimc_dev->lock;
return vb2_queue_init(dst_vq);
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 6bb86b5..f3a9e24 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -868,7 +868,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->ops = &deinterlace_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
q_data[V4L2_M2M_SRC].fmt = &formats[0];
q_data[V4L2_M2M_SRC].width = 640;
q_data[V4L2_M2M_SRC].height = 480;
@@ -885,7 +885,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->ops = &deinterlace_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
q_data[V4L2_M2M_DST].fmt = &formats[0];
q_data[V4L2_M2M_DST].width = 640;
q_data[V4L2_M2M_DST].height = 480;
diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c
index 08e2437..02a40c5 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -777,7 +777,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->ops = &m2mtest_qops;
src_vq->mem_ops = &vb2_vmalloc_memops;
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->dev->dev_mutex;
ret = vb2_queue_init(src_vq);
@@ -790,7 +790,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->ops = &m2mtest_qops;
dst_vq->mem_ops = &vb2_vmalloc_memops;
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->dev->dev_mutex;
return vb2_queue_init(dst_vq);
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index c690435..af3e106 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -766,7 +766,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->ops = &emmaprp_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(src_vq);
if (ret)
@@ -778,7 +778,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->ops = &emmaprp_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
return vb2_queue_init(dst_vq);
}
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index 5372111..4e4d163 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -1160,7 +1160,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct camif_buffer);
q->drv_priv = vp;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
ret = vb2_queue_init(q);
if (ret)
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index 0fcf7d7..bf7c9b3 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -157,7 +157,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->ops = &g2d_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->dev->mutex;
ret = vb2_queue_init(src_vq);
@@ -170,7 +170,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->ops = &g2d_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->dev->mutex;
return vb2_queue_init(dst_vq);
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index a1c78c8..f5e9870 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1701,7 +1701,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->ops = &s5p_jpeg_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->jpeg->lock;
ret = vb2_queue_init(src_vq);
@@ -1714,7 +1714,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->ops = &s5p_jpeg_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->jpeg->lock;
return vb2_queue_init(dst_vq);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index e2aac59..0e8c171 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -794,7 +794,7 @@ static int s5p_mfc_open(struct file *file)
goto err_queue_init;
}
q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(q);
if (ret) {
mfc_err("Failed to initialize videobuf2 queue(capture)\n");
@@ -816,7 +816,7 @@ static int s5p_mfc_open(struct file *file)
goto err_queue_init;
}
q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(q);
if (ret) {
mfc_err("Failed to initialize videobuf2 queue(output)\n");
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index 4835173..f0b6c90 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -472,7 +472,7 @@ static int isi_camera_init_videobuf(struct vb2_queue *q,
q->buf_struct_size = sizeof(struct frame_buffer);
q->ops = &isi_video_qops;
q->mem_ops = &vb2_dma_contig_memops;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
return vb2_queue_init(q);
}
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
index d73abca..3e84480 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -794,7 +794,7 @@ static int mx2_camera_init_videobuf(struct vb2_queue *q,
q->ops = &mx2_videobuf_ops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct mx2_buffer);
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
return vb2_queue_init(q);
}
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
index f975b70..9ed81ac 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -453,7 +453,7 @@ static int mx3_camera_init_videobuf(struct vb2_queue *q,
q->ops = &mx3_videobuf_ops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct mx3_camera_buffer);
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
return vb2_queue_init(q);
}
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 3b1c05a..0ff5cfa 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1360,7 +1360,7 @@ static int rcar_vin_init_videobuf2(struct vb2_queue *vq,
vq->ops = &rcar_vin_vb2_ops;
vq->mem_ops = &vb2_dma_contig_memops;
vq->buf_struct_size = sizeof(struct rcar_vin_buffer);
- vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
return vb2_queue_init(vq);
}
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 150bd4d..3e75a46 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -1665,7 +1665,7 @@ static int sh_mobile_ceu_init_videobuf(struct vb2_queue *q,
q->ops = &sh_mobile_ceu_videobuf_ops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct sh_mobile_ceu_buffer);
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
return vb2_queue_init(q);
}
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 1296c53..8ea3b89 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -1770,7 +1770,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->ops = &vpe_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
- src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(src_vq);
if (ret)
@@ -1783,7 +1783,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->ops = &vpe_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
- dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
return vb2_queue_init(dst_vq);
}
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index e9cd96e..776015b 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -1429,7 +1429,7 @@ static int __init vivi_create_instance(int inst)
q->buf_struct_size = sizeof(struct vivi_buffer);
q->ops = &vivi_video_qops;
q->mem_ops = &vb2_vmalloc_memops;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
ret = vb2_queue_init(q);
if (ret)
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index b4687a8..e41f07d 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -1051,7 +1051,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
video->queue.buf_struct_size = sizeof(struct vsp1_video_buffer);
video->queue.ops = &vsp1_video_queue_qops;
video->queue.mem_ops = &vb2_dma_contig_memops;
- video->queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+ video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(&video->queue);
if (ret < 0) {
dev_err(video->vsp1->dev, "failed to initialize vb2 queue\n");
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 2775c90..52c49cb 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1029,7 +1029,7 @@ static int em28xx_vb2_setup(struct em28xx *dev)
q = &dev->vb_vidq;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->drv_priv = dev;
q->buf_struct_size = sizeof(struct em28xx_buffer);
q->ops = &em28xx_video_qops;
@@ -1043,7 +1043,7 @@ static int em28xx_vb2_setup(struct em28xx *dev)
q = &dev->vb_vbiq;
q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->drv_priv = dev;
q->buf_struct_size = sizeof(struct em28xx_buffer);
q->ops = &em28xx_vbi_qops;
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index abf365a..8bef015 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -1001,7 +1001,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf);
pdev->vb_queue.ops = &pwc_vb_queue_ops;
pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
- pdev->vb_queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ pdev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
rc = vb2_queue_init(&pdev->vb_queue);
if (rc < 0) {
PWC_ERROR("Oops, could not initialize vb2 queue.\n");
diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c
index c45c988..37bc00f 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -641,7 +641,7 @@ int stk1160_vb2_setup(struct stk1160 *dev)
q->buf_struct_size = sizeof(struct stk1160_buffer);
q->ops = &stk1160_video_qops;
q->mem_ops = &vb2_vmalloc_memops;
- q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
rc = vb2_queue_init(q);
if (rc < 0)
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 496bc2e..01ed1ec8 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -679,7 +679,7 @@ int usbtv_video_init(struct usbtv *usbtv)
usbtv->vb2q.buf_struct_size = sizeof(struct usbtv_buf);
usbtv->vb2q.ops = &usbtv_vb2_ops;
usbtv->vb2q.mem_ops = &vb2_vmalloc_memops;
- usbtv->vb2q.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ usbtv->vb2q.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
usbtv->vb2q.lock = &usbtv->vb2q_lock;
ret = vb2_queue_init(&usbtv->vb2q);
if (ret < 0) {
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index ff7be97..7c14616 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -151,7 +151,7 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
queue->queue.buf_struct_size = sizeof(struct uvc_buffer);
queue->queue.ops = &uvc_queue_qops;
queue->queue.mem_ops = &vb2_vmalloc_memops;
- queue->queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ queue->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
ret = vb2_queue_init(&queue->queue);
if (ret)
return ret;
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index edab3af..411429c 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -488,7 +488,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
* Clear any buffer state related flags.
*/
b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
- b->flags |= q->timestamp_type;
+ b->flags |= q->timestamp_flags;
switch (vb->state) {
case VB2_BUF_STATE_QUEUED:
@@ -1473,7 +1473,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
* For output buffers copy the timestamp if needed,
* and the timecode field and flag if needed.
*/
- if (q->timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_COPY)
+ if (q->timestamp_flags == V4L2_BUF_FLAG_TIMESTAMP_COPY)
vb->v4l2_buf.timestamp = b->timestamp;
vb->v4l2_buf.flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;
if (b->flags & V4L2_BUF_FLAG_TIMECODE)
@@ -2226,11 +2226,11 @@ int vb2_queue_init(struct vb2_queue *q)
WARN_ON(!q->io_modes) ||
WARN_ON(!q->ops->queue_setup) ||
WARN_ON(!q->ops->buf_queue) ||
- WARN_ON(q->timestamp_type & ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
+ WARN_ON(q->timestamp_flags & ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
return -EINVAL;
/* Warn that the driver should choose an appropriate timestamp type */
- WARN_ON(q->timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
+ WARN_ON(q->timestamp_flags == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
INIT_LIST_HEAD(&q->queued_list);
INIT_LIST_HEAD(&q->done_list);
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index bef53ce..3770be6 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -342,7 +342,7 @@ struct vb2_queue {
const struct vb2_mem_ops *mem_ops;
void *drv_priv;
unsigned int buf_struct_size;
- u32 timestamp_type;
+ u32 timestamp_flags;
gfp_t gfp_flags;
/* private: internal use only */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
` (3 preceding siblings ...)
2014-03-01 13:17 ` [PATH v6 04/10] v4l: Rename vb2_queue.timestamp_type as timestamp_flags Sakari Ailus
@ 2014-03-01 13:17 ` Sakari Ailus
2014-03-01 13:39 ` Hans Verkuil
2014-03-01 16:13 ` [PATH v6 05.1/11] v4l: Timestamp flags will soon contain timestamp source, not just type Sakari Ailus
2014-03-01 13:17 ` [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly Sakari Ailus
` (4 subsequent siblings)
9 siblings, 2 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:17 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
Some devices do not produce timestamps that correspond to the end of the
frame. The user space should be informed on the matter. This patch achieves
that by adding buffer flags (and a mask) for timestamp sources since more
possible timestamping points are expected than just two.
A three-bit mask is defined (V4L2_BUF_FLAG_TSTAMP_SRC_MASK) and two of the
eight possible values is are defined V4L2_BUF_FLAG_TSTAMP_SRC_EOF for end of
frame (value zero) V4L2_BUF_FLAG_TSTAMP_SRC_SOE for start of exposure (next
value).
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Kamil Debski <k.debski@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
Documentation/DocBook/media/v4l/io.xml | 36 +++++++++++++++++++++++++-----
drivers/media/v4l2-core/videobuf2-core.c | 4 +++-
include/media/videobuf2-core.h | 2 ++
include/uapi/linux/videodev2.h | 4 ++++
4 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index 46d24b3..d44401c 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -653,12 +653,6 @@ plane, are stored in struct <structname>v4l2_plane</structname> instead.
In that case, struct <structname>v4l2_buffer</structname> contains an array of
plane structures.</para>
- <para>For timestamp types that are sampled from the system clock
-(V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) it is guaranteed that the timestamp is
-taken after the complete frame has been received (or transmitted in
-case of video output devices). For other kinds of
-timestamps this may vary depending on the driver.</para>
-
<table frame="none" pgwide="1" id="v4l2-buffer">
<title>struct <structname>v4l2_buffer</structname></title>
<tgroup cols="4">
@@ -1119,6 +1113,36 @@ in which case caches have not been used.</entry>
<entry>The CAPTURE buffer timestamp has been taken from the
corresponding OUTPUT buffer. This flag applies only to mem2mem devices.</entry>
</row>
+ <row>
+ <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant></entry>
+ <entry>0x00070000</entry>
+ <entry>Mask for timestamp sources below. The timestamp source
+ defines the point of time the timestamp is taken in relation to
+ the frame. Logical and operation between the
+ <structfield>flags</structfield> field and
+ <constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant> produces the
+ value of the timestamp source.</entry>
+ </row>
+ <row>
+ <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_EOF</constant></entry>
+ <entry>0x00000000</entry>
+ <entry>End Of Frame. The buffer timestamp has been taken
+ when the last pixel of the frame has been received or the
+ last pixel of the frame has been transmitted. In practice,
+ software generated timestamps will typically be read from
+ the clock a small amount of time after the last pixel has
+ been received or transmitten, depending on the system and
+ other activity in it.</entry>
+ </row>
+ <row>
+ <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_SOE</constant></entry>
+ <entry>0x00010000</entry>
+ <entry>Start Of Exposure. The buffer timestamp has been
+ taken when the exposure of the frame has begun. This is
+ only valid for the
+ <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> buffer
+ type.</entry>
+ </row>
</tbody>
</tgroup>
</table>
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 411429c..3dda083 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2226,7 +2226,9 @@ int vb2_queue_init(struct vb2_queue *q)
WARN_ON(!q->io_modes) ||
WARN_ON(!q->ops->queue_setup) ||
WARN_ON(!q->ops->buf_queue) ||
- WARN_ON(q->timestamp_flags & ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
+ WARN_ON(q->timestamp_flags &
+ ~(V4L2_BUF_FLAG_TIMESTAMP_MASK |
+ V4L2_BUF_FLAG_TSTAMP_SRC_MASK)))
return -EINVAL;
/* Warn that the driver should choose an appropriate timestamp type */
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 3770be6..bf6859e 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -312,6 +312,8 @@ struct v4l2_fh;
* @buf_struct_size: size of the driver-specific buffer structure;
* "0" indicates the driver doesn't want to use a custom buffer
* structure type, so sizeof(struct vb2_buffer) will is used
+ * @timestamp_flags: Timestamp flags; V4L2_BUF_FLAGS_TIMESTAMP_* and
+ * V4L2_BUF_FLAGS_TSTAMP_SRC_*
* @gfp_flags: additional gfp flags used when allocating the buffers.
* Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32
* to force the buffer allocation to a specific memory zone.
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index e9ee444..82e8661 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -695,6 +695,10 @@ struct v4l2_buffer {
#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 0x00000000
#define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x00002000
#define V4L2_BUF_FLAG_TIMESTAMP_COPY 0x00004000
+/* Timestamp sources. */
+#define V4L2_BUF_FLAG_TSTAMP_SRC_MASK 0x00070000
+#define V4L2_BUF_FLAG_TSTAMP_SRC_EOF 0x00000000
+#define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000
/**
* struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
` (4 preceding siblings ...)
2014-03-01 13:17 ` [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them Sakari Ailus
@ 2014-03-01 13:17 ` Sakari Ailus
2014-03-01 14:28 ` Hans Verkuil
2014-03-01 13:17 ` [PATH v6 07/10] uvcvideo: Tell the user space we're using start-of-exposure timestamps Sakari Ailus
` (3 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:17 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
For COPY timestamps, buffer timestamp source flags will traverse the queue
untouched.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
drivers/media/v4l2-core/videobuf2-core.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 3dda083..7afeb6b 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -488,7 +488,22 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
* Clear any buffer state related flags.
*/
b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
- b->flags |= q->timestamp_flags;
+ if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
+ V4L2_BUF_FLAG_TIMESTAMP_COPY) {
+ /*
+ * For COPY timestamps, we just set the timestamp type
+ * here. The timestamp source is already in b->flags.
+ */
+ b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
+ } else {
+ /*
+ * For non-COPY timestamps, drop timestamp source and
+ * obtain the timestamp type and source from the
+ * queue.
+ */
+ b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ b->flags |= q->timestamp_flags;
+ }
switch (vb->state) {
case VB2_BUF_STATE_QUEUED:
@@ -1031,6 +1046,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
/* Zero flags that the vb2 core handles */
vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
+ if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
+ V4L2_BUF_FLAG_TIMESTAMP_COPY) {
+ /*
+ * Non-COPY timestamps will get their timestamp and
+ * timestamp source flags from the queue.
+ */
+ vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ }
+
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
/*
* For output buffers mask out the timecode flag:
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 07/10] uvcvideo: Tell the user space we're using start-of-exposure timestamps
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
` (5 preceding siblings ...)
2014-03-01 13:17 ` [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly Sakari Ailus
@ 2014-03-01 13:17 ` Sakari Ailus
2014-03-01 13:17 ` [PATH v6 08/10] exynos-gsc, m2m-deinterlace, mx2_emmaprp: Copy v4l2_buffer data from src to dst Sakari Ailus
` (2 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:17 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
The UVC device provided timestamps are taken from the clock once the
exposure of the frame has begun, not when the reception of the frame would
have been finished as almost anywhere else. Show this to the user space by
using V4L2_BUF_FLAG_TSTAMP_SRC_SOE buffer flag.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/media/usb/uvc/uvc_queue.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 7c14616..935556e 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -151,7 +151,8 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
queue->queue.buf_struct_size = sizeof(struct uvc_buffer);
queue->queue.ops = &uvc_queue_qops;
queue->queue.mem_ops = &vb2_vmalloc_memops;
- queue->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ queue->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
+ | V4L2_BUF_FLAG_TSTAMP_SRC_SOE;
ret = vb2_queue_init(&queue->queue);
if (ret)
return ret;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 08/10] exynos-gsc, m2m-deinterlace, mx2_emmaprp: Copy v4l2_buffer data from src to dst
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
` (6 preceding siblings ...)
2014-03-01 13:17 ` [PATH v6 07/10] uvcvideo: Tell the user space we're using start-of-exposure timestamps Sakari Ailus
@ 2014-03-01 13:17 ` Sakari Ailus
2014-03-01 13:17 ` [PATH v6 09/10] v4l: Copy timestamp source flags to destination on m2m devices Sakari Ailus
2014-03-01 13:17 ` [PATH v6 10/10] v4l: Document timestamp buffer flag behaviour Sakari Ailus
9 siblings, 0 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:17 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
The timestamp and timecode fields were copied from destination to source,
not the other way around as they should. Fix it.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Kamil Debski <k.debski@samsung.com>
---
drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 ++--
drivers/media/platform/m2m-deinterlace.c | 4 ++--
drivers/media/platform/mx2_emmaprp.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 6741025..3a842ee 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -88,8 +88,8 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
if (src_vb && dst_vb) {
- src_vb->v4l2_buf.timestamp = dst_vb->v4l2_buf.timestamp;
- src_vb->v4l2_buf.timecode = dst_vb->v4l2_buf.timecode;
+ dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
+ dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
v4l2_m2m_buf_done(src_vb, vb_state);
v4l2_m2m_buf_done(dst_vb, vb_state);
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index f3a9e24..3416131 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -207,8 +207,8 @@ static void dma_callback(void *data)
src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
- src_vb->v4l2_buf.timestamp = dst_vb->v4l2_buf.timestamp;
- src_vb->v4l2_buf.timecode = dst_vb->v4l2_buf.timecode;
+ dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
+ dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index af3e106..6debb02 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -377,8 +377,8 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
- src_vb->v4l2_buf.timestamp = dst_vb->v4l2_buf.timestamp;
- src_vb->v4l2_buf.timecode = dst_vb->v4l2_buf.timecode;
+ dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
+ dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
spin_lock_irqsave(&pcdev->irqlock, flags);
v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 09/10] v4l: Copy timestamp source flags to destination on m2m devices
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
` (7 preceding siblings ...)
2014-03-01 13:17 ` [PATH v6 08/10] exynos-gsc, m2m-deinterlace, mx2_emmaprp: Copy v4l2_buffer data from src to dst Sakari Ailus
@ 2014-03-01 13:17 ` Sakari Ailus
2014-03-01 13:17 ` [PATH v6 10/10] v4l: Document timestamp buffer flag behaviour Sakari Ailus
9 siblings, 0 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:17 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
Copy the flags containing the timestamp source from source buffer flags to
the destination buffer flags on memory-to-memory devices. This is analogous
to copying the timestamp field from source to destination.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Kamil Debski <k.debski@samsung.com>
---
drivers/media/platform/coda.c | 3 +++
drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 ++++
drivers/media/platform/exynos4-is/fimc-m2m.c | 3 +++
drivers/media/platform/m2m-deinterlace.c | 3 +++
drivers/media/platform/mem2mem_testdev.c | 3 +++
drivers/media/platform/mx2_emmaprp.c | 5 +++++
drivers/media/platform/s5p-g2d/g2d.c | 3 +++
drivers/media/platform/s5p-jpeg/jpeg-core.c | 3 +++
drivers/media/platform/s5p-mfc/s5p_mfc.c | 5 +++++
drivers/media/platform/ti-vpe/vpe.c | 2 ++
10 files changed, 34 insertions(+)
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 81b6f7b..3e5199e 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -2829,6 +2829,9 @@ static void coda_finish_encode(struct coda_ctx *ctx)
}
dst_buf->v4l2_buf.timestamp = src_buf->v4l2_buf.timestamp;
+ dst_buf->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ dst_buf->v4l2_buf.flags |=
+ src_buf->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
dst_buf->v4l2_buf.timecode = src_buf->v4l2_buf.timecode;
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 3a842ee..d0ea94f 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -90,6 +90,10 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
if (src_vb && dst_vb) {
dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
+ dst_vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ dst_vb->v4l2_buf.flags |=
+ src_vb->v4l2_buf.flags
+ & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
v4l2_m2m_buf_done(src_vb, vb_state);
v4l2_m2m_buf_done(dst_vb, vb_state);
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index bfc900d..36971d9 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -134,6 +134,9 @@ static void fimc_device_run(void *priv)
goto dma_unlock;
dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
+ dst_vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ dst_vb->v4l2_buf.flags |=
+ src_vb->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
/* Reconfigure hardware if the context has changed. */
if (fimc->m2m.ctx != ctx) {
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 3416131..c21d14f 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -208,6 +208,9 @@ static void dma_callback(void *data)
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
+ dst_vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ dst_vb->v4l2_buf.flags |=
+ src_vb->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c
index 02a40c5..4bb5e88 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -239,6 +239,9 @@ static int device_process(struct m2mtest_ctx *ctx,
memcpy(&out_vb->v4l2_buf.timestamp,
&in_vb->v4l2_buf.timestamp,
sizeof(struct timeval));
+ out_vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ out_vb->v4l2_buf.flags |=
+ in_vb->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
switch (ctx->mode) {
case MEM2MEM_HFLIP | MEM2MEM_VFLIP:
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index 6debb02..0b7480e 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -378,6 +378,11 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
+ dst_vb->v4l2_buf.flags &=
+ ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ dst_vb->v4l2_buf.flags |=
+ src_vb->v4l2_buf.flags
+ & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
spin_lock_irqsave(&pcdev->irqlock, flags);
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index bf7c9b3..357af1e 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -560,6 +560,9 @@ static irqreturn_t g2d_isr(int irq, void *prv)
dst->v4l2_buf.timecode = src->v4l2_buf.timecode;
dst->v4l2_buf.timestamp = src->v4l2_buf.timestamp;
+ dst->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ dst->v4l2_buf.flags |=
+ src->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
v4l2_m2m_buf_done(src, VB2_BUF_STATE_DONE);
v4l2_m2m_buf_done(dst, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index f5e9870..da0ad88 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1766,6 +1766,9 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
dst_buf->v4l2_buf.timecode = src_buf->v4l2_buf.timecode;
dst_buf->v4l2_buf.timestamp = src_buf->v4l2_buf.timestamp;
+ dst_buf->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ dst_buf->v4l2_buf.flags |=
+ src_buf->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
v4l2_m2m_buf_done(src_buf, state);
if (curr_ctx->mode == S5P_JPEG_ENCODE)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 0e8c171..0c47199 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -232,6 +232,11 @@ static void s5p_mfc_handle_frame_copy_time(struct s5p_mfc_ctx *ctx)
src_buf->b->v4l2_buf.timecode;
dst_buf->b->v4l2_buf.timestamp =
src_buf->b->v4l2_buf.timestamp;
+ dst_buf->b->v4l2_buf.flags &=
+ ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ dst_buf->b->v4l2_buf.flags |=
+ src_buf->b->v4l2_buf.flags
+ & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
switch (frame_type) {
case S5P_FIMV_DECODE_FRAME_I_FRAME:
dst_buf->b->v4l2_buf.flags |=
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 8ea3b89..7a77a5b 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -1278,6 +1278,8 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
d_buf = &d_vb->v4l2_buf;
d_buf->timestamp = s_buf->timestamp;
+ d_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ d_buf->flags |= s_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
if (s_buf->flags & V4L2_BUF_FLAG_TIMECODE) {
d_buf->flags |= V4L2_BUF_FLAG_TIMECODE;
d_buf->timecode = s_buf->timecode;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATH v6 10/10] v4l: Document timestamp buffer flag behaviour
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
` (8 preceding siblings ...)
2014-03-01 13:17 ` [PATH v6 09/10] v4l: Copy timestamp source flags to destination on m2m devices Sakari Ailus
@ 2014-03-01 13:17 ` Sakari Ailus
2014-03-01 13:42 ` Hans Verkuil
9 siblings, 1 reply; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 13:17 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
Timestamp buffer flags are constant at the moment. Document them so that 1)
they're always valid and 2) not changed by the drivers. This leaves room to
extend the functionality later on if needed.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
Documentation/DocBook/media/v4l/io.xml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index d44401c..1bffb1c 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -653,6 +653,20 @@ plane, are stored in struct <structname>v4l2_plane</structname> instead.
In that case, struct <structname>v4l2_buffer</structname> contains an array of
plane structures.</para>
+ <para>Dequeued video buffers come with timestamps. The driver
+ decides at which part of the frame and with which clock the
+ timestamp is taken. Please see flags in the masks
+ <constant>V4L2_BUF_FLAG_TIMESTAMP_MASK</constant> and
+ <constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant> in <xref
+ linkend="buffer-flags">. These flags are always valid and constant
+ across all buffers during the whole video stream. Changes in these
+ flags may take place as a side effect of &VIDIOC-S-INPUT; or
+ &VIDIOC-S-OUTPUT; however. The
+ <constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant> timestamp type
+ which is used by e.g. on mem-to-mem devices is an exception to the
+ rule: the timestamp source flags are copied from the OUTPUT video
+ buffer to the CAPTURE video buffer.</para>
+
<table frame="none" pgwide="1" id="v4l2-buffer">
<title>struct <structname>v4l2_buffer</structname></title>
<tgroup cols="4">
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them
2014-03-01 13:17 ` [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them Sakari Ailus
@ 2014-03-01 13:39 ` Hans Verkuil
2014-03-01 16:22 ` Sakari Ailus
2014-03-01 16:13 ` [PATH v6 05.1/11] v4l: Timestamp flags will soon contain timestamp source, not just type Sakari Ailus
1 sibling, 1 reply; 21+ messages in thread
From: Hans Verkuil @ 2014-03-01 13:39 UTC (permalink / raw)
To: Sakari Ailus, linux-media; +Cc: k.debski, laurent.pinchart
Hi Sakari,
Don't worry, it's a very minor change:
On 03/01/2014 02:17 PM, Sakari Ailus wrote:
> Some devices do not produce timestamps that correspond to the end of the
> frame. The user space should be informed on the matter. This patch achieves
> that by adding buffer flags (and a mask) for timestamp sources since more
> possible timestamping points are expected than just two.
>
> A three-bit mask is defined (V4L2_BUF_FLAG_TSTAMP_SRC_MASK) and two of the
> eight possible values is are defined V4L2_BUF_FLAG_TSTAMP_SRC_EOF for end of
> frame (value zero) V4L2_BUF_FLAG_TSTAMP_SRC_SOE for start of exposure (next
> value).
>
> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> Acked-by: Kamil Debski <k.debski@samsung.com>
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
> Documentation/DocBook/media/v4l/io.xml | 36 +++++++++++++++++++++++++-----
> drivers/media/v4l2-core/videobuf2-core.c | 4 +++-
> include/media/videobuf2-core.h | 2 ++
> include/uapi/linux/videodev2.h | 4 ++++
> 4 files changed, 39 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
> index 46d24b3..d44401c 100644
> --- a/Documentation/DocBook/media/v4l/io.xml
> +++ b/Documentation/DocBook/media/v4l/io.xml
> @@ -653,12 +653,6 @@ plane, are stored in struct <structname>v4l2_plane</structname> instead.
> In that case, struct <structname>v4l2_buffer</structname> contains an array of
> plane structures.</para>
>
> - <para>For timestamp types that are sampled from the system clock
> -(V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) it is guaranteed that the timestamp is
> -taken after the complete frame has been received (or transmitted in
> -case of video output devices). For other kinds of
> -timestamps this may vary depending on the driver.</para>
> -
> <table frame="none" pgwide="1" id="v4l2-buffer">
> <title>struct <structname>v4l2_buffer</structname></title>
> <tgroup cols="4">
> @@ -1119,6 +1113,36 @@ in which case caches have not been used.</entry>
> <entry>The CAPTURE buffer timestamp has been taken from the
> corresponding OUTPUT buffer. This flag applies only to mem2mem devices.</entry>
> </row>
> + <row>
> + <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant></entry>
> + <entry>0x00070000</entry>
> + <entry>Mask for timestamp sources below. The timestamp source
> + defines the point of time the timestamp is taken in relation to
> + the frame. Logical and operation between the
Rephrase to: "A logical 'and' operation"
I read it at first more like 'apples and oranges': 'logical and operation'.
It's unambiguous after rephrasing.
Regards,
Hans
> + <structfield>flags</structfield> field and
> + <constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant> produces the
> + value of the timestamp source.</entry>
> + </row>
> + <row>
> + <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_EOF</constant></entry>
> + <entry>0x00000000</entry>
> + <entry>End Of Frame. The buffer timestamp has been taken
> + when the last pixel of the frame has been received or the
> + last pixel of the frame has been transmitted. In practice,
> + software generated timestamps will typically be read from
> + the clock a small amount of time after the last pixel has
> + been received or transmitten, depending on the system and
> + other activity in it.</entry>
> + </row>
> + <row>
> + <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_SOE</constant></entry>
> + <entry>0x00010000</entry>
> + <entry>Start Of Exposure. The buffer timestamp has been
> + taken when the exposure of the frame has begun. This is
> + only valid for the
> + <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> buffer
> + type.</entry>
> + </row>
> </tbody>
> </tgroup>
> </table>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index 411429c..3dda083 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -2226,7 +2226,9 @@ int vb2_queue_init(struct vb2_queue *q)
> WARN_ON(!q->io_modes) ||
> WARN_ON(!q->ops->queue_setup) ||
> WARN_ON(!q->ops->buf_queue) ||
> - WARN_ON(q->timestamp_flags & ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
> + WARN_ON(q->timestamp_flags &
> + ~(V4L2_BUF_FLAG_TIMESTAMP_MASK |
> + V4L2_BUF_FLAG_TSTAMP_SRC_MASK)))
> return -EINVAL;
>
> /* Warn that the driver should choose an appropriate timestamp type */
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index 3770be6..bf6859e 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -312,6 +312,8 @@ struct v4l2_fh;
> * @buf_struct_size: size of the driver-specific buffer structure;
> * "0" indicates the driver doesn't want to use a custom buffer
> * structure type, so sizeof(struct vb2_buffer) will is used
> + * @timestamp_flags: Timestamp flags; V4L2_BUF_FLAGS_TIMESTAMP_* and
> + * V4L2_BUF_FLAGS_TSTAMP_SRC_*
> * @gfp_flags: additional gfp flags used when allocating the buffers.
> * Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32
> * to force the buffer allocation to a specific memory zone.
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index e9ee444..82e8661 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -695,6 +695,10 @@ struct v4l2_buffer {
> #define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 0x00000000
> #define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x00002000
> #define V4L2_BUF_FLAG_TIMESTAMP_COPY 0x00004000
> +/* Timestamp sources. */
> +#define V4L2_BUF_FLAG_TSTAMP_SRC_MASK 0x00070000
> +#define V4L2_BUF_FLAG_TSTAMP_SRC_EOF 0x00000000
> +#define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000
>
> /**
> * struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATH v6 10/10] v4l: Document timestamp buffer flag behaviour
2014-03-01 13:17 ` [PATH v6 10/10] v4l: Document timestamp buffer flag behaviour Sakari Ailus
@ 2014-03-01 13:42 ` Hans Verkuil
0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2014-03-01 13:42 UTC (permalink / raw)
To: Sakari Ailus, linux-media; +Cc: k.debski, laurent.pinchart
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Regards,
Hans
On 03/01/2014 02:17 PM, Sakari Ailus wrote:
> Timestamp buffer flags are constant at the moment. Document them so that 1)
> they're always valid and 2) not changed by the drivers. This leaves room to
> extend the functionality later on if needed.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> ---
> Documentation/DocBook/media/v4l/io.xml | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
> index d44401c..1bffb1c 100644
> --- a/Documentation/DocBook/media/v4l/io.xml
> +++ b/Documentation/DocBook/media/v4l/io.xml
> @@ -653,6 +653,20 @@ plane, are stored in struct <structname>v4l2_plane</structname> instead.
> In that case, struct <structname>v4l2_buffer</structname> contains an array of
> plane structures.</para>
>
> + <para>Dequeued video buffers come with timestamps. The driver
> + decides at which part of the frame and with which clock the
> + timestamp is taken. Please see flags in the masks
> + <constant>V4L2_BUF_FLAG_TIMESTAMP_MASK</constant> and
> + <constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant> in <xref
> + linkend="buffer-flags">. These flags are always valid and constant
> + across all buffers during the whole video stream. Changes in these
> + flags may take place as a side effect of &VIDIOC-S-INPUT; or
> + &VIDIOC-S-OUTPUT; however. The
> + <constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant> timestamp type
> + which is used by e.g. on mem-to-mem devices is an exception to the
> + rule: the timestamp source flags are copied from the OUTPUT video
> + buffer to the CAPTURE video buffer.</para>
> +
> <table frame="none" pgwide="1" id="v4l2-buffer">
> <title>struct <structname>v4l2_buffer</structname></title>
> <tgroup cols="4">
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATH v6 04/10] v4l: Rename vb2_queue.timestamp_type as timestamp_flags
2014-03-01 13:17 ` [PATH v6 04/10] v4l: Rename vb2_queue.timestamp_type as timestamp_flags Sakari Ailus
@ 2014-03-01 13:43 ` Hans Verkuil
0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2014-03-01 13:43 UTC (permalink / raw)
To: Sakari Ailus, linux-media; +Cc: k.debski, laurent.pinchart
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Regards,
Hans
On 03/01/2014 02:17 PM, Sakari Ailus wrote:
> The timestamp_type field used to contain only the timestamp type. Soon it
> will be used for timestamp source flags as well. Rename the field
> accordingly.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> ---
> drivers/media/parport/bw-qcam.c | 2 +-
> drivers/media/platform/blackfin/bfin_capture.c | 2 +-
> drivers/media/platform/coda.c | 4 ++--
> drivers/media/platform/davinci/vpbe_display.c | 2 +-
> drivers/media/platform/davinci/vpif_capture.c | 2 +-
> drivers/media/platform/davinci/vpif_display.c | 2 +-
> drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 ++--
> drivers/media/platform/exynos4-is/fimc-capture.c | 2 +-
> drivers/media/platform/exynos4-is/fimc-lite.c | 2 +-
> drivers/media/platform/exynos4-is/fimc-m2m.c | 4 ++--
> drivers/media/platform/m2m-deinterlace.c | 4 ++--
> drivers/media/platform/mem2mem_testdev.c | 4 ++--
> drivers/media/platform/mx2_emmaprp.c | 4 ++--
> drivers/media/platform/s3c-camif/camif-capture.c | 2 +-
> drivers/media/platform/s5p-g2d/g2d.c | 4 ++--
> drivers/media/platform/s5p-jpeg/jpeg-core.c | 4 ++--
> drivers/media/platform/s5p-mfc/s5p_mfc.c | 4 ++--
> drivers/media/platform/soc_camera/atmel-isi.c | 2 +-
> drivers/media/platform/soc_camera/mx2_camera.c | 2 +-
> drivers/media/platform/soc_camera/mx3_camera.c | 2 +-
> drivers/media/platform/soc_camera/rcar_vin.c | 2 +-
> drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | 2 +-
> drivers/media/platform/ti-vpe/vpe.c | 4 ++--
> drivers/media/platform/vivi.c | 2 +-
> drivers/media/platform/vsp1/vsp1_video.c | 2 +-
> drivers/media/usb/em28xx/em28xx-video.c | 4 ++--
> drivers/media/usb/pwc/pwc-if.c | 2 +-
> drivers/media/usb/stk1160/stk1160-v4l.c | 2 +-
> drivers/media/usb/usbtv/usbtv-video.c | 2 +-
> drivers/media/usb/uvc/uvc_queue.c | 2 +-
> drivers/media/v4l2-core/videobuf2-core.c | 8 ++++----
> include/media/videobuf2-core.h | 2 +-
> 32 files changed, 46 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/media/parport/bw-qcam.c b/drivers/media/parport/bw-qcam.c
> index d12bd33..a0a6ee6 100644
> --- a/drivers/media/parport/bw-qcam.c
> +++ b/drivers/media/parport/bw-qcam.c
> @@ -965,7 +965,7 @@ static struct qcam *qcam_init(struct parport *port)
> q->drv_priv = qcam;
> q->ops = &qcam_video_qops;
> q->mem_ops = &vb2_vmalloc_memops;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> err = vb2_queue_init(q);
> if (err < 0) {
> v4l2_err(v4l2_dev, "couldn't init vb2_queue for %s.\n", port->name);
> diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
> index 2819165..200bec9 100644
> --- a/drivers/media/platform/blackfin/bfin_capture.c
> +++ b/drivers/media/platform/blackfin/bfin_capture.c
> @@ -997,7 +997,7 @@ static int bcap_probe(struct platform_device *pdev)
> q->buf_struct_size = sizeof(struct bcap_buffer);
> q->ops = &bcap_video_qops;
> q->mem_ops = &vb2_dma_contig_memops;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> ret = vb2_queue_init(q);
> if (ret)
> diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
> index 61f3dbc..81b6f7b 100644
> --- a/drivers/media/platform/coda.c
> +++ b/drivers/media/platform/coda.c
> @@ -2428,7 +2428,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> src_vq->ops = &coda_qops;
> src_vq->mem_ops = &vb2_dma_contig_memops;
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>
> ret = vb2_queue_init(src_vq);
> if (ret)
> @@ -2440,7 +2440,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> dst_vq->ops = &coda_qops;
> dst_vq->mem_ops = &vb2_dma_contig_memops;
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>
> return vb2_queue_init(dst_vq);
> }
> diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
> index b02aba4..e512767 100644
> --- a/drivers/media/platform/davinci/vpbe_display.c
> +++ b/drivers/media/platform/davinci/vpbe_display.c
> @@ -1415,7 +1415,7 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
> q->ops = &video_qops;
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct vpbe_disp_buffer);
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> ret = vb2_queue_init(q);
> if (ret) {
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index 735ec47..cd6da8b 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1023,7 +1023,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
> q->ops = &video_qops;
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct vpif_cap_buffer);
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> ret = vb2_queue_init(q);
> if (ret) {
> diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
> index 9d115cd..fd68236 100644
> --- a/drivers/media/platform/davinci/vpif_display.c
> +++ b/drivers/media/platform/davinci/vpif_display.c
> @@ -983,7 +983,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
> q->ops = &video_qops;
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct vpif_disp_buffer);
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> ret = vb2_queue_init(q);
> if (ret) {
> diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
> index 810c3e1..6741025 100644
> --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
> +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
> @@ -590,7 +590,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->ops = &gsc_m2m_qops;
> src_vq->mem_ops = &vb2_dma_contig_memops;
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>
> ret = vb2_queue_init(src_vq);
> if (ret)
> @@ -603,7 +603,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->ops = &gsc_m2m_qops;
> dst_vq->mem_ops = &vb2_dma_contig_memops;
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>
> return vb2_queue_init(dst_vq);
> }
> diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
> index 8a712ca..92ae812 100644
> --- a/drivers/media/platform/exynos4-is/fimc-capture.c
> +++ b/drivers/media/platform/exynos4-is/fimc-capture.c
> @@ -1782,7 +1782,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
> q->ops = &fimc_capture_qops;
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct fimc_vid_buffer);
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> q->lock = &fimc->lock;
>
> ret = vb2_queue_init(q);
> diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
> index 1234734..2be4bb5 100644
> --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> @@ -1313,7 +1313,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct flite_buffer);
> q->drv_priv = fimc;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> q->lock = &fimc->lock;
>
> ret = vb2_queue_init(q);
> diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
> index 9da95bd..bfc900d 100644
> --- a/drivers/media/platform/exynos4-is/fimc-m2m.c
> +++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
> @@ -557,7 +557,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->ops = &fimc_qops;
> src_vq->mem_ops = &vb2_dma_contig_memops;
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> src_vq->lock = &ctx->fimc_dev->lock;
>
> ret = vb2_queue_init(src_vq);
> @@ -570,7 +570,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->ops = &fimc_qops;
> dst_vq->mem_ops = &vb2_dma_contig_memops;
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> dst_vq->lock = &ctx->fimc_dev->lock;
>
> return vb2_queue_init(dst_vq);
> diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
> index 6bb86b5..f3a9e24 100644
> --- a/drivers/media/platform/m2m-deinterlace.c
> +++ b/drivers/media/platform/m2m-deinterlace.c
> @@ -868,7 +868,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> src_vq->ops = &deinterlace_qops;
> src_vq->mem_ops = &vb2_dma_contig_memops;
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> q_data[V4L2_M2M_SRC].fmt = &formats[0];
> q_data[V4L2_M2M_SRC].width = 640;
> q_data[V4L2_M2M_SRC].height = 480;
> @@ -885,7 +885,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> dst_vq->ops = &deinterlace_qops;
> dst_vq->mem_ops = &vb2_dma_contig_memops;
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> q_data[V4L2_M2M_DST].fmt = &formats[0];
> q_data[V4L2_M2M_DST].width = 640;
> q_data[V4L2_M2M_DST].height = 480;
> diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c
> index 08e2437..02a40c5 100644
> --- a/drivers/media/platform/mem2mem_testdev.c
> +++ b/drivers/media/platform/mem2mem_testdev.c
> @@ -777,7 +777,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> src_vq->ops = &m2mtest_qops;
> src_vq->mem_ops = &vb2_vmalloc_memops;
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> src_vq->lock = &ctx->dev->dev_mutex;
>
> ret = vb2_queue_init(src_vq);
> @@ -790,7 +790,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> dst_vq->ops = &m2mtest_qops;
> dst_vq->mem_ops = &vb2_vmalloc_memops;
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> dst_vq->lock = &ctx->dev->dev_mutex;
>
> return vb2_queue_init(dst_vq);
> diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
> index c690435..af3e106 100644
> --- a/drivers/media/platform/mx2_emmaprp.c
> +++ b/drivers/media/platform/mx2_emmaprp.c
> @@ -766,7 +766,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> src_vq->ops = &emmaprp_qops;
> src_vq->mem_ops = &vb2_dma_contig_memops;
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>
> ret = vb2_queue_init(src_vq);
> if (ret)
> @@ -778,7 +778,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> dst_vq->ops = &emmaprp_qops;
> dst_vq->mem_ops = &vb2_dma_contig_memops;
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>
> return vb2_queue_init(dst_vq);
> }
> diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
> index 5372111..4e4d163 100644
> --- a/drivers/media/platform/s3c-camif/camif-capture.c
> +++ b/drivers/media/platform/s3c-camif/camif-capture.c
> @@ -1160,7 +1160,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct camif_buffer);
> q->drv_priv = vp;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> ret = vb2_queue_init(q);
> if (ret)
> diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
> index 0fcf7d7..bf7c9b3 100644
> --- a/drivers/media/platform/s5p-g2d/g2d.c
> +++ b/drivers/media/platform/s5p-g2d/g2d.c
> @@ -157,7 +157,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->ops = &g2d_qops;
> src_vq->mem_ops = &vb2_dma_contig_memops;
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> src_vq->lock = &ctx->dev->mutex;
>
> ret = vb2_queue_init(src_vq);
> @@ -170,7 +170,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->ops = &g2d_qops;
> dst_vq->mem_ops = &vb2_dma_contig_memops;
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> dst_vq->lock = &ctx->dev->mutex;
>
> return vb2_queue_init(dst_vq);
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> index a1c78c8..f5e9870 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> @@ -1701,7 +1701,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> src_vq->ops = &s5p_jpeg_qops;
> src_vq->mem_ops = &vb2_dma_contig_memops;
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> src_vq->lock = &ctx->jpeg->lock;
>
> ret = vb2_queue_init(src_vq);
> @@ -1714,7 +1714,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> dst_vq->ops = &s5p_jpeg_qops;
> dst_vq->mem_ops = &vb2_dma_contig_memops;
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> dst_vq->lock = &ctx->jpeg->lock;
>
> return vb2_queue_init(dst_vq);
> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
> index e2aac59..0e8c171 100644
> --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
> @@ -794,7 +794,7 @@ static int s5p_mfc_open(struct file *file)
> goto err_queue_init;
> }
> q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> ret = vb2_queue_init(q);
> if (ret) {
> mfc_err("Failed to initialize videobuf2 queue(capture)\n");
> @@ -816,7 +816,7 @@ static int s5p_mfc_open(struct file *file)
> goto err_queue_init;
> }
> q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> ret = vb2_queue_init(q);
> if (ret) {
> mfc_err("Failed to initialize videobuf2 queue(output)\n");
> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
> index 4835173..f0b6c90 100644
> --- a/drivers/media/platform/soc_camera/atmel-isi.c
> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> @@ -472,7 +472,7 @@ static int isi_camera_init_videobuf(struct vb2_queue *q,
> q->buf_struct_size = sizeof(struct frame_buffer);
> q->ops = &isi_video_qops;
> q->mem_ops = &vb2_dma_contig_memops;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> return vb2_queue_init(q);
> }
> diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
> index d73abca..3e84480 100644
> --- a/drivers/media/platform/soc_camera/mx2_camera.c
> +++ b/drivers/media/platform/soc_camera/mx2_camera.c
> @@ -794,7 +794,7 @@ static int mx2_camera_init_videobuf(struct vb2_queue *q,
> q->ops = &mx2_videobuf_ops;
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct mx2_buffer);
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> return vb2_queue_init(q);
> }
> diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
> index f975b70..9ed81ac 100644
> --- a/drivers/media/platform/soc_camera/mx3_camera.c
> +++ b/drivers/media/platform/soc_camera/mx3_camera.c
> @@ -453,7 +453,7 @@ static int mx3_camera_init_videobuf(struct vb2_queue *q,
> q->ops = &mx3_videobuf_ops;
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct mx3_camera_buffer);
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> return vb2_queue_init(q);
> }
> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
> index 3b1c05a..0ff5cfa 100644
> --- a/drivers/media/platform/soc_camera/rcar_vin.c
> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
> @@ -1360,7 +1360,7 @@ static int rcar_vin_init_videobuf2(struct vb2_queue *vq,
> vq->ops = &rcar_vin_vb2_ops;
> vq->mem_ops = &vb2_dma_contig_memops;
> vq->buf_struct_size = sizeof(struct rcar_vin_buffer);
> - vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> return vb2_queue_init(vq);
> }
> diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
> index 150bd4d..3e75a46 100644
> --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
> +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
> @@ -1665,7 +1665,7 @@ static int sh_mobile_ceu_init_videobuf(struct vb2_queue *q,
> q->ops = &sh_mobile_ceu_videobuf_ops;
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct sh_mobile_ceu_buffer);
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> return vb2_queue_init(q);
> }
> diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
> index 1296c53..8ea3b89 100644
> --- a/drivers/media/platform/ti-vpe/vpe.c
> +++ b/drivers/media/platform/ti-vpe/vpe.c
> @@ -1770,7 +1770,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> src_vq->ops = &vpe_qops;
> src_vq->mem_ops = &vb2_dma_contig_memops;
> - src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>
> ret = vb2_queue_init(src_vq);
> if (ret)
> @@ -1783,7 +1783,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
> dst_vq->ops = &vpe_qops;
> dst_vq->mem_ops = &vb2_dma_contig_memops;
> - dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>
> return vb2_queue_init(dst_vq);
> }
> diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
> index e9cd96e..776015b 100644
> --- a/drivers/media/platform/vivi.c
> +++ b/drivers/media/platform/vivi.c
> @@ -1429,7 +1429,7 @@ static int __init vivi_create_instance(int inst)
> q->buf_struct_size = sizeof(struct vivi_buffer);
> q->ops = &vivi_video_qops;
> q->mem_ops = &vb2_vmalloc_memops;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> ret = vb2_queue_init(q);
> if (ret)
> diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
> index b4687a8..e41f07d 100644
> --- a/drivers/media/platform/vsp1/vsp1_video.c
> +++ b/drivers/media/platform/vsp1/vsp1_video.c
> @@ -1051,7 +1051,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
> video->queue.buf_struct_size = sizeof(struct vsp1_video_buffer);
> video->queue.ops = &vsp1_video_queue_qops;
> video->queue.mem_ops = &vb2_dma_contig_memops;
> - video->queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> ret = vb2_queue_init(&video->queue);
> if (ret < 0) {
> dev_err(video->vsp1->dev, "failed to initialize vb2 queue\n");
> diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
> index 2775c90..52c49cb 100644
> --- a/drivers/media/usb/em28xx/em28xx-video.c
> +++ b/drivers/media/usb/em28xx/em28xx-video.c
> @@ -1029,7 +1029,7 @@ static int em28xx_vb2_setup(struct em28xx *dev)
> q = &dev->vb_vidq;
> q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> q->drv_priv = dev;
> q->buf_struct_size = sizeof(struct em28xx_buffer);
> q->ops = &em28xx_video_qops;
> @@ -1043,7 +1043,7 @@ static int em28xx_vb2_setup(struct em28xx *dev)
> q = &dev->vb_vbiq;
> q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
> q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> q->drv_priv = dev;
> q->buf_struct_size = sizeof(struct em28xx_buffer);
> q->ops = &em28xx_vbi_qops;
> diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
> index abf365a..8bef015 100644
> --- a/drivers/media/usb/pwc/pwc-if.c
> +++ b/drivers/media/usb/pwc/pwc-if.c
> @@ -1001,7 +1001,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
> pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf);
> pdev->vb_queue.ops = &pwc_vb_queue_ops;
> pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
> - pdev->vb_queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + pdev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> rc = vb2_queue_init(&pdev->vb_queue);
> if (rc < 0) {
> PWC_ERROR("Oops, could not initialize vb2 queue.\n");
> diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c
> index c45c988..37bc00f 100644
> --- a/drivers/media/usb/stk1160/stk1160-v4l.c
> +++ b/drivers/media/usb/stk1160/stk1160-v4l.c
> @@ -641,7 +641,7 @@ int stk1160_vb2_setup(struct stk1160 *dev)
> q->buf_struct_size = sizeof(struct stk1160_buffer);
> q->ops = &stk1160_video_qops;
> q->mem_ops = &vb2_vmalloc_memops;
> - q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>
> rc = vb2_queue_init(q);
> if (rc < 0)
> diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
> index 496bc2e..01ed1ec8 100644
> --- a/drivers/media/usb/usbtv/usbtv-video.c
> +++ b/drivers/media/usb/usbtv/usbtv-video.c
> @@ -679,7 +679,7 @@ int usbtv_video_init(struct usbtv *usbtv)
> usbtv->vb2q.buf_struct_size = sizeof(struct usbtv_buf);
> usbtv->vb2q.ops = &usbtv_vb2_ops;
> usbtv->vb2q.mem_ops = &vb2_vmalloc_memops;
> - usbtv->vb2q.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + usbtv->vb2q.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> usbtv->vb2q.lock = &usbtv->vb2q_lock;
> ret = vb2_queue_init(&usbtv->vb2q);
> if (ret < 0) {
> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
> index ff7be97..7c14616 100644
> --- a/drivers/media/usb/uvc/uvc_queue.c
> +++ b/drivers/media/usb/uvc/uvc_queue.c
> @@ -151,7 +151,7 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
> queue->queue.buf_struct_size = sizeof(struct uvc_buffer);
> queue->queue.ops = &uvc_queue_qops;
> queue->queue.mem_ops = &vb2_vmalloc_memops;
> - queue->queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + queue->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> ret = vb2_queue_init(&queue->queue);
> if (ret)
> return ret;
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index edab3af..411429c 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -488,7 +488,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
> * Clear any buffer state related flags.
> */
> b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
> - b->flags |= q->timestamp_type;
> + b->flags |= q->timestamp_flags;
>
> switch (vb->state) {
> case VB2_BUF_STATE_QUEUED:
> @@ -1473,7 +1473,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
> * For output buffers copy the timestamp if needed,
> * and the timecode field and flag if needed.
> */
> - if (q->timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_COPY)
> + if (q->timestamp_flags == V4L2_BUF_FLAG_TIMESTAMP_COPY)
> vb->v4l2_buf.timestamp = b->timestamp;
> vb->v4l2_buf.flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;
> if (b->flags & V4L2_BUF_FLAG_TIMECODE)
> @@ -2226,11 +2226,11 @@ int vb2_queue_init(struct vb2_queue *q)
> WARN_ON(!q->io_modes) ||
> WARN_ON(!q->ops->queue_setup) ||
> WARN_ON(!q->ops->buf_queue) ||
> - WARN_ON(q->timestamp_type & ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
> + WARN_ON(q->timestamp_flags & ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
> return -EINVAL;
>
> /* Warn that the driver should choose an appropriate timestamp type */
> - WARN_ON(q->timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
> + WARN_ON(q->timestamp_flags == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
>
> INIT_LIST_HEAD(&q->queued_list);
> INIT_LIST_HEAD(&q->done_list);
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index bef53ce..3770be6 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -342,7 +342,7 @@ struct vb2_queue {
> const struct vb2_mem_ops *mem_ops;
> void *drv_priv;
> unsigned int buf_struct_size;
> - u32 timestamp_type;
> + u32 timestamp_flags;
> gfp_t gfp_flags;
>
> /* private: internal use only */
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly
2014-03-01 13:17 ` [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly Sakari Ailus
@ 2014-03-01 14:28 ` Hans Verkuil
2014-03-01 16:51 ` Sakari Ailus
2014-03-01 16:59 ` [PATH v6.1 " Sakari Ailus
0 siblings, 2 replies; 21+ messages in thread
From: Hans Verkuil @ 2014-03-01 14:28 UTC (permalink / raw)
To: Sakari Ailus, linux-media; +Cc: k.debski, laurent.pinchart
Hi Sakari,
I believe this needs some more work. See comments below:
On 03/01/2014 02:17 PM, Sakari Ailus wrote:
> For COPY timestamps, buffer timestamp source flags will traverse the queue
> untouched.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> ---
> drivers/media/v4l2-core/videobuf2-core.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index 3dda083..7afeb6b 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -488,7 +488,22 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
> * Clear any buffer state related flags.
> */
> b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
> - b->flags |= q->timestamp_flags;
> + if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
> + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
> + /*
> + * For COPY timestamps, we just set the timestamp type
> + * here. The timestamp source is already in b->flags.
> + */
> + b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
> + } else {
> + /*
> + * For non-COPY timestamps, drop timestamp source and
> + * obtain the timestamp type and source from the
> + * queue.
> + */
> + b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
> + b->flags |= q->timestamp_flags;
> + }
It's correct, but I would do it a bit differently:
b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
V4L2_BUF_FLAG_TIMESTAMP_COPY) {
/*
* For non-COPY timestamps, drop timestamp source and
* obtain the timestamp type and source from the
* queue.
*/
b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
}
That way it is clearer that the timestamp type is always set and that it is
just the timestamp source that has special handling.
>
> switch (vb->state) {
> case VB2_BUF_STATE_QUEUED:
> @@ -1031,6 +1046,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
>
> /* Zero flags that the vb2 core handles */
> vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
> + if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
> + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
> + /*
> + * Non-COPY timestamps will get their timestamp and
> + * timestamp source flags from the queue.
> + */
> + vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
> + }
This should be:
if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b->type)) {
Capture buffers also need to clear the TSTAMP_SRC flags as they will get it
from the output queue. In other words: capture buffers never set the timestamp
source flags, only output buffers can do that if timestamps are copied.
As an aside: the more I think about it, the more I believe that we're not quite
doing the right thing when it comes to copying timestamps. The problem is that
TIMESTAMP_COPY is part of the timestamp type mask. It should be a separate bit.
That way output buffers supply both type and source, and capture buffers give
those back to the application. Right now you can't copy the timestamp type since
COPY is part of those types.
We did not really think that through.
Regards,
Hans
> +
> if (V4L2_TYPE_IS_OUTPUT(b->type)) {
> /*
> * For output buffers mask out the timecode flag:
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATH v6 05.1/11] v4l: Timestamp flags will soon contain timestamp source, not just type
2014-03-01 13:17 ` [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them Sakari Ailus
2014-03-01 13:39 ` Hans Verkuil
@ 2014-03-01 16:13 ` Sakari Ailus
1 sibling, 0 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 16:13 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, k.debski, laurent.pinchart
Mask out other bits when comparing timestamp types.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
This change was missing from the set. The check needs to be changed as there
will be also timestamp source flags, not just timestamp type flags in the
field.
drivers/media/v4l2-core/videobuf2-core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 411429c..521350a 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1473,7 +1473,8 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
* For output buffers copy the timestamp if needed,
* and the timecode field and flag if needed.
*/
- if (q->timestamp_flags == V4L2_BUF_FLAG_TIMESTAMP_COPY)
+ if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
+ V4L2_BUF_FLAG_TIMESTAMP_COPY)
vb->v4l2_buf.timestamp = b->timestamp;
vb->v4l2_buf.flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;
if (b->flags & V4L2_BUF_FLAG_TIMECODE)
@@ -2230,7 +2231,8 @@ int vb2_queue_init(struct vb2_queue *q)
return -EINVAL;
/* Warn that the driver should choose an appropriate timestamp type */
- WARN_ON(q->timestamp_flags == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
+ WARN_ON((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
+ V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
INIT_LIST_HEAD(&q->queued_list);
INIT_LIST_HEAD(&q->done_list);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them
2014-03-01 13:39 ` Hans Verkuil
@ 2014-03-01 16:22 ` Sakari Ailus
0 siblings, 0 replies; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 16:22 UTC (permalink / raw)
To: Hans Verkuil, linux-media; +Cc: k.debski, laurent.pinchart
Hi Hans,
Hans Verkuil wrote:
> Hi Sakari,
>
> Don't worry, it's a very minor change:
I won't; I'm always happy to get comments. ;-) Thank you again.
> On 03/01/2014 02:17 PM, Sakari Ailus wrote:
>> Some devices do not produce timestamps that correspond to the end of the
>> frame. The user space should be informed on the matter. This patch achieves
>> that by adding buffer flags (and a mask) for timestamp sources since more
>> possible timestamping points are expected than just two.
>>
>> A three-bit mask is defined (V4L2_BUF_FLAG_TSTAMP_SRC_MASK) and two of the
>> eight possible values is are defined V4L2_BUF_FLAG_TSTAMP_SRC_EOF for end of
>> frame (value zero) V4L2_BUF_FLAG_TSTAMP_SRC_SOE for start of exposure (next
>> value).
I'll fix that soonish.
--
Sakari Ailus
sakari.ailus@iki.fi
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly
2014-03-01 14:28 ` Hans Verkuil
@ 2014-03-01 16:51 ` Sakari Ailus
2014-03-02 7:24 ` Hans Verkuil
2014-03-01 16:59 ` [PATH v6.1 " Sakari Ailus
1 sibling, 1 reply; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 16:51 UTC (permalink / raw)
To: Hans Verkuil, linux-media; +Cc: k.debski, laurent.pinchart
Hi Hans,
Thanks for the comments.
Hans Verkuil wrote:
> On 03/01/2014 02:17 PM, Sakari Ailus wrote:
>> For COPY timestamps, buffer timestamp source flags will traverse the queue
>> untouched.
>>
>> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
>> ---
>> drivers/media/v4l2-core/videobuf2-core.c | 26 +++++++++++++++++++++++++-
>> 1 file changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
>> index 3dda083..7afeb6b 100644
>> --- a/drivers/media/v4l2-core/videobuf2-core.c
>> +++ b/drivers/media/v4l2-core/videobuf2-core.c
>> @@ -488,7 +488,22 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
>> * Clear any buffer state related flags.
>> */
>> b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
>> - b->flags |= q->timestamp_flags;
>> + if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
>> + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
>> + /*
>> + * For COPY timestamps, we just set the timestamp type
>> + * here. The timestamp source is already in b->flags.
>> + */
>> + b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
>> + } else {
>> + /*
>> + * For non-COPY timestamps, drop timestamp source and
>> + * obtain the timestamp type and source from the
>> + * queue.
>> + */
>> + b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
>> + b->flags |= q->timestamp_flags;
>> + }
>
> It's correct, but I would do it a bit differently:
>
> b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
> b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
> if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
> V4L2_BUF_FLAG_TIMESTAMP_COPY) {
> /*
> * For non-COPY timestamps, drop timestamp source and
> * obtain the timestamp type and source from the
> * queue.
> */
> b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
> b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
> }
>
> That way it is clearer that the timestamp type is always set and that it is
> just the timestamp source that has special handling.
I was actually pondering between the above and what ended up into the
code. ;-) I'll fix that and change the comment to say:
/*
* For non-COPY timestamps, drop timestamp source bits
* and obtain the timestamp source from the queue.
*/
>
>>
>> switch (vb->state) {
>> case VB2_BUF_STATE_QUEUED:
>> @@ -1031,6 +1046,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
>>
>> /* Zero flags that the vb2 core handles */
>> vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
>> + if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
>> + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
>> + /*
>> + * Non-COPY timestamps will get their timestamp and
>> + * timestamp source flags from the queue.
>> + */
>> + vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
>> + }
>
> This should be:
>
> if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
> V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b->type)) {
>
> Capture buffers also need to clear the TSTAMP_SRC flags as they will get it
> from the output queue. In other words: capture buffers never set the timestamp
> source flags, only output buffers can do that if timestamps are copied.
Good point. I'll also change the comment accordingly:
/*
* Non-COPY timestamps and non-OUTPUT queues will get
* their timestamp and timestamp source flags from the
* queue.
*/
> As an aside: the more I think about it, the more I believe that we're not quite
> doing the right thing when it comes to copying timestamps. The problem is that
> TIMESTAMP_COPY is part of the timestamp type mask. It should be a separate bit.
> That way output buffers supply both type and source, and capture buffers give
> those back to the application. Right now you can't copy the timestamp type since
> COPY is part of those types.
Is that a real problem? The timestamp types are related to clocks and in
that sense, "copy" is one of them: it's anything the program queueing it
to the OUTPUT queue has specified. In other words, I don't think the
combination of monotonic (or realtime) and copy would be meaningful.
> We did not really think that through.
At least I don't see a problem with how it's currently implemented. :-)
--
Kind regards,
Sakari Ailus
sakari.ailus@iki.fi
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATH v6.1 06/10] v4l: Handle buffer timestamp flags correctly
2014-03-01 14:28 ` Hans Verkuil
2014-03-01 16:51 ` Sakari Ailus
@ 2014-03-01 16:59 ` Sakari Ailus
2014-03-02 7:12 ` Hans Verkuil
1 sibling, 1 reply; 21+ messages in thread
From: Sakari Ailus @ 2014-03-01 16:59 UTC (permalink / raw)
To: linux-media; +Cc: k.debski, hverkuil, laurent.pinchart
For COPY timestamps, buffer timestamp source flags will traverse the queue
untouched.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
changes since v6:
- Clean up changes to __fill_v4l2_buffer().
- Drop timestamp source flags for non-OUTPUT buffers in __fill_vb2_buffer().
- Comments fixed accordingly.
drivers/media/v4l2-core/videobuf2-core.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 42a8568..79eb9ba 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -488,7 +488,16 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
* Clear any buffer state related flags.
*/
b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
- b->flags |= q->timestamp_flags;
+ b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
+ if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
+ V4L2_BUF_FLAG_TIMESTAMP_COPY) {
+ /*
+ * For non-COPY timestamps, drop timestamp source bits
+ * and obtain the timestamp source from the queue.
+ */
+ b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ }
switch (vb->state) {
case VB2_BUF_STATE_QUEUED:
@@ -1031,6 +1040,16 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
/* Zero flags that the vb2 core handles */
vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
+ if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
+ V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b->type)) {
+ /*
+ * Non-COPY timestamps and non-OUTPUT queues will get
+ * their timestamp and timestamp source flags from the
+ * queue.
+ */
+ vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ }
+
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
/*
* For output buffers mask out the timecode flag:
--
1.7.10.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATH v6.1 06/10] v4l: Handle buffer timestamp flags correctly
2014-03-01 16:59 ` [PATH v6.1 " Sakari Ailus
@ 2014-03-02 7:12 ` Hans Verkuil
0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2014-03-02 7:12 UTC (permalink / raw)
To: Sakari Ailus, linux-media; +Cc: k.debski, laurent.pinchart
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Regards,
Hans
On 03/01/2014 05:59 PM, Sakari Ailus wrote:
> For COPY timestamps, buffer timestamp source flags will traverse the queue
> untouched.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> ---
> changes since v6:
> - Clean up changes to __fill_v4l2_buffer().
> - Drop timestamp source flags for non-OUTPUT buffers in __fill_vb2_buffer().
> - Comments fixed accordingly.
>
> drivers/media/v4l2-core/videobuf2-core.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index 42a8568..79eb9ba 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -488,7 +488,16 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
> * Clear any buffer state related flags.
> */
> b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
> - b->flags |= q->timestamp_flags;
> + b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
> + if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
> + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
> + /*
> + * For non-COPY timestamps, drop timestamp source bits
> + * and obtain the timestamp source from the queue.
> + */
> + b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
> + b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
> + }
>
> switch (vb->state) {
> case VB2_BUF_STATE_QUEUED:
> @@ -1031,6 +1040,16 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
>
> /* Zero flags that the vb2 core handles */
> vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
> + if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
> + V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b->type)) {
> + /*
> + * Non-COPY timestamps and non-OUTPUT queues will get
> + * their timestamp and timestamp source flags from the
> + * queue.
> + */
> + vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
> + }
> +
> if (V4L2_TYPE_IS_OUTPUT(b->type)) {
> /*
> * For output buffers mask out the timecode flag:
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly
2014-03-01 16:51 ` Sakari Ailus
@ 2014-03-02 7:24 ` Hans Verkuil
0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2014-03-02 7:24 UTC (permalink / raw)
To: Sakari Ailus, linux-media; +Cc: k.debski, laurent.pinchart
On 03/01/2014 05:51 PM, Sakari Ailus wrote:
> Hi Hans,
>
> Thanks for the comments.
>
> Hans Verkuil wrote:
>> On 03/01/2014 02:17 PM, Sakari Ailus wrote:
>>> For COPY timestamps, buffer timestamp source flags will traverse the queue
>>> untouched.
>>>
>>> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
>>> ---
>>> drivers/media/v4l2-core/videobuf2-core.c | 26 +++++++++++++++++++++++++-
>>> 1 file changed, 25 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
>>> index 3dda083..7afeb6b 100644
>>> --- a/drivers/media/v4l2-core/videobuf2-core.c
>>> +++ b/drivers/media/v4l2-core/videobuf2-core.c
>>> @@ -488,7 +488,22 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
>>> * Clear any buffer state related flags.
>>> */
>>> b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
>>> - b->flags |= q->timestamp_flags;
>>> + if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
>>> + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
>>> + /*
>>> + * For COPY timestamps, we just set the timestamp type
>>> + * here. The timestamp source is already in b->flags.
>>> + */
>>> + b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
>>> + } else {
>>> + /*
>>> + * For non-COPY timestamps, drop timestamp source and
>>> + * obtain the timestamp type and source from the
>>> + * queue.
>>> + */
>>> + b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
>>> + b->flags |= q->timestamp_flags;
>>> + }
>>
>> It's correct, but I would do it a bit differently:
>>
>> b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
>> b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
>> if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
>> V4L2_BUF_FLAG_TIMESTAMP_COPY) {
>> /*
>> * For non-COPY timestamps, drop timestamp source and
>> * obtain the timestamp type and source from the
>> * queue.
>> */
>> b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
>> b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
>> }
>>
>> That way it is clearer that the timestamp type is always set and that it is
>> just the timestamp source that has special handling.
>
> I was actually pondering between the above and what ended up into the
> code. ;-) I'll fix that and change the comment to say:
>
> /*
> * For non-COPY timestamps, drop timestamp source bits
> * and obtain the timestamp source from the queue.
> */
>>
>>>
>>> switch (vb->state) {
>>> case VB2_BUF_STATE_QUEUED:
>>> @@ -1031,6 +1046,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
>>>
>>> /* Zero flags that the vb2 core handles */
>>> vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
>>> + if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
>>> + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
>>> + /*
>>> + * Non-COPY timestamps will get their timestamp and
>>> + * timestamp source flags from the queue.
>>> + */
>>> + vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
>>> + }
>>
>> This should be:
>>
>> if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
>> V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b->type)) {
>>
>> Capture buffers also need to clear the TSTAMP_SRC flags as they will get it
>> from the output queue. In other words: capture buffers never set the timestamp
>> source flags, only output buffers can do that if timestamps are copied.
>
> Good point. I'll also change the comment accordingly:
>
> /*
> * Non-COPY timestamps and non-OUTPUT queues will get
> * their timestamp and timestamp source flags from the
> * queue.
> */
>
>> As an aside: the more I think about it, the more I believe that we're not quite
>> doing the right thing when it comes to copying timestamps. The problem is that
>> TIMESTAMP_COPY is part of the timestamp type mask. It should be a separate bit.
>> That way output buffers supply both type and source, and capture buffers give
>> those back to the application. Right now you can't copy the timestamp type since
>> COPY is part of those types.
>
> Is that a real problem? The timestamp types are related to clocks and in
> that sense, "copy" is one of them: it's anything the program queueing it
> to the OUTPUT queue has specified. In other words, I don't think the
> combination of monotonic (or realtime) and copy would be meaningful.
>
>> We did not really think that through.
>
> At least I don't see a problem with how it's currently implemented. :-)
Well, the problem is that when you capture from hardware you get a timestamp
and a timestamp type (i.e. which clock did the timestamp use?). If you then
pass that captured stream through a m2m device for postprocessing you will
have lost the timestamp type on the other side of the m2m device since it
will be replaced with COPY.
That's not right IMHO.
What should happen I think for m2m copy devices is the following:
Initially after creating the buffers the timestamp type is set to COPY for
both capture and output buffers. You fill in the output buffer with timestamp,
timestamp source and timestamp type and call QBUF. At the moment QUERYBUF
will return what you put in there. Dequeuing that buffer on the capture side
will give back what you put in.
On the capture side the timestamp type should be set to COPY when you queue
the empty buffer and it will stay that way until the buffer is filled up
with the new frame in the m2m device.
I'm not sure what to do on the output side when dequeuing a buffer: keep the
values you put in when queuing it, or replace it with COPY. I think keeping
it is better, you might want to queue the same buffer to another m2m device
so you don't want to set up those values again.
Yeah, I think that would make sense. COPY can still be part of the timestamp
type mask, but it's just replaced by the user's timestamp settings as you
would expect.
Regards,
Hans
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2014-03-02 7:25 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-01 13:16 [PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags Sakari Ailus
2014-03-01 13:16 ` [PATH v6 01/10] vb2: fix timecode and flags handling for output buffers Sakari Ailus
2014-03-01 13:16 ` [PATH v6 02/10] v4l: Document timestamp behaviour to correspond to reality Sakari Ailus
2014-03-01 13:17 ` [PATH v6 03/10] v4l: Use full 32 bits for buffer flags Sakari Ailus
2014-03-01 13:17 ` [PATH v6 04/10] v4l: Rename vb2_queue.timestamp_type as timestamp_flags Sakari Ailus
2014-03-01 13:43 ` Hans Verkuil
2014-03-01 13:17 ` [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them Sakari Ailus
2014-03-01 13:39 ` Hans Verkuil
2014-03-01 16:22 ` Sakari Ailus
2014-03-01 16:13 ` [PATH v6 05.1/11] v4l: Timestamp flags will soon contain timestamp source, not just type Sakari Ailus
2014-03-01 13:17 ` [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly Sakari Ailus
2014-03-01 14:28 ` Hans Verkuil
2014-03-01 16:51 ` Sakari Ailus
2014-03-02 7:24 ` Hans Verkuil
2014-03-01 16:59 ` [PATH v6.1 " Sakari Ailus
2014-03-02 7:12 ` Hans Verkuil
2014-03-01 13:17 ` [PATH v6 07/10] uvcvideo: Tell the user space we're using start-of-exposure timestamps Sakari Ailus
2014-03-01 13:17 ` [PATH v6 08/10] exynos-gsc, m2m-deinterlace, mx2_emmaprp: Copy v4l2_buffer data from src to dst Sakari Ailus
2014-03-01 13:17 ` [PATH v6 09/10] v4l: Copy timestamp source flags to destination on m2m devices Sakari Ailus
2014-03-01 13:17 ` [PATH v6 10/10] v4l: Document timestamp buffer flag behaviour Sakari Ailus
2014-03-01 13:42 ` Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox