Developer World
Spresense SDK Library v1.4.1-ee8f2dd
video.h
Go to the documentation of this file.
1 /****************************************************************************
2  * modules/include/video/video.h
3  *
4  * Copyright 2018 Sony Semiconductor Solutions Corporation
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17  * the names of its contributors may be used to endorse or promote
18  * products derived from this software without specific prior written
19  * permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ****************************************************************************/
39 #ifndef __MODULES_INCLUDE_VIDEO_VIDEO_H
40 #define __MODULES_INCLUDE_VIDEO_VIDEO_H
41 
42 /****************************************************************************
43  * Included Files
44  ****************************************************************************/
45 #include <stdint.h>
46 #include <sys/ioctl.h>
47 #include <video/video_controls.h>
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
56 /****************************************************************************
57  * Pre-processor Definitions
58  ****************************************************************************/
59 #define _VIDIOCBASE (0x1000)
60 
61 #define _VIDIOC(nr) _IOC(_VIDIOCBASE,nr)
62 
75 #define VIDIOC_ENUM_FMT _VIDIOC(0x0001)
76 
84 #define VIDIOC_ENUM_FRAMESIZES _VIDIOC(0x0002)
85 
93 #define VIDIOC_ENUM_FRAMEINTERVALS _VIDIOC(0x0003)
94 
102 #define VIDIOC_TRY_FMT _VIDIOC(0x0004)
103 
111 #define VIDIOC_S_FMT _VIDIOC(0x0005)
112 
120 #define VIDIOC_S_PARM _VIDIOC(0x0006)
121 
122 
130 #define VIDIOC_REQBUFS _VIDIOC(0x0007)
131 
139 #define VIDIOC_QBUF _VIDIOC(0x0008)
140 
148 #define VIDIOC_DQBUF _VIDIOC(0x0009)
149 
157 #define VIDIOC_STREAMON _VIDIOC(0x000A)
158 
166 #define VIDIOC_STREAMOFF _VIDIOC(0x000B)
167 
175 #define VIDIOC_DO_HALFPUSH _VIDIOC(0x000C)
176 
188 #define VIDIOC_TAKEPICT_START _VIDIOC(0x000D)
189 
190 
198 #define VIDIOC_TAKEPICT_STOP _VIDIOC(0x000E)
199 
207 #define VIDIOC_QUERYCTRL _VIDIOC(0x000F)
208 
216 #define VIDIOC_QUERY_EXT_CTRL _VIDIOC(0x0010)
217 
224 #define VIDIOC_QUERYMENU _VIDIOC(0x0011)
225 
232 #define VIDIOC_G_CTRL _VIDIOC(0x0012)
233 
240 #define VIDIOC_S_CTRL _VIDIOC(0x0013)
241 
242 
248 #define VIDIOC_G_EXT_CTRLS _VIDIOC(0x0014)
249 
255 #define VIDIOC_S_EXT_CTRLS _VIDIOC(0x0015)
256 
262 #define VIDIOC_CANCEL_DQBUF _VIDIOC(0x0016)
263 
271 #define VIDEO_HSIZE_QVGA (320)
272 #define VIDEO_VSIZE_QVGA (240)
273 #define VIDEO_HSIZE_VGA (640)
274 #define VIDEO_VSIZE_VGA (480)
275 #define VIDEO_HSIZE_QUADVGA (1280)
276 #define VIDEO_VSIZE_QUADVGA (960)
277 #define VIDEO_HSIZE_HD (1280)
278 #define VIDEO_VSIZE_HD (720)
279 #define VIDEO_HSIZE_FULLHD (1920)
280 #define VIDEO_VSIZE_FULLHD (1080)
281 #define VIDEO_HSIZE_5M (2560)
282 #define VIDEO_VSIZE_5M (1920)
283 #define VIDEO_HSIZE_3M (2048)
284 #define VIDEO_VSIZE_3M (1536)
287 #define v4l2_fourcc(a, b, c, d)\
288  ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
289  ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
290 #define v4l2_fourcc_be(a, b, c, d) (v4l2_fourcc(a, b, c, d) | (1 << 31))
291 
294 #define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y')
295 
298 #define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P')
299 
302 #define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G')
303 
306 #define V4L2_PIX_FMT_JPEG_WITH_SUBIMG v4l2_fourcc('J', 'S', 'U', 'B')
307 
310 #define V4L2_FMT_DSC_MAX (32)
311 
314 #define V4L2_CTRL_MAX_DIMS (4)
315 
318 #define V4L2_REQBUFS_COUNT_MAX (256)
319 
322 #define V4L2_BUF_FLAG_ERROR (0x0001)
323 
326 /****************************************************************************
327  * Public Types
328  ****************************************************************************/
362 };
363 
371 };
372 
386 };
387 
393 };
394 
400  uint32_t count;
402  uint32_t type;
403  uint32_t memory;
404  uint32_t mode;
405 };
407 
409  uint32_t type;
410  uint32_t flags;
411  uint8_t frames;
412  uint8_t seconds;
413  uint8_t minutes;
414  uint8_t hours;
415  uint8_t userbits[4];
416 };
417 typedef struct v4l2_timecode v4l2_timecode_t;
418 
419 struct v4l2_plane {
420  uint32_t bytesused;
421  uint32_t length;
422  union {
423  uint32_t mem_offset;
424  unsigned long userptr;
425  int fd;
426  } m;
427  uint32_t data_offset;
428  uint32_t reserved[11];
429 };
430 typedef struct v4l2_plane v4l2_plane_t;
431 
438 struct v4l2_buffer {
439  uint16_t index;
440  uint16_t type;
441  uint32_t bytesused;
442  uint16_t flags;
445  uint16_t field;
446  struct v4l2_timecode timecode;
447  uint16_t sequence;
448  uint16_t memory;
449  union {
450  uint32_t offset;
451  unsigned long userptr;
452  struct v4l2_plane *planes;
453  int fd;
454  } m;
455  uint32_t length;
456 };
457 typedef struct v4l2_buffer v4l2_buffer_t;
458 
463 struct v4l2_fmtdesc {
464  uint16_t index;
465  uint16_t type;
466  uint32_t flags;
467  char description[V4L2_FMT_DSC_MAX];
468  uint32_t pixelformat;
470 };
471 
476 };
477 
479  uint16_t width;
480  uint16_t height;
481 };
482 
484  uint16_t min_width;
485  uint16_t max_width;
486  uint16_t step_width;
487  uint16_t min_height;
488  uint16_t max_height;
489  uint16_t step_height;
490 };
491 
497  uint32_t index;
498  uint32_t buf_type;
499  uint32_t pixel_format;
500  uint32_t type;
501  union {
502  struct v4l2_frmsize_discrete discrete;
505  struct v4l2_frmsize_stepwise stepwise;
509  };
511  uint32_t subimg_type;
513  union {
514  struct v4l2_frmsize_discrete discrete;
517  struct v4l2_frmsize_stepwise stepwise;
521  } subimg;
522 };
523 
530 };
531 
534 struct v4l2_fract {
535  uint32_t numerator;
536  uint32_t denominator;
537 };
538 
542  struct v4l2_fract min;
543  struct v4l2_fract max;
544  struct v4l2_fract step;
545 };
546 
552  uint32_t index;
553  uint32_t buf_type;
554  uint32_t pixel_format;
555  uint16_t width;
556  uint16_t height;
558  uint16_t subimg_width;
559  uint16_t subimg_height;
560  uint32_t type;
561  union {
562  struct v4l2_fract discrete;
563  struct v4l2_frmival_stepwise stepwise;
564  };
565 };
566 
570  uint16_t width;
571  uint16_t height;
572  uint32_t pixelformat;
577  uint16_t subimg_width;
580  uint16_t subimg_height;
586  uint32_t field;
587  uint32_t bytesperline;
588  uint32_t sizeimage;
590  uint32_t colorspace;
591  uint32_t priv;
592  uint32_t flags;
593  union {
594  uint32_t ycbcr_enc;
595  uint32_t hsv_enc;
596  };
597  uint32_t quantization;
598  uint32_t xfer_func;
599 };
600 typedef struct v4l2_pix_format v4l2_pix_format_t;
601 
606 struct v4l2_format {
607  uint32_t type;
608  union {
609  struct v4l2_pix_format pix;
610  } fmt;
611 };
612 typedef struct v4l2_format v4l2_format_t;
613 
615  uint32_t capability; /* Supported modes */
616  uint32_t capturemode; /* Current mode */
617  struct v4l2_fract timeperframe; /* Time per frame in seconds */
618  uint32_t extendedmode; /* Driver-specific extensions */
619  uint32_t readbuffers; /* # of buffers for read */
620 };
621 
622 
628  uint32_t type; /* enum v4l2_buf_type */
629  union {
630  struct v4l2_captureparm capture;
631 // struct v4l2_outputparm output;
632  } parm;
633 };
634 
638  V4L2_CTRL_TYPE_INTEGER = 1,
639  V4L2_CTRL_TYPE_BOOLEAN = 2,
640  V4L2_CTRL_TYPE_MENU = 3,
641  V4L2_CTRL_TYPE_BUTTON = 4,
642  V4L2_CTRL_TYPE_INTEGER64 = 5,
643  V4L2_CTRL_TYPE_CTRL_CLASS = 6,
644  V4L2_CTRL_TYPE_STRING = 7,
645  V4L2_CTRL_TYPE_BITMASK = 8,
646  V4L2_CTRL_TYPE_INTEGER_MENU = 9,
647  V4L2_CTRL_TYPE_U8FIXEDPOINT_Q7 = 10,
648  V4L2_CTRL_TYPE_U16FIXEDPOINT_Q8 = 11,
649  V4L2_CTRL_TYPE_INTEGER_TIMES_3 = 12,
650 
651  /* Compound types are >= 0x0100 */
652  V4L2_CTRL_COMPOUND_TYPES = 0x0100,
653  V4L2_CTRL_TYPE_U8 = 0x0100,
654  V4L2_CTRL_TYPE_U16 = 0x0101,
655  V4L2_CTRL_TYPE_U32 = 0x0102,
656 };
657 
658 
664  uint16_t ctrl_class;
665  uint16_t id;
666  uint16_t type;
667  char name[32];
668  int32_t minimum;
669  int32_t maximum;
670  uint32_t step;
671  int32_t default_value;
672  uint32_t flags; };
673 
679  uint16_t ctrl_class;
680  uint16_t id;
681  uint16_t type;
682  char name[32];
683  int64_t minimum;
684  int64_t maximum;
685  uint64_t step;
686  int64_t default_value;
687  uint32_t flags;
688  uint32_t elem_size;
689  uint32_t elems;
690  uint32_t nr_of_dims;
691  uint32_t dims[V4L2_CTRL_MAX_DIMS];
692 };
693 
699  uint16_t ctrl_class;
700  uint16_t id;
701  uint32_t index;
702  union {
703  char name[32];
704  int64_t value;
705  };
706 } __attribute__ ((packed));
707 
712 struct v4l2_control {
713  uint16_t id;
714  int32_t value;
715 };
716 
722  uint16_t id;
723  uint16_t size;
724  union {
725  int32_t value;
726  int64_t value64;
727  char *string;
728  uint8_t *p_u8;
729  uint16_t *p_u16;
730  uint32_t *p_u32;
731  void *ptr;
732  };
733 } __attribute__ ((packed));
734 
740  union {
741  uint16_t ctrl_class;
742  uint16_t which;
743  };
744  uint16_t count;
745  uint16_t error_idx;
747 };
748 
751 /****************************************************************************
752  * Public Function Prototypes
753  ****************************************************************************/
754 
769 int video_initialize(FAR const char *devpath);
770 
778 int video_uninitialize(void);
779 
784 #ifdef __cplusplus
785 }
786 #endif
787 #endif /* __MODULES_INCLUDE_VIDEO_VIDEO_H */
uint16_t id
Definition: video.h:77
v4l2_buf_mode
Definition: video.h:390
uint16_t width
Definition: video.h:555
parameter of ioctl(VIDIOC_G_CTRL / VIDIOC_S_CTRL)
Definition: video.h:712
Definition: video.h:358
uint16_t memory
Definition: video.h:448
v4l2_field
Definition: video.h:375
int32_t maximum
Definition: video.h:669
uint32_t mode
Definition: video.h:404
parameter of ioctl(VIDIOC_QUERYCTRL)
Definition: video.h:663
uint16_t subimg_width
Definition: video.h:577
uint16_t max_height
Definition: video.h:488
uint32_t buf_type
Definition: video.h:553
uint16_t count
Definition: video.h:744
uint32_t ycbcr_enc
Definition: video.h:594
Definition: video.h:541
uint32_t index
Definition: video.h:701
Definition: video.h:473
int64_t maximum
Definition: video.h:684
Definition: video.h:483
Definition: video.h:359
uint32_t index
Definition: video.h:552
uint32_t count
Definition: video.h:400
uint32_t pixel_format
Definition: video.h:499
uint16_t step_height
Definition: video.h:489
uint32_t field
Definition: video.h:586
Definition: video.h:348
uint32_t pixelformat
Definition: video.h:468
uint16_t max_width
Definition: video.h:485
parameter of ioctl(VIDIOC_S_FMT)
Definition: video.h:606
int video_uninitialize(void)
uint32_t type
Definition: video.h:560
uint16_t id
Definition: video.h:665
Definition: video.h:527
uint8_t * p_u8
Definition: video.h:728
Definition: video.h:378
Definition: video.h:370
v4l2_frmivaltypes
Definition: video.h:526
uint16_t type
Definition: video.h:465
uint16_t height
Definition: video.h:571
uint16_t min_height
Definition: video.h:487
uint32_t bytesused
Definition: video.h:441
int64_t default_value
Definition: video.h:686
int64_t value
Definition: video.h:704
uint32_t flags
Definition: video.h:672
uint32_t buf_type
Definition: video.h:498
Definition: video.h:345
int32_t minimum
Definition: video.h:668
uint16_t type
Definition: video.h:681
parameter of ioctl(VIDIOC_ENUM_FMT)
Definition: video.h:463
uint64_t step
Definition: video.h:685
Definition: video.h:383
Definition: video.h:352
Definition: video.h:380
uint16_t flags
Definition: video.h:442
Definition: video.h:379
uint16_t ctrl_class
Definition: video.h:664
uint32_t subimg_pixel_format
Definition: video.h:510
uint32_t nr_of_dims
Definition: video.h:690
parameter of ioctl(VIDIOC_ENUM_FRAMEINTERVALS)
Definition: video.h:551
uint32_t bytesperline
Definition: video.h:587
Definition: video.h:349
uint16_t ctrl_class
Definition: video.h:699
uint32_t sizeimage
Definition: video.h:588
parameter of ioctl(VIDIOC_QUERYMENU)
Definition: video.h:698
int64_t value64
Definition: video.h:726
uint32_t elem_size
Definition: video.h:688
uint32_t * p_u32
Definition: video.h:730
Definition: video.h:342
uint16_t step_width
Definition: video.h:486
Definition: video.h:408
Definition: video.h:391
uint32_t flags
Definition: video.h:592
Definition: video.h:534
uint16_t height
Definition: video.h:480
unsigned long userptr
Definition: video.h:451
uint32_t type
Definition: video.h:500
Definition: video.h:347
Definition: video.h:368
uint16_t ctrl_class
Definition: video.h:741
uint32_t pixelformat
Definition: video.h:572
Definition: video.h:346
Definition: video.h:384
parameter of ioctl(VIDIOC_G_EXT_CTRLS / VIDIOC_S_EXT_CTRLS)
Definition: video.h:739
uint32_t numerator
Definition: video.h:535
#define V4L2_CTRL_MAX_DIMS
Definition: video.h:314
__attribute__((deprecated("\eprecated attention callback type is used. \ \lease use \udioAttentionCb\as callback type. \ \))) int AS_CreateAudioManager(AudioSubSystemIDs ids
Activate AudioSubSystem[Deprecated] This API is to make it compatible with old application. Will delete most application seems to migrate to new API.
Definition: video.h:569
v4l2_memory
Definition: video.h:366
uint16_t subimg_width
Definition: video.h:558
int32_t default_value
Definition: video.h:671
uint16_t ctrl_class
Definition: video.h:679
v4l2_buf_type
Definition: video.h:339
Definition: video.h:354
uint16_t error_idx
Definition: video.h:745
v4l2_ctrl_type
Definition: video.h:637
Definition: video.h:478
Definition: video.h:721
uint32_t denominator
Definition: video.h:536
uint32_t type
Definition: video.h:402
Definition: video.h:376
uint32_t type
Definition: video.h:607
Definition: video.h:367
uint32_t memory
Definition: video.h:403
uint32_t subimg_pixelformat
Definition: video.h:469
uint16_t subimg_height
Definition: video.h:580
Definition: video.h:360
uint32_t subimg_type
Definition: video.h:511
Definition: video.h:344
uint16_t * p_u16
Definition: video.h:729
uint16_t type
Definition: video.h:666
uint32_t flags
Definition: video.h:687
int64_t value
Definition: video.h:81
uint32_t elems
Definition: video.h:689
Definition: video.h:340
char name[32]
Definition: video.h:80
int video_initialize(FAR const char *devpath)
Parameter of ioctl(VIDIOC_QBUF) and ioctl(VIDIOC_DQBUF). Currently, support only index...
Definition: video.h:438
Definition: video.h:381
uint16_t field
Definition: video.h:445
uint16_t size
Definition: video.h:723
Definition: video.h:382
uint16_t height
Definition: video.h:556
Definition: video.h:385
Definition: video.h:529
parameter of ioctl(VIDIOC_QUERY_EXT_CTRL)
Definition: video.h:678
uint32_t pixel_format
Definition: video.h:554
uint32_t step
Definition: video.h:670
uint16_t id
Definition: video.h:700
struct v4l2_ext_control * controls
Definition: video.h:746
uint32_t xfer_func
Definition: video.h:598
parameter of ioctl(VIDIOC_REQBUFS)
Definition: video.h:399
uint32_t index
Definition: video.h:497
uint16_t id
Definition: video.h:722
uint16_t index
Definition: video.h:439
Definition: video.h:369
Definition: video.h:419
Definition: video.h:528
Definition: video.h:392
Definition: video.h:474
Definition: video.h:614
uint32_t length
Definition: video.h:455
uint16_t min_width
Definition: video.h:484
v4l2_frmsizetypes
Definition: video.h:472
uint16_t id
Definition: video.h:680
Definition: video.h:377
uint32_t quantization
Definition: video.h:597
Definition: video.h:475
uint16_t width
Definition: video.h:570
uint16_t width
Definition: video.h:479
uint32_t subimg_pixelformat
Definition: video.h:583
Definition: video.h:356
parameter of ioctl(VIDIOC_S_PARM)
Definition: video.h:627
uint16_t index
Definition: video.h:464
uint16_t subimg_height
Definition: video.h:559
int64_t minimum
Definition: video.h:683
parameter of ioctl(VIDIOC_ENUM_FRAMESIZES)
Definition: video.h:496
uint16_t sequence
Definition: video.h:447
#define V4L2_FMT_DSC_MAX
Definition: video.h:310
uint32_t priv
Definition: video.h:591
int32_t value
Definition: video.h:725
uint16_t type
Definition: video.h:440
uint32_t colorspace
Definition: video.h:590
uint32_t hsv_enc
Definition: video.h:595
Definition: video.h:350
uint32_t subimg_pixel_format
Definition: video.h:557