diff options
author | Sumit Semwal <sumit.semwal@ti.com> | 2012-06-14 09:37:37 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-11-25 14:11:12 -0500 |
commit | c538404869b69db543ce23cf041192c192a65330 (patch) | |
tree | 9566b4a8e2472a8ed17bb99674dec4bb6f48a688 /include/media | |
parent | 4b9c1cb641c466cd3b366132017da3c8ab9d540c (diff) |
[media] v4l: vb2: add support for shared buffer (dma_buf)
This patch adds support for DMABUF memory type in videobuf2. It calls relevant
APIs of dma_buf for v4l reqbuf / qbuf / dqbuf operations.
For this version, the support is for videobuf2 as a user of the shared buffer;
so the allocation of the buffer is done outside of V4L2. [A sample allocator of
dma-buf shared buffer is given at [1]]
[1]: Rob Clark's DRM:
https://github.com/robclark/kernel-omap4/commits/drmplane-dmabuf
[original work in the PoC for buffer sharing]
Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Sumit Semwal <sumit.semwal@ti.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/videobuf2-core.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index e04252a9fea6..689ae4ac2572 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/mutex.h> | 16 | #include <linux/mutex.h> |
17 | #include <linux/poll.h> | 17 | #include <linux/poll.h> |
18 | #include <linux/videodev2.h> | 18 | #include <linux/videodev2.h> |
19 | #include <linux/dma-buf.h> | ||
19 | 20 | ||
20 | struct vb2_alloc_ctx; | 21 | struct vb2_alloc_ctx; |
21 | struct vb2_fileio_data; | 22 | struct vb2_fileio_data; |
@@ -41,6 +42,20 @@ struct vb2_fileio_data; | |||
41 | * argument to other ops in this structure | 42 | * argument to other ops in this structure |
42 | * @put_userptr: inform the allocator that a USERPTR buffer will no longer | 43 | * @put_userptr: inform the allocator that a USERPTR buffer will no longer |
43 | * be used | 44 | * be used |
45 | * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation; | ||
46 | * used for DMABUF memory types; alloc_ctx is the alloc context | ||
47 | * dbuf is the shared dma_buf; returns NULL on failure; | ||
48 | * allocator private per-buffer structure on success; | ||
49 | * this needs to be used for further accesses to the buffer | ||
50 | * @detach_dmabuf: inform the exporter of the buffer that the current DMABUF | ||
51 | * buffer is no longer used; the buf_priv argument is the | ||
52 | * allocator private per-buffer structure previously returned | ||
53 | * from the attach_dmabuf callback | ||
54 | * @map_dmabuf: request for access to the dmabuf from allocator; the allocator | ||
55 | * of dmabuf is informed that this driver is going to use the | ||
56 | * dmabuf | ||
57 | * @unmap_dmabuf: releases access control to the dmabuf - allocator is notified | ||
58 | * that this driver is done using the dmabuf for now | ||
44 | * @vaddr: return a kernel virtual address to a given memory buffer | 59 | * @vaddr: return a kernel virtual address to a given memory buffer |
45 | * associated with the passed private structure or NULL if no | 60 | * associated with the passed private structure or NULL if no |
46 | * such mapping exists | 61 | * such mapping exists |
@@ -56,6 +71,8 @@ struct vb2_fileio_data; | |||
56 | * Required ops for USERPTR types: get_userptr, put_userptr. | 71 | * Required ops for USERPTR types: get_userptr, put_userptr. |
57 | * Required ops for MMAP types: alloc, put, num_users, mmap. | 72 | * Required ops for MMAP types: alloc, put, num_users, mmap. |
58 | * Required ops for read/write access types: alloc, put, num_users, vaddr | 73 | * Required ops for read/write access types: alloc, put, num_users, vaddr |
74 | * Required ops for DMABUF types: attach_dmabuf, detach_dmabuf, map_dmabuf, | ||
75 | * unmap_dmabuf. | ||
59 | */ | 76 | */ |
60 | struct vb2_mem_ops { | 77 | struct vb2_mem_ops { |
61 | void *(*alloc)(void *alloc_ctx, unsigned long size); | 78 | void *(*alloc)(void *alloc_ctx, unsigned long size); |
@@ -65,6 +82,12 @@ struct vb2_mem_ops { | |||
65 | unsigned long size, int write); | 82 | unsigned long size, int write); |
66 | void (*put_userptr)(void *buf_priv); | 83 | void (*put_userptr)(void *buf_priv); |
67 | 84 | ||
85 | void *(*attach_dmabuf)(void *alloc_ctx, struct dma_buf *dbuf, | ||
86 | unsigned long size, int write); | ||
87 | void (*detach_dmabuf)(void *buf_priv); | ||
88 | int (*map_dmabuf)(void *buf_priv); | ||
89 | void (*unmap_dmabuf)(void *buf_priv); | ||
90 | |||
68 | void *(*vaddr)(void *buf_priv); | 91 | void *(*vaddr)(void *buf_priv); |
69 | void *(*cookie)(void *buf_priv); | 92 | void *(*cookie)(void *buf_priv); |
70 | 93 | ||
@@ -75,6 +98,8 @@ struct vb2_mem_ops { | |||
75 | 98 | ||
76 | struct vb2_plane { | 99 | struct vb2_plane { |
77 | void *mem_priv; | 100 | void *mem_priv; |
101 | struct dma_buf *dbuf; | ||
102 | unsigned int dbuf_mapped; | ||
78 | }; | 103 | }; |
79 | 104 | ||
80 | /** | 105 | /** |
@@ -83,12 +108,14 @@ struct vb2_plane { | |||
83 | * @VB2_USERPTR: driver supports USERPTR with streaming API | 108 | * @VB2_USERPTR: driver supports USERPTR with streaming API |
84 | * @VB2_READ: driver supports read() style access | 109 | * @VB2_READ: driver supports read() style access |
85 | * @VB2_WRITE: driver supports write() style access | 110 | * @VB2_WRITE: driver supports write() style access |
111 | * @VB2_DMABUF: driver supports DMABUF with streaming API | ||
86 | */ | 112 | */ |
87 | enum vb2_io_modes { | 113 | enum vb2_io_modes { |
88 | VB2_MMAP = (1 << 0), | 114 | VB2_MMAP = (1 << 0), |
89 | VB2_USERPTR = (1 << 1), | 115 | VB2_USERPTR = (1 << 1), |
90 | VB2_READ = (1 << 2), | 116 | VB2_READ = (1 << 2), |
91 | VB2_WRITE = (1 << 3), | 117 | VB2_WRITE = (1 << 3), |
118 | VB2_DMABUF = (1 << 4), | ||
92 | }; | 119 | }; |
93 | 120 | ||
94 | /** | 121 | /** |