Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
videobuf2-core.c File Reference
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-event.h>
#include <media/videobuf2-core.h>

Go to the source code of this file.

Data Structures

struct  vb2_fileio_buf
 
struct  vb2_fileio_data
 

Macros

#define dprintk(level, fmt, arg...)
 
#define call_memop(q, op, args...)
 
#define call_qop(q, op, args...)   (((q)->ops->op) ? ((q)->ops->op(args)) : 0)
 
#define V4L2_BUFFER_STATE_FLAGS
 

Functions

 module_param (debug, int, 0644)
 
int vb2_querybuf (struct vb2_queue *q, struct v4l2_buffer *b)
 
 EXPORT_SYMBOL (vb2_querybuf)
 
int vb2_reqbufs (struct vb2_queue *q, struct v4l2_requestbuffers *req)
 
 EXPORT_SYMBOL_GPL (vb2_reqbufs)
 
int vb2_create_bufs (struct vb2_queue *q, struct v4l2_create_buffers *create)
 
 EXPORT_SYMBOL_GPL (vb2_create_bufs)
 
voidvb2_plane_vaddr (struct vb2_buffer *vb, unsigned int plane_no)
 
 EXPORT_SYMBOL_GPL (vb2_plane_vaddr)
 
voidvb2_plane_cookie (struct vb2_buffer *vb, unsigned int plane_no)
 
 EXPORT_SYMBOL_GPL (vb2_plane_cookie)
 
void vb2_buffer_done (struct vb2_buffer *vb, enum vb2_buffer_state state)
 
 EXPORT_SYMBOL_GPL (vb2_buffer_done)
 
int vb2_prepare_buf (struct vb2_queue *q, struct v4l2_buffer *b)
 
 EXPORT_SYMBOL_GPL (vb2_prepare_buf)
 
int vb2_qbuf (struct vb2_queue *q, struct v4l2_buffer *b)
 
 EXPORT_SYMBOL_GPL (vb2_qbuf)
 
int vb2_wait_for_all_buffers (struct vb2_queue *q)
 
 EXPORT_SYMBOL_GPL (vb2_wait_for_all_buffers)
 
int vb2_dqbuf (struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
 
 EXPORT_SYMBOL_GPL (vb2_dqbuf)
 
int vb2_streamon (struct vb2_queue *q, enum v4l2_buf_type type)
 
 EXPORT_SYMBOL_GPL (vb2_streamon)
 
int vb2_streamoff (struct vb2_queue *q, enum v4l2_buf_type type)
 
 EXPORT_SYMBOL_GPL (vb2_streamoff)
 
int vb2_mmap (struct vb2_queue *q, struct vm_area_struct *vma)
 
 EXPORT_SYMBOL_GPL (vb2_mmap)
 
unsigned long vb2_get_unmapped_area (struct vb2_queue *q, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
 
 EXPORT_SYMBOL_GPL (vb2_get_unmapped_area)
 
unsigned int vb2_poll (struct vb2_queue *q, struct file *file, poll_table *wait)
 
 EXPORT_SYMBOL_GPL (vb2_poll)
 
int vb2_queue_init (struct vb2_queue *q)
 
 EXPORT_SYMBOL_GPL (vb2_queue_init)
 
void vb2_queue_release (struct vb2_queue *q)
 
 EXPORT_SYMBOL_GPL (vb2_queue_release)
 
size_t vb2_read (struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblocking)
 
 EXPORT_SYMBOL_GPL (vb2_read)
 
size_t vb2_write (struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblocking)
 
 EXPORT_SYMBOL_GPL (vb2_write)
 
int vb2_ioctl_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p)
 
 EXPORT_SYMBOL_GPL (vb2_ioctl_reqbufs)
 
int vb2_ioctl_create_bufs (struct file *file, void *priv, struct v4l2_create_buffers *p)
 
 EXPORT_SYMBOL_GPL (vb2_ioctl_create_bufs)
 
int vb2_ioctl_prepare_buf (struct file *file, void *priv, struct v4l2_buffer *p)
 
 EXPORT_SYMBOL_GPL (vb2_ioctl_prepare_buf)
 
int vb2_ioctl_querybuf (struct file *file, void *priv, struct v4l2_buffer *p)
 
 EXPORT_SYMBOL_GPL (vb2_ioctl_querybuf)
 
int vb2_ioctl_qbuf (struct file *file, void *priv, struct v4l2_buffer *p)
 
 EXPORT_SYMBOL_GPL (vb2_ioctl_qbuf)
 
int vb2_ioctl_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)
 
 EXPORT_SYMBOL_GPL (vb2_ioctl_dqbuf)
 
int vb2_ioctl_streamon (struct file *file, void *priv, enum v4l2_buf_type i)
 
 EXPORT_SYMBOL_GPL (vb2_ioctl_streamon)
 
int vb2_ioctl_streamoff (struct file *file, void *priv, enum v4l2_buf_type i)
 
 EXPORT_SYMBOL_GPL (vb2_ioctl_streamoff)
 
int vb2_fop_mmap (struct file *file, struct vm_area_struct *vma)
 
 EXPORT_SYMBOL_GPL (vb2_fop_mmap)
 
int vb2_fop_release (struct file *file)
 
 EXPORT_SYMBOL_GPL (vb2_fop_release)
 
ssize_t vb2_fop_write (struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 EXPORT_SYMBOL_GPL (vb2_fop_write)
 
ssize_t vb2_fop_read (struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 EXPORT_SYMBOL_GPL (vb2_fop_read)
 
unsigned int vb2_fop_poll (struct file *file, poll_table *wait)
 
 EXPORT_SYMBOL_GPL (vb2_fop_poll)
 
unsigned long vb2_fop_get_unmapped_area (struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
 
 EXPORT_SYMBOL_GPL (vb2_fop_get_unmapped_area)
 
void vb2_ops_wait_prepare (struct vb2_queue *vq)
 
 EXPORT_SYMBOL_GPL (vb2_ops_wait_prepare)
 
void vb2_ops_wait_finish (struct vb2_queue *vq)
 
 EXPORT_SYMBOL_GPL (vb2_ops_wait_finish)
 
 MODULE_DESCRIPTION ("Driver helper framework for Video for Linux 2")
 
 MODULE_AUTHOR ("Pawel Osciak <[email protected]>, Marek Szyprowski")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define call_memop (   q,
  op,
  args... 
)
Value:
(((q)->mem_ops->op) ? \
((q)->mem_ops->op(args)) : 0)

Definition at line 36 of file videobuf2-core.c.

#define call_qop (   q,
  op,
  args... 
)    (((q)->ops->op) ? ((q)->ops->op(args)) : 0)

Definition at line 40 of file videobuf2-core.c.

#define dprintk (   level,
  fmt,
  arg... 
)
Value:
do { \
if (debug >= level) \
printk(KERN_DEBUG "vb2: " fmt, ## arg); \
} while (0)

Definition at line 30 of file videobuf2-core.c.

#define V4L2_BUFFER_STATE_FLAGS
Value:
V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR | \
V4L2_BUF_FLAG_PREPARED)

Definition at line 43 of file videobuf2-core.c.

Function Documentation

EXPORT_SYMBOL ( vb2_querybuf  )
EXPORT_SYMBOL_GPL ( vb2_reqbufs  )
EXPORT_SYMBOL_GPL ( vb2_create_bufs  )
EXPORT_SYMBOL_GPL ( vb2_plane_vaddr  )
EXPORT_SYMBOL_GPL ( vb2_plane_cookie  )
EXPORT_SYMBOL_GPL ( vb2_buffer_done  )
EXPORT_SYMBOL_GPL ( vb2_prepare_buf  )
EXPORT_SYMBOL_GPL ( vb2_qbuf  )
EXPORT_SYMBOL_GPL ( vb2_wait_for_all_buffers  )
EXPORT_SYMBOL_GPL ( vb2_dqbuf  )
EXPORT_SYMBOL_GPL ( vb2_streamon  )
EXPORT_SYMBOL_GPL ( vb2_streamoff  )
EXPORT_SYMBOL_GPL ( vb2_mmap  )
EXPORT_SYMBOL_GPL ( vb2_get_unmapped_area  )
EXPORT_SYMBOL_GPL ( vb2_poll  )
EXPORT_SYMBOL_GPL ( vb2_queue_init  )
EXPORT_SYMBOL_GPL ( vb2_queue_release  )
EXPORT_SYMBOL_GPL ( vb2_read  )
EXPORT_SYMBOL_GPL ( vb2_write  )
EXPORT_SYMBOL_GPL ( vb2_ioctl_reqbufs  )
EXPORT_SYMBOL_GPL ( vb2_ioctl_create_bufs  )
EXPORT_SYMBOL_GPL ( vb2_ioctl_prepare_buf  )
EXPORT_SYMBOL_GPL ( vb2_ioctl_querybuf  )
EXPORT_SYMBOL_GPL ( vb2_ioctl_qbuf  )
EXPORT_SYMBOL_GPL ( vb2_ioctl_dqbuf  )
EXPORT_SYMBOL_GPL ( vb2_ioctl_streamon  )
EXPORT_SYMBOL_GPL ( vb2_ioctl_streamoff  )
EXPORT_SYMBOL_GPL ( vb2_fop_mmap  )
EXPORT_SYMBOL_GPL ( vb2_fop_release  )
EXPORT_SYMBOL_GPL ( vb2_fop_write  )
EXPORT_SYMBOL_GPL ( vb2_fop_read  )
EXPORT_SYMBOL_GPL ( vb2_fop_poll  )
EXPORT_SYMBOL_GPL ( vb2_fop_get_unmapped_area  )
EXPORT_SYMBOL_GPL ( vb2_ops_wait_prepare  )
EXPORT_SYMBOL_GPL ( vb2_ops_wait_finish  )
MODULE_AUTHOR ( "Pawel Osciak <[email protected] ,
Marek Szyprowski"   
)
MODULE_DESCRIPTION ( "Driver helper framework for Video for Linux 2"  )
MODULE_LICENSE ( "GPL"  )
module_param ( debug  ,
int  ,
0644   
)
void vb2_buffer_done ( struct vb2_buffer vb,
enum vb2_buffer_state  state 
)

vb2_buffer_done() - inform videobuf that an operation on a buffer is finished : vb2_buffer returned from the driver : either VB2_BUF_STATE_DONE if the operation finished successfully or VB2_BUF_STATE_ERROR if the operation finished with an error

This function should be called by the driver after a hardware operation on a buffer is finished and the buffer may be returned to userspace. The driver cannot use this buffer anymore until it is queued back to it by videobuf by the means of buf_queue callback. Only buffers previously queued to the driver by buf_queue can be passed to this function.

Definition at line 789 of file videobuf2-core.c.

int vb2_create_bufs ( struct vb2_queue q,
struct v4l2_create_buffers create 
)

vb2_create_bufs() - Wrapper for __create_bufs() that also verifies the memory and type values. : videobuf2 queue : creation parameters, passed from userspace to vidioc_create_bufs handler in driver

Definition at line 724 of file videobuf2-core.c.

int vb2_dqbuf ( struct vb2_queue q,
struct v4l2_buffer b,
bool  nonblocking 
)

vb2_dqbuf() - Dequeue a buffer to the userspace : videobuf2 queue : buffer structure passed from userspace to vidioc_dqbuf handler in driver : if true, this call will not sleep waiting for a buffer if no buffers ready for dequeuing are present. Normally the driver would be passing (file->f_flags & O_NONBLOCK) here

Should be called from vidioc_dqbuf ioctl handler of a driver. This function: 1) verifies the passed buffer, 2) calls buf_finish callback in the driver (if provided), in which driver can perform any additional operations that may be required before returning the buffer to userspace, such as cache sync, 3) the buffer struct members are filled with relevant information for the userspace.

The return values from this function are intended to be directly returned from vidioc_dqbuf handler in driver.

Definition at line 1326 of file videobuf2-core.c.

unsigned long vb2_fop_get_unmapped_area ( struct file file,
unsigned long  addr,
unsigned long  len,
unsigned long  pgoff,
unsigned long  flags 
)

Definition at line 2356 of file videobuf2-core.c.

int vb2_fop_mmap ( struct file file,
struct vm_area_struct vma 
)

Definition at line 2250 of file videobuf2-core.c.

unsigned int vb2_fop_poll ( struct file file,
poll_table wait 
)

Definition at line 2314 of file videobuf2-core.c.

ssize_t vb2_fop_read ( struct file file,
char __user buf,
size_t  count,
loff_t *  ppos 
)

Definition at line 2292 of file videobuf2-core.c.

int vb2_fop_release ( struct file file)

Definition at line 2258 of file videobuf2-core.c.

ssize_t vb2_fop_write ( struct file file,
char __user buf,
size_t  count,
loff_t *  ppos 
)

Definition at line 2270 of file videobuf2-core.c.

unsigned long vb2_get_unmapped_area ( struct vb2_queue q,
unsigned long  addr,
unsigned long  len,
unsigned long  pgoff,
unsigned long  flags 
)

Definition at line 1611 of file videobuf2-core.c.

int vb2_ioctl_create_bufs ( struct file file,
void priv,
struct v4l2_create_buffers p 
)

Definition at line 2166 of file videobuf2-core.c.

int vb2_ioctl_dqbuf ( struct file file,
void priv,
struct v4l2_buffer p 
)

Definition at line 2218 of file videobuf2-core.c.

int vb2_ioctl_prepare_buf ( struct file file,
void priv,
struct v4l2_buffer p 
)

Definition at line 2188 of file videobuf2-core.c.

int vb2_ioctl_qbuf ( struct file file,
void priv,
struct v4l2_buffer p 
)

Definition at line 2208 of file videobuf2-core.c.

int vb2_ioctl_querybuf ( struct file file,
void priv,
struct v4l2_buffer p 
)

Definition at line 2199 of file videobuf2-core.c.

int vb2_ioctl_reqbufs ( struct file file,
void priv,
struct v4l2_requestbuffers p 
)

Definition at line 2147 of file videobuf2-core.c.

int vb2_ioctl_streamoff ( struct file file,
void priv,
enum v4l2_buf_type  i 
)

Definition at line 2238 of file videobuf2-core.c.

int vb2_ioctl_streamon ( struct file file,
void priv,
enum v4l2_buf_type  i 
)

Definition at line 2228 of file videobuf2-core.c.

int vb2_mmap ( struct vb2_queue q,
struct vm_area_struct vma 
)

vb2_mmap() - map video buffers into application address space : videobuf2 queue : vma passed to the mmap file operation handler in the driver

Should be called from mmap file operation handler of a driver. This function maps one plane of one of the available video buffers to userspace. To map whole video memory allocated on reqbufs, this function has to be called once per each plane per each buffer previously allocated.

When the userspace application calls mmap, it passes to it an offset returned to it earlier by the means of vidioc_querybuf handler. That offset acts as a "cookie", which is then used to identify the plane to be mapped. This function finds a plane with a matching offset and a mapping is performed by the means of a provided memory operation.

The return values from this function are intended to be directly returned from the mmap handler in driver.

Definition at line 1561 of file videobuf2-core.c.

void vb2_ops_wait_finish ( struct vb2_queue vq)

Definition at line 2374 of file videobuf2-core.c.

void vb2_ops_wait_prepare ( struct vb2_queue vq)

Definition at line 2368 of file videobuf2-core.c.

void* vb2_plane_cookie ( struct vb2_buffer vb,
unsigned int  plane_no 
)

vb2_plane_cookie() - Return allocator specific cookie for the given plane : vb2_buffer to which the plane in question belongs to : plane number for which the cookie is to be returned

This function returns an allocator specific cookie for a given plane if available, NULL otherwise. The allocator should provide some simple static inline function, which would convert this cookie to the allocator specific type that can be used directly by the driver to access the buffer. This can be for example physical address, pointer to scatter list or IOMMU mapping.

Definition at line 766 of file videobuf2-core.c.

void* vb2_plane_vaddr ( struct vb2_buffer vb,
unsigned int  plane_no 
)

vb2_plane_vaddr() - Return a kernel virtual address of a given plane : vb2_buffer to which the plane in question belongs to : plane number for which the address is to be returned

This function returns a kernel virtual address of a given plane if such a mapping exist, NULL otherwise.

Definition at line 743 of file videobuf2-core.c.

unsigned int vb2_poll ( struct vb2_queue q,
struct file file,
poll_table wait 
)

Definition at line 1663 of file videobuf2-core.c.

int vb2_prepare_buf ( struct vb2_queue q,
struct v4l2_buffer b 
)

vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel : videobuf2 queue : buffer structure passed from userspace to vidioc_prepare_buf handler in driver

Should be called from vidioc_prepare_buf ioctl handler of a driver. This function: 1) verifies the passed buffer, 2) calls buf_prepare callback in the driver (if provided), in which driver-specific buffer initialization can be performed,

The return values from this function are intended to be directly returned from vidioc_prepare_buf handler in driver.

Definition at line 1015 of file videobuf2-core.c.

int vb2_qbuf ( struct vb2_queue q,
struct v4l2_buffer b 
)

vb2_qbuf() - Queue a buffer from userspace : videobuf2 queue : buffer structure passed from userspace to vidioc_qbuf handler in driver

Should be called from vidioc_qbuf ioctl handler of a driver. This function: 1) verifies the passed buffer, 2) if necessary, calls buf_prepare callback in the driver (if provided), in which driver-specific buffer initialization can be performed, 3) if streaming is on, queues the buffer in driver by the means of buf_queue callback for processing.

The return values from this function are intended to be directly returned from vidioc_qbuf handler in driver.

Definition at line 1081 of file videobuf2-core.c.

int vb2_querybuf ( struct vb2_queue q,
struct v4l2_buffer b 
)

vb2_querybuf() - query video buffer information : videobuf queue : buffer struct passed from userspace to vidioc_querybuf handler in driver

Should be called from vidioc_querybuf ioctl handler in driver. This function will verify the passed v4l2_buffer structure and fill the relevant information for the userspace.

The return values from this function are intended to be directly returned from vidioc_querybuf handler in driver.

Definition at line 408 of file videobuf2-core.c.

int vb2_queue_init ( struct vb2_queue q)

vb2_queue_init() - initialize a videobuf2 queue : videobuf2 queue; this structure should be allocated in driver

The vb2_queue structure should be allocated by the driver. The driver is responsible of clearing it's content and setting initial values for some required entries before calling this function. q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer to the struct vb2_queue description in include/media/videobuf2-core.h for more information.

Definition at line 1738 of file videobuf2-core.c.

void vb2_queue_release ( struct vb2_queue q)

vb2_queue_release() - stop streaming, release the queue and free memory : videobuf2 queue

This function stops streaming and performs necessary clean ups, including freeing video buffer memory. The driver is responsible for freeing the vb2_queue structure itself.

Definition at line 1772 of file videobuf2-core.c.

size_t vb2_read ( struct vb2_queue q,
char __user data,
size_t  count,
loff_t *  ppos,
int  nonblocking 
)

Definition at line 2116 of file videobuf2-core.c.

int vb2_reqbufs ( struct vb2_queue q,
struct v4l2_requestbuffers req 
)

vb2_reqbufs() - Wrapper for __reqbufs() that also verifies the memory and type values. : videobuf2 queue : struct passed from userspace to vidioc_reqbufs handler in driver

Definition at line 618 of file videobuf2-core.c.

int vb2_streamoff ( struct vb2_queue q,
enum v4l2_buf_type  type 
)

vb2_streamoff - stop streaming : videobuf2 queue : type argument passed from userspace to vidioc_streamoff handler

Should be called from vidioc_streamoff handler of a driver. This function: 1) verifies current state, 2) stop streaming and dequeues any queued buffers, including those previously passed to the driver (after waiting for the driver to finish).

This call can be used for pausing playback. The return values from this function are intended to be directly returned from vidioc_streamoff handler in the driver

Definition at line 1485 of file videobuf2-core.c.

int vb2_streamon ( struct vb2_queue q,
enum v4l2_buf_type  type 
)

vb2_streamon - start streaming : videobuf2 queue : type argument passed from userspace to vidioc_streamon handler

Should be called from vidioc_streamon handler of a driver. This function: 1) verifies current state 2) passes any previously queued buffers to the driver and starts streaming

The return values from this function are intended to be directly returned from vidioc_streamon handler in the driver.

Definition at line 1425 of file videobuf2-core.c.

int vb2_wait_for_all_buffers ( struct vb2_queue q)

vb2_wait_for_all_buffers() - wait until all buffers are given back to vb2 : videobuf2 queue

This function will wait until all buffers that have been given to the driver by buf_queue() are given back to vb2 with vb2_buffer_done(). It doesn't call wait_prepare, wait_finish pair. It is intended to be called with all locks taken, for example from stop_streaming() callback.

Definition at line 1293 of file videobuf2-core.c.

size_t vb2_write ( struct vb2_queue q,
char __user data,
size_t  count,
loff_t *  ppos,
int  nonblocking 
)

Definition at line 2123 of file videobuf2-core.c.