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-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)     v4l2 common internal API header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)     This header contains internal shared ioctl definitions for use by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)     internal low-level v4l2 drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)     Each ioctl begins with VIDIOC_INT_ to clearly mark that it is an internal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)     define,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)     Copyright (C) 2005  Hans Verkuil <hverkuil@xs4all.nl>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #ifndef V4L2_COMMON_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define V4L2_COMMON_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <media/v4l2-dev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /* Common printk constructs for v4l-i2c drivers. These macros create a unique
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)    prefix consisting of the driver name, the adapter number and the i2c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)    address. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define v4l_printk(level, name, adapter, addr, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	printk(level "%s %d-%04x: " fmt, name, i2c_adapter_id(adapter), addr , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define v4l_client_printk(level, client, fmt, arg...)			    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	v4l_printk(level, (client)->dev.driver->name, (client)->adapter, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		   (client)->addr, fmt , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define v4l_err(client, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	v4l_client_printk(KERN_ERR, client, fmt , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define v4l_warn(client, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	v4l_client_printk(KERN_WARNING, client, fmt , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define v4l_info(client, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	v4l_client_printk(KERN_INFO, client, fmt , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /* These three macros assume that the debug level is set with a module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)    parameter called 'debug'. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define v4l_dbg(level, debug, client, fmt, arg...)			     \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	do {								     \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		if (debug >= (level))					     \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 			v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) /* Add a version of v4l_dbg to be used on drivers using dev_foo() macros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define dev_dbg_lvl(__dev, __level, __debug, __fmt, __arg...)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	do {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		if (__debug >= (__level))				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 			dev_printk(KERN_DEBUG, __dev, __fmt, ##__arg);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) /* ------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) /* These printk constructs can be used with v4l2_device and v4l2_subdev */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define v4l2_printk(level, dev, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	printk(level "%s: " fmt, (dev)->name , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define v4l2_err(dev, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	v4l2_printk(KERN_ERR, dev, fmt , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define v4l2_warn(dev, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	v4l2_printk(KERN_WARNING, dev, fmt , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define v4l2_info(dev, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	v4l2_printk(KERN_INFO, dev, fmt , ## arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /* These three macros assume that the debug level is set with a module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)    parameter called 'debug'. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define v4l2_dbg(level, debug, dev, fmt, arg...)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	do {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		if (debug >= (level))					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			v4l2_printk(KERN_DEBUG, dev, fmt , ## arg);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * v4l2_ctrl_query_fill- Fill in a struct v4l2_queryctrl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * @qctrl: pointer to the &struct v4l2_queryctrl to be filled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * @min: minimum value for the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * @max: maximum value for the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * @step: control step
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * @def: default value for the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * Fills the &struct v4l2_queryctrl fields for the query control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *    This function assumes that the @qctrl->id field is filled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * Returns -EINVAL if the control is not known by the V4L2 core, 0 on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			 s32 min, s32 max, s32 step, s32 def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^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) struct v4l2_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct v4l2_subdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct v4l2_subdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /* I2C Helper functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #include <linux/i2c.h>
^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)  * enum v4l2_i2c_tuner_type - specifies the range of tuner address that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *	should be used when seeking for I2C devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * @ADDRS_RADIO:		Radio tuner addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *				Represent the following I2C addresses:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  *				0x10 (if compiled with tea5761 support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *				and 0x60.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * @ADDRS_DEMOD:		Demod tuner addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *				Represent the following I2C addresses:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *				0x42, 0x43, 0x4a and 0x4b.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * @ADDRS_TV:			TV tuner addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  *				Represent the following I2C addresses:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  *				0x42, 0x43, 0x4a, 0x4b, 0x60, 0x61, 0x62,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  *				0x63 and 0x64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * @ADDRS_TV_WITH_DEMOD:	TV tuner addresses if demod is present, this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  *				excludes addresses used by the demodulator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *				from the list of candidates.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  *				Represent the following I2C addresses:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *				0x60, 0x61, 0x62, 0x63 and 0x64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * NOTE: All I2C addresses above use the 7-bit notation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) enum v4l2_i2c_tuner_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	ADDRS_RADIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	ADDRS_DEMOD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	ADDRS_TV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	ADDRS_TV_WITH_DEMOD,
^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) #if defined(CONFIG_VIDEO_V4L2_I2C)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * v4l2_i2c_new_subdev - Load an i2c module and return an initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  *	&struct v4l2_subdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * @v4l2_dev: pointer to &struct v4l2_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * @adapter: pointer to struct i2c_adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * @client_type:  name of the chip that's on the adapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * @addr: I2C address. If zero, it will use @probe_addrs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * @probe_addrs: array with a list of address. The last entry at such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *	array should be %I2C_CLIENT_END.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * returns a &struct v4l2_subdev pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		struct i2c_adapter *adapter, const char *client_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		u8 addr, const unsigned short *probe_addrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * v4l2_i2c_new_subdev_board - Load an i2c module and return an initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  *	&struct v4l2_subdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * @v4l2_dev: pointer to &struct v4l2_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * @adapter: pointer to struct i2c_adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * @info: pointer to struct i2c_board_info used to replace the irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  *	 platform_data and addr arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * @probe_addrs: array with a list of address. The last entry at such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  *	array should be %I2C_CLIENT_END.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * returns a &struct v4l2_subdev pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		struct i2c_adapter *adapter, struct i2c_board_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		const unsigned short *probe_addrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * v4l2_i2c_subdev_set_name - Set name for an I²C sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * @client: pointer to struct i2c_client
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * @devname: the name of the device; if NULL, the I²C device's name will be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * @postfix: sub-device specific string to put right after the I²C device name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  *	     may be NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) void v4l2_i2c_subdev_set_name(struct v4l2_subdev *sd, struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			      const char *devname, const char *postfix);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * v4l2_i2c_subdev_init - Initializes a &struct v4l2_subdev with data from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *	an i2c_client struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * @client: pointer to struct i2c_client
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * @ops: pointer to &struct v4l2_subdev_ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		const struct v4l2_subdev_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  * v4l2_i2c_subdev_addr - returns i2c client address of &struct v4l2_subdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  * Returns the address of an I2C sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  * v4l2_i2c_tuner_addrs - Return a list of I2C tuner addresses to probe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * @type: type of the tuner to seek, as defined by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  *	  &enum v4l2_i2c_tuner_type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  * NOTE: Use only if the tuner addresses are unknown.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  * v4l2_i2c_subdev_unregister - Unregister a v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) void v4l2_i2c_subdev_unregister(struct v4l2_subdev *sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static inline struct v4l2_subdev *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		    struct i2c_adapter *adapter, const char *client_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		    u8 addr, const unsigned short *probe_addrs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static inline struct v4l2_subdev *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			  struct i2c_adapter *adapter, struct i2c_board_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			  const unsigned short *probe_addrs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) v4l2_i2c_subdev_set_name(struct v4l2_subdev *sd, struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			 const char *devname, const char *postfix)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		     const struct v4l2_subdev_ops *ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static inline unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	return I2C_CLIENT_END;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static inline const unsigned short *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) static inline void v4l2_i2c_subdev_unregister(struct v4l2_subdev *sd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /* ------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) /* SPI Helper functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) #include <linux/spi/spi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #if defined(CONFIG_SPI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  *  v4l2_spi_new_subdev - Load an spi module and return an initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  *	&struct v4l2_subdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * @v4l2_dev: pointer to &struct v4l2_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  * @master: pointer to struct spi_master.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  * @info: pointer to struct spi_board_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  * returns a &struct v4l2_subdev pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		struct spi_master *master, struct spi_board_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)  * v4l2_spi_subdev_init - Initialize a v4l2_subdev with data from an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)  *	spi_device struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)  * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)  * @spi: pointer to struct spi_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)  * @ops: pointer to &struct v4l2_subdev_ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		const struct v4l2_subdev_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)  * v4l2_spi_subdev_unregister - Unregister a v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)  * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) static inline struct v4l2_subdev *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		    struct spi_master *master, struct spi_board_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		     const struct v4l2_subdev_ops *ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) static inline void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /* ------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  * FIXME: these remaining ioctls/structs should be removed as well, but they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  * are still used in tuner-simple.c (TUNER_SET_CONFIG) and cx18/ivtv (RESET).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  * To remove these ioctls some more cleanup is needed in those modules.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  * It doesn't make much sense on documenting them, as what we really want is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  * to get rid of them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) /* s_config */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) struct v4l2_priv_tun_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	int tuner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	void *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) #define TUNER_SET_CONFIG           _IOW('d', 92, struct v4l2_priv_tun_config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) #define VIDIOC_INT_RESET		_IOW ('d', 102, u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) /* ------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) /* Miscellaneous helper functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)  * v4l_bound_align_image - adjust video dimensions according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  *	a given constraints.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)  * @width:	pointer to width that will be adjusted if needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  * @wmin:	minimum width.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  * @wmax:	maximum width.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)  * @walign:	least significant bit on width.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)  * @height:	pointer to height that will be adjusted if needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)  * @hmin:	minimum height.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)  * @hmax:	maximum height.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  * @halign:	least significant bit on height.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  * @salign:	least significant bit for the image size (e. g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)  *		:math:`width * height`).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  * Clip an image to have @width between @wmin and @wmax, and @height between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  * @hmin and @hmax, inclusive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)  * Additionally, the @width will be a multiple of :math:`2^{walign}`,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)  * the @height will be a multiple of :math:`2^{halign}`, and the overall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)  * size :math:`width * height` will be a multiple of :math:`2^{salign}`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  *    #. The clipping rectangle may be shrunk or enlarged to fit the alignment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)  *       constraints.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)  *    #. @wmax must not be smaller than @wmin.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)  *    #. @hmax must not be smaller than @hmin.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)  *    #. The alignments must not be so high there are no possible image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)  *       sizes within the allowed bounds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  *    #. @wmin and @hmin must be at least 1 (don't use 0).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)  *    #. For @walign, @halign and @salign, if you don't care about a certain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  *       alignment, specify ``0``, as :math:`2^0 = 1` and one byte alignment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)  *       is equivalent to no alignment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)  *    #. If you only want to adjust downward, specify a maximum that's the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)  *       same as the initial value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) void v4l_bound_align_image(unsigned int *width, unsigned int wmin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 			   unsigned int wmax, unsigned int walign,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 			   unsigned int *height, unsigned int hmin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			   unsigned int hmax, unsigned int halign,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 			   unsigned int salign);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)  * v4l2_find_nearest_size - Find the nearest size among a discrete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)  *	set of resolutions contained in an array of a driver specific struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)  * @array: a driver specific array of image sizes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)  * @array_size: the length of the driver specific array of image sizes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)  * @width_field: the name of the width field in the driver specific struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)  * @height_field: the name of the height field in the driver specific struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)  * @width: desired width.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)  * @height: desired height.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)  * Finds the closest resolution to minimize the width and height differences
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  * between what requested and the supported resolutions. The size of the width
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  * and height fields in the driver specific must equal to that of u32, i.e. four
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  * bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  * Returns the best match or NULL if the length of the array is zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) #define v4l2_find_nearest_size(array, array_size, width_field, height_field, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 			       width, height)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	({								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		BUILD_BUG_ON(sizeof((array)->width_field) != sizeof(u32) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 			     sizeof((array)->height_field) != sizeof(u32)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		(typeof(&(array)[0]))__v4l2_find_nearest_size(		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			(array), array_size, sizeof(*(array)),		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			offsetof(typeof(*(array)), width_field),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 			offsetof(typeof(*(array)), height_field),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 			width, height);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) const void *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) __v4l2_find_nearest_size(const void *array, size_t array_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			 size_t entry_size, size_t width_offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 			 size_t height_offset, s32 width, s32 height);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)  * v4l2_g_parm_cap - helper routine for vidioc_g_parm to fill this in by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)  *      calling the g_frame_interval op of the given subdev. It only works
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)  *      for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)  *      function name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)  * @vdev: the struct video_device pointer. Used to determine the device caps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)  * @sd: the sub-device pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)  * @a: the VIDIOC_G_PARM argument.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) int v4l2_g_parm_cap(struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		    struct v4l2_subdev *sd, struct v4l2_streamparm *a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)  * v4l2_s_parm_cap - helper routine for vidioc_s_parm to fill this in by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)  *      calling the s_frame_interval op of the given subdev. It only works
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)  *      for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)  *      function name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)  * @vdev: the struct video_device pointer. Used to determine the device caps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)  * @sd: the sub-device pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)  * @a: the VIDIOC_S_PARM argument.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) int v4l2_s_parm_cap(struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		    struct v4l2_subdev *sd, struct v4l2_streamparm *a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /* Compare two v4l2_fract structs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) #define V4L2_FRACT_COMPARE(a, OP, b)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	((u64)(a).numerator * (b).denominator OP	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	(u64)(b).numerator * (a).denominator)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) /* ------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /* Pixel format and FourCC helpers */
^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)  * enum v4l2_pixel_encoding - specifies the pixel encoding value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)  * @V4L2_PIXEL_ENC_UNKNOWN:	Pixel encoding is unknown/un-initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)  * @V4L2_PIXEL_ENC_YUV:		Pixel encoding is YUV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)  * @V4L2_PIXEL_ENC_RGB:		Pixel encoding is RGB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)  * @V4L2_PIXEL_ENC_BAYER:	Pixel encoding is Bayer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) enum v4l2_pixel_encoding {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	V4L2_PIXEL_ENC_UNKNOWN = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	V4L2_PIXEL_ENC_YUV = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	V4L2_PIXEL_ENC_RGB = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	V4L2_PIXEL_ENC_BAYER = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)  * struct v4l2_format_info - information about a V4L2 format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)  * @format: 4CC format identifier (V4L2_PIX_FMT_*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)  * @pixel_enc: Pixel encoding (see enum v4l2_pixel_encoding above)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)  * @mem_planes: Number of memory planes, which includes the alpha plane (1 to 4).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)  * @comp_planes: Number of component planes, which includes the alpha plane (1 to 4).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)  * @bpp: Array of per-plane bytes per pixel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)  * @hdiv: Horizontal chroma subsampling factor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)  * @vdiv: Vertical chroma subsampling factor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)  * @block_w: Per-plane macroblock pixel width (optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)  * @block_h: Per-plane macroblock pixel height (optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) struct v4l2_format_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	u32 format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	u8 pixel_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	u8 mem_planes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	u8 comp_planes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	u8 bpp[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	u8 hdiv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	u8 vdiv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	u8 block_w[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	u8 block_h[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) static inline bool v4l2_is_format_rgb(const struct v4l2_format_info *f)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	return f && f->pixel_enc == V4L2_PIXEL_ENC_RGB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) static inline bool v4l2_is_format_yuv(const struct v4l2_format_info *f)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	return f && f->pixel_enc == V4L2_PIXEL_ENC_YUV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static inline bool v4l2_is_format_bayer(const struct v4l2_format_info *f)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	return f && f->pixel_enc == V4L2_PIXEL_ENC_BAYER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) const struct v4l2_format_info *v4l2_format_info(u32 format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) void v4l2_apply_frmsize_constraints(u32 *width, u32 *height,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 				    const struct v4l2_frmsize_stepwise *frmsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 		     u32 width, u32 height);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 			u32 width, u32 height);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	 * When the timestamp comes from 32-bit user space, there may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	 * uninitialized data in tv_usec, so cast it to u32.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	 * Otherwise allow invalid input for backwards compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	return buf->timestamp.tv_sec * NSEC_PER_SEC +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 		(u32)buf->timestamp.tv_usec * NSEC_PER_USEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) static inline void v4l2_buffer_set_timestamp(struct v4l2_buffer *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 					     u64 timestamp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	struct timespec64 ts = ns_to_timespec64(timestamp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	buf->timestamp.tv_sec  = ts.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	buf->timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
^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) static inline bool v4l2_is_colorspace_valid(__u32 colorspace)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	return colorspace > V4L2_COLORSPACE_DEFAULT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	       colorspace <= V4L2_COLORSPACE_DCI_P3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) static inline bool v4l2_is_xfer_func_valid(__u32 xfer_func)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	return xfer_func > V4L2_XFER_FUNC_DEFAULT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	       xfer_func <= V4L2_XFER_FUNC_SMPTE2084;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) static inline bool v4l2_is_ycbcr_enc_valid(__u8 ycbcr_enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	return ycbcr_enc > V4L2_YCBCR_ENC_DEFAULT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	       ycbcr_enc <= V4L2_YCBCR_ENC_SMPTE240M;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) static inline bool v4l2_is_hsv_enc_valid(__u8 hsv_enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	return hsv_enc == V4L2_HSV_ENC_180 || hsv_enc == V4L2_HSV_ENC_256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) static inline bool v4l2_is_quant_valid(__u8 quantization)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	return quantization == V4L2_QUANTIZATION_FULL_RANGE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	       quantization == V4L2_QUANTIZATION_LIM_RANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) #endif /* V4L2_COMMON_H_ */