diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-04-11 03:36:57 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-04-16 17:45:33 -0400 |
commit | ebd7c50510f4b56285bb9fb4ba56a501c9c8f7df (patch) | |
tree | 62b8f34954fb8f5d17f6bb3b1f0ec0ac430cdf4d | |
parent | dcc2428a5e930aa7c0f40840a946b68a396ceae6 (diff) |
[media] vb2: set timestamp when using write()
When using write() to write data to an output video node the vb2 core
should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody
else is able to provide this information with the write() operation.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pawel Osciak <pawel@osciak.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-core.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 0f495f1d6946..07ab0677e259 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <media/v4l2-dev.h> | 22 | #include <media/v4l2-dev.h> |
23 | #include <media/v4l2-fh.h> | 23 | #include <media/v4l2-fh.h> |
24 | #include <media/v4l2-event.h> | 24 | #include <media/v4l2-event.h> |
25 | #include <media/v4l2-common.h> | ||
25 | #include <media/videobuf2-core.h> | 26 | #include <media/videobuf2-core.h> |
26 | 27 | ||
27 | static int debug; | 28 | static int debug; |
@@ -2800,6 +2801,14 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
2800 | { | 2801 | { |
2801 | struct vb2_fileio_data *fileio; | 2802 | struct vb2_fileio_data *fileio; |
2802 | struct vb2_fileio_buf *buf; | 2803 | struct vb2_fileio_buf *buf; |
2804 | /* | ||
2805 | * When using write() to write data to an output video node the vb2 core | ||
2806 | * should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody | ||
2807 | * else is able to provide this information with the write() operation. | ||
2808 | */ | ||
2809 | bool set_timestamp = !read && | ||
2810 | (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) == | ||
2811 | V4L2_BUF_FLAG_TIMESTAMP_COPY; | ||
2803 | int ret, index; | 2812 | int ret, index; |
2804 | 2813 | ||
2805 | dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n", | 2814 | dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n", |
@@ -2901,6 +2910,8 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
2901 | fileio->b.memory = q->memory; | 2910 | fileio->b.memory = q->memory; |
2902 | fileio->b.index = index; | 2911 | fileio->b.index = index; |
2903 | fileio->b.bytesused = buf->pos; | 2912 | fileio->b.bytesused = buf->pos; |
2913 | if (set_timestamp) | ||
2914 | v4l2_get_timestamp(&fileio->b.timestamp); | ||
2904 | ret = vb2_internal_qbuf(q, &fileio->b); | 2915 | ret = vb2_internal_qbuf(q, &fileio->b); |
2905 | dprintk(5, "vb2_dbuf result: %d\n", ret); | 2916 | dprintk(5, "vb2_dbuf result: %d\n", ret); |
2906 | if (ret) | 2917 | if (ret) |