diff options
-rw-r--r-- | Documentation/DocBook/media/v4l/vidioc-expbuf.xml | 8 | ||||
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-core.c | 8 | ||||
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-dma-contig.c | 4 | ||||
-rw-r--r-- | include/media/videobuf2-core.h | 2 |
4 files changed, 12 insertions, 10 deletions
diff --git a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml index e287c8fc803b..4165e7bfa4ff 100644 --- a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml +++ b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml | |||
@@ -73,7 +73,8 @@ range from zero to the maximal number of valid planes for the currently active | |||
73 | format. For the single-planar API, applications must set <structfield> plane | 73 | format. For the single-planar API, applications must set <structfield> plane |
74 | </structfield> to zero. Additional flags may be posted in the <structfield> | 74 | </structfield> to zero. Additional flags may be posted in the <structfield> |
75 | flags </structfield> field. Refer to a manual for open() for details. | 75 | flags </structfield> field. Refer to a manual for open() for details. |
76 | Currently only O_CLOEXEC is supported. All other fields must be set to zero. | 76 | Currently only O_CLOEXEC, O_RDONLY, O_WRONLY, and O_RDWR are supported. All |
77 | other fields must be set to zero. | ||
77 | In the case of multi-planar API, every plane is exported separately using | 78 | In the case of multi-planar API, every plane is exported separately using |
78 | multiple <constant> VIDIOC_EXPBUF </constant> calls. </para> | 79 | multiple <constant> VIDIOC_EXPBUF </constant> calls. </para> |
79 | 80 | ||
@@ -170,8 +171,9 @@ multi-planar API. Otherwise this value must be set to zero. </entry> | |||
170 | <entry>__u32</entry> | 171 | <entry>__u32</entry> |
171 | <entry><structfield>flags</structfield></entry> | 172 | <entry><structfield>flags</structfield></entry> |
172 | <entry>Flags for the newly created file, currently only <constant> | 173 | <entry>Flags for the newly created file, currently only <constant> |
173 | O_CLOEXEC </constant> is supported, refer to the manual of open() for more | 174 | O_CLOEXEC </constant>, <constant>O_RDONLY</constant>, <constant>O_WRONLY |
174 | details.</entry> | 175 | </constant>, and <constant>O_RDWR</constant> are supported, refer to the manual |
176 | of open() for more details.</entry> | ||
175 | </row> | 177 | </row> |
176 | <row> | 178 | <row> |
177 | <entry>__s32</entry> | 179 | <entry>__s32</entry> |
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index b19b306c8f7f..57ba131f08ad 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -1824,8 +1824,8 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) | |||
1824 | return -EINVAL; | 1824 | return -EINVAL; |
1825 | } | 1825 | } |
1826 | 1826 | ||
1827 | if (eb->flags & ~O_CLOEXEC) { | 1827 | if (eb->flags & ~(O_CLOEXEC | O_ACCMODE)) { |
1828 | dprintk(1, "Queue does support only O_CLOEXEC flag\n"); | 1828 | dprintk(1, "Queue does support only O_CLOEXEC and access mode flags\n"); |
1829 | return -EINVAL; | 1829 | return -EINVAL; |
1830 | } | 1830 | } |
1831 | 1831 | ||
@@ -1848,14 +1848,14 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) | |||
1848 | 1848 | ||
1849 | vb_plane = &vb->planes[eb->plane]; | 1849 | vb_plane = &vb->planes[eb->plane]; |
1850 | 1850 | ||
1851 | dbuf = call_memop(q, get_dmabuf, vb_plane->mem_priv); | 1851 | dbuf = call_memop(q, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE); |
1852 | if (IS_ERR_OR_NULL(dbuf)) { | 1852 | if (IS_ERR_OR_NULL(dbuf)) { |
1853 | dprintk(1, "Failed to export buffer %d, plane %d\n", | 1853 | dprintk(1, "Failed to export buffer %d, plane %d\n", |
1854 | eb->index, eb->plane); | 1854 | eb->index, eb->plane); |
1855 | return -EINVAL; | 1855 | return -EINVAL; |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | ret = dma_buf_fd(dbuf, eb->flags); | 1858 | ret = dma_buf_fd(dbuf, eb->flags & ~O_ACCMODE); |
1859 | if (ret < 0) { | 1859 | if (ret < 0) { |
1860 | dprintk(3, "buffer %d, plane %d failed to export (%d)\n", | 1860 | dprintk(3, "buffer %d, plane %d failed to export (%d)\n", |
1861 | eb->index, eb->plane, ret); | 1861 | eb->index, eb->plane, ret); |
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 646f08f4f504..33d3871d1e13 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c | |||
@@ -393,7 +393,7 @@ static struct sg_table *vb2_dc_get_base_sgt(struct vb2_dc_buf *buf) | |||
393 | return sgt; | 393 | return sgt; |
394 | } | 394 | } |
395 | 395 | ||
396 | static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv) | 396 | static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv, unsigned long flags) |
397 | { | 397 | { |
398 | struct vb2_dc_buf *buf = buf_priv; | 398 | struct vb2_dc_buf *buf = buf_priv; |
399 | struct dma_buf *dbuf; | 399 | struct dma_buf *dbuf; |
@@ -404,7 +404,7 @@ static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv) | |||
404 | if (WARN_ON(!buf->sgt_base)) | 404 | if (WARN_ON(!buf->sgt_base)) |
405 | return NULL; | 405 | return NULL; |
406 | 406 | ||
407 | dbuf = dma_buf_export(buf, &vb2_dc_dmabuf_ops, buf->size, 0); | 407 | dbuf = dma_buf_export(buf, &vb2_dc_dmabuf_ops, buf->size, flags); |
408 | if (IS_ERR(dbuf)) | 408 | if (IS_ERR(dbuf)) |
409 | return NULL; | 409 | return NULL; |
410 | 410 | ||
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index bd8218b15009..941055e9d125 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h | |||
@@ -83,7 +83,7 @@ struct vb2_fileio_data; | |||
83 | struct vb2_mem_ops { | 83 | struct vb2_mem_ops { |
84 | void *(*alloc)(void *alloc_ctx, unsigned long size, gfp_t gfp_flags); | 84 | void *(*alloc)(void *alloc_ctx, unsigned long size, gfp_t gfp_flags); |
85 | void (*put)(void *buf_priv); | 85 | void (*put)(void *buf_priv); |
86 | struct dma_buf *(*get_dmabuf)(void *buf_priv); | 86 | struct dma_buf *(*get_dmabuf)(void *buf_priv, unsigned long flags); |
87 | 87 | ||
88 | void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr, | 88 | void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr, |
89 | unsigned long size, int write); | 89 | unsigned long size, int write); |