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

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Video capture interface for Linux version 2
 *
 * A generic framework to process V4L2 ioctl commands.
 *
 * Authors:	Alan Cox, <[email protected]> (version 1)
 *              Mauro Carvalho Chehab <[email protected]> (version 2)
 */

#include <linux/compat.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/version.h>

#include <linux/v4l2-subdev.h>
#include <linux/videodev2.h>

#include <media/media-device.h> /* for media_set_bus_info() */
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-event.h>
#include <media/v4l2-device.h>
#include <media/videobuf2-v4l2.h>
#include <media/v4l2-mc.h>
#include <media/v4l2-mem2mem.h>

#include <trace/events/v4l2.h>

#define is_valid_ioctl(vfd, cmd)

struct std_descr {};

static const struct std_descr standards[] =;

/* video4linux standard ID conversion to standard name
 */
const char *v4l2_norm_to_name(v4l2_std_id id)
{}
EXPORT_SYMBOL();

/* Returns frame period for the given standard */
void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod)
{}
EXPORT_SYMBOL();

/* Fill in the fields of a v4l2_standard structure according to the
   'id' and 'transmission' parameters.  Returns negative on error.  */
int v4l2_video_std_construct(struct v4l2_standard *vs,
			     int id, const char *name)
{}
EXPORT_SYMBOL();

/* Fill in the fields of a v4l2_standard structure according to the
 * 'id' and 'vs->index' parameters. Returns negative on error. */
int v4l_video_std_enumstd(struct v4l2_standard *vs, v4l2_std_id id)
{}

/* ----------------------------------------------------------------- */
/* some arrays for pretty-printing debug messages of enum types      */

const char *v4l2_field_names[] =;
EXPORT_SYMBOL();

const char *v4l2_type_names[] =;
EXPORT_SYMBOL();

static const char *v4l2_memory_names[] =;

#define prt_names(a, arr)

/* ------------------------------------------------------------------ */
/* debug help functions                                               */

static void v4l_print_querycap(const void *arg, bool write_only)
{}

static void v4l_print_enuminput(const void *arg, bool write_only)
{}

static void v4l_print_enumoutput(const void *arg, bool write_only)
{}

static void v4l_print_audio(const void *arg, bool write_only)
{}

static void v4l_print_audioout(const void *arg, bool write_only)
{}

static void v4l_print_fmtdesc(const void *arg, bool write_only)
{}

static void v4l_print_format(const void *arg, bool write_only)
{}

static void v4l_print_framebuffer(const void *arg, bool write_only)
{}

static void v4l_print_buftype(const void *arg, bool write_only)
{}

static void v4l_print_modulator(const void *arg, bool write_only)
{}

static void v4l_print_tuner(const void *arg, bool write_only)
{}

static void v4l_print_frequency(const void *arg, bool write_only)
{}

static void v4l_print_standard(const void *arg, bool write_only)
{}

static void v4l_print_std(const void *arg, bool write_only)
{}

static void v4l_print_hw_freq_seek(const void *arg, bool write_only)
{}

static void v4l_print_requestbuffers(const void *arg, bool write_only)
{}

static void v4l_print_buffer(const void *arg, bool write_only)
{}

static void v4l_print_exportbuffer(const void *arg, bool write_only)
{}

static void v4l_print_create_buffers(const void *arg, bool write_only)
{}

static void v4l_print_remove_buffers(const void *arg, bool write_only)
{}

static void v4l_print_streamparm(const void *arg, bool write_only)
{}

static void v4l_print_queryctrl(const void *arg, bool write_only)
{}

static void v4l_print_query_ext_ctrl(const void *arg, bool write_only)
{}

static void v4l_print_querymenu(const void *arg, bool write_only)
{}

static void v4l_print_control(const void *arg, bool write_only)
{}

static void v4l_print_ext_controls(const void *arg, bool write_only)
{}

static void v4l_print_cropcap(const void *arg, bool write_only)
{}

static void v4l_print_crop(const void *arg, bool write_only)
{}

static void v4l_print_selection(const void *arg, bool write_only)
{}

static void v4l_print_jpegcompression(const void *arg, bool write_only)
{}

static void v4l_print_enc_idx(const void *arg, bool write_only)
{}

static void v4l_print_encoder_cmd(const void *arg, bool write_only)
{}

static void v4l_print_decoder_cmd(const void *arg, bool write_only)
{}

static void v4l_print_dbg_chip_info(const void *arg, bool write_only)
{}

static void v4l_print_dbg_register(const void *arg, bool write_only)
{}

static void v4l_print_dv_timings(const void *arg, bool write_only)
{}

static void v4l_print_enum_dv_timings(const void *arg, bool write_only)
{}

static void v4l_print_dv_timings_cap(const void *arg, bool write_only)
{}

static void v4l_print_frmsizeenum(const void *arg, bool write_only)
{}

static void v4l_print_frmivalenum(const void *arg, bool write_only)
{}

static void v4l_print_event(const void *arg, bool write_only)
{}

static void v4l_print_event_subscription(const void *arg, bool write_only)
{}

static void v4l_print_sliced_vbi_cap(const void *arg, bool write_only)
{}

static void v4l_print_freq_band(const void *arg, bool write_only)
{}

static void v4l_print_edid(const void *arg, bool write_only)
{}

static void v4l_print_u32(const void *arg, bool write_only)
{}

static void v4l_print_newline(const void *arg, bool write_only)
{}

static void v4l_print_default(const void *arg, bool write_only)
{}

static bool check_ext_ctrls(struct v4l2_ext_controls *c, unsigned long ioctl)
{}

static int check_fmt(struct file *file, enum v4l2_buf_type type)
{}

static void v4l_sanitize_colorspace(u32 pixelformat, u32 *colorspace,
				    u32 *encoding, u32 *quantization,
				    u32 *xfer_func)
{}

static void v4l_sanitize_format(struct v4l2_format *fmt)
{}

static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_g_input(const struct v4l2_ioctl_ops *ops,
		       struct file *file, void *fh, void *arg)
{}

static int v4l_g_output(const struct v4l2_ioctl_ops *ops,
			struct file *file, void *fh, void *arg)
{}

static int v4l_s_input(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_output(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_g_priority(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_priority(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_enuminput(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
{}

static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static void v4l_pix_format_touch(struct v4l2_pix_format *p)
{}

static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_streamon(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_streamoff(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_g_tuner(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_g_modulator(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_modulator(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_enumstd(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_std(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_querystd(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_fbuf(const struct v4l2_ioctl_ops *ops,
		      struct file *file, void *fh, void *arg)
{}

static int v4l_overlay(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_querybuf(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_qbuf(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_dqbuf(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_prepare_buf(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_remove_bufs(const struct v4l2_ioctl_ops *ops,
			   struct file *file, void *fh, void *arg)
{}

static int v4l_g_parm(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_parm(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_querymenu(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

/*
 * The selection API specified originally that the _MPLANE buffer types
 * shouldn't be used. The reasons for this are lost in the mists of time
 * (or just really crappy memories). Regardless, this is really annoying
 * for userspace. So to keep things simple we map _MPLANE buffer types
 * to their 'regular' counterparts before calling the driver. And we
 * restore it afterwards. This way applications can use either buffer
 * type and drivers don't need to check for both.
 */
static int v4l_g_selection(const struct v4l2_ioctl_ops *ops,
			   struct file *file, void *fh, void *arg)
{}

static int v4l_s_selection(const struct v4l2_ioctl_ops *ops,
			   struct file *file, void *fh, void *arg)
{}

static int v4l_g_crop(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_s_crop(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_cropcap(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_log_status(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_dqevent(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_subscribe_event(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_unsubscribe_event(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,
				struct file *file, void *fh, void *arg)
{}

struct v4l2_ioctl_info {};

/* This control needs a priority check */
#define INFO_FL_PRIO
/* This control can be valid if the filehandle passes a control handler. */
#define INFO_FL_CTRL
/* Queuing ioctl */
#define INFO_FL_QUEUE
/* Always copy back result, even on error */
#define INFO_FL_ALWAYS_COPY
/* Zero struct from after the field to the end */
#define INFO_FL_CLEAR(v4l2_struct, field)
#define INFO_FL_CLEAR_MASK

#define DEFINE_V4L_STUB_FUNC(_vidioc)

#define IOCTL_INFO(_ioctl, _func, _debug, _flags)

DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()
DEFINE_V4L_STUB_FUNC()

static const struct v4l2_ioctl_info v4l2_ioctls[] =;
#define V4L2_IOCTLS

static bool v4l2_is_known_ioctl(unsigned int cmd)
{}

static struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev,
					 struct v4l2_fh *vfh, unsigned int cmd,
					 void *arg)
{}

/* Common ioctl debug function. This function can be used by
   external ioctl messages as well as internal V4L ioctl */
void v4l_printk_ioctl(const char *prefix, unsigned int cmd)
{}
EXPORT_SYMBOL();

static long __video_do_ioctl(struct file *file,
		unsigned int cmd, void *arg)
{}

static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
			    void __user **user_ptr, void ***kernel_ptr)
{}

static unsigned int video_translate_cmd(unsigned int cmd)
{}

static int video_get_user(void __user *arg, void *parg,
			  unsigned int real_cmd, unsigned int cmd,
			  bool *always_copy)
{}

static int video_put_user(void __user *arg, void *parg,
			  unsigned int real_cmd, unsigned int cmd)
{}

long
video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg,
	       v4l2_kioctl func)
{}

long video_ioctl2(struct file *file,
	       unsigned int cmd, unsigned long arg)
{}
EXPORT_SYMBOL();