1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Video for Linux Two header file 5 * 6 * Copyright (C) 1999-2012 the contributors 7 * Copyright (C) 2012 Nokia Corporation 8 * Contact: Sakari Ailus <sakari.ailus@iki.fi> 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 3. The names of its contributors may not be used to endorse or promote 20 * products derived from this software without specific prior written 21 * permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 * Minimal V4L2 definitions for the video(4) framework. 36 * Extracted from OpenBSD sys/videoio.h. 37 */ 38 39 #ifndef _SYS_VIDEOIO_H_ 40 #define _SYS_VIDEOIO_H_ 41 42 #include <sys/types.h> 43 #include <sys/ioccom.h> 44 #include <sys/time.h> 45 46 typedef u_int64_t v4l2_std_id; 47 48 /* 49 * Four-character-code (FOURCC) 50 */ 51 #define v4l2_fourcc(a, b, c, d) \ 52 ((u_int32_t)(a) | ((u_int32_t)(b) << 8) | \ 53 ((u_int32_t)(c) << 16) | ((u_int32_t)(d) << 24)) 54 55 /* 56 * Enums 57 */ 58 enum v4l2_field { 59 V4L2_FIELD_ANY = 0, 60 V4L2_FIELD_NONE = 1, 61 V4L2_FIELD_TOP = 2, 62 V4L2_FIELD_BOTTOM = 3, 63 V4L2_FIELD_INTERLACED = 4, 64 V4L2_FIELD_SEQ_TB = 5, 65 V4L2_FIELD_SEQ_BT = 6, 66 V4L2_FIELD_ALTERNATE = 7, 67 V4L2_FIELD_INTERLACED_TB = 8, 68 V4L2_FIELD_INTERLACED_BT = 9, 69 }; 70 71 enum v4l2_buf_type { 72 V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, 73 V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, 74 V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, 75 V4L2_BUF_TYPE_VBI_CAPTURE = 4, 76 V4L2_BUF_TYPE_VBI_OUTPUT = 5, 77 V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, 78 V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, 79 V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8, 80 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9, 81 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10, 82 V4L2_BUF_TYPE_SDR_CAPTURE = 11, 83 V4L2_BUF_TYPE_SDR_OUTPUT = 12, 84 V4L2_BUF_TYPE_META_CAPTURE = 13, 85 V4L2_BUF_TYPE_META_OUTPUT = 14, 86 /* Deprecated, do not use */ 87 V4L2_BUF_TYPE_PRIVATE = 0x80, 88 }; 89 90 enum v4l2_memory { 91 V4L2_MEMORY_MMAP = 1, 92 V4L2_MEMORY_USERPTR = 2, 93 V4L2_MEMORY_OVERLAY = 3, 94 V4L2_MEMORY_DMABUF = 4, 95 }; 96 97 enum v4l2_colorspace { 98 V4L2_COLORSPACE_DEFAULT = 0, 99 V4L2_COLORSPACE_SMPTE170M = 1, 100 V4L2_COLORSPACE_SMPTE240M = 2, 101 V4L2_COLORSPACE_REC709 = 3, 102 V4L2_COLORSPACE_BT878 = 4, 103 V4L2_COLORSPACE_470_SYSTEM_M = 5, 104 V4L2_COLORSPACE_470_SYSTEM_BG = 6, 105 V4L2_COLORSPACE_JPEG = 7, 106 V4L2_COLORSPACE_SRGB = 8, 107 V4L2_COLORSPACE_OPRGB = 9, 108 V4L2_COLORSPACE_BT2020 = 10, 109 V4L2_COLORSPACE_RAW = 11, 110 V4L2_COLORSPACE_DCI_P3 = 12, 111 }; 112 113 enum v4l2_xfer_func { 114 V4L2_XFER_FUNC_DEFAULT = 0, 115 V4L2_XFER_FUNC_709 = 1, 116 V4L2_XFER_FUNC_SRGB = 2, 117 V4L2_XFER_FUNC_OPRGB = 3, 118 V4L2_XFER_FUNC_SMPTE240M = 4, 119 V4L2_XFER_FUNC_NONE = 5, 120 V4L2_XFER_FUNC_DCI_P3 = 6, 121 V4L2_XFER_FUNC_SMPTE2084 = 7, 122 }; 123 124 enum v4l2_ycbcr_encoding { 125 V4L2_YCBCR_ENC_DEFAULT = 0, 126 V4L2_YCBCR_ENC_601 = 1, 127 V4L2_YCBCR_ENC_709 = 2, 128 V4L2_YCBCR_ENC_XV601 = 3, 129 V4L2_YCBCR_ENC_XV709 = 4, 130 V4L2_YCBCR_ENC_SYCC = 5, 131 V4L2_YCBCR_ENC_BT2020 = 6, 132 V4L2_YCBCR_ENC_BT2020_CONST_LUM = 7, 133 V4L2_YCBCR_ENC_SMPTE240M = 8, 134 }; 135 136 enum v4l2_ctrl_type { 137 V4L2_CTRL_TYPE_INTEGER = 1, 138 V4L2_CTRL_TYPE_BOOLEAN = 2, 139 V4L2_CTRL_TYPE_MENU = 3, 140 V4L2_CTRL_TYPE_BUTTON = 4, 141 V4L2_CTRL_TYPE_INTEGER64 = 5, 142 V4L2_CTRL_TYPE_CTRL_CLASS = 6, 143 V4L2_CTRL_TYPE_STRING = 7, 144 V4L2_CTRL_TYPE_BITMASK = 8, 145 V4L2_CTRL_TYPE_INTEGER_MENU = 9, 146 }; 147 148 enum v4l2_frmsizetypes { 149 V4L2_FRMSIZE_TYPE_DISCRETE = 1, 150 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, 151 V4L2_FRMSIZE_TYPE_STEPWISE = 3, 152 }; 153 154 enum v4l2_frmivaltypes { 155 V4L2_FRMIVAL_TYPE_DISCRETE = 1, 156 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, 157 V4L2_FRMIVAL_TYPE_STEPWISE = 3, 158 }; 159 160 /* 161 * Structures 162 */ 163 struct v4l2_fract { 164 u_int32_t numerator; 165 u_int32_t denominator; 166 }; 167 168 struct v4l2_rect { 169 int32_t left; 170 int32_t top; 171 u_int32_t width; 172 u_int32_t height; 173 }; 174 175 struct v4l2_capability { 176 u_int8_t driver[16]; 177 u_int8_t card[32]; 178 u_int8_t bus_info[32]; 179 u_int32_t version; 180 u_int32_t capabilities; 181 u_int32_t device_caps; 182 u_int32_t reserved[3]; 183 }; 184 185 struct v4l2_pix_format { 186 u_int32_t width; 187 u_int32_t height; 188 u_int32_t pixelformat; 189 u_int32_t field; /* enum v4l2_field */ 190 u_int32_t bytesperline; /* for padding, zero if unused */ 191 u_int32_t sizeimage; 192 u_int32_t colorspace; /* enum v4l2_colorspace */ 193 u_int32_t priv; /* private data, depends on pixelformat */ 194 u_int32_t flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */ 195 union { 196 /* enum v4l2_ycbcr_encoding */ 197 u_int32_t ycbcr_enc; 198 /* enum v4l2_hsv_encoding */ 199 u_int32_t hsv_enc; 200 }; 201 u_int32_t quantization; /* enum v4l2_quantization */ 202 u_int32_t xfer_func; /* enum v4l2_xfer_func */ 203 }; 204 205 /* 206 * Multi-planar capture (VIDIOC_*_MPLANE) 207 */ 208 #define VIDEO_MAX_PLANES 8 209 210 struct v4l2_plane_pix_format { 211 u_int32_t sizeimage; 212 u_int32_t bytesperline; 213 u_int16_t reserved[6]; 214 } __packed; 215 216 struct v4l2_pix_format_mplane { 217 u_int32_t width; 218 u_int32_t height; 219 u_int32_t pixelformat; 220 u_int32_t field; 221 u_int32_t colorspace; 222 struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES]; 223 u_int8_t num_planes; 224 u_int8_t flags; 225 union { 226 u_int8_t ycbcr_enc; 227 u_int8_t hsv_enc; 228 }; 229 u_int8_t quantization; 230 u_int8_t xfer_func; 231 u_int8_t reserved[7]; 232 } __packed; 233 234 #define V4L2_TYPE_IS_MULTIPLANAR(type) \ 235 ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE || \ 236 (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) 237 238 struct v4l2_clip { 239 struct v4l2_rect c; 240 struct v4l2_clip *next; 241 }; 242 243 struct v4l2_window { 244 struct v4l2_rect w; 245 u_int32_t field; 246 u_int32_t chromakey; 247 struct v4l2_clip *clips; 248 u_int32_t clipcount; 249 void *bitmap; 250 u_int8_t global_alpha; 251 }; 252 253 struct v4l2_format { 254 u_int32_t type; 255 union { 256 struct v4l2_pix_format pix; 257 struct v4l2_pix_format_mplane pix_mp; 258 struct v4l2_window win; 259 void *_align; 260 u_int8_t raw_data[200]; 261 } fmt; 262 }; 263 264 struct v4l2_fmtdesc { 265 u_int32_t index; /* Format number */ 266 u_int32_t type; /* enum v4l2_buf_type */ 267 u_int32_t flags; 268 u_int8_t description[32]; /* Description string */ 269 u_int32_t pixelformat; /* Format fourcc */ 270 u_int32_t mbus_code; /* Media bus code */ 271 u_int32_t reserved[3]; 272 }; 273 274 struct v4l2_timecode { 275 u_int32_t type; 276 u_int32_t flags; 277 u_int8_t frames; 278 u_int8_t seconds; 279 u_int8_t minutes; 280 u_int8_t hours; 281 u_int8_t userbits[4]; 282 }; 283 284 struct v4l2_buffer { 285 u_int32_t index; 286 u_int32_t type; 287 u_int32_t bytesused; 288 u_int32_t flags; 289 u_int32_t field; 290 struct timeval timestamp; 291 struct v4l2_timecode timecode; 292 u_int32_t sequence; 293 294 /* memory location */ 295 u_int32_t memory; 296 union { 297 u_int32_t offset; 298 unsigned long userptr; 299 struct v4l2_plane *planes; 300 int32_t fd; 301 } m; 302 u_int32_t length; 303 u_int32_t reserved2; 304 union { 305 int32_t request_fd; 306 u_int32_t reserved; 307 }; 308 }; 309 310 struct v4l2_requestbuffers { 311 u_int32_t count; 312 u_int32_t type; /* enum v4l2_buf_type */ 313 u_int32_t memory; /* enum v4l2_memory */ 314 u_int32_t capabilities; 315 u_int8_t flags; 316 u_int8_t reserved[3]; 317 }; 318 319 struct v4l2_captureparm { 320 u_int32_t capability; /* Supported modes */ 321 u_int32_t capturemode; /* Current mode */ 322 struct v4l2_fract timeperframe; /* Time per frame in seconds */ 323 u_int32_t extendedmode; /* Driver-specific extensions */ 324 u_int32_t readbuffers; /* # of buffers for read */ 325 u_int32_t reserved[4]; 326 }; 327 328 /* Simplified v4l2_streamparm: only the capture member is included */ 329 struct v4l2_streamparm { 330 u_int32_t type; /* enum v4l2_buf_type */ 331 union { 332 struct v4l2_captureparm capture; 333 u_int8_t raw_data[200]; 334 } parm; 335 }; 336 337 struct v4l2_input { 338 u_int32_t index; /* Which input */ 339 u_int8_t name[32]; /* Label */ 340 u_int32_t type; /* Type of input */ 341 u_int32_t audioset; /* Associated audios (bitfield) */ 342 u_int32_t tuner; /* Tuner index */ 343 u_int64_t std; 344 u_int32_t status; 345 u_int32_t capabilities; 346 u_int32_t reserved[3]; 347 }; 348 349 struct v4l2_standard { 350 u_int32_t index; 351 v4l2_std_id id; 352 u_int8_t name[24]; 353 struct v4l2_fract frameperiod; 354 u_int32_t framelines; 355 u_int32_t reserved[4]; 356 }; 357 358 struct v4l2_plane { 359 u_int32_t bytesused; 360 u_int32_t length; 361 union { 362 u_int32_t mem_offset; 363 unsigned long userptr; 364 int32_t fd; 365 } m; 366 u_int32_t data_offset; 367 u_int32_t reserved[11]; 368 }; 369 370 struct v4l2_control { 371 u_int32_t id; 372 int32_t value; 373 }; 374 375 struct v4l2_queryctrl { 376 u_int32_t id; 377 u_int32_t type; /* enum v4l2_ctrl_type */ 378 u_int8_t name[32]; /* Whatever */ 379 int32_t minimum; /* Note signedness */ 380 int32_t maximum; 381 int32_t step; 382 int32_t default_value; 383 u_int32_t flags; 384 u_int32_t reserved[2]; 385 }; 386 387 struct v4l2_querymenu { 388 u_int32_t id; 389 u_int32_t index; 390 union { 391 u_int8_t name[32]; 392 int64_t value; 393 }; 394 u_int32_t reserved; 395 } __packed; 396 397 struct v4l2_cropcap { 398 u_int32_t type; 399 struct v4l2_rect bounds; 400 struct v4l2_rect defrect; 401 struct v4l2_fract pixelaspect; 402 }; 403 404 struct v4l2_crop { 405 u_int32_t type; 406 struct v4l2_rect c; 407 }; 408 409 struct v4l2_frmsize_discrete { 410 u_int32_t width; /* Frame width [pixel] */ 411 u_int32_t height; /* Frame height [pixel] */ 412 }; 413 414 struct v4l2_frmsize_stepwise { 415 u_int32_t min_width; /* Minimum frame width [pixel] */ 416 u_int32_t max_width; /* Maximum frame width [pixel] */ 417 u_int32_t step_width; /* Frame width step size [pixel] */ 418 u_int32_t min_height; /* Minimum frame height [pixel] */ 419 u_int32_t max_height; /* Maximum frame height [pixel] */ 420 u_int32_t step_height; /* Frame height step size [pixel] */ 421 }; 422 423 struct v4l2_frmsizeenum { 424 u_int32_t index; /* Frame size number */ 425 u_int32_t pixel_format; /* Pixel format */ 426 u_int32_t type; /* Frame size type the device supports. */ 427 428 union { /* Frame size */ 429 struct v4l2_frmsize_discrete discrete; 430 struct v4l2_frmsize_stepwise stepwise; 431 }; 432 433 u_int32_t reserved[2]; /* Reserved space for future use */ 434 }; 435 436 struct v4l2_frmival_stepwise { 437 struct v4l2_fract min; /* Minimum frame interval [s] */ 438 struct v4l2_fract max; /* Maximum frame interval [s] */ 439 struct v4l2_fract step; /* Frame interval step size [s] */ 440 }; 441 442 struct v4l2_frmivalenum { 443 u_int32_t index; /* Frame format index */ 444 u_int32_t pixel_format; /* Pixel format */ 445 u_int32_t width; /* Frame width */ 446 u_int32_t height; /* Frame height */ 447 u_int32_t type; /* Frame interval type the device supports. */ 448 449 union { /* Frame interval */ 450 struct v4l2_fract discrete; 451 struct v4l2_frmival_stepwise stepwise; 452 }; 453 454 u_int32_t reserved[2]; /* Reserved space for future use */ 455 }; 456 457 /* 458 * Pixel formats 459 */ 460 461 /* Luminance+Chrominance formats */ 462 #define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') 463 #define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') 464 #define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') 465 #define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') 466 #define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') 467 #define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') 468 #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') 469 #define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') 470 #define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') 471 #define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') 472 #define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') 473 #define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') 474 475 /* Compressed formats */ 476 #define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') 477 #define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') 478 #define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4') 479 #define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') 480 #define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') 481 #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') 482 483 /* YUV411 planar and vendor webcam formats */ 484 #define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') 485 #define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') 486 487 /* Grey formats */ 488 #define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') 489 #define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') 490 #define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') 491 #define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') 492 493 /* RGB formats */ 494 #define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') 495 #define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') 496 #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') 497 #define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') 498 #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') 499 #define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') 500 #define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') 501 #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') 502 #define V4L2_PIX_FMT_XBGR32 v4l2_fourcc('X', 'R', '2', '4') 503 #define V4L2_PIX_FMT_ABGR32 v4l2_fourcc('A', 'R', '2', '4') 504 #define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') 505 #define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') 506 507 /* Bayer formats */ 508 #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') 509 #define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') 510 #define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') 511 #define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R', 'G', 'G', 'B') 512 #define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') 513 #define V4L2_PIX_FMT_SGBRG16 v4l2_fourcc('G', 'B', '1', '6') 514 #define V4L2_PIX_FMT_SRGGB16 v4l2_fourcc('R', 'G', '1', '6') 515 #define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') 516 #define V4L2_PIX_FMT_SRGGB10P v4l2_fourcc('p', 'R', 'A', 'A') 517 518 /* Depth format */ 519 #define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') 520 521 /* 522 * Capability flags 523 */ 524 #define V4L2_CAP_VIDEO_CAPTURE 0x00000001 525 #define V4L2_CAP_VIDEO_CAPTURE_MPLANE 0x00001000 526 #define V4L2_CAP_STREAMING 0x04000000 527 #define V4L2_CAP_EXT_PIX_FORMAT 0x00200000 528 #define V4L2_CAP_READWRITE 0x01000000 529 #define V4L2_CAP_DEVICE_CAPS 0x80000000 530 #define V4L2_CAP_TIMEPERFRAME 0x1000 531 532 /* 533 * Buffer flags 534 */ 535 #define V4L2_BUF_FLAG_MAPPED 0x00000001 536 #define V4L2_BUF_FLAG_QUEUED 0x00000002 537 #define V4L2_BUF_FLAG_DONE 0x00000004 538 #define V4L2_BUF_FLAG_ERROR 0x00000040 539 #define V4L2_BUF_FLAG_TIMESTAMP_MASK 0x0000e000 540 #define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x00002000 541 #define V4L2_BUF_FLAG_TSTAMP_SRC_MASK 0x00070000 542 #define V4L2_BUF_FLAG_TSTAMP_SRC_EOF 0x00000000 543 #define V4L2_BUF_FLAG_TIMECODE 0x00000100 544 545 /* 546 * Format flags 547 */ 548 #define V4L2_FMT_FLAG_COMPRESSED 0x0001 549 #define V4L2_FMT_FLAG_EMULATED 0x0002 550 551 /* 552 * Buffer capabilities 553 */ 554 #define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0) 555 556 /* 557 * Input types 558 */ 559 #define V4L2_INPUT_TYPE_TUNER 1 560 #define V4L2_INPUT_TYPE_CAMERA 2 561 562 /* 563 * Analog TV standards 564 */ 565 #define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000) 566 #define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000) 567 #define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000) 568 #define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000) 569 #define V4L2_STD_NTSC (V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | \ 570 V4L2_STD_NTSC_443 | V4L2_STD_NTSC_M_KR) 571 572 /* 573 * Control IDs 574 */ 575 #define V4L2_CTRL_CLASS_USER 0x00980000 576 #define V4L2_CTRL_CLASS_MPEG 0x00990000 577 #define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) 578 579 /* 580 * MPEG/codec control class 581 */ 582 #define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) 583 #define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+14) 584 #define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE + 0) 585 #define V4L2_CID_CONTRAST (V4L2_CID_BASE + 1) 586 #define V4L2_CID_SATURATION (V4L2_CID_BASE + 2) 587 #define V4L2_CID_HUE (V4L2_CID_BASE + 3) 588 #define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE + 12) 589 #define V4L2_CID_RED_BALANCE (V4L2_CID_BASE + 14) 590 #define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE + 15) 591 #define V4L2_CID_GAMMA (V4L2_CID_BASE + 16) 592 #define V4L2_CID_GAIN (V4L2_CID_BASE + 19) 593 #define V4L2_CID_HFLIP (V4L2_CID_BASE + 20) 594 #define V4L2_CID_VFLIP (V4L2_CID_BASE + 21) 595 #define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE + 24) 596 #define V4L2_CID_HUE_AUTO (V4L2_CID_BASE + 25) 597 #define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE + 26) 598 #define V4L2_CID_SHARPNESS (V4L2_CID_BASE + 27) 599 #define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE + 28) 600 #define V4L2_CID_LASTP1 (V4L2_CID_BASE + 44) 601 602 #define V4L2_CID_CAMERA_CLASS_BASE 0x009a0000 603 #define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE + 1) 604 #define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 2) 605 #define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE + 3) 606 #define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 4) 607 #define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 5) 608 #define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 8) 609 #define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 9) 610 #define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE + 12) 611 #define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 13) 612 #define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE + 15) 613 #define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE + 16) 614 615 /* 616 * IDs reserved for driver specific controls 617 */ 618 #define V4L2_CID_PRIVATE_BASE 0x08000000 619 620 /* 621 * Control flags 622 */ 623 #define V4L2_CTRL_FLAG_DISABLED 0x0001 624 #define V4L2_CTRL_FLAG_GRABBED 0x0002 625 #define V4L2_CTRL_FLAG_READ_ONLY 0x0004 626 #define V4L2_CTRL_FLAG_UPDATE 0x0008 627 #define V4L2_CTRL_FLAG_INACTIVE 0x0010 628 #define V4L2_CTRL_FLAG_SLIDER 0x0020 629 #define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040 630 #define V4L2_CTRL_FLAG_VOLATILE 0x0080 631 632 /* 633 * V4L2 ioctl definitions 634 */ 635 #define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability) 636 #define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc) 637 #define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format) 638 #define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format) 639 #define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers) 640 #define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer) 641 #define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer) 642 #define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer) 643 #define VIDIOC_STREAMON _IOW('V', 18, int) 644 #define VIDIOC_STREAMOFF _IOW('V', 19, int) 645 #define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm) 646 #define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm) 647 #define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id) 648 #define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id) 649 #define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard) 650 #define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input) 651 #define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control) 652 #define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control) 653 #define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl) 654 #define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu) 655 #define VIDIOC_G_INPUT _IOR('V', 38, int) 656 #define VIDIOC_S_INPUT _IOWR('V', 39, int) 657 #define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap) 658 #define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop) 659 #define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop) 660 #define VIDIOC_G_PRIORITY _IOR('V', 67, u_int32_t) 661 #define VIDIOC_S_PRIORITY _IOW('V', 68, u_int32_t) 662 #define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format) 663 #define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum) 664 #define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum) 665 666 _Static_assert(sizeof(struct v4l2_pix_format) == 48, "v4l2_pix_format layout"); 667 _Static_assert(sizeof(struct v4l2_capability) == 104, "v4l2_capability layout"); 668 _Static_assert(sizeof(struct v4l2_requestbuffers) == 20, 669 "v4l2_requestbuffers layout"); 670 _Static_assert(sizeof(struct v4l2_querymenu) == 44, "v4l2_querymenu layout"); 671 _Static_assert(sizeof(struct v4l2_cropcap) == 44, "v4l2_cropcap layout"); 672 _Static_assert(sizeof(struct v4l2_crop) == 20, "v4l2_crop layout"); 673 #ifdef __LP64__ 674 _Static_assert(__offsetof(struct v4l2_format, fmt) == 8, "v4l2_format layout"); 675 _Static_assert(sizeof(struct v4l2_format) == 208, "v4l2_format layout"); 676 _Static_assert(sizeof(struct v4l2_buffer) == 88, "v4l2_buffer layout"); 677 #elif defined(__i386__) 678 /* i386 is the only 32-bit port with a 32-bit time_t. */ 679 _Static_assert(__offsetof(struct v4l2_format, fmt) == 4, "v4l2_format layout"); 680 _Static_assert(sizeof(struct v4l2_format) == 204, "v4l2_format layout"); 681 _Static_assert(sizeof(struct v4l2_buffer) == 68, "v4l2_buffer layout"); 682 #else 683 /* ILP32 with a 64-bit time_t: arm, powerpc, mips, riscv32. */ 684 _Static_assert(__offsetof(struct v4l2_format, fmt) == 4, "v4l2_format layout"); 685 _Static_assert(sizeof(struct v4l2_format) == 204, "v4l2_format layout"); 686 _Static_assert(sizeof(struct v4l2_buffer) == 80, "v4l2_buffer layout"); 687 #endif 688 689 #endif /* _SYS_VIDEOIO_H_ */ 690