linux/drivers/media/common/videobuf2/videobuf2-v4l2.c

/*
 * videobuf2-v4l2.c - V4L2 driver helper framework
 *
 * Copyright (C) 2010 Samsung Electronics
 *
 * Author: Pawel Osciak <[email protected]>
 *	   Marek Szyprowski <[email protected]>
 *
 * The vb2_thread implementation was based on code from videobuf-dvb.c:
 *	(c) 2004 Gerd Knorr <[email protected]> [SUSE Labs]
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 */

#include <linux/device.h>
#include <linux/err.h>
#include <linux/freezer.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/poll.h>
#include <linux/sched.h>
#include <linux/slab.h>

#include <media/v4l2-common.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fh.h>

#include <media/videobuf2-v4l2.h>

static int debug;
module_param(debug, int, 0644);

#define dprintk(q, level, fmt, arg...)

/* Flags that are set by us */
#define V4L2_BUFFER_MASK_FLAGS
/* Output buffer flags that should be passed on to the driver */
#define V4L2_BUFFER_OUT_FLAGS

/*
 * __verify_planes_array() - verify that the planes array passed in struct
 * v4l2_buffer from userspace can be safely used
 */
static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer *b)
{}

static int __verify_planes_array_core(struct vb2_buffer *vb, const void *pb)
{}

/*
 * __verify_length() - Verify that the bytesused value for each plane fits in
 * the plane length and that the data offset doesn't exceed the bytesused value.
 */
static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b)
{}

/*
 * __init_vb2_v4l2_buffer() - initialize the vb2_v4l2_buffer struct
 */
static void __init_vb2_v4l2_buffer(struct vb2_buffer *vb)
{}

static void __copy_timestamp(struct vb2_buffer *vb, const void *pb)
{
	const struct v4l2_buffer *b = pb;
	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
	struct vb2_queue *q = vb->vb2_queue;

	if (q->is_output) {
		/*
		 * For output buffers copy the timestamp if needed,
		 * and the timecode field and flag if needed.
		 */
		if (q->copy_timestamp)
			vb->timestamp = v4l2_buffer_get_timestamp(b);
		vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;
		if (b->flags & V4L2_BUF_FLAG_TIMECODE)
			vbuf->timecode = b->timecode;
	}
};

static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
{}

static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
{}

static void set_buffer_cache_hints(struct vb2_queue *q,
				   struct vb2_buffer *vb,
				   struct v4l2_buffer *b)
{}

static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
				    struct vb2_buffer *vb, struct v4l2_buffer *b,
				    bool is_prepare, struct media_request **p_req)
{}

/*
 * __fill_v4l2_buffer() - fill in a struct v4l2_buffer with information to be
 * returned to userspace
 */
static void __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb)
{}

/*
 * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a
 * v4l2_buffer by the userspace. It also verifies that struct
 * v4l2_buffer has a valid number of planes.
 */
static int __fill_vb2_buffer(struct vb2_buffer *vb, struct vb2_plane *planes)
{}

static const struct vb2_buf_ops v4l2_buf_ops =;

struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp)
{}
EXPORT_SYMBOL_GPL();

/*
 * vb2_querybuf() - query video buffer information
 * @q:		vb2 queue
 * @b:		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.
 */
int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b)
{}
EXPORT_SYMBOL();

static void vb2_set_flags_and_caps(struct vb2_queue *q, u32 memory,
				   u32 *flags, u32 *caps, u32 *max_num_bufs)
{}

int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
{}
EXPORT_SYMBOL_GPL();

int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
		    struct v4l2_buffer *b)
{}
EXPORT_SYMBOL_GPL();

int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
{}
EXPORT_SYMBOL_GPL();

int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
	     struct v4l2_buffer *b)
{}
EXPORT_SYMBOL_GPL();

int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
{}
EXPORT_SYMBOL_GPL();

int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
{}
EXPORT_SYMBOL_GPL();

int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
{}
EXPORT_SYMBOL_GPL();

int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb)
{}
EXPORT_SYMBOL_GPL();

int vb2_queue_init_name(struct vb2_queue *q, const char *name)
{}
EXPORT_SYMBOL_GPL();

int vb2_queue_init(struct vb2_queue *q)
{}
EXPORT_SYMBOL_GPL();

void vb2_queue_release(struct vb2_queue *q)
{}
EXPORT_SYMBOL_GPL();

int vb2_queue_change_type(struct vb2_queue *q, unsigned int type)
{}
EXPORT_SYMBOL_GPL();

__poll_t vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
{}
EXPORT_SYMBOL_GPL();

/*
 * The following functions are not part of the vb2 core API, but are helper
 * functions that plug into struct v4l2_ioctl_ops, struct v4l2_file_operations
 * and struct vb2_ops.
 * They contain boilerplate code that most if not all drivers have to do
 * and so they simplify the driver code.
 */

/* vb2 ioctl helpers */

int vb2_ioctl_remove_bufs(struct file *file, void *priv,
			  struct v4l2_remove_buffers *d)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_reqbufs(struct file *file, void *priv,
			  struct v4l2_requestbuffers *p)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_create_bufs(struct file *file, void *priv,
			  struct v4l2_create_buffers *p)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_prepare_buf(struct file *file, void *priv,
			  struct v4l2_buffer *p)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
{}
EXPORT_SYMBOL_GPL();

int vb2_ioctl_expbuf(struct file *file, void *priv, struct v4l2_exportbuffer *p)
{}
EXPORT_SYMBOL_GPL();

/* v4l2_file_operations helpers */

int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma)
{}
EXPORT_SYMBOL_GPL();

int _vb2_fop_release(struct file *file, struct mutex *lock)
{}
EXPORT_SYMBOL_GPL();

int vb2_fop_release(struct file *file)
{}
EXPORT_SYMBOL_GPL();

ssize_t vb2_fop_write(struct file *file, const char __user *buf,
		size_t count, loff_t *ppos)
{}
EXPORT_SYMBOL_GPL();

ssize_t vb2_fop_read(struct file *file, char __user *buf,
		size_t count, loff_t *ppos)
{}
EXPORT_SYMBOL_GPL();

__poll_t vb2_fop_poll(struct file *file, poll_table *wait)
{}
EXPORT_SYMBOL_GPL();

#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)
{
	struct video_device *vdev = video_devdata(file);

	return vb2_get_unmapped_area(vdev->queue, addr, len, pgoff, flags);
}
EXPORT_SYMBOL_GPL(vb2_fop_get_unmapped_area);
#endif

void vb2_video_unregister_device(struct video_device *vdev)
{}
EXPORT_SYMBOL_GPL();

/* vb2_ops helpers. Only use if vq->lock is non-NULL. */

void vb2_ops_wait_prepare(struct vb2_queue *vq)
{}
EXPORT_SYMBOL_GPL();

void vb2_ops_wait_finish(struct vb2_queue *vq)
{}
EXPORT_SYMBOL_GPL();

/*
 * Note that this function is called during validation time and
 * thus the req_queue_mutex is held to ensure no request objects
 * can be added or deleted while validating. So there is no need
 * to protect the objects list.
 */
int vb2_request_validate(struct media_request *req)
{}
EXPORT_SYMBOL_GPL();

void vb2_request_queue(struct media_request *req)
{}
EXPORT_SYMBOL_GPL();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();