aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/videobuf2-core.h
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2010-12-06 03:56:55 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 19:31:34 -0400
commitb25748fe612626d6c9e344482bb028d76c1e11f2 (patch)
treedc4b9029f15af23d2d2648274b0fddc8afe60e96 /include/media/videobuf2-core.h
parent5ba3f757f0592ca001266b4a6214d0332349909c (diff)
[media] v4l: videobuf2: add read() and write() emulator
Add a generic file io (read and write) emulator for videobuf2. It uses MMAP memory type buffers and generic vb2 calls: req_bufs, qbuf and dqbuf. Video date is being copied from mmap buffers to userspace with standard copy_to_user() function. To add support for file io the driver needs to provide an additional callback - read_setup or write_setup. It should provide the default number of buffers used by emulator and flags. With these flags one can detemine the style of read() or write() emulation. By default 'streaming' style is used. With VB2_FILEIO_READ_ONCE flag one can select 'one shot' mode for read() emulator. With VB2_FILEIO_WRITE_IMMEDIATE flag one can select immediate conversion of write calls to qbuf for write() emulator, so the vb2 will not wait until each buffer is filled completely before queueing it to the driver. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> CC: Pawel Osciak <pawel@osciak.com> Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media/videobuf2-core.h')
-rw-r--r--include/media/videobuf2-core.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 1dafac05ce1a..0d71fc5efc46 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -18,6 +18,7 @@
18#include <linux/videodev2.h> 18#include <linux/videodev2.h>
19 19
20struct vb2_alloc_ctx; 20struct vb2_alloc_ctx;
21struct vb2_fileio_data;
21 22
22/** 23/**
23 * struct vb2_mem_ops - memory handling/memory allocator operations 24 * struct vb2_mem_ops - memory handling/memory allocator operations
@@ -54,6 +55,7 @@ struct vb2_alloc_ctx;
54 * 55 *
55 * Required ops for USERPTR types: get_userptr, put_userptr. 56 * Required ops for USERPTR types: get_userptr, put_userptr.
56 * Required ops for MMAP types: alloc, put, num_users, mmap. 57 * Required ops for MMAP types: alloc, put, num_users, mmap.
58 * Required ops for read/write access types: alloc, put, num_users, vaddr
57 */ 59 */
58struct vb2_mem_ops { 60struct vb2_mem_ops {
59 void *(*alloc)(void *alloc_ctx, unsigned long size); 61 void *(*alloc)(void *alloc_ctx, unsigned long size);
@@ -249,6 +251,7 @@ struct vb2_ops {
249 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued 251 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued
250 * @alloc_ctx: memory type/allocator-specific contexts for each plane 252 * @alloc_ctx: memory type/allocator-specific contexts for each plane
251 * @streaming: current streaming state 253 * @streaming: current streaming state
254 * @fileio: file io emulator internal data, used only if emulator is active
252 */ 255 */
253struct vb2_queue { 256struct vb2_queue {
254 enum v4l2_buf_type type; 257 enum v4l2_buf_type type;
@@ -275,6 +278,8 @@ struct vb2_queue {
275 void *alloc_ctx[VIDEO_MAX_PLANES]; 278 void *alloc_ctx[VIDEO_MAX_PLANES];
276 279
277 unsigned int streaming:1; 280 unsigned int streaming:1;
281
282 struct vb2_fileio_data *fileio;
278}; 283};
279 284
280void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no); 285void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no);
@@ -298,6 +303,10 @@ int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
298 303
299int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma); 304int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma);
300unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait); 305unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
306size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
307 loff_t *ppos, int nonblock);
308size_t vb2_write(struct vb2_queue *q, char __user *data, size_t count,
309 loff_t *ppos, int nonblock);
301 310
302/** 311/**
303 * vb2_is_streaming() - return streaming status of the queue 312 * vb2_is_streaming() - return streaming status of the queue