Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003     v4l2 common internal API header
0004 
0005     This header contains internal shared ioctl definitions for use by the
0006     internal low-level v4l2 drivers.
0007     Each ioctl begins with VIDIOC_INT_ to clearly mark that it is an internal
0008     define,
0009 
0010     Copyright (C) 2005  Hans Verkuil <hverkuil@xs4all.nl>
0011 
0012  */
0013 
0014 #ifndef V4L2_COMMON_H_
0015 #define V4L2_COMMON_H_
0016 
0017 #include <linux/time.h>
0018 #include <media/v4l2-dev.h>
0019 
0020 /* Common printk constructs for v4l-i2c drivers. These macros create a unique
0021    prefix consisting of the driver name, the adapter number and the i2c
0022    address. */
0023 #define v4l_printk(level, name, adapter, addr, fmt, arg...) \
0024     printk(level "%s %d-%04x: " fmt, name, i2c_adapter_id(adapter), addr , ## arg)
0025 
0026 #define v4l_client_printk(level, client, fmt, arg...)               \
0027     v4l_printk(level, (client)->dev.driver->name, (client)->adapter, \
0028            (client)->addr, fmt , ## arg)
0029 
0030 #define v4l_err(client, fmt, arg...) \
0031     v4l_client_printk(KERN_ERR, client, fmt , ## arg)
0032 
0033 #define v4l_warn(client, fmt, arg...) \
0034     v4l_client_printk(KERN_WARNING, client, fmt , ## arg)
0035 
0036 #define v4l_info(client, fmt, arg...) \
0037     v4l_client_printk(KERN_INFO, client, fmt , ## arg)
0038 
0039 /* These three macros assume that the debug level is set with a module
0040    parameter called 'debug'. */
0041 #define v4l_dbg(level, debug, client, fmt, arg...)               \
0042     do {                                     \
0043         if (debug >= (level))                        \
0044             v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \
0045     } while (0)
0046 
0047 /* Add a version of v4l_dbg to be used on drivers using dev_foo() macros */
0048 #define dev_dbg_lvl(__dev, __level, __debug, __fmt, __arg...)       \
0049     do {                                \
0050         if (__debug >= (__level))               \
0051             dev_printk(KERN_DEBUG, __dev, __fmt, ##__arg);  \
0052     } while (0)
0053 
0054 /* ------------------------------------------------------------------------- */
0055 
0056 /* These printk constructs can be used with v4l2_device and v4l2_subdev */
0057 #define v4l2_printk(level, dev, fmt, arg...) \
0058     printk(level "%s: " fmt, (dev)->name , ## arg)
0059 
0060 #define v4l2_err(dev, fmt, arg...) \
0061     v4l2_printk(KERN_ERR, dev, fmt , ## arg)
0062 
0063 #define v4l2_warn(dev, fmt, arg...) \
0064     v4l2_printk(KERN_WARNING, dev, fmt , ## arg)
0065 
0066 #define v4l2_info(dev, fmt, arg...) \
0067     v4l2_printk(KERN_INFO, dev, fmt , ## arg)
0068 
0069 /* These three macros assume that the debug level is set with a module
0070    parameter called 'debug'. */
0071 #define v4l2_dbg(level, debug, dev, fmt, arg...)            \
0072     do {                                \
0073         if (debug >= (level))                   \
0074             v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \
0075     } while (0)
0076 
0077 /**
0078  * v4l2_ctrl_query_fill- Fill in a struct v4l2_queryctrl
0079  *
0080  * @qctrl: pointer to the &struct v4l2_queryctrl to be filled
0081  * @min: minimum value for the control
0082  * @max: maximum value for the control
0083  * @step: control step
0084  * @def: default value for the control
0085  *
0086  * Fills the &struct v4l2_queryctrl fields for the query control.
0087  *
0088  * .. note::
0089  *
0090  *    This function assumes that the @qctrl->id field is filled.
0091  *
0092  * Returns -EINVAL if the control is not known by the V4L2 core, 0 on success.
0093  */
0094 
0095 int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
0096              s32 min, s32 max, s32 step, s32 def);
0097 
0098 /* ------------------------------------------------------------------------- */
0099 
0100 struct v4l2_device;
0101 struct v4l2_subdev;
0102 struct v4l2_subdev_ops;
0103 
0104 /* I2C Helper functions */
0105 #include <linux/i2c.h>
0106 
0107 /**
0108  * enum v4l2_i2c_tuner_type - specifies the range of tuner address that
0109  *  should be used when seeking for I2C devices.
0110  *
0111  * @ADDRS_RADIO:        Radio tuner addresses.
0112  *              Represent the following I2C addresses:
0113  *              0x10 (if compiled with tea5761 support)
0114  *              and 0x60.
0115  * @ADDRS_DEMOD:        Demod tuner addresses.
0116  *              Represent the following I2C addresses:
0117  *              0x42, 0x43, 0x4a and 0x4b.
0118  * @ADDRS_TV:           TV tuner addresses.
0119  *              Represent the following I2C addresses:
0120  *              0x42, 0x43, 0x4a, 0x4b, 0x60, 0x61, 0x62,
0121  *              0x63 and 0x64.
0122  * @ADDRS_TV_WITH_DEMOD:    TV tuner addresses if demod is present, this
0123  *              excludes addresses used by the demodulator
0124  *              from the list of candidates.
0125  *              Represent the following I2C addresses:
0126  *              0x60, 0x61, 0x62, 0x63 and 0x64.
0127  *
0128  * NOTE: All I2C addresses above use the 7-bit notation.
0129  */
0130 enum v4l2_i2c_tuner_type {
0131     ADDRS_RADIO,
0132     ADDRS_DEMOD,
0133     ADDRS_TV,
0134     ADDRS_TV_WITH_DEMOD,
0135 };
0136 
0137 #if defined(CONFIG_VIDEO_V4L2_I2C)
0138 
0139 /**
0140  * v4l2_i2c_new_subdev - Load an i2c module and return an initialized
0141  *  &struct v4l2_subdev.
0142  *
0143  * @v4l2_dev: pointer to &struct v4l2_device
0144  * @adapter: pointer to struct i2c_adapter
0145  * @client_type:  name of the chip that's on the adapter.
0146  * @addr: I2C address. If zero, it will use @probe_addrs
0147  * @probe_addrs: array with a list of address. The last entry at such
0148  *  array should be %I2C_CLIENT_END.
0149  *
0150  * returns a &struct v4l2_subdev pointer.
0151  */
0152 struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
0153         struct i2c_adapter *adapter, const char *client_type,
0154         u8 addr, const unsigned short *probe_addrs);
0155 
0156 /**
0157  * v4l2_i2c_new_subdev_board - Load an i2c module and return an initialized
0158  *  &struct v4l2_subdev.
0159  *
0160  * @v4l2_dev: pointer to &struct v4l2_device
0161  * @adapter: pointer to struct i2c_adapter
0162  * @info: pointer to struct i2c_board_info used to replace the irq,
0163  *   platform_data and addr arguments.
0164  * @probe_addrs: array with a list of address. The last entry at such
0165  *  array should be %I2C_CLIENT_END.
0166  *
0167  * returns a &struct v4l2_subdev pointer.
0168  */
0169 struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
0170         struct i2c_adapter *adapter, struct i2c_board_info *info,
0171         const unsigned short *probe_addrs);
0172 
0173 /**
0174  * v4l2_i2c_subdev_set_name - Set name for an I²C sub-device
0175  *
0176  * @sd: pointer to &struct v4l2_subdev
0177  * @client: pointer to struct i2c_client
0178  * @devname: the name of the device; if NULL, the I²C device's name will be used
0179  * @postfix: sub-device specific string to put right after the I²C device name;
0180  *       may be NULL
0181  */
0182 void v4l2_i2c_subdev_set_name(struct v4l2_subdev *sd, struct i2c_client *client,
0183                   const char *devname, const char *postfix);
0184 
0185 /**
0186  * v4l2_i2c_subdev_init - Initializes a &struct v4l2_subdev with data from
0187  *  an i2c_client struct.
0188  *
0189  * @sd: pointer to &struct v4l2_subdev
0190  * @client: pointer to struct i2c_client
0191  * @ops: pointer to &struct v4l2_subdev_ops
0192  */
0193 void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
0194         const struct v4l2_subdev_ops *ops);
0195 
0196 /**
0197  * v4l2_i2c_subdev_addr - returns i2c client address of &struct v4l2_subdev.
0198  *
0199  * @sd: pointer to &struct v4l2_subdev
0200  *
0201  * Returns the address of an I2C sub-device
0202  */
0203 unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd);
0204 
0205 /**
0206  * v4l2_i2c_tuner_addrs - Return a list of I2C tuner addresses to probe.
0207  *
0208  * @type: type of the tuner to seek, as defined by
0209  *    &enum v4l2_i2c_tuner_type.
0210  *
0211  * NOTE: Use only if the tuner addresses are unknown.
0212  */
0213 const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type);
0214 
0215 /**
0216  * v4l2_i2c_subdev_unregister - Unregister a v4l2_subdev
0217  *
0218  * @sd: pointer to &struct v4l2_subdev
0219  */
0220 void v4l2_i2c_subdev_unregister(struct v4l2_subdev *sd);
0221 
0222 #else
0223 
0224 static inline struct v4l2_subdev *
0225 v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
0226             struct i2c_adapter *adapter, const char *client_type,
0227             u8 addr, const unsigned short *probe_addrs)
0228 {
0229     return NULL;
0230 }
0231 
0232 static inline struct v4l2_subdev *
0233 v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
0234               struct i2c_adapter *adapter, struct i2c_board_info *info,
0235               const unsigned short *probe_addrs)
0236 {
0237     return NULL;
0238 }
0239 
0240 static inline void
0241 v4l2_i2c_subdev_set_name(struct v4l2_subdev *sd, struct i2c_client *client,
0242              const char *devname, const char *postfix)
0243 {}
0244 
0245 static inline void
0246 v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
0247              const struct v4l2_subdev_ops *ops)
0248 {}
0249 
0250 static inline unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd)
0251 {
0252     return I2C_CLIENT_END;
0253 }
0254 
0255 static inline const unsigned short *
0256 v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type)
0257 {
0258     return NULL;
0259 }
0260 
0261 static inline void v4l2_i2c_subdev_unregister(struct v4l2_subdev *sd)
0262 {}
0263 
0264 #endif
0265 
0266 /* ------------------------------------------------------------------------- */
0267 
0268 /* SPI Helper functions */
0269 
0270 #include <linux/spi/spi.h>
0271 
0272 #if defined(CONFIG_SPI)
0273 
0274 /**
0275  *  v4l2_spi_new_subdev - Load an spi module and return an initialized
0276  *  &struct v4l2_subdev.
0277  *
0278  *
0279  * @v4l2_dev: pointer to &struct v4l2_device.
0280  * @master: pointer to struct spi_master.
0281  * @info: pointer to struct spi_board_info.
0282  *
0283  * returns a &struct v4l2_subdev pointer.
0284  */
0285 struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev,
0286         struct spi_master *master, struct spi_board_info *info);
0287 
0288 /**
0289  * v4l2_spi_subdev_init - Initialize a v4l2_subdev with data from an
0290  *  spi_device struct.
0291  *
0292  * @sd: pointer to &struct v4l2_subdev
0293  * @spi: pointer to struct spi_device.
0294  * @ops: pointer to &struct v4l2_subdev_ops
0295  */
0296 void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
0297         const struct v4l2_subdev_ops *ops);
0298 
0299 /**
0300  * v4l2_spi_subdev_unregister - Unregister a v4l2_subdev
0301  *
0302  * @sd: pointer to &struct v4l2_subdev
0303  */
0304 void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd);
0305 
0306 #else
0307 
0308 static inline struct v4l2_subdev *
0309 v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev,
0310             struct spi_master *master, struct spi_board_info *info)
0311 {
0312     return NULL;
0313 }
0314 
0315 static inline void
0316 v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
0317              const struct v4l2_subdev_ops *ops)
0318 {}
0319 
0320 static inline void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd)
0321 {}
0322 #endif
0323 
0324 /* ------------------------------------------------------------------------- */
0325 
0326 /*
0327  * FIXME: these remaining ioctls/structs should be removed as well, but they
0328  * are still used in tuner-simple.c (TUNER_SET_CONFIG) and cx18/ivtv (RESET).
0329  * To remove these ioctls some more cleanup is needed in those modules.
0330  *
0331  * It doesn't make much sense on documenting them, as what we really want is
0332  * to get rid of them.
0333  */
0334 
0335 /* s_config */
0336 struct v4l2_priv_tun_config {
0337     int tuner;
0338     void *priv;
0339 };
0340 #define TUNER_SET_CONFIG           _IOW('d', 92, struct v4l2_priv_tun_config)
0341 
0342 #define VIDIOC_INT_RESET        _IOW ('d', 102, u32)
0343 
0344 /* ------------------------------------------------------------------------- */
0345 
0346 /* Miscellaneous helper functions */
0347 
0348 /**
0349  * v4l_bound_align_image - adjust video dimensions according to
0350  *  a given constraints.
0351  *
0352  * @width:  pointer to width that will be adjusted if needed.
0353  * @wmin:   minimum width.
0354  * @wmax:   maximum width.
0355  * @walign: least significant bit on width.
0356  * @height: pointer to height that will be adjusted if needed.
0357  * @hmin:   minimum height.
0358  * @hmax:   maximum height.
0359  * @halign: least significant bit on height.
0360  * @salign: least significant bit for the image size (e. g.
0361  *      :math:`width * height`).
0362  *
0363  * Clip an image to have @width between @wmin and @wmax, and @height between
0364  * @hmin and @hmax, inclusive.
0365  *
0366  * Additionally, the @width will be a multiple of :math:`2^{walign}`,
0367  * the @height will be a multiple of :math:`2^{halign}`, and the overall
0368  * size :math:`width * height` will be a multiple of :math:`2^{salign}`.
0369  *
0370  * .. note::
0371  *
0372  *    #. The clipping rectangle may be shrunk or enlarged to fit the alignment
0373  *       constraints.
0374  *    #. @wmax must not be smaller than @wmin.
0375  *    #. @hmax must not be smaller than @hmin.
0376  *    #. The alignments must not be so high there are no possible image
0377  *       sizes within the allowed bounds.
0378  *    #. @wmin and @hmin must be at least 1 (don't use 0).
0379  *    #. For @walign, @halign and @salign, if you don't care about a certain
0380  *       alignment, specify ``0``, as :math:`2^0 = 1` and one byte alignment
0381  *       is equivalent to no alignment.
0382  *    #. If you only want to adjust downward, specify a maximum that's the
0383  *       same as the initial value.
0384  */
0385 void v4l_bound_align_image(unsigned int *width, unsigned int wmin,
0386                unsigned int wmax, unsigned int walign,
0387                unsigned int *height, unsigned int hmin,
0388                unsigned int hmax, unsigned int halign,
0389                unsigned int salign);
0390 
0391 /**
0392  * v4l2_find_nearest_size - Find the nearest size among a discrete
0393  *  set of resolutions contained in an array of a driver specific struct.
0394  *
0395  * @array: a driver specific array of image sizes
0396  * @array_size: the length of the driver specific array of image sizes
0397  * @width_field: the name of the width field in the driver specific struct
0398  * @height_field: the name of the height field in the driver specific struct
0399  * @width: desired width.
0400  * @height: desired height.
0401  *
0402  * Finds the closest resolution to minimize the width and height differences
0403  * between what requested and the supported resolutions. The size of the width
0404  * and height fields in the driver specific must equal to that of u32, i.e. four
0405  * bytes.
0406  *
0407  * Returns the best match or NULL if the length of the array is zero.
0408  */
0409 #define v4l2_find_nearest_size(array, array_size, width_field, height_field, \
0410                    width, height)               \
0411     ({                              \
0412         BUILD_BUG_ON(sizeof((array)->width_field) != sizeof(u32) || \
0413                  sizeof((array)->height_field) != sizeof(u32)); \
0414         (typeof(&(array)[0]))__v4l2_find_nearest_size(      \
0415             (array), array_size, sizeof(*(array)),      \
0416             offsetof(typeof(*(array)), width_field),    \
0417             offsetof(typeof(*(array)), height_field),   \
0418             width, height);                 \
0419     })
0420 const void *
0421 __v4l2_find_nearest_size(const void *array, size_t array_size,
0422              size_t entry_size, size_t width_offset,
0423              size_t height_offset, s32 width, s32 height);
0424 
0425 /**
0426  * v4l2_g_parm_cap - helper routine for vidioc_g_parm to fill this in by
0427  *      calling the g_frame_interval op of the given subdev. It only works
0428  *      for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the
0429  *      function name.
0430  *
0431  * @vdev: the struct video_device pointer. Used to determine the device caps.
0432  * @sd: the sub-device pointer.
0433  * @a: the VIDIOC_G_PARM argument.
0434  */
0435 int v4l2_g_parm_cap(struct video_device *vdev,
0436             struct v4l2_subdev *sd, struct v4l2_streamparm *a);
0437 
0438 /**
0439  * v4l2_s_parm_cap - helper routine for vidioc_s_parm to fill this in by
0440  *      calling the s_frame_interval op of the given subdev. It only works
0441  *      for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the
0442  *      function name.
0443  *
0444  * @vdev: the struct video_device pointer. Used to determine the device caps.
0445  * @sd: the sub-device pointer.
0446  * @a: the VIDIOC_S_PARM argument.
0447  */
0448 int v4l2_s_parm_cap(struct video_device *vdev,
0449             struct v4l2_subdev *sd, struct v4l2_streamparm *a);
0450 
0451 /* Compare two v4l2_fract structs */
0452 #define V4L2_FRACT_COMPARE(a, OP, b)            \
0453     ((u64)(a).numerator * (b).denominator OP    \
0454     (u64)(b).numerator * (a).denominator)
0455 
0456 /* ------------------------------------------------------------------------- */
0457 
0458 /* Pixel format and FourCC helpers */
0459 
0460 /**
0461  * enum v4l2_pixel_encoding - specifies the pixel encoding value
0462  *
0463  * @V4L2_PIXEL_ENC_UNKNOWN: Pixel encoding is unknown/un-initialized
0464  * @V4L2_PIXEL_ENC_YUV:     Pixel encoding is YUV
0465  * @V4L2_PIXEL_ENC_RGB:     Pixel encoding is RGB
0466  * @V4L2_PIXEL_ENC_BAYER:   Pixel encoding is Bayer
0467  */
0468 enum v4l2_pixel_encoding {
0469     V4L2_PIXEL_ENC_UNKNOWN = 0,
0470     V4L2_PIXEL_ENC_YUV = 1,
0471     V4L2_PIXEL_ENC_RGB = 2,
0472     V4L2_PIXEL_ENC_BAYER = 3,
0473 };
0474 
0475 /**
0476  * struct v4l2_format_info - information about a V4L2 format
0477  * @format: 4CC format identifier (V4L2_PIX_FMT_*)
0478  * @pixel_enc: Pixel encoding (see enum v4l2_pixel_encoding above)
0479  * @mem_planes: Number of memory planes, which includes the alpha plane (1 to 4).
0480  * @comp_planes: Number of component planes, which includes the alpha plane (1 to 4).
0481  * @bpp: Array of per-plane bytes per pixel
0482  * @hdiv: Horizontal chroma subsampling factor
0483  * @vdiv: Vertical chroma subsampling factor
0484  * @block_w: Per-plane macroblock pixel width (optional)
0485  * @block_h: Per-plane macroblock pixel height (optional)
0486  */
0487 struct v4l2_format_info {
0488     u32 format;
0489     u8 pixel_enc;
0490     u8 mem_planes;
0491     u8 comp_planes;
0492     u8 bpp[4];
0493     u8 hdiv;
0494     u8 vdiv;
0495     u8 block_w[4];
0496     u8 block_h[4];
0497 };
0498 
0499 static inline bool v4l2_is_format_rgb(const struct v4l2_format_info *f)
0500 {
0501     return f && f->pixel_enc == V4L2_PIXEL_ENC_RGB;
0502 }
0503 
0504 static inline bool v4l2_is_format_yuv(const struct v4l2_format_info *f)
0505 {
0506     return f && f->pixel_enc == V4L2_PIXEL_ENC_YUV;
0507 }
0508 
0509 static inline bool v4l2_is_format_bayer(const struct v4l2_format_info *f)
0510 {
0511     return f && f->pixel_enc == V4L2_PIXEL_ENC_BAYER;
0512 }
0513 
0514 const struct v4l2_format_info *v4l2_format_info(u32 format);
0515 void v4l2_apply_frmsize_constraints(u32 *width, u32 *height,
0516                     const struct v4l2_frmsize_stepwise *frmsize);
0517 int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
0518              u32 width, u32 height);
0519 int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
0520             u32 width, u32 height);
0521 
0522 /**
0523  * v4l2_get_link_freq - Get link rate from transmitter
0524  *
0525  * @handler: The transmitter's control handler
0526  * @mul: The multiplier between pixel rate and link frequency. Bits per pixel on
0527  *   D-PHY, samples per clock on parallel. 0 otherwise.
0528  * @div: The divisor between pixel rate and link frequency. Number of data lanes
0529  *   times two on D-PHY, 1 on parallel. 0 otherwise.
0530  *
0531  * This function is intended for obtaining the link frequency from the
0532  * transmitter sub-devices. It returns the link rate, either from the
0533  * V4L2_CID_LINK_FREQ control implemented by the transmitter, or value
0534  * calculated based on the V4L2_CID_PIXEL_RATE implemented by the transmitter.
0535  *
0536  * Returns link frequency on success, otherwise a negative error code:
0537  *  -ENOENT: Link frequency or pixel rate control not found
0538  *  -EINVAL: Invalid link frequency value
0539  */
0540 s64 v4l2_get_link_freq(struct v4l2_ctrl_handler *handler, unsigned int mul,
0541                unsigned int div);
0542 
0543 static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
0544 {
0545     /*
0546      * When the timestamp comes from 32-bit user space, there may be
0547      * uninitialized data in tv_usec, so cast it to u32.
0548      * Otherwise allow invalid input for backwards compatibility.
0549      */
0550     return buf->timestamp.tv_sec * NSEC_PER_SEC +
0551         (u32)buf->timestamp.tv_usec * NSEC_PER_USEC;
0552 }
0553 
0554 static inline void v4l2_buffer_set_timestamp(struct v4l2_buffer *buf,
0555                          u64 timestamp)
0556 {
0557     struct timespec64 ts = ns_to_timespec64(timestamp);
0558 
0559     buf->timestamp.tv_sec  = ts.tv_sec;
0560     buf->timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
0561 }
0562 
0563 static inline bool v4l2_is_colorspace_valid(__u32 colorspace)
0564 {
0565     return colorspace > V4L2_COLORSPACE_DEFAULT &&
0566            colorspace < V4L2_COLORSPACE_LAST;
0567 }
0568 
0569 static inline bool v4l2_is_xfer_func_valid(__u32 xfer_func)
0570 {
0571     return xfer_func > V4L2_XFER_FUNC_DEFAULT &&
0572            xfer_func < V4L2_XFER_FUNC_LAST;
0573 }
0574 
0575 static inline bool v4l2_is_ycbcr_enc_valid(__u8 ycbcr_enc)
0576 {
0577     return ycbcr_enc > V4L2_YCBCR_ENC_DEFAULT &&
0578            ycbcr_enc < V4L2_YCBCR_ENC_LAST;
0579 }
0580 
0581 static inline bool v4l2_is_hsv_enc_valid(__u8 hsv_enc)
0582 {
0583     return hsv_enc == V4L2_HSV_ENC_180 || hsv_enc == V4L2_HSV_ENC_256;
0584 }
0585 
0586 static inline bool v4l2_is_quant_valid(__u8 quantization)
0587 {
0588     return quantization == V4L2_QUANTIZATION_FULL_RANGE ||
0589            quantization == V4L2_QUANTIZATION_LIM_RANGE;
0590 }
0591 
0592 #endif /* V4L2_COMMON_H_ */