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

Go to the source code of this file.

Data Structures

struct  v4l2_m2m_dev
 

Macros

#define dprintk(fmt, arg...)
 
#define TRANS_QUEUED   (1 << 0)
 
#define TRANS_RUNNING   (1 << 1)
 
#define DST_QUEUE_OFF_BASE   (1 << 30)
 

Functions

 MODULE_DESCRIPTION ("Mem to mem device framework for videobuf")
 
 MODULE_AUTHOR ("Pawel Osciak, <[email protected]>")
 
 MODULE_LICENSE ("GPL")
 
 module_param (debug, bool, 0644)
 
struct vb2_queuev4l2_m2m_get_vq (struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type)
 
 EXPORT_SYMBOL (v4l2_m2m_get_vq)
 
voidv4l2_m2m_next_buf (struct v4l2_m2m_queue_ctx *q_ctx)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_next_buf)
 
voidv4l2_m2m_buf_remove (struct v4l2_m2m_queue_ctx *q_ctx)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_buf_remove)
 
voidv4l2_m2m_get_curr_priv (struct v4l2_m2m_dev *m2m_dev)
 
 EXPORT_SYMBOL (v4l2_m2m_get_curr_priv)
 
void v4l2_m2m_job_finish (struct v4l2_m2m_dev *m2m_dev, struct v4l2_m2m_ctx *m2m_ctx)
 
 EXPORT_SYMBOL (v4l2_m2m_job_finish)
 
int v4l2_m2m_reqbufs (struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_requestbuffers *reqbufs)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_reqbufs)
 
int v4l2_m2m_querybuf (struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_querybuf)
 
int v4l2_m2m_qbuf (struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_qbuf)
 
int v4l2_m2m_dqbuf (struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_dqbuf)
 
int v4l2_m2m_streamon (struct file *file, struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_streamon)
 
int v4l2_m2m_streamoff (struct file *file, struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_streamoff)
 
unsigned int v4l2_m2m_poll (struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct poll_table_struct *wait)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_poll)
 
int v4l2_m2m_mmap (struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct vm_area_struct *vma)
 
 EXPORT_SYMBOL (v4l2_m2m_mmap)
 
struct v4l2_m2m_devv4l2_m2m_init (struct v4l2_m2m_ops *m2m_ops)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_init)
 
void v4l2_m2m_release (struct v4l2_m2m_dev *m2m_dev)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_release)
 
struct v4l2_m2m_ctxv4l2_m2m_ctx_init (struct v4l2_m2m_dev *m2m_dev, void *drv_priv, int(*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq))
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_ctx_init)
 
void v4l2_m2m_ctx_release (struct v4l2_m2m_ctx *m2m_ctx)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_ctx_release)
 
void v4l2_m2m_buf_queue (struct v4l2_m2m_ctx *m2m_ctx, struct vb2_buffer *vb)
 
 EXPORT_SYMBOL_GPL (v4l2_m2m_buf_queue)
 

Macro Definition Documentation

#define dprintk (   fmt,
  arg... 
)
Value:
do { \
if (debug) \
printk(KERN_DEBUG "%s: " fmt, __func__, ## arg);\
} while (0)

Definition at line 33 of file v4l2-mem2mem.c.

#define DST_QUEUE_OFF_BASE   (1 << 30)

Definition at line 49 of file v4l2-mem2mem.c.

#define TRANS_QUEUED   (1 << 0)

Definition at line 41 of file v4l2-mem2mem.c.

#define TRANS_RUNNING   (1 << 1)

Definition at line 43 of file v4l2-mem2mem.c.

Function Documentation

EXPORT_SYMBOL ( v4l2_m2m_get_vq  )
EXPORT_SYMBOL ( v4l2_m2m_get_curr_priv  )
EXPORT_SYMBOL ( v4l2_m2m_job_finish  )
EXPORT_SYMBOL ( v4l2_m2m_mmap  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_next_buf  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_buf_remove  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_reqbufs  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_querybuf  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_qbuf  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_dqbuf  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_streamon  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_streamoff  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_poll  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_init  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_release  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_ctx_init  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_ctx_release  )
EXPORT_SYMBOL_GPL ( v4l2_m2m_buf_queue  )
MODULE_AUTHOR ( "Pawel  Osciak,
< pawel @osciak.com >"   
)
MODULE_DESCRIPTION ( "Mem to mem device framework for videobuf"  )
MODULE_LICENSE ( "GPL"  )
module_param ( debug  ,
bool  ,
0644   
)
void v4l2_m2m_buf_queue ( struct v4l2_m2m_ctx m2m_ctx,
struct vb2_buffer vb 
)

v4l2_m2m_buf_queue() - add a buffer to the proper ready buffers list.

Call from buf_queue(), videobuf_queue_ops callback.

Definition at line 631 of file v4l2-mem2mem.c.

void* v4l2_m2m_buf_remove ( struct v4l2_m2m_queue_ctx q_ctx)

v4l2_m2m_buf_remove() - take off a buffer from the list of ready buffers and return it

Definition at line 118 of file v4l2-mem2mem.c.

struct v4l2_m2m_ctx* v4l2_m2m_ctx_init ( struct v4l2_m2m_dev m2m_dev,
void drv_priv,
int(*)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)  queue_init 
)
read

v4l2_m2m_ctx_init() - allocate and initialize a m2m context - driver's instance private data - a previously initialized m2m_dev struct - a callback for queue type-specific initialization function to be used for initializing videobuf_queues

Usually called from driver's open() function.

Definition at line 552 of file v4l2-mem2mem.c.

void v4l2_m2m_ctx_release ( struct v4l2_m2m_ctx m2m_ctx)

v4l2_m2m_ctx_release() - release m2m context

Usually called from driver's release() function.

Definition at line 595 of file v4l2-mem2mem.c.

int v4l2_m2m_dqbuf ( struct file file,
struct v4l2_m2m_ctx m2m_ctx,
struct v4l2_buffer buf 
)

v4l2_m2m_dqbuf() - dequeue a source or destination buffer, depending on the type

Definition at line 361 of file v4l2-mem2mem.c.

void* v4l2_m2m_get_curr_priv ( struct v4l2_m2m_dev m2m_dev)

v4l2_m2m_get_curr_priv() - return driver private data for the currently running instance or NULL if no instance is running

Definition at line 145 of file v4l2-mem2mem.c.

struct vb2_queue* v4l2_m2m_get_vq ( struct v4l2_m2m_ctx m2m_ctx,
enum v4l2_buf_type  type 
)
read

v4l2_m2m_get_vq() - return vb2_queue for the given type

Definition at line 80 of file v4l2-mem2mem.c.

struct v4l2_m2m_dev* v4l2_m2m_init ( struct v4l2_m2m_ops m2m_ops)
read

v4l2_m2m_init() - initialize per-driver m2m data

Usually called from driver's probe() function.

Definition at line 509 of file v4l2-mem2mem.c.

void v4l2_m2m_job_finish ( struct v4l2_m2m_dev m2m_dev,
struct v4l2_m2m_ctx m2m_ctx 
)

v4l2_m2m_job_finish() - inform the framework that a job has been finished and have it clean up

Called by a driver to yield back the device after it has finished with it. Should be called as soon as possible after reaching a state which allows other instances to take control of the device.

This function has to be called only after device_run() callback has been called on the driver. To prevent recursion, it should not be called directly from the device_run() callback though.

Definition at line 268 of file v4l2-mem2mem.c.

int v4l2_m2m_mmap ( struct file file,
struct v4l2_m2m_ctx m2m_ctx,
struct vm_area_struct vma 
)

v4l2_m2m_mmap() - source and destination queues-aware mmap multiplexer

Call from driver's mmap() function. Will handle mmap() for both queues seamlessly for videobuffer, which will receive normal per-queue offsets and proper videobuf queue pointers. The differentiation is made outside videobuf by adding a predefined offset to buffers from one of the queues and subtracting it before passing it back to videobuf. Only drivers (and thus applications) receive modified offsets.

Definition at line 487 of file v4l2-mem2mem.c.

void* v4l2_m2m_next_buf ( struct v4l2_m2m_queue_ctx q_ctx)

v4l2_m2m_next_buf() - return next buffer from the list of ready buffers

Definition at line 96 of file v4l2-mem2mem.c.

unsigned int v4l2_m2m_poll ( struct file file,
struct v4l2_m2m_ctx m2m_ctx,
struct poll_table_struct wait 
)

v4l2_m2m_poll() - poll replacement, for destination buffers only

Call from the driver's poll() function. Will poll both queues. If a buffer is available to dequeue (with dqbuf) from the source queue, this will indicate that a non-blocking write can be performed, while read will be returned in case of the destination queue.

Definition at line 410 of file v4l2-mem2mem.c.

int v4l2_m2m_qbuf ( struct file file,
struct v4l2_m2m_ctx m2m_ctx,
struct v4l2_buffer buf 
)

v4l2_m2m_qbuf() - enqueue a source or destination buffer, depending on the type

Definition at line 342 of file v4l2-mem2mem.c.

int v4l2_m2m_querybuf ( struct file file,
struct v4l2_m2m_ctx m2m_ctx,
struct v4l2_buffer buf 
)

v4l2_m2m_querybuf() - multi-queue-aware QUERYBUF multiplexer

See v4l2_m2m_mmap() documentation for details.

Definition at line 313 of file v4l2-mem2mem.c.

void v4l2_m2m_release ( struct v4l2_m2m_dev m2m_dev)

v4l2_m2m_release() - cleans up and frees a m2m_dev structure

Usually called from driver's remove() function.

Definition at line 537 of file v4l2-mem2mem.c.

int v4l2_m2m_reqbufs ( struct file file,
struct v4l2_m2m_ctx m2m_ctx,
struct v4l2_requestbuffers reqbufs 
)

v4l2_m2m_reqbufs() - multi-queue-aware REQBUFS multiplexer

Definition at line 298 of file v4l2-mem2mem.c.

int v4l2_m2m_streamoff ( struct file file,
struct v4l2_m2m_ctx m2m_ctx,
enum v4l2_buf_type  type 
)

v4l2_m2m_streamoff() - turn off streaming for a video queue

Definition at line 392 of file v4l2-mem2mem.c.

int v4l2_m2m_streamon ( struct file file,
struct v4l2_m2m_ctx m2m_ctx,
enum v4l2_buf_type  type 
)

v4l2_m2m_streamon() - turn on streaming for a video queue

Definition at line 374 of file v4l2-mem2mem.c.