diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-04-14 06:33:00 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-04-16 17:57:25 -0400 |
commit | 3415a89f48dce655ae353bc70a8e292764e8e931 (patch) | |
tree | 5e14b498a4f12817dce2ca2666aa05477ad0f755 /include/media | |
parent | 5f26f2501b81190b60a0b72d611668fb6a59dd24 (diff) |
[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 @@ | |||
20 | 20 | ||
21 | struct vb2_alloc_ctx; | 21 | struct vb2_alloc_ctx; |
22 | struct vb2_fileio_data; | 22 | struct vb2_fileio_data; |
23 | struct vb2_threadio_data; | ||
23 | 24 | ||
24 | /** | 25 | /** |
25 | * struct vb2_mem_ops - memory handling/memory allocator operations | 26 | * struct vb2_mem_ops - memory handling/memory allocator operations |
@@ -375,6 +376,7 @@ struct v4l2_fh; | |||
375 | * @start_streaming_called: start_streaming() was called successfully and we | 376 | * @start_streaming_called: start_streaming() was called successfully and we |
376 | * started streaming. | 377 | * started streaming. |
377 | * @fileio: file io emulator internal data, used only if emulator is active | 378 | * @fileio: file io emulator internal data, used only if emulator is active |
379 | * @threadio: thread io internal data, used only if thread is active | ||
378 | */ | 380 | */ |
379 | struct vb2_queue { | 381 | struct vb2_queue { |
380 | enum v4l2_buf_type type; | 382 | enum v4l2_buf_type type; |
@@ -411,6 +413,7 @@ struct vb2_queue { | |||
411 | unsigned int start_streaming_called:1; | 413 | unsigned int start_streaming_called:1; |
412 | 414 | ||
413 | struct vb2_fileio_data *fileio; | 415 | struct vb2_fileio_data *fileio; |
416 | struct vb2_threadio_data *threadio; | ||
414 | 417 | ||
415 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 418 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
416 | /* | 419 | /* |
@@ -461,6 +464,35 @@ size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, | |||
461 | loff_t *ppos, int nonblock); | 464 | loff_t *ppos, int nonblock); |
462 | size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, | 465 | size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, |
463 | loff_t *ppos, int nonblock); | 466 | loff_t *ppos, int nonblock); |
467 | /** | ||
468 | * vb2_thread_fnc - callback function for use with vb2_thread | ||
469 | * | ||
470 | * This is called whenever a buffer is dequeued in the thread. | ||
471 | */ | ||
472 | typedef int (*vb2_thread_fnc)(struct vb2_buffer *vb, void *priv); | ||
473 | |||
474 | /** | ||
475 | * vb2_thread_start() - start a thread for the given queue. | ||
476 | * @q: videobuf queue | ||
477 | * @fnc: callback function | ||
478 | * @priv: priv pointer passed to the callback function | ||
479 | * @thread_name:the name of the thread. This will be prefixed with "vb2-". | ||
480 | * | ||
481 | * This starts a thread that will queue and dequeue until an error occurs | ||
482 | * or @vb2_thread_stop is called. | ||
483 | * | ||
484 | * This function should not be used for anything else but the videobuf2-dvb | ||
485 | * support. If you think you have another good use-case for this, then please | ||
486 | * contact the linux-media mailinglist first. | ||
487 | */ | ||
488 | int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv, | ||
489 | const char *thread_name); | ||
490 | |||
491 | /** | ||
492 | * vb2_thread_stop() - stop the thread for the given queue. | ||
493 | * @q: videobuf queue | ||
494 | */ | ||
495 | int vb2_thread_stop(struct vb2_queue *q); | ||
464 | 496 | ||
465 | /** | 497 | /** |
466 | * vb2_is_streaming() - return streaming status of the queue | 498 | * vb2_is_streaming() - return streaming status of the queue |