Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *	V 4 L 2   D R I V E R   H E L P E R   A P I
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Moved from videodev2.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *	Some commonly needed functions for drivers (v4l2-common.o module)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #ifndef _V4L2_DEV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define _V4L2_DEV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/cdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/android_kabi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <media/media-entity.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define VIDEO_MAJOR	81
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * enum vfl_devnode_type - type of V4L2 device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * @VFL_TYPE_VIDEO:	for video input/output devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * @VFL_TYPE_VBI:	for vertical blank data (i.e. closed captions, teletext)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * @VFL_TYPE_RADIO:	for radio tuners
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * @VFL_TYPE_SUBDEV:	for V4L2 subdevices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * @VFL_TYPE_SDR:	for Software Defined Radio tuners
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * @VFL_TYPE_TOUCH:	for touch sensors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * @VFL_TYPE_MAX:	number of VFL types, must always be last in the enum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) enum vfl_devnode_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	VFL_TYPE_VIDEO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	VFL_TYPE_VBI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	VFL_TYPE_RADIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	VFL_TYPE_SUBDEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	VFL_TYPE_SDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	VFL_TYPE_TOUCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	VFL_TYPE_MAX /* Shall be the last one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * enum  vfl_direction - Identifies if a &struct video_device corresponds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  *	to a receiver, a transmitter or a mem-to-mem device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * @VFL_DIR_RX:		device is a receiver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * @VFL_DIR_TX:		device is a transmitter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * @VFL_DIR_M2M:	device is a memory to memory device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * Note: Ignored if &enum vfl_devnode_type is %VFL_TYPE_SUBDEV.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) enum vfl_devnode_direction {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	VFL_DIR_RX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	VFL_DIR_TX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	VFL_DIR_M2M,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) struct v4l2_ioctl_callbacks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) struct video_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) struct v4l2_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) struct v4l2_ctrl_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * enum v4l2_video_device_flags - Flags used by &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * @V4L2_FL_REGISTERED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *	indicates that a &struct video_device is registered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  *	Drivers can clear this flag if they want to block all future
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *	device access. It is cleared by video_unregister_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * @V4L2_FL_USES_V4L2_FH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *	indicates that file->private_data points to &struct v4l2_fh.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *	This flag is set by the core when v4l2_fh_init() is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *	All new drivers should use it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * @V4L2_FL_QUIRK_INVERTED_CROP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *	some old M2M drivers use g/s_crop/cropcap incorrectly: crop and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *	compose are swapped. If this flag is set, then the selection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  *	targets are swapped in the g/s_crop/cropcap functions in v4l2-ioctl.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  *	This allows those drivers to correctly implement the selection API,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *	but the old crop API will still work as expected in order to preserve
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *	backwards compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  *	Never set this flag for new drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * @V4L2_FL_SUBDEV_RO_DEVNODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *	indicates that the video device node is registered in read-only mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  *	The flag only applies to device nodes registered for sub-devices, it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  *	set by the core when the sub-devices device nodes are registered with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *	v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *	handler to restrict access to some ioctl calls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) enum v4l2_video_device_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	V4L2_FL_REGISTERED		= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	V4L2_FL_USES_V4L2_FH		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	V4L2_FL_QUIRK_INVERTED_CROP	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	V4L2_FL_SUBDEV_RO_DEVNODE	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* Priority helper functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * struct v4l2_prio_state - stores the priority states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * @prios: array with elements to store the array priorities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *    The size of @prios array matches the number of priority types defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  *    by enum &v4l2_priority.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct v4l2_prio_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	atomic_t prios[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * v4l2_prio_init - initializes a struct v4l2_prio_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * @global: pointer to &struct v4l2_prio_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) void v4l2_prio_init(struct v4l2_prio_state *global);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * v4l2_prio_change - changes the v4l2 file handler priority
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * @global: pointer to the &struct v4l2_prio_state of the device node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * @local: pointer to the desired priority, as defined by enum &v4l2_priority
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * @new: Priority type requested, as defined by enum &v4l2_priority.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  *	This function should be used only by the V4L2 core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		     enum v4l2_priority new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * v4l2_prio_open - Implements the priority logic for a file handler open
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * @global: pointer to the &struct v4l2_prio_state of the device node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * @local: pointer to the desired priority, as defined by enum &v4l2_priority
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  *	This function should be used only by the V4L2 core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  * v4l2_prio_close - Implements the priority logic for a file handler close
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * @global: pointer to the &struct v4l2_prio_state of the device node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * @local: priority to be released, as defined by enum &v4l2_priority
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  *	This function should be used only by the V4L2 core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * v4l2_prio_max - Return the maximum priority, as stored at the @global array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * @global: pointer to the &struct v4l2_prio_state of the device node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  *	This function should be used only by the V4L2 core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * v4l2_prio_check - Implements the priority logic for a file handler close
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * @global: pointer to the &struct v4l2_prio_state of the device node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * @local: desired priority, as defined by enum &v4l2_priority local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *	This function should be used only by the V4L2 core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * struct v4l2_file_operations - fs operations used by a V4L2 device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * @owner: pointer to struct module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * @read: operations needed to implement the read() syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  * @write: operations needed to implement the write() syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  * @poll: operations needed to implement the poll() syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * @unlocked_ioctl: operations needed to implement the ioctl() syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * @compat_ioctl32: operations needed to implement the ioctl() syscall for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *	the special case where the Kernel uses 64 bits instructions, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *	the userspace uses 32 bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * @get_unmapped_area: called by the mmap() syscall, used when %!CONFIG_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * @mmap: operations needed to implement the mmap() syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * @open: operations needed to implement the open() syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * @release: operations needed to implement the release() syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  *	Those operations are used to implemente the fs struct file_operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  *	at the V4L2 drivers. The V4L2 core overrides the fs ops with some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  *	extra logic needed by the subsystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct v4l2_file_operations {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	struct module *owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	__poll_t (*poll) (struct file *, struct poll_table_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	long (*compat_ioctl32) (struct file *, unsigned int, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	unsigned long (*get_unmapped_area) (struct file *, unsigned long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 				unsigned long, unsigned long, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	int (*mmap) (struct file *, struct vm_area_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	int (*open) (struct file *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	int (*release) (struct file *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  * Newer version of video_device, handled by videodev2.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  *	This version moves redundant code from video device code to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  *	the common handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  * struct video_device - Structure used to create and manage the V4L2 device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  *	nodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  * @entity: &struct media_entity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  * @intf_devnode: pointer to &struct media_intf_devnode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  * @pipe: &struct media_pipeline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  * @fops: pointer to &struct v4l2_file_operations for the video device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  * @device_caps: device capabilities as used in v4l2_capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * @dev: &struct device for the video device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  * @cdev: character device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  * @v4l2_dev: pointer to &struct v4l2_device parent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * @dev_parent: pointer to &struct device parent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  * @ctrl_handler: Control handler associated with this device node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  *	 May be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  * @queue: &struct vb2_queue associated with this device node. May be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * @prio: pointer to &struct v4l2_prio_state with device's Priority state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  *	 If NULL, then v4l2_dev->prio will be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * @name: video device name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  * @vfl_dir: V4L receiver, transmitter or m2m
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  * @minor: device node 'minor'. It is set to -1 if the registration failed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  * @num: number of the video device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  * @flags: video device flags. Use bitops to set/clear/test flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)  *	   Contains a set of &enum v4l2_video_device_flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  * @index: attribute to differentiate multiple indices on one physical device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  * @fh_lock: Lock for all v4l2_fhs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  * @fh_list: List of &struct v4l2_fh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  * @dev_debug: Internal device debug flags, not for use by drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  * @tvnorms: Supported tv norms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)  * @release: video device release() callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  * @ioctl_ops: pointer to &struct v4l2_ioctl_ops with ioctl callbacks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)  * @valid_ioctls: bitmap with the valid ioctls for this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)  * @lock: pointer to &struct mutex serialization lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  *	Only set @dev_parent if that can't be deduced from @v4l2_dev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #if defined(CONFIG_MEDIA_CONTROLLER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	struct media_entity entity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	struct media_intf_devnode *intf_devnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	struct media_pipeline pipe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	const struct v4l2_file_operations *fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	u32 device_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	/* sysfs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	struct device dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	struct cdev *cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	struct v4l2_device *v4l2_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	struct device *dev_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	struct v4l2_ctrl_handler *ctrl_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	struct vb2_queue *queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	struct v4l2_prio_state *prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	/* device info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	char name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	enum vfl_devnode_type vfl_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	enum vfl_devnode_direction vfl_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	int minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	u16 num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	/* V4L2 file handles */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	spinlock_t		fh_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	struct list_head	fh_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	int dev_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	v4l2_std_id tvnorms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	/* callbacks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	void (*release)(struct video_device *vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	const struct v4l2_ioctl_ops *ioctl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	DECLARE_BITMAP(valid_ioctls, BASE_VIDIOC_PRIVATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	struct mutex *lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	ANDROID_KABI_RESERVE(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)  * media_entity_to_video_device - Returns a &struct video_device from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)  *	the &struct media_entity embedded on it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)  * @__entity: pointer to &struct media_entity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) #define media_entity_to_video_device(__entity) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	container_of(__entity, struct video_device, entity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  * to_video_device - Returns a &struct video_device from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  *	&struct device embedded on it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  * @cd: pointer to &struct device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #define to_video_device(cd) container_of(cd, struct video_device, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  * __video_register_device - register video4linux devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)  * @vdev: struct video_device to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)  * @type: type of device to register, as defined by &enum vfl_devnode_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)  * @nr:   which device node number is desired:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)  *	(0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)  * @warn_if_nr_in_use: warn if the desired device node number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)  *        was already in use and another number was chosen instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  * @owner: module that owns the video device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)  * The registration code assigns minor numbers and device node numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)  * based on the requested type and registers the new device node with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)  * the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  * This function assumes that struct video_device was zeroed when it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)  * was allocated and does not contain any stale date.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  * An error is returned if no free minor or device node number could be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  * found, or if the registration of the device node failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)  * Returns 0 on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  *	This function is meant to be used only inside the V4L2 core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)  *	Drivers should use video_register_device() or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  *	video_register_device_no_warn().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) int __must_check __video_register_device(struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 					 enum vfl_devnode_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 					 int nr, int warn_if_nr_in_use,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 					 struct module *owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  *  video_register_device - register video4linux devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  * @vdev: struct video_device to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)  * @type: type of device to register, as defined by &enum vfl_devnode_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)  * @nr:   which device node number is desired:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)  *	(0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)  * Internally, it calls __video_register_device(). Please see its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  * documentation for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)  *	if video_register_device fails, the release() callback of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)  *	&struct video_device structure is *not* called, so the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)  *	is responsible for freeing any data. Usually that means that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)  *	you video_device_release() should be called on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) static inline int __must_check video_register_device(struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 						     enum vfl_devnode_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 						     int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)  *  video_register_device_no_warn - register video4linux devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)  * @vdev: struct video_device to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)  * @type: type of device to register, as defined by &enum vfl_devnode_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)  * @nr:   which device node number is desired:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)  *	(0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)  * This function is identical to video_register_device() except that no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)  * warning is issued if the desired device node number was already in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  * Internally, it calls __video_register_device(). Please see its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  * documentation for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  *	if video_register_device fails, the release() callback of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)  *	&struct video_device structure is *not* called, so the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)  *	is responsible for freeing any data. Usually that means that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)  *	you video_device_release() should be called on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static inline int __must_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) video_register_device_no_warn(struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			      enum vfl_devnode_type type, int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)  * video_unregister_device - Unregister video devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)  * @vdev: &struct video_device to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)  * Does nothing if vdev == NULL or if video_is_registered() returns false.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) void video_unregister_device(struct video_device *vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)  * video_device_alloc - helper function to alloc &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)  * Returns NULL if %-ENOMEM or a &struct video_device on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) struct video_device * __must_check video_device_alloc(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)  * video_device_release - helper function to release &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)  * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)  * Can also be used for video_device->release\(\).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) void video_device_release(struct video_device *vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)  * video_device_release_empty - helper function to implement the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)  *	video_device->release\(\) callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)  * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)  * This release function does nothing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)  * It should be used when the video_device is a static global struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)  *	Having a static video_device is a dubious construction at best.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) void video_device_release_empty(struct video_device *vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)  * v4l2_disable_ioctl- mark that a given command isn't implemented.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)  *	shouldn't use core locking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)  * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)  * @cmd: ioctl command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)  * This function allows drivers to provide just one v4l2_ioctl_ops struct, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)  * disable ioctls based on the specific card that is actually found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)  *    This must be called before video_register_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)  *    See also the comments for determine_valid_ioctls().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) static inline void v4l2_disable_ioctl(struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 				      unsigned int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	if (_IOC_NR(cmd) < BASE_VIDIOC_PRIVATE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 		set_bit(_IOC_NR(cmd), vdev->valid_ioctls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)  * video_get_drvdata - gets private data from &struct video_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)  * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)  * returns a pointer to the private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static inline void *video_get_drvdata(struct video_device *vdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	return dev_get_drvdata(&vdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)  * video_set_drvdata - sets private data from &struct video_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)  * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)  * @data: private data pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) static inline void video_set_drvdata(struct video_device *vdev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	dev_set_drvdata(&vdev->dev, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)  * video_devdata - gets &struct video_device from struct file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)  * @file: pointer to struct file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct video_device *video_devdata(struct file *file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)  * video_drvdata - gets private data from &struct video_device using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)  *	struct file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)  * @file: pointer to struct file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)  * This is function combines both video_get_drvdata() and video_devdata()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)  * as this is used very often.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) static inline void *video_drvdata(struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	return video_get_drvdata(video_devdata(file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)  * video_device_node_name - returns the video device name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)  * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)  * Returns the device name string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) static inline const char *video_device_node_name(struct video_device *vdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	return dev_name(&vdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)  * video_is_registered - returns true if the &struct video_device is registered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)  * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) static inline int video_is_registered(struct video_device *vdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	return test_bit(V4L2_FL_REGISTERED, &vdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) #endif /* _V4L2_DEV_H */