diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-04-14 07:33:00 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-04-16 18:57:25 -0300 |
commit | 3415a89f48dce655ae353bc70a8e292764e8e931 (patch) | |
tree | 5e14b498a4f12817dce2ca2666aa05477ad0f755 /include/media | |
parent | 5f26f2501b81190b60a0b72d611668fb6a59dd24 (diff) | |
download | linux-3415a89f48dce655ae353bc70a8e292764e8e931.tar.bz2 |
[media] vb2: add thread support
In order to implement vb2 DVB support you need to be able to start
a kernel thread that queues and dequeues buffers, calling a callback
function for every buffer. This patch adds support for that.
It's based on drivers/media/v4l2-core/videobuf-dvb.c, but with all the DVB
specific stuff stripped out, thus making it much more generic.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/videobuf2-core.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index b1859f6953b2..46e76096c22a 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -20,6 +20,7 @@ struct vb2_alloc_ctx; struct vb2_fileio_data; +struct vb2_threadio_data; /** * struct vb2_mem_ops - memory handling/memory allocator operations @@ -375,6 +376,7 @@ struct v4l2_fh; * @start_streaming_called: start_streaming() was called successfully and we * started streaming. * @fileio: file io emulator internal data, used only if emulator is active + * @threadio: thread io internal data, used only if thread is active */ struct vb2_queue { enum v4l2_buf_type type; @@ -411,6 +413,7 @@ struct vb2_queue { unsigned int start_streaming_called:1; struct vb2_fileio_data *fileio; + struct vb2_threadio_data *threadio; #ifdef CONFIG_VIDEO_ADV_DEBUG /* @@ -461,6 +464,35 @@ size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblock); size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, loff_t *ppos, int nonblock); +/** + * vb2_thread_fnc - callback function for use with vb2_thread + * + * This is called whenever a buffer is dequeued in the thread. + */ +typedef int (*vb2_thread_fnc)(struct vb2_buffer *vb, void *priv); + +/** + * vb2_thread_start() - start a thread for the given queue. + * @q: videobuf queue + * @fnc: callback function + * @priv: priv pointer passed to the callback function + * @thread_name:the name of the thread. This will be prefixed with "vb2-". + * + * This starts a thread that will queue and dequeue until an error occurs + * or @vb2_thread_stop is called. + * + * This function should not be used for anything else but the videobuf2-dvb + * support. If you think you have another good use-case for this, then please + * contact the linux-media mailinglist first. + */ +int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv, + const char *thread_name); + +/** + * vb2_thread_stop() - stop the thread for the given queue. + * @q: videobuf queue + */ +int vb2_thread_stop(struct vb2_queue *q); /** * vb2_is_streaming() - return streaming status of the queue |