aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKamil Debski <k.debski@samsung.com>2013-01-25 04:29:57 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 12:53:05 -0500
commit6aa69f99b2ecc7f9b387fcf22d30e6601b58819f (patch)
tree4cfb60434345720acec8f88a754ffe7f6bf86176
parent53bf0f446bc387eabdd535dca080789cc74607f4 (diff)
[media] vb2: Add support for non monotonic timestamps
Not all drivers use monotonic timestamps. This patch adds a way to set the timestamp type per every queue. In addition, set proper timestamp type in drivers that I am sure that use either MONOTONIC or COPY timestamps. Other drivers will correctly report UNKNOWN timestamp type instead of assuming that all drivers use monotonic timestamps. Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/platform/blackfin/bfin_capture.c1
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c1
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c1
-rw-r--r--drivers/media/platform/davinci/vpif_display.c1
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c1
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-capture.c1
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-lite.c1
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c2
-rw-r--r--drivers/media/platform/soc_camera/atmel-isi.c1
-rw-r--r--drivers/media/platform/soc_camera/mx2_camera.c1
-rw-r--r--drivers/media/platform/soc_camera/mx3_camera.c1
-rw-r--r--drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c1
-rw-r--r--drivers/media/platform/vivi.c1
-rw-r--r--drivers/media/usb/pwc/pwc-if.c1
-rw-r--r--drivers/media/usb/stk1160/stk1160-v4l.c1
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c1
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c8
-rw-r--r--include/media/videobuf2-core.h1
18 files changed, 24 insertions, 2 deletions
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 5f209d5810dc..8ffe42aabd85 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -1029,6 +1029,7 @@ static int bcap_probe(struct platform_device *pdev)
1029 q->buf_struct_size = sizeof(struct bcap_buffer); 1029 q->buf_struct_size = sizeof(struct bcap_buffer);
1030 q->ops = &bcap_video_qops; 1030 q->ops = &bcap_video_qops;
1031 q->mem_ops = &vb2_dma_contig_memops; 1031 q->mem_ops = &vb2_dma_contig_memops;
1032 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1032 1033
1033 vb2_queue_init(q); 1034 vb2_queue_init(q);
1034 1035
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index 5e6b0cab514b..9f9f2c1a073f 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1404,6 +1404,7 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
1404 q->ops = &video_qops; 1404 q->ops = &video_qops;
1405 q->mem_ops = &vb2_dma_contig_memops; 1405 q->mem_ops = &vb2_dma_contig_memops;
1406 q->buf_struct_size = sizeof(struct vpbe_disp_buffer); 1406 q->buf_struct_size = sizeof(struct vpbe_disp_buffer);
1407 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1407 1408
1408 ret = vb2_queue_init(q); 1409 ret = vb2_queue_init(q);
1409 if (ret) { 1410 if (ret) {
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 5892d2bc8eee..1943e41f3866 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1035,6 +1035,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
1035 q->ops = &video_qops; 1035 q->ops = &video_qops;
1036 q->mem_ops = &vb2_dma_contig_memops; 1036 q->mem_ops = &vb2_dma_contig_memops;
1037 q->buf_struct_size = sizeof(struct vpif_cap_buffer); 1037 q->buf_struct_size = sizeof(struct vpif_cap_buffer);
1038 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1038 1039
1039 ret = vb2_queue_init(q); 1040 ret = vb2_queue_init(q);
1040 if (ret) { 1041 if (ret) {
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index dd249c96126d..5477c2cb8653 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1001,6 +1001,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
1001 q->ops = &video_qops; 1001 q->ops = &video_qops;
1002 q->mem_ops = &vb2_dma_contig_memops; 1002 q->mem_ops = &vb2_dma_contig_memops;
1003 q->buf_struct_size = sizeof(struct vpif_disp_buffer); 1003 q->buf_struct_size = sizeof(struct vpif_disp_buffer);
1004 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1004 1005
1005 ret = vb2_queue_init(q); 1006 ret = vb2_queue_init(q);
1006 if (ret) { 1007 if (ret) {
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index a55793c3d811..e91f350929eb 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -1153,6 +1153,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
1153 q->mem_ops = &vb2_dma_contig_memops; 1153 q->mem_ops = &vb2_dma_contig_memops;
1154 q->buf_struct_size = sizeof(struct camif_buffer); 1154 q->buf_struct_size = sizeof(struct camif_buffer);
1155 q->drv_priv = vp; 1155 q->drv_priv = vp;
1156 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1156 1157
1157 ret = vb2_queue_init(q); 1158 ret = vb2_queue_init(q);
1158 if (ret) 1159 if (ret)
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c
index f553cc2a8ee8..87b68420f771 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -1797,6 +1797,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
1797 q->ops = &fimc_capture_qops; 1797 q->ops = &fimc_capture_qops;
1798 q->mem_ops = &vb2_dma_contig_memops; 1798 q->mem_ops = &vb2_dma_contig_memops;
1799 q->buf_struct_size = sizeof(struct fimc_vid_buffer); 1799 q->buf_struct_size = sizeof(struct fimc_vid_buffer);
1800 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1800 1801
1801 ret = vb2_queue_init(q); 1802 ret = vb2_queue_init(q);
1802 if (ret) 1803 if (ret)
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c b/drivers/media/platform/s5p-fimc/fimc-lite.c
index bfc4206935c8..47fbf7bcf608 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -1325,6 +1325,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
1325 q->mem_ops = &vb2_dma_contig_memops; 1325 q->mem_ops = &vb2_dma_contig_memops;
1326 q->buf_struct_size = sizeof(struct flite_buffer); 1326 q->buf_struct_size = sizeof(struct flite_buffer);
1327 q->drv_priv = fimc; 1327 q->drv_priv = fimc;
1328 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1328 1329
1329 ret = vb2_queue_init(q); 1330 ret = vb2_queue_init(q);
1330 if (ret < 0) 1331 if (ret < 0)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index e84703c314ce..92c6bf11af74 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -804,6 +804,7 @@ static int s5p_mfc_open(struct file *file)
804 goto err_queue_init; 804 goto err_queue_init;
805 } 805 }
806 q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops; 806 q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops;
807 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
807 ret = vb2_queue_init(q); 808 ret = vb2_queue_init(q);
808 if (ret) { 809 if (ret) {
809 mfc_err("Failed to initialize videobuf2 queue(capture)\n"); 810 mfc_err("Failed to initialize videobuf2 queue(capture)\n");
@@ -825,6 +826,7 @@ static int s5p_mfc_open(struct file *file)
825 goto err_queue_init; 826 goto err_queue_init;
826 } 827 }
827 q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops; 828 q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops;
829 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
828 ret = vb2_queue_init(q); 830 ret = vb2_queue_init(q);
829 if (ret) { 831 if (ret) {
830 mfc_err("Failed to initialize videobuf2 queue(output)\n"); 832 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 82dbf99d347c..c314ff9b98dc 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -514,6 +514,7 @@ static int isi_camera_init_videobuf(struct vb2_queue *q,
514 q->buf_struct_size = sizeof(struct frame_buffer); 514 q->buf_struct_size = sizeof(struct frame_buffer);
515 q->ops = &isi_video_qops; 515 q->ops = &isi_video_qops;
516 q->mem_ops = &vb2_dma_contig_memops; 516 q->mem_ops = &vb2_dma_contig_memops;
517 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
517 518
518 return vb2_queue_init(q); 519 return vb2_queue_init(q);
519} 520}
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
index ffba7d91f413..048c26a27c34 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -797,6 +797,7 @@ static int mx2_camera_init_videobuf(struct vb2_queue *q,
797 q->ops = &mx2_videobuf_ops; 797 q->ops = &mx2_videobuf_ops;
798 q->mem_ops = &vb2_dma_contig_memops; 798 q->mem_ops = &vb2_dma_contig_memops;
799 q->buf_struct_size = sizeof(struct mx2_buffer); 799 q->buf_struct_size = sizeof(struct mx2_buffer);
800 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
800 801
801 return vb2_queue_init(q); 802 return vb2_queue_init(q);
802} 803}
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
index f5cbb92db545..2c3bd69fb38c 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -455,6 +455,7 @@ static int mx3_camera_init_videobuf(struct vb2_queue *q,
455 q->ops = &mx3_videobuf_ops; 455 q->ops = &mx3_videobuf_ops;
456 q->mem_ops = &vb2_dma_contig_memops; 456 q->mem_ops = &vb2_dma_contig_memops;
457 q->buf_struct_size = sizeof(struct mx3_camera_buffer); 457 q->buf_struct_size = sizeof(struct mx3_camera_buffer);
458 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
458 459
459 return vb2_queue_init(q); 460 return vb2_queue_init(q);
460} 461}
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 bb08a46432f4..973e72b24fa8 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -2026,6 +2026,7 @@ static int sh_mobile_ceu_init_videobuf(struct vb2_queue *q,
2026 q->ops = &sh_mobile_ceu_videobuf_ops; 2026 q->ops = &sh_mobile_ceu_videobuf_ops;
2027 q->mem_ops = &vb2_dma_contig_memops; 2027 q->mem_ops = &vb2_dma_contig_memops;
2028 q->buf_struct_size = sizeof(struct sh_mobile_ceu_buffer); 2028 q->buf_struct_size = sizeof(struct sh_mobile_ceu_buffer);
2029 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2029 2030
2030 return vb2_queue_init(q); 2031 return vb2_queue_init(q);
2031} 2032}
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 8a33a712f480..c46d2e8677a5 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -1429,6 +1429,7 @@ static int __init vivi_create_instance(int inst)
1429 q->buf_struct_size = sizeof(struct vivi_buffer); 1429 q->buf_struct_size = sizeof(struct vivi_buffer);
1430 q->ops = &vivi_video_qops; 1430 q->ops = &vivi_video_qops;
1431 q->mem_ops = &vb2_vmalloc_memops; 1431 q->mem_ops = &vb2_vmalloc_memops;
1432 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1432 1433
1433 ret = vb2_queue_init(q); 1434 ret = vb2_queue_init(q);
1434 if (ret) 1435 if (ret)
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index 5ec15cb1ed26..77bbf7889659 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -1001,6 +1001,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1001 pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf); 1001 pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf);
1002 pdev->vb_queue.ops = &pwc_vb_queue_ops; 1002 pdev->vb_queue.ops = &pwc_vb_queue_ops;
1003 pdev->vb_queue.mem_ops = &vb2_vmalloc_memops; 1003 pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
1004 pdev->vb_queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1004 rc = vb2_queue_init(&pdev->vb_queue); 1005 rc = vb2_queue_init(&pdev->vb_queue);
1005 if (rc < 0) { 1006 if (rc < 0) {
1006 PWC_ERROR("Oops, could not initialize vb2 queue.\n"); 1007 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 6694f9e2ca57..5307a63e378f 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -687,6 +687,7 @@ int stk1160_vb2_setup(struct stk1160 *dev)
687 q->buf_struct_size = sizeof(struct stk1160_buffer); 687 q->buf_struct_size = sizeof(struct stk1160_buffer);
688 q->ops = &stk1160_video_qops; 688 q->ops = &stk1160_video_qops;
689 q->mem_ops = &vb2_vmalloc_memops; 689 q->mem_ops = &vb2_vmalloc_memops;
690 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
690 691
691 rc = vb2_queue_init(q); 692 rc = vb2_queue_init(q);
692 if (rc < 0) 693 if (rc < 0)
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 6c233a54ce40..cd962be860ca 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -149,6 +149,7 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
149 queue->queue.buf_struct_size = sizeof(struct uvc_buffer); 149 queue->queue.buf_struct_size = sizeof(struct uvc_buffer);
150 queue->queue.ops = &uvc_queue_qops; 150 queue->queue.ops = &uvc_queue_qops;
151 queue->queue.mem_ops = &vb2_vmalloc_memops; 151 queue->queue.mem_ops = &vb2_vmalloc_memops;
152 queue->queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
152 ret = vb2_queue_init(&queue->queue); 153 ret = vb2_queue_init(&queue->queue);
153 if (ret) 154 if (ret)
154 return ret; 155 return ret;
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index db1235dcb328..be0448161c60 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -403,7 +403,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
403 * Clear any buffer state related flags. 403 * Clear any buffer state related flags.
404 */ 404 */
405 b->flags &= ~V4L2_BUFFER_MASK_FLAGS; 405 b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
406 b->flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 406 b->flags |= q->timestamp_type;
407 407
408 switch (vb->state) { 408 switch (vb->state) {
409 case VB2_BUF_STATE_QUEUED: 409 case VB2_BUF_STATE_QUEUED:
@@ -2039,9 +2039,13 @@ int vb2_queue_init(struct vb2_queue *q)
2039 WARN_ON(!q->type) || 2039 WARN_ON(!q->type) ||
2040 WARN_ON(!q->io_modes) || 2040 WARN_ON(!q->io_modes) ||
2041 WARN_ON(!q->ops->queue_setup) || 2041 WARN_ON(!q->ops->queue_setup) ||
2042 WARN_ON(!q->ops->buf_queue)) 2042 WARN_ON(!q->ops->buf_queue) ||
2043 WARN_ON(q->timestamp_type & ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
2043 return -EINVAL; 2044 return -EINVAL;
2044 2045
2046 /* Warn that the driver should choose an appropriate timestamp type */
2047 WARN_ON(q->timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
2048
2045 INIT_LIST_HEAD(&q->queued_list); 2049 INIT_LIST_HEAD(&q->queued_list);
2046 INIT_LIST_HEAD(&q->done_list); 2050 INIT_LIST_HEAD(&q->done_list);
2047 spin_lock_init(&q->done_lock); 2051 spin_lock_init(&q->done_lock);
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 9cfd4ee9e56f..a2d427450780 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -326,6 +326,7 @@ struct vb2_queue {
326 const struct vb2_mem_ops *mem_ops; 326 const struct vb2_mem_ops *mem_ops;
327 void *drv_priv; 327 void *drv_priv;
328 unsigned int buf_struct_size; 328 unsigned int buf_struct_size;
329 u32 timestamp_type;
329 330
330/* private: internal use only */ 331/* private: internal use only */
331 enum v4l2_memory memory; 332 enum v4l2_memory memory;