Browse Source

video: driver: Add V4L2_MEMORY_DMABUF support

Use V4L2_MEMORY_DMABUF memory instead of V4L2_MEMORY_USERPTR
in all video usecases.

Change-Id: If763047f3f94ed2a19c239f8ce41d89fc2f086c4
Signed-off-by: Chinmay Sawarkar <[email protected]>
Chinmay Sawarkar 4 years ago
parent
commit
9f4ffee965

+ 5 - 0
driver/vidc/inc/msm_vidc_vb2.h

@@ -13,6 +13,11 @@
 void *msm_vb2_get_userptr(struct device *dev, unsigned long vaddr,
 void *msm_vb2_get_userptr(struct device *dev, unsigned long vaddr,
 			unsigned long size, enum dma_data_direction dma_dir);
 			unsigned long size, enum dma_data_direction dma_dir);
 void msm_vb2_put_userptr(void *buf_priv);
 void msm_vb2_put_userptr(void *buf_priv);
+void* msm_vb2_attach_dmabuf(struct device* dev, struct dma_buf* dbuf,
+	unsigned long size, enum dma_data_direction dma_dir);
+void msm_vb2_detach_dmabuf(void* buf_priv);
+int msm_vb2_map_dmabuf(void* buf_priv);
+void msm_vb2_unmap_dmabuf(void* buf_priv);
 
 
 /* vb2_ops */
 /* vb2_ops */
 int msm_vidc_queue_setup(struct vb2_queue *q,
 int msm_vidc_queue_setup(struct vb2_queue *q,

+ 1 - 1
driver/vidc/src/msm_vidc_driver.c

@@ -1047,7 +1047,7 @@ static int vb2q_init(struct msm_vidc_inst *inst,
 	core = inst->core;
 	core = inst->core;
 
 
 	q->type = type;
 	q->type = type;
-	q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
+	q->io_modes = VB2_DMABUF;
 	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 	q->ops = core->vb2_ops;
 	q->ops = core->vb2_ops;
 	q->mem_ops = core->vb2_mem_ops;
 	q->mem_ops = core->vb2_mem_ops;

+ 4 - 0
driver/vidc/src/msm_vidc_platform.c

@@ -69,6 +69,10 @@ static struct vb2_ops msm_vb2_ops = {
 static struct vb2_mem_ops msm_vb2_mem_ops = {
 static struct vb2_mem_ops msm_vb2_mem_ops = {
 	.get_userptr                    = msm_vb2_get_userptr,
 	.get_userptr                    = msm_vb2_get_userptr,
 	.put_userptr                    = msm_vb2_put_userptr,
 	.put_userptr                    = msm_vb2_put_userptr,
+	.attach_dmabuf                  = msm_vb2_attach_dmabuf,
+	.detach_dmabuf                  = msm_vb2_detach_dmabuf,
+	.map_dmabuf                     = msm_vb2_map_dmabuf,
+	.unmap_dmabuf                   = msm_vb2_unmap_dmabuf,
 };
 };
 
 
 static int msm_vidc_init_ops(struct msm_vidc_core *core)
 static int msm_vidc_init_ops(struct msm_vidc_core *core)

+ 19 - 0
driver/vidc/src/msm_vidc_vb2.c

@@ -22,6 +22,25 @@ void msm_vb2_put_userptr(void *buf_priv)
 {
 {
 }
 }
 
 
+void* msm_vb2_attach_dmabuf(struct device* dev, struct dma_buf* dbuf,
+	unsigned long size, enum dma_data_direction dma_dir)
+{
+	return (void*)0xdeadbeef;
+}
+
+void msm_vb2_detach_dmabuf(void* buf_priv)
+{
+}
+
+int msm_vb2_map_dmabuf(void* buf_priv)
+{
+	return 0;
+}
+
+void msm_vb2_unmap_dmabuf(void* buf_priv)
+{
+}
+
 int msm_vidc_queue_setup(struct vb2_queue *q,
 int msm_vidc_queue_setup(struct vb2_queue *q,
 		unsigned int *num_buffers, unsigned int *num_planes,
 		unsigned int *num_buffers, unsigned int *num_planes,
 		unsigned int sizes[], struct device *alloc_devs[])
 		unsigned int sizes[], struct device *alloc_devs[])