| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | v4l2 common internal API header |
|---|
| 3 | 4 | |
|---|
| .. | .. |
|---|
| 8 | 9 | |
|---|
| 9 | 10 | Copyright (C) 2005 Hans Verkuil <hverkuil@xs4all.nl> |
|---|
| 10 | 11 | |
|---|
| 11 | | - This program is free software; you can redistribute it and/or modify |
|---|
| 12 | | - it under the terms of the GNU General Public License as published by |
|---|
| 13 | | - the Free Software Foundation; either version 2 of the License, or |
|---|
| 14 | | - (at your option) any later version. |
|---|
| 15 | | - |
|---|
| 16 | | - This program is distributed in the hope that it will be useful, |
|---|
| 17 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 19 | | - GNU General Public License for more details. |
|---|
| 20 | | - |
|---|
| 21 | | - You should have received a copy of the GNU General Public License |
|---|
| 22 | | - along with this program; if not, write to the Free Software |
|---|
| 23 | | - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 24 | 12 | */ |
|---|
| 25 | 13 | |
|---|
| 26 | 14 | #ifndef V4L2_COMMON_H_ |
|---|
| 27 | 15 | #define V4L2_COMMON_H_ |
|---|
| 28 | 16 | |
|---|
| 17 | +#include <linux/time.h> |
|---|
| 29 | 18 | #include <media/v4l2-dev.h> |
|---|
| 30 | 19 | |
|---|
| 31 | 20 | /* Common printk constructs for v4l-i2c drivers. These macros create a unique |
|---|
| .. | .. |
|---|
| 108 | 97 | |
|---|
| 109 | 98 | /* ------------------------------------------------------------------------- */ |
|---|
| 110 | 99 | |
|---|
| 111 | | -/* I2C Helper functions */ |
|---|
| 112 | | - |
|---|
| 113 | | -struct i2c_driver; |
|---|
| 114 | | -struct i2c_adapter; |
|---|
| 115 | | -struct i2c_client; |
|---|
| 116 | | -struct i2c_device_id; |
|---|
| 117 | 100 | struct v4l2_device; |
|---|
| 118 | 101 | struct v4l2_subdev; |
|---|
| 119 | 102 | struct v4l2_subdev_ops; |
|---|
| 120 | 103 | |
|---|
| 121 | | -/** |
|---|
| 122 | | - * v4l2_i2c_new_subdev - Load an i2c module and return an initialized |
|---|
| 123 | | - * &struct v4l2_subdev. |
|---|
| 124 | | - * |
|---|
| 125 | | - * @v4l2_dev: pointer to &struct v4l2_device |
|---|
| 126 | | - * @adapter: pointer to struct i2c_adapter |
|---|
| 127 | | - * @client_type: name of the chip that's on the adapter. |
|---|
| 128 | | - * @addr: I2C address. If zero, it will use @probe_addrs |
|---|
| 129 | | - * @probe_addrs: array with a list of address. The last entry at such |
|---|
| 130 | | - * array should be %I2C_CLIENT_END. |
|---|
| 131 | | - * |
|---|
| 132 | | - * returns a &struct v4l2_subdev pointer. |
|---|
| 133 | | - */ |
|---|
| 134 | | -struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, |
|---|
| 135 | | - struct i2c_adapter *adapter, const char *client_type, |
|---|
| 136 | | - u8 addr, const unsigned short *probe_addrs); |
|---|
| 137 | | - |
|---|
| 138 | | -struct i2c_board_info; |
|---|
| 139 | | - |
|---|
| 140 | | -/** |
|---|
| 141 | | - * v4l2_i2c_new_subdev_board - Load an i2c module and return an initialized |
|---|
| 142 | | - * &struct v4l2_subdev. |
|---|
| 143 | | - * |
|---|
| 144 | | - * @v4l2_dev: pointer to &struct v4l2_device |
|---|
| 145 | | - * @adapter: pointer to struct i2c_adapter |
|---|
| 146 | | - * @info: pointer to struct i2c_board_info used to replace the irq, |
|---|
| 147 | | - * platform_data and addr arguments. |
|---|
| 148 | | - * @probe_addrs: array with a list of address. The last entry at such |
|---|
| 149 | | - * array should be %I2C_CLIENT_END. |
|---|
| 150 | | - * |
|---|
| 151 | | - * returns a &struct v4l2_subdev pointer. |
|---|
| 152 | | - */ |
|---|
| 153 | | -struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, |
|---|
| 154 | | - struct i2c_adapter *adapter, struct i2c_board_info *info, |
|---|
| 155 | | - const unsigned short *probe_addrs); |
|---|
| 156 | | - |
|---|
| 157 | | -/** |
|---|
| 158 | | - * v4l2_i2c_subdev_init - Initializes a &struct v4l2_subdev with data from |
|---|
| 159 | | - * an i2c_client struct. |
|---|
| 160 | | - * |
|---|
| 161 | | - * @sd: pointer to &struct v4l2_subdev |
|---|
| 162 | | - * @client: pointer to struct i2c_client |
|---|
| 163 | | - * @ops: pointer to &struct v4l2_subdev_ops |
|---|
| 164 | | - */ |
|---|
| 165 | | -void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, |
|---|
| 166 | | - const struct v4l2_subdev_ops *ops); |
|---|
| 167 | | - |
|---|
| 168 | | -/** |
|---|
| 169 | | - * v4l2_i2c_subdev_addr - returns i2c client address of &struct v4l2_subdev. |
|---|
| 170 | | - * |
|---|
| 171 | | - * @sd: pointer to &struct v4l2_subdev |
|---|
| 172 | | - * |
|---|
| 173 | | - * Returns the address of an I2C sub-device |
|---|
| 174 | | - */ |
|---|
| 175 | | -unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd); |
|---|
| 104 | +/* I2C Helper functions */ |
|---|
| 105 | +#include <linux/i2c.h> |
|---|
| 176 | 106 | |
|---|
| 177 | 107 | /** |
|---|
| 178 | 108 | * enum v4l2_i2c_tuner_type - specifies the range of tuner address that |
|---|
| .. | .. |
|---|
| 203 | 133 | ADDRS_TV, |
|---|
| 204 | 134 | ADDRS_TV_WITH_DEMOD, |
|---|
| 205 | 135 | }; |
|---|
| 136 | + |
|---|
| 137 | +#if defined(CONFIG_VIDEO_V4L2_I2C) |
|---|
| 138 | + |
|---|
| 139 | +/** |
|---|
| 140 | + * v4l2_i2c_new_subdev - Load an i2c module and return an initialized |
|---|
| 141 | + * &struct v4l2_subdev. |
|---|
| 142 | + * |
|---|
| 143 | + * @v4l2_dev: pointer to &struct v4l2_device |
|---|
| 144 | + * @adapter: pointer to struct i2c_adapter |
|---|
| 145 | + * @client_type: name of the chip that's on the adapter. |
|---|
| 146 | + * @addr: I2C address. If zero, it will use @probe_addrs |
|---|
| 147 | + * @probe_addrs: array with a list of address. The last entry at such |
|---|
| 148 | + * array should be %I2C_CLIENT_END. |
|---|
| 149 | + * |
|---|
| 150 | + * returns a &struct v4l2_subdev pointer. |
|---|
| 151 | + */ |
|---|
| 152 | +struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, |
|---|
| 153 | + struct i2c_adapter *adapter, const char *client_type, |
|---|
| 154 | + u8 addr, const unsigned short *probe_addrs); |
|---|
| 155 | + |
|---|
| 156 | +/** |
|---|
| 157 | + * v4l2_i2c_new_subdev_board - Load an i2c module and return an initialized |
|---|
| 158 | + * &struct v4l2_subdev. |
|---|
| 159 | + * |
|---|
| 160 | + * @v4l2_dev: pointer to &struct v4l2_device |
|---|
| 161 | + * @adapter: pointer to struct i2c_adapter |
|---|
| 162 | + * @info: pointer to struct i2c_board_info used to replace the irq, |
|---|
| 163 | + * platform_data and addr arguments. |
|---|
| 164 | + * @probe_addrs: array with a list of address. The last entry at such |
|---|
| 165 | + * array should be %I2C_CLIENT_END. |
|---|
| 166 | + * |
|---|
| 167 | + * returns a &struct v4l2_subdev pointer. |
|---|
| 168 | + */ |
|---|
| 169 | +struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, |
|---|
| 170 | + struct i2c_adapter *adapter, struct i2c_board_info *info, |
|---|
| 171 | + const unsigned short *probe_addrs); |
|---|
| 172 | + |
|---|
| 173 | +/** |
|---|
| 174 | + * v4l2_i2c_subdev_set_name - Set name for an I²C sub-device |
|---|
| 175 | + * |
|---|
| 176 | + * @sd: pointer to &struct v4l2_subdev |
|---|
| 177 | + * @client: pointer to struct i2c_client |
|---|
| 178 | + * @devname: the name of the device; if NULL, the I²C device drivers's name |
|---|
| 179 | + * will be used |
|---|
| 180 | + * @postfix: sub-device specific string to put right after the I²C device name; |
|---|
| 181 | + * may be NULL |
|---|
| 182 | + */ |
|---|
| 183 | +void v4l2_i2c_subdev_set_name(struct v4l2_subdev *sd, struct i2c_client *client, |
|---|
| 184 | + const char *devname, const char *postfix); |
|---|
| 185 | + |
|---|
| 186 | +/** |
|---|
| 187 | + * v4l2_i2c_subdev_init - Initializes a &struct v4l2_subdev with data from |
|---|
| 188 | + * an i2c_client struct. |
|---|
| 189 | + * |
|---|
| 190 | + * @sd: pointer to &struct v4l2_subdev |
|---|
| 191 | + * @client: pointer to struct i2c_client |
|---|
| 192 | + * @ops: pointer to &struct v4l2_subdev_ops |
|---|
| 193 | + */ |
|---|
| 194 | +void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, |
|---|
| 195 | + const struct v4l2_subdev_ops *ops); |
|---|
| 196 | + |
|---|
| 197 | +/** |
|---|
| 198 | + * v4l2_i2c_subdev_addr - returns i2c client address of &struct v4l2_subdev. |
|---|
| 199 | + * |
|---|
| 200 | + * @sd: pointer to &struct v4l2_subdev |
|---|
| 201 | + * |
|---|
| 202 | + * Returns the address of an I2C sub-device |
|---|
| 203 | + */ |
|---|
| 204 | +unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd); |
|---|
| 205 | + |
|---|
| 206 | 206 | /** |
|---|
| 207 | 207 | * v4l2_i2c_tuner_addrs - Return a list of I2C tuner addresses to probe. |
|---|
| 208 | 208 | * |
|---|
| .. | .. |
|---|
| 213 | 213 | */ |
|---|
| 214 | 214 | const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type); |
|---|
| 215 | 215 | |
|---|
| 216 | +/** |
|---|
| 217 | + * v4l2_i2c_subdev_unregister - Unregister a v4l2_subdev |
|---|
| 218 | + * |
|---|
| 219 | + * @sd: pointer to &struct v4l2_subdev |
|---|
| 220 | + */ |
|---|
| 221 | +void v4l2_i2c_subdev_unregister(struct v4l2_subdev *sd); |
|---|
| 222 | + |
|---|
| 223 | +#else |
|---|
| 224 | + |
|---|
| 225 | +static inline struct v4l2_subdev * |
|---|
| 226 | +v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, |
|---|
| 227 | + struct i2c_adapter *adapter, const char *client_type, |
|---|
| 228 | + u8 addr, const unsigned short *probe_addrs) |
|---|
| 229 | +{ |
|---|
| 230 | + return NULL; |
|---|
| 231 | +} |
|---|
| 232 | + |
|---|
| 233 | +static inline struct v4l2_subdev * |
|---|
| 234 | +v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, |
|---|
| 235 | + struct i2c_adapter *adapter, struct i2c_board_info *info, |
|---|
| 236 | + const unsigned short *probe_addrs) |
|---|
| 237 | +{ |
|---|
| 238 | + return NULL; |
|---|
| 239 | +} |
|---|
| 240 | + |
|---|
| 241 | +static inline void |
|---|
| 242 | +v4l2_i2c_subdev_set_name(struct v4l2_subdev *sd, struct i2c_client *client, |
|---|
| 243 | + const char *devname, const char *postfix) |
|---|
| 244 | +{} |
|---|
| 245 | + |
|---|
| 246 | +static inline void |
|---|
| 247 | +v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, |
|---|
| 248 | + const struct v4l2_subdev_ops *ops) |
|---|
| 249 | +{} |
|---|
| 250 | + |
|---|
| 251 | +static inline unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd) |
|---|
| 252 | +{ |
|---|
| 253 | + return I2C_CLIENT_END; |
|---|
| 254 | +} |
|---|
| 255 | + |
|---|
| 256 | +static inline const unsigned short * |
|---|
| 257 | +v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type) |
|---|
| 258 | +{ |
|---|
| 259 | + return NULL; |
|---|
| 260 | +} |
|---|
| 261 | + |
|---|
| 262 | +static inline void v4l2_i2c_subdev_unregister(struct v4l2_subdev *sd) |
|---|
| 263 | +{} |
|---|
| 264 | + |
|---|
| 265 | +#endif |
|---|
| 266 | + |
|---|
| 216 | 267 | /* ------------------------------------------------------------------------- */ |
|---|
| 217 | 268 | |
|---|
| 218 | 269 | /* SPI Helper functions */ |
|---|
| 219 | | -#if defined(CONFIG_SPI) |
|---|
| 220 | 270 | |
|---|
| 221 | 271 | #include <linux/spi/spi.h> |
|---|
| 222 | 272 | |
|---|
| 223 | | -struct spi_device; |
|---|
| 273 | +#if defined(CONFIG_SPI) |
|---|
| 224 | 274 | |
|---|
| 225 | 275 | /** |
|---|
| 226 | 276 | * v4l2_spi_new_subdev - Load an spi module and return an initialized |
|---|
| .. | .. |
|---|
| 246 | 296 | */ |
|---|
| 247 | 297 | void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, |
|---|
| 248 | 298 | const struct v4l2_subdev_ops *ops); |
|---|
| 299 | + |
|---|
| 300 | +/** |
|---|
| 301 | + * v4l2_spi_subdev_unregister - Unregister a v4l2_subdev |
|---|
| 302 | + * |
|---|
| 303 | + * @sd: pointer to &struct v4l2_subdev |
|---|
| 304 | + */ |
|---|
| 305 | +void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd); |
|---|
| 306 | + |
|---|
| 307 | +#else |
|---|
| 308 | + |
|---|
| 309 | +static inline struct v4l2_subdev * |
|---|
| 310 | +v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev, |
|---|
| 311 | + struct spi_master *master, struct spi_board_info *info) |
|---|
| 312 | +{ |
|---|
| 313 | + return NULL; |
|---|
| 314 | +} |
|---|
| 315 | + |
|---|
| 316 | +static inline void |
|---|
| 317 | +v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, |
|---|
| 318 | + const struct v4l2_subdev_ops *ops) |
|---|
| 319 | +{} |
|---|
| 320 | + |
|---|
| 321 | +static inline void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd) |
|---|
| 322 | +{} |
|---|
| 249 | 323 | #endif |
|---|
| 250 | 324 | |
|---|
| 251 | 325 | /* ------------------------------------------------------------------------- */ |
|---|
| .. | .. |
|---|
| 283 | 357 | * @height: pointer to height that will be adjusted if needed. |
|---|
| 284 | 358 | * @hmin: minimum height. |
|---|
| 285 | 359 | * @hmax: maximum height. |
|---|
| 286 | | - * @halign: least significant bit on width. |
|---|
| 360 | + * @halign: least significant bit on height. |
|---|
| 287 | 361 | * @salign: least significant bit for the image size (e. g. |
|---|
| 288 | 362 | * :math:`width * height`). |
|---|
| 289 | 363 | * |
|---|
| .. | .. |
|---|
| 350 | 424 | size_t height_offset, s32 width, s32 height); |
|---|
| 351 | 425 | |
|---|
| 352 | 426 | /** |
|---|
| 353 | | - * v4l2_get_timestamp - helper routine to get a timestamp to be used when |
|---|
| 354 | | - * filling streaming metadata. Internally, it uses ktime_get_ts(), |
|---|
| 355 | | - * which is the recommended way to get it. |
|---|
| 356 | | - * |
|---|
| 357 | | - * @tv: pointer to &struct timeval to be filled. |
|---|
| 358 | | - */ |
|---|
| 359 | | -void v4l2_get_timestamp(struct timeval *tv); |
|---|
| 360 | | - |
|---|
| 361 | | -/** |
|---|
| 362 | 427 | * v4l2_g_parm_cap - helper routine for vidioc_g_parm to fill this in by |
|---|
| 363 | 428 | * calling the g_frame_interval op of the given subdev. It only works |
|---|
| 364 | 429 | * for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the |
|---|
| .. | .. |
|---|
| 384 | 449 | int v4l2_s_parm_cap(struct video_device *vdev, |
|---|
| 385 | 450 | struct v4l2_subdev *sd, struct v4l2_streamparm *a); |
|---|
| 386 | 451 | |
|---|
| 452 | +/* Compare two v4l2_fract structs */ |
|---|
| 453 | +#define V4L2_FRACT_COMPARE(a, OP, b) \ |
|---|
| 454 | + ((u64)(a).numerator * (b).denominator OP \ |
|---|
| 455 | + (u64)(b).numerator * (a).denominator) |
|---|
| 456 | + |
|---|
| 457 | +/* ------------------------------------------------------------------------- */ |
|---|
| 458 | + |
|---|
| 459 | +/* Pixel format and FourCC helpers */ |
|---|
| 460 | + |
|---|
| 461 | +/** |
|---|
| 462 | + * enum v4l2_pixel_encoding - specifies the pixel encoding value |
|---|
| 463 | + * |
|---|
| 464 | + * @V4L2_PIXEL_ENC_UNKNOWN: Pixel encoding is unknown/un-initialized |
|---|
| 465 | + * @V4L2_PIXEL_ENC_YUV: Pixel encoding is YUV |
|---|
| 466 | + * @V4L2_PIXEL_ENC_RGB: Pixel encoding is RGB |
|---|
| 467 | + * @V4L2_PIXEL_ENC_BAYER: Pixel encoding is Bayer |
|---|
| 468 | + */ |
|---|
| 469 | +enum v4l2_pixel_encoding { |
|---|
| 470 | + V4L2_PIXEL_ENC_UNKNOWN = 0, |
|---|
| 471 | + V4L2_PIXEL_ENC_YUV = 1, |
|---|
| 472 | + V4L2_PIXEL_ENC_RGB = 2, |
|---|
| 473 | + V4L2_PIXEL_ENC_BAYER = 3, |
|---|
| 474 | +}; |
|---|
| 475 | + |
|---|
| 476 | +/** |
|---|
| 477 | + * struct v4l2_format_info - information about a V4L2 format |
|---|
| 478 | + * @format: 4CC format identifier (V4L2_PIX_FMT_*) |
|---|
| 479 | + * @pixel_enc: Pixel encoding (see enum v4l2_pixel_encoding above) |
|---|
| 480 | + * @mem_planes: Number of memory planes, which includes the alpha plane (1 to 4). |
|---|
| 481 | + * @comp_planes: Number of component planes, which includes the alpha plane (1 to 4). |
|---|
| 482 | + * @bpp: Array of per-plane bytes per pixel |
|---|
| 483 | + * @hdiv: Horizontal chroma subsampling factor |
|---|
| 484 | + * @vdiv: Vertical chroma subsampling factor |
|---|
| 485 | + * @block_w: Per-plane macroblock pixel width (optional) |
|---|
| 486 | + * @block_h: Per-plane macroblock pixel height (optional) |
|---|
| 487 | + */ |
|---|
| 488 | +struct v4l2_format_info { |
|---|
| 489 | + u32 format; |
|---|
| 490 | + u8 pixel_enc; |
|---|
| 491 | + u8 mem_planes; |
|---|
| 492 | + u8 comp_planes; |
|---|
| 493 | + u8 bpp[4]; |
|---|
| 494 | + u8 hdiv; |
|---|
| 495 | + u8 vdiv; |
|---|
| 496 | + u8 block_w[4]; |
|---|
| 497 | + u8 block_h[4]; |
|---|
| 498 | +}; |
|---|
| 499 | + |
|---|
| 500 | +static inline bool v4l2_is_format_rgb(const struct v4l2_format_info *f) |
|---|
| 501 | +{ |
|---|
| 502 | + return f && f->pixel_enc == V4L2_PIXEL_ENC_RGB; |
|---|
| 503 | +} |
|---|
| 504 | + |
|---|
| 505 | +static inline bool v4l2_is_format_yuv(const struct v4l2_format_info *f) |
|---|
| 506 | +{ |
|---|
| 507 | + return f && f->pixel_enc == V4L2_PIXEL_ENC_YUV; |
|---|
| 508 | +} |
|---|
| 509 | + |
|---|
| 510 | +static inline bool v4l2_is_format_bayer(const struct v4l2_format_info *f) |
|---|
| 511 | +{ |
|---|
| 512 | + return f && f->pixel_enc == V4L2_PIXEL_ENC_BAYER; |
|---|
| 513 | +} |
|---|
| 514 | + |
|---|
| 515 | +const struct v4l2_format_info *v4l2_format_info(u32 format); |
|---|
| 516 | +void v4l2_apply_frmsize_constraints(u32 *width, u32 *height, |
|---|
| 517 | + const struct v4l2_frmsize_stepwise *frmsize); |
|---|
| 518 | +int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat, |
|---|
| 519 | + u32 width, u32 height); |
|---|
| 520 | +int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat, |
|---|
| 521 | + u32 width, u32 height); |
|---|
| 522 | + |
|---|
| 523 | +static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf) |
|---|
| 524 | +{ |
|---|
| 525 | + /* |
|---|
| 526 | + * When the timestamp comes from 32-bit user space, there may be |
|---|
| 527 | + * uninitialized data in tv_usec, so cast it to u32. |
|---|
| 528 | + * Otherwise allow invalid input for backwards compatibility. |
|---|
| 529 | + */ |
|---|
| 530 | + return buf->timestamp.tv_sec * NSEC_PER_SEC + |
|---|
| 531 | + (u32)buf->timestamp.tv_usec * NSEC_PER_USEC; |
|---|
| 532 | +} |
|---|
| 533 | + |
|---|
| 534 | +static inline void v4l2_buffer_set_timestamp(struct v4l2_buffer *buf, |
|---|
| 535 | + u64 timestamp) |
|---|
| 536 | +{ |
|---|
| 537 | + struct timespec64 ts = ns_to_timespec64(timestamp); |
|---|
| 538 | + |
|---|
| 539 | + buf->timestamp.tv_sec = ts.tv_sec; |
|---|
| 540 | + buf->timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC; |
|---|
| 541 | +} |
|---|
| 542 | + |
|---|
| 543 | +static inline bool v4l2_is_colorspace_valid(__u32 colorspace) |
|---|
| 544 | +{ |
|---|
| 545 | + return colorspace > V4L2_COLORSPACE_DEFAULT && |
|---|
| 546 | + colorspace <= V4L2_COLORSPACE_DCI_P3; |
|---|
| 547 | +} |
|---|
| 548 | + |
|---|
| 549 | +static inline bool v4l2_is_xfer_func_valid(__u32 xfer_func) |
|---|
| 550 | +{ |
|---|
| 551 | + return xfer_func > V4L2_XFER_FUNC_DEFAULT && |
|---|
| 552 | + xfer_func <= V4L2_XFER_FUNC_SMPTE2084; |
|---|
| 553 | +} |
|---|
| 554 | + |
|---|
| 555 | +static inline bool v4l2_is_ycbcr_enc_valid(__u8 ycbcr_enc) |
|---|
| 556 | +{ |
|---|
| 557 | + return ycbcr_enc > V4L2_YCBCR_ENC_DEFAULT && |
|---|
| 558 | + ycbcr_enc <= V4L2_YCBCR_ENC_SMPTE240M; |
|---|
| 559 | +} |
|---|
| 560 | + |
|---|
| 561 | +static inline bool v4l2_is_hsv_enc_valid(__u8 hsv_enc) |
|---|
| 562 | +{ |
|---|
| 563 | + return hsv_enc == V4L2_HSV_ENC_180 || hsv_enc == V4L2_HSV_ENC_256; |
|---|
| 564 | +} |
|---|
| 565 | + |
|---|
| 566 | +static inline bool v4l2_is_quant_valid(__u8 quantization) |
|---|
| 567 | +{ |
|---|
| 568 | + return quantization == V4L2_QUANTIZATION_FULL_RANGE || |
|---|
| 569 | + quantization == V4L2_QUANTIZATION_LIM_RANGE; |
|---|
| 570 | +} |
|---|
| 571 | + |
|---|
| 387 | 572 | #endif /* V4L2_COMMON_H_ */ |
|---|