[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>
This commit is contained in:
		
					parent
					
						
							
								53bf0f446b
							
						
					
				
			
			
				commit
				
					
						6aa69f99b2
					
				
			
		
					 18 changed files with 24 additions and 2 deletions
				
			
		|  | @ -1029,6 +1029,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; | ||||
| 
 | ||||
| 	vb2_queue_init(q); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1404,6 +1404,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; | ||||
| 
 | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret) { | ||||
|  |  | |||
|  | @ -1035,6 +1035,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; | ||||
| 
 | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret) { | ||||
|  |  | |||
|  | @ -1001,6 +1001,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; | ||||
| 
 | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret) { | ||||
|  |  | |||
|  | @ -1153,6 +1153,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; | ||||
| 
 | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret) | ||||
|  |  | |||
|  | @ -1797,6 +1797,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; | ||||
| 
 | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret) | ||||
|  |  | |||
|  | @ -1325,6 +1325,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; | ||||
| 
 | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret < 0) | ||||
|  |  | |||
|  | @ -804,6 +804,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; | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret) { | ||||
| 		mfc_err("Failed to initialize videobuf2 queue(capture)\n"); | ||||
|  | @ -825,6 +826,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; | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret) { | ||||
| 		mfc_err("Failed to initialize videobuf2 queue(output)\n"); | ||||
|  |  | |||
|  | @ -514,6 +514,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; | ||||
| 
 | ||||
| 	return vb2_queue_init(q); | ||||
| } | ||||
|  |  | |||
|  | @ -797,6 +797,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; | ||||
| 
 | ||||
| 	return vb2_queue_init(q); | ||||
| } | ||||
|  |  | |||
|  | @ -455,6 +455,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; | ||||
| 
 | ||||
| 	return vb2_queue_init(q); | ||||
| } | ||||
|  |  | |||
|  | @ -2026,6 +2026,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; | ||||
| 
 | ||||
| 	return vb2_queue_init(q); | ||||
| } | ||||
|  |  | |||
|  | @ -1429,6 +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; | ||||
| 
 | ||||
| 	ret = vb2_queue_init(q); | ||||
| 	if (ret) | ||||
|  |  | |||
|  | @ -1001,6 +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; | ||||
| 	rc = vb2_queue_init(&pdev->vb_queue); | ||||
| 	if (rc < 0) { | ||||
| 		PWC_ERROR("Oops, could not initialize vb2 queue.\n"); | ||||
|  |  | |||
|  | @ -687,6 +687,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; | ||||
| 
 | ||||
| 	rc = vb2_queue_init(q); | ||||
| 	if (rc < 0) | ||||
|  |  | |||
|  | @ -149,6 +149,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; | ||||
| 	ret = vb2_queue_init(&queue->queue); | ||||
| 	if (ret) | ||||
| 		return ret; | ||||
|  |  | |||
|  | @ -403,7 +403,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 |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||||
| 	b->flags |= q->timestamp_type; | ||||
| 
 | ||||
| 	switch (vb->state) { | ||||
| 	case VB2_BUF_STATE_QUEUED: | ||||
|  | @ -2039,9 +2039,13 @@ int vb2_queue_init(struct vb2_queue *q) | |||
| 	    WARN_ON(!q->type)		  || | ||||
| 	    WARN_ON(!q->io_modes)	  || | ||||
| 	    WARN_ON(!q->ops->queue_setup) || | ||||
| 	    WARN_ON(!q->ops->buf_queue)) | ||||
| 	    WARN_ON(!q->ops->buf_queue)   || | ||||
| 	    WARN_ON(q->timestamp_type & ~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); | ||||
| 
 | ||||
| 	INIT_LIST_HEAD(&q->queued_list); | ||||
| 	INIT_LIST_HEAD(&q->done_list); | ||||
| 	spin_lock_init(&q->done_lock); | ||||
|  |  | |||
|  | @ -326,6 +326,7 @@ struct vb2_queue { | |||
| 	const struct vb2_mem_ops	*mem_ops; | ||||
| 	void				*drv_priv; | ||||
| 	unsigned int			buf_struct_size; | ||||
| 	u32				timestamp_type; | ||||
| 
 | ||||
| /* private: internal use only */ | ||||
| 	enum v4l2_memory		memory; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kamil Debski
				Kamil Debski