linux/drivers/media/v4l2-core/v4l2-dev.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Video capture interface for Linux version 2
 *
 *	A generic video device interface for the LINUX operating system
 *	using a set of device structures/vectors for low level operations.
 *
 * Authors:	Alan Cox, <[email protected]> (version 1)
 *              Mauro Carvalho Chehab <[email protected]> (version 2)
 *
 * Fixes:	20000516  Claudio Matsuoka <[email protected]>
 *		- Added procfs support
 */

#define pr_fmt(fmt)

#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/uaccess.h>

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

#define VIDEO_NUM_DEVICES
#define VIDEO_NAME

#define dprintk(fmt, arg...)

/*
 *	sysfs stuff
 */

static ssize_t index_show(struct device *cd,
			  struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(index);

static ssize_t dev_debug_show(struct device *cd,
			  struct device_attribute *attr, char *buf)
{}

static ssize_t dev_debug_store(struct device *cd, struct device_attribute *attr,
			  const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(dev_debug);

static ssize_t name_show(struct device *cd,
			 struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(name);

static struct attribute *video_device_attrs[] =;
ATTRIBUTE_GROUPS();

/*
 *	Active devices
 */
static struct video_device *video_devices[VIDEO_NUM_DEVICES];
static DEFINE_MUTEX(videodev_lock);
static DECLARE_BITMAP(devnode_nums[VFL_TYPE_MAX], VIDEO_NUM_DEVICES);

/* Device node utility functions */

/* Note: these utility functions all assume that vfl_type is in the range
   [0, VFL_TYPE_MAX-1]. */

#ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES
/* Return the bitmap corresponding to vfl_type. */
static inline unsigned long *devnode_bits(enum vfl_devnode_type vfl_type)
{}
#else
/* Return the bitmap corresponding to vfl_type. */
static inline unsigned long *devnode_bits(enum vfl_devnode_type vfl_type)
{
	return devnode_nums[vfl_type];
}
#endif

/* Mark device node number vdev->num as used */
static inline void devnode_set(struct video_device *vdev)
{}

/* Mark device node number vdev->num as unused */
static inline void devnode_clear(struct video_device *vdev)
{}

/* Try to find a free device node number in the range [from, to> */
static inline int devnode_find(struct video_device *vdev, int from, int to)
{}

struct video_device *video_device_alloc(void)
{}
EXPORT_SYMBOL();

void video_device_release(struct video_device *vdev)
{}
EXPORT_SYMBOL();

void video_device_release_empty(struct video_device *vdev)
{}
EXPORT_SYMBOL();

static inline void video_get(struct video_device *vdev)
{}

static inline void video_put(struct video_device *vdev)
{}

/* Called when the last user of the video device exits. */
static void v4l2_device_release(struct device *cd)
{}

static struct class video_class =;

struct video_device *video_devdata(struct file *file)
{}
EXPORT_SYMBOL();


/* Priority handling */

static inline bool prio_is_valid(enum v4l2_priority prio)
{}

void v4l2_prio_init(struct v4l2_prio_state *global)
{}
EXPORT_SYMBOL();

int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
		     enum v4l2_priority new)
{}
EXPORT_SYMBOL();

void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local)
{}
EXPORT_SYMBOL();

void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local)
{}
EXPORT_SYMBOL();

enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
{}
EXPORT_SYMBOL();

int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local)
{}
EXPORT_SYMBOL();


static ssize_t v4l2_read(struct file *filp, char __user *buf,
		size_t sz, loff_t *off)
{}

static ssize_t v4l2_write(struct file *filp, const char __user *buf,
		size_t sz, loff_t *off)
{}

static __poll_t v4l2_poll(struct file *filp, struct poll_table_struct *poll)
{}

static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{}

#ifdef CONFIG_MMU
#define v4l2_get_unmapped_area
#else
static unsigned long v4l2_get_unmapped_area(struct file *filp,
		unsigned long addr, unsigned long len, unsigned long pgoff,
		unsigned long flags)
{
	struct video_device *vdev = video_devdata(filp);
	int ret;

	if (!vdev->fops->get_unmapped_area)
		return -ENOSYS;
	if (!video_is_registered(vdev))
		return -ENODEV;
	ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
	if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
		dprintk("%s: get_unmapped_area (%d)\n",
			video_device_node_name(vdev), ret);
	return ret;
}
#endif

static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
{}

/* Override for the open function */
static int v4l2_open(struct inode *inode, struct file *filp)
{}

/* Override for the release function */
static int v4l2_release(struct inode *inode, struct file *filp)
{}

static const struct file_operations v4l2_fops =;

/**
 * get_index - assign stream index number based on v4l2_dev
 * @vdev: video_device to assign index number to, vdev->v4l2_dev should be assigned
 *
 * Note that when this is called the new device has not yet been registered
 * in the video_device array, but it was able to obtain a minor number.
 *
 * This means that we can always obtain a free stream index number since
 * the worst case scenario is that there are VIDEO_NUM_DEVICES - 1 slots in
 * use of the video_device array.
 *
 * Returns a free index number.
 */
static int get_index(struct video_device *vdev)
{}

#define SET_VALID_IOCTL(ops, cmd, op)

/* This determines which ioctls are actually implemented in the driver.
   It's a one-time thing which simplifies video_ioctl2 as it can just do
   a bit test.

   Note that drivers can override this by setting bits to 1 in
   vdev->valid_ioctls. If an ioctl is marked as 1 when this function is
   called, then that ioctl will actually be marked as unimplemented.

   It does that by first setting up the local valid_ioctls bitmap, and
   at the end do a:

   vdev->valid_ioctls = valid_ioctls & ~(vdev->valid_ioctls)
 */
static void determine_valid_ioctls(struct video_device *vdev)
{}

static int video_register_media_controller(struct video_device *vdev)
{}

int __video_register_device(struct video_device *vdev,
			    enum vfl_devnode_type type,
			    int nr, int warn_if_nr_in_use,
			    struct module *owner)
{}
EXPORT_SYMBOL();

/**
 *	video_unregister_device - unregister a video4linux device
 *	@vdev: the device to unregister
 *
 *	This unregisters the passed device. Future open calls will
 *	be met with errors.
 */
void video_unregister_device(struct video_device *vdev)
{}
EXPORT_SYMBOL();

#if defined(CONFIG_MEDIA_CONTROLLER)

__must_check int video_device_pipeline_start(struct video_device *vdev,
					     struct media_pipeline *pipe)
{}
EXPORT_SYMBOL_GPL();

__must_check int __video_device_pipeline_start(struct video_device *vdev,
					       struct media_pipeline *pipe)
{}
EXPORT_SYMBOL_GPL();

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

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

__must_check int video_device_pipeline_alloc_start(struct video_device *vdev)
{}
EXPORT_SYMBOL_GPL();

struct media_pipeline *video_device_pipeline(struct video_device *vdev)
{}
EXPORT_SYMBOL_GPL();

#endif /* CONFIG_MEDIA_CONTROLLER */

/*
 *	Initialise video for linux
 */
static int __init videodev_init(void)
{}

static void __exit videodev_exit(void)
{}

subsys_initcall(videodev_init);
module_exit()

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