Commit 3c5be988 authored by Junghak Sung's avatar Junghak Sung Committed by Mauro Carvalho Chehab

[media] media: videobuf2: Move v4l2-specific stuff to videobuf2-v4l2

Move v4l2-specific stuff from videobu2-core to videobuf2-v4l2
without doing any functional changes.
Signed-off-by: default avatarJunghak Sung <jh1009.sung@samsung.com>
Signed-off-by: default avatarGeunyoung Kim <nenggun.kim@samsung.com>
Acked-by: default avatarSeung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: default avatarInki Dae <inki.dae@samsung.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent b0e0e1f8
This diff is collapsed.
#ifndef _MEDIA_VIDEOBUF2_INTERNAL_H
#define _MEDIA_VIDEOBUF2_INTERNAL_H
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <media/videobuf2-core.h>
extern int vb2_debug;
#define dprintk(level, fmt, arg...) \
do { \
if (vb2_debug >= level) \
pr_info("vb2: %s: " fmt, __func__, ## arg); \
} while (0)
#ifdef CONFIG_VIDEO_ADV_DEBUG
/*
* If advanced debugging is on, then count how often each op is called
* successfully, which can either be per-buffer or per-queue.
*
* This makes it easy to check that the 'init' and 'cleanup'
* (and variations thereof) stay balanced.
*/
#define log_memop(vb, op) \
dprintk(2, "call_memop(%p, %d, %s)%s\n", \
(vb)->vb2_queue, (vb)->index, #op, \
(vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
#define call_memop(vb, op, args...) \
({ \
struct vb2_queue *_q = (vb)->vb2_queue; \
int err; \
\
log_memop(vb, op); \
err = _q->mem_ops->op ? _q->mem_ops->op(args) : 0; \
if (!err) \
(vb)->cnt_mem_ ## op++; \
err; \
})
#define call_ptr_memop(vb, op, args...) \
({ \
struct vb2_queue *_q = (vb)->vb2_queue; \
void *ptr; \
\
log_memop(vb, op); \
ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL; \
if (!IS_ERR_OR_NULL(ptr)) \
(vb)->cnt_mem_ ## op++; \
ptr; \
})
#define call_void_memop(vb, op, args...) \
({ \
struct vb2_queue *_q = (vb)->vb2_queue; \
\
log_memop(vb, op); \
if (_q->mem_ops->op) \
_q->mem_ops->op(args); \
(vb)->cnt_mem_ ## op++; \
})
#define log_qop(q, op) \
dprintk(2, "call_qop(%p, %s)%s\n", q, #op, \
(q)->ops->op ? "" : " (nop)")
#define call_qop(q, op, args...) \
({ \
int err; \
\
log_qop(q, op); \
err = (q)->ops->op ? (q)->ops->op(args) : 0; \
if (!err) \
(q)->cnt_ ## op++; \
err; \
})
#define call_void_qop(q, op, args...) \
({ \
log_qop(q, op); \
if ((q)->ops->op) \
(q)->ops->op(args); \
(q)->cnt_ ## op++; \
})
#define log_vb_qop(vb, op, args...) \
dprintk(2, "call_vb_qop(%p, %d, %s)%s\n", \
(vb)->vb2_queue, (vb)->index, #op, \
(vb)->vb2_queue->ops->op ? "" : " (nop)")
#define call_vb_qop(vb, op, args...) \
({ \
int err; \
\
log_vb_qop(vb, op); \
err = (vb)->vb2_queue->ops->op ? \
(vb)->vb2_queue->ops->op(args) : 0; \
if (!err) \
(vb)->cnt_ ## op++; \
err; \
})
#define call_void_vb_qop(vb, op, args...) \
({ \
log_vb_qop(vb, op); \
if ((vb)->vb2_queue->ops->op) \
(vb)->vb2_queue->ops->op(args); \
(vb)->cnt_ ## op++; \
})
#else
#define call_memop(vb, op, args...) \
((vb)->vb2_queue->mem_ops->op ? \
(vb)->vb2_queue->mem_ops->op(args) : 0)
#define call_ptr_memop(vb, op, args...) \
((vb)->vb2_queue->mem_ops->op ? \
(vb)->vb2_queue->mem_ops->op(args) : NULL)
#define call_void_memop(vb, op, args...) \
do { \
if ((vb)->vb2_queue->mem_ops->op) \
(vb)->vb2_queue->mem_ops->op(args); \
} while (0)
#define call_qop(q, op, args...) \
((q)->ops->op ? (q)->ops->op(args) : 0)
#define call_void_qop(q, op, args...) \
do { \
if ((q)->ops->op) \
(q)->ops->op(args); \
} while (0)
#define call_vb_qop(vb, op, args...) \
((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
#define call_void_vb_qop(vb, op, args...) \
do { \
if ((vb)->vb2_queue->ops->op) \
(vb)->vb2_queue->ops->op(args); \
} while (0)
#endif
#define call_bufop(q, op, args...) \
({ \
int ret = 0; \
if (q && q->buf_ops && q->buf_ops->op) \
ret = q->buf_ops->op(args); \
ret; \
})
bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb);
int vb2_verify_memory_type(struct vb2_queue *q,
enum vb2_memory memory, unsigned int type);
#endif /* _MEDIA_VIDEOBUF2_INTERNAL_H */
This diff is collapsed.
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <linux/mm_types.h> #include <linux/mm_types.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/videodev2.h>
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#define VB2_MAX_FRAME (32) #define VB2_MAX_FRAME (32)
...@@ -504,23 +503,25 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state); ...@@ -504,23 +503,25 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
void vb2_discard_done(struct vb2_queue *q); void vb2_discard_done(struct vb2_queue *q);
int vb2_wait_for_all_buffers(struct vb2_queue *q); int vb2_wait_for_all_buffers(struct vb2_queue *q);
int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b); int vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb);
int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req); int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
unsigned int *count);
int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
unsigned int *count, const void *parg);
int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb);
int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb);
int vb2_core_dqbuf(struct vb2_queue *q, void *pb, bool nonblocking);
int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create); int vb2_core_streamon(struct vb2_queue *q, unsigned int type);
int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b); int vb2_core_streamoff(struct vb2_queue *q, unsigned int type);
int __must_check vb2_queue_init(struct vb2_queue *q); int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
unsigned int index, unsigned int plane, unsigned int flags);
void vb2_queue_release(struct vb2_queue *q); int vb2_core_queue_init(struct vb2_queue *q);
void vb2_queue_error(struct vb2_queue *q); void vb2_core_queue_release(struct vb2_queue *q);
int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b);
int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type); void vb2_queue_error(struct vb2_queue *q);
int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma); int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma);
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
...@@ -530,41 +531,6 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, ...@@ -530,41 +531,6 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
unsigned long pgoff, unsigned long pgoff,
unsigned long flags); unsigned long flags);
#endif #endif
unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
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 * vb2_is_streaming() - return streaming status of the queue
...@@ -669,48 +635,4 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q) ...@@ -669,48 +635,4 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q)
q->last_buffer_dequeued = false; q->last_buffer_dequeued = false;
} }
/*
* The following functions are not part of the vb2 core API, but are simple
* helper functions that you can use in your struct v4l2_file_operations,
* struct v4l2_ioctl_ops and struct vb2_ops. They will serialize if vb2_queue->lock
* or video_device->lock is set, and they will set and test vb2_queue->owner
* to check if the calling filehandle is permitted to do the queuing operation.
*/
/* struct v4l2_ioctl_ops helpers */
int vb2_ioctl_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *p);
int vb2_ioctl_create_bufs(struct file *file, void *priv,
struct v4l2_create_buffers *p);
int vb2_ioctl_prepare_buf(struct file *file, void *priv,
struct v4l2_buffer *p);
int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p);
int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p);
int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i);
int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i);
int vb2_ioctl_expbuf(struct file *file, void *priv,
struct v4l2_exportbuffer *p);
/* struct v4l2_file_operations helpers */
int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma);
int vb2_fop_release(struct file *file);
int _vb2_fop_release(struct file *file, struct mutex *lock);
ssize_t vb2_fop_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos);
ssize_t vb2_fop_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos);
unsigned int vb2_fop_poll(struct file *file, poll_table *wait);
#ifndef CONFIG_MMU
unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags);
#endif
/* struct vb2_ops helpers, only use if vq->lock is non-NULL. */
void vb2_ops_wait_prepare(struct vb2_queue *vq);
void vb2_ops_wait_finish(struct vb2_queue *vq);
#endif /* _MEDIA_VIDEOBUF2_CORE_H */ #endif /* _MEDIA_VIDEOBUF2_CORE_H */
...@@ -6,7 +6,13 @@ ...@@ -6,7 +6,13 @@
#include <dvb_demux.h> #include <dvb_demux.h>
#include <dvb_net.h> #include <dvb_net.h>
#include <dvb_frontend.h> #include <dvb_frontend.h>
#include <media/videobuf2-core.h>
#include <media/videobuf2-v4l2.h>
/*
* TODO: This header file should be replaced with videobuf2-core.h
* Currently, vb2_thread is not a stuff of videobuf2-core,
* since vb2_thread has many dependencies on videobuf2-v4l2.
*/
struct vb2_dvb { struct vb2_dvb {
/* filling that the job of the driver */ /* filling that the job of the driver */
......
...@@ -50,4 +50,100 @@ struct vb2_v4l2_buffer { ...@@ -50,4 +50,100 @@ struct vb2_v4l2_buffer {
#define to_vb2_v4l2_buffer(vb) \ #define to_vb2_v4l2_buffer(vb) \
container_of(vb, struct vb2_v4l2_buffer, vb2_buf) container_of(vb, struct vb2_v4l2_buffer, vb2_buf)
int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b);
int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b);
int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
int __must_check vb2_queue_init(struct vb2_queue *q);
void vb2_queue_release(struct vb2_queue *q);
unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
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);
/*
* The following functions are not part of the vb2 core API, but are simple
* helper functions that you can use in your struct v4l2_file_operations,
* struct v4l2_ioctl_ops and struct vb2_ops. They will serialize if vb2_queue->lock
* or video_device->lock is set, and they will set and test vb2_queue->owner
* to check if the calling filehandle is permitted to do the queuing operation.
*/
/* struct v4l2_ioctl_ops helpers */
int vb2_ioctl_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *p);
int vb2_ioctl_create_bufs(struct file *file, void *priv,
struct v4l2_create_buffers *p);
int vb2_ioctl_prepare_buf(struct file *file, void *priv,
struct v4l2_buffer *p);
int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p);
int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p);
int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i);
int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i);
int vb2_ioctl_expbuf(struct file *file, void *priv,
struct v4l2_exportbuffer *p);
/* struct v4l2_file_operations helpers */
int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma);
int vb2_fop_release(struct file *file);
int _vb2_fop_release(struct file *file, struct mutex *lock);
ssize_t vb2_fop_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos);
ssize_t vb2_fop_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos);
unsigned int vb2_fop_poll(struct file *file, poll_table *wait);
#ifndef CONFIG_MMU
unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags);
#endif
/* struct vb2_ops helpers, only use if vq->lock is non-NULL. */
void vb2_ops_wait_prepare(struct vb2_queue *vq);
void vb2_ops_wait_finish(struct vb2_queue *vq);
#endif /* _MEDIA_VIDEOBUF2_V4L2_H */ #endif /* _MEDIA_VIDEOBUF2_V4L2_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment