Developer World
Spresense SDK Library v2.0.1-3834d32
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 __INCLUDE_NUTTX_VIDEO_H
40 #define __INCLUDE_NUTTX_VIDEO_H
41 
42 /****************************************************************************
43  * Included Files
44  ****************************************************************************/
45 #include <stdint.h>
46 #include <sys/ioctl.h>
47 #include "video_controls.h"
48 
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
58 /****************************************************************************
59  * Pre-processor Definitions
60  ****************************************************************************/
61 #define _VIDIOCBASE (0x1000)
62 
63 #define _VIDIOC(nr) _IOC(_VIDIOCBASE,nr)
64 
77 #define VIDIOC_ENUM_FMT _VIDIOC(0x0001)
78 
86 #define VIDIOC_ENUM_FRAMESIZES _VIDIOC(0x0002)
87 
95 #define VIDIOC_ENUM_FRAMEINTERVALS _VIDIOC(0x0003)
96 
104 #define VIDIOC_TRY_FMT _VIDIOC(0x0004)
105 
113 #define VIDIOC_S_FMT _VIDIOC(0x0005)
114 
122 #define VIDIOC_S_PARM _VIDIOC(0x0006)
123 
124 
132 #define VIDIOC_REQBUFS _VIDIOC(0x0007)
133 
141 #define VIDIOC_QBUF _VIDIOC(0x0008)
142 
150 #define VIDIOC_DQBUF _VIDIOC(0x0009)
151 
159 #define VIDIOC_STREAMON _VIDIOC(0x000A)
160 
168 #define VIDIOC_STREAMOFF _VIDIOC(0x000B)
169 
177 #define VIDIOC_DO_HALFPUSH _VIDIOC(0x000C)
178 
190 #define VIDIOC_TAKEPICT_START _VIDIOC(0x000D)
191 
192 
200 #define VIDIOC_TAKEPICT_STOP _VIDIOC(0x000E)
201 
209 #define VIDIOC_QUERYCTRL _VIDIOC(0x000F)
210 
218 #define VIDIOC_QUERY_EXT_CTRL _VIDIOC(0x0010)
219 
227 #define VIDIOC_QUERYMENU _VIDIOC(0x0011)
228 
236 #define VIDIOC_G_CTRL _VIDIOC(0x0012)
237 
245 #define VIDIOC_S_CTRL _VIDIOC(0x0013)
246 
247 
254 #define VIDIOC_G_EXT_CTRLS _VIDIOC(0x0014)
255 
262 #define VIDIOC_S_EXT_CTRLS _VIDIOC(0x0015)
263 
270 #define VIDIOC_CANCEL_DQBUF _VIDIOC(0x0016)
271 
279 #define VIDEO_HSIZE_QVGA (320)
280 #define VIDEO_VSIZE_QVGA (240)
281 #define VIDEO_HSIZE_VGA (640)
282 #define VIDEO_VSIZE_VGA (480)
283 #define VIDEO_HSIZE_QUADVGA (1280)
284 #define VIDEO_VSIZE_QUADVGA (960)
285 #define VIDEO_HSIZE_HD (1280)
286 #define VIDEO_VSIZE_HD (720)
287 #define VIDEO_HSIZE_FULLHD (1920)
288 #define VIDEO_VSIZE_FULLHD (1080)
289 #define VIDEO_HSIZE_5M (2560)
290 #define VIDEO_VSIZE_5M (1920)
291 #define VIDEO_HSIZE_3M (2048)
292 #define VIDEO_VSIZE_3M (1536)
295 #define v4l2_fourcc(a, b, c, d)\
296  ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
297  ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
298 #define v4l2_fourcc_be(a, b, c, d) (v4l2_fourcc(a, b, c, d) | (1 << 31))
299 
302 #define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y')
303 
306 #define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P')
307 
310 #define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G')
311 
314 #define V4L2_PIX_FMT_JPEG_WITH_SUBIMG v4l2_fourcc('J', 'S', 'U', 'B')
315 
318 #define V4L2_FMT_DSC_MAX (32)
319 
322 #define V4L2_CTRL_MAX_DIMS (4)
323 
326 #define V4L2_REQBUFS_COUNT_MAX (256)
327 
330 #define V4L2_BUF_FLAG_ERROR (0x0001)
331 
334 /****************************************************************************
335  * Public Types
336  ****************************************************************************/
370 };
371 
379 };
380 
394 };
395 
401 };
402 
409  uint32_t count;
411  uint32_t type;
412  uint32_t memory;
413  uint32_t mode;
414 };
416 
418  uint32_t type;
419  uint32_t flags;
420  uint8_t frames;
421  uint8_t seconds;
422  uint8_t minutes;
423  uint8_t hours;
424  uint8_t userbits[4];
425 };
426 typedef struct v4l2_timecode v4l2_timecode_t;
427 
428 struct v4l2_plane {
429  uint32_t bytesused;
430  uint32_t length;
431  union {
432  uint32_t mem_offset;
433  unsigned long userptr;
434  int fd;
435  } m;
436  uint32_t data_offset;
437  uint32_t reserved[11];
438 };
439 typedef struct v4l2_plane v4l2_plane_t;
440 
448 struct v4l2_buffer {
449  uint16_t index;
450  uint16_t type;
451  uint32_t bytesused;
452  uint16_t flags;
455  uint16_t field;
456  struct v4l2_timecode timecode;
457  uint16_t sequence;
458  uint16_t memory;
459  union {
460  uint32_t offset;
461  unsigned long userptr;
462  struct v4l2_plane *planes;
463  int fd;
464  } m;
465  uint32_t length;
466 };
467 typedef struct v4l2_buffer v4l2_buffer_t;
468 
474 struct v4l2_fmtdesc {
475  uint16_t index;
476  uint16_t type;
477  uint32_t flags;
478  char description[V4L2_FMT_DSC_MAX];
479  uint32_t pixelformat;
481 };
482 
487 };
488 
490  uint16_t width;
491  uint16_t height;
492 };
493 
495  uint16_t min_width;
496  uint16_t max_width;
497  uint16_t step_width;
498  uint16_t min_height;
499  uint16_t max_height;
500  uint16_t step_height;
501 };
502 
509  uint32_t index;
510  uint32_t buf_type;
511  uint32_t pixel_format;
512  uint32_t type;
513  union {
514  struct v4l2_frmsize_discrete discrete;
517  struct v4l2_frmsize_stepwise stepwise;
521  };
523  uint32_t subimg_type;
525  union {
526  struct v4l2_frmsize_discrete discrete;
529  struct v4l2_frmsize_stepwise stepwise;
533  } subimg;
534 };
535 
542 };
543 
546 struct v4l2_fract {
547  uint32_t numerator;
548  uint32_t denominator;
549 };
550 
554  struct v4l2_fract min;
555  struct v4l2_fract max;
556  struct v4l2_fract step;
557 };
558 
565  uint32_t index;
566  uint32_t buf_type;
567  uint32_t pixel_format;
568  uint16_t width;
569  uint16_t height;
571  uint16_t subimg_width;
572  uint16_t subimg_height;
573  uint32_t type;
574  union {
575  struct v4l2_fract discrete;
576  struct v4l2_frmival_stepwise stepwise;
577  };
578 };
579 
583  uint16_t width;
584  uint16_t height;
585  uint32_t pixelformat;
590  uint16_t subimg_width;
593  uint16_t subimg_height;
599  uint32_t field;
600  uint32_t bytesperline;
601  uint32_t sizeimage;
603  uint32_t colorspace;
604  uint32_t priv;
605  uint32_t flags;
606  union {
607  uint32_t ycbcr_enc;
608  uint32_t hsv_enc;
609  };
610  uint32_t quantization;
611  uint32_t xfer_func;
612 };
613 typedef struct v4l2_pix_format v4l2_pix_format_t;
614 
620 struct v4l2_format {
621  uint32_t type;
622  union {
623  struct v4l2_pix_format pix;
624  } fmt;
625 };
626 typedef struct v4l2_format v4l2_format_t;
627 
629  uint32_t capability; /* Supported modes */
630  uint32_t capturemode; /* Current mode */
631  struct v4l2_fract timeperframe; /* Time per frame in seconds */
632  uint32_t extendedmode; /* Driver-specific extensions */
633  uint32_t readbuffers; /* # of buffers for read */
634 };
635 
636 
643  uint32_t type; /* enum v4l2_buf_type */
644  union {
645  struct v4l2_captureparm capture;
646 // struct v4l2_outputparm output;
647  } parm;
648 };
649 
666  /* Compound types are >= 0x0100 */
668  V4L2_CTRL_TYPE_U8 = 0x0100,
671 };
672 
673 
680  uint16_t ctrl_class;
681  uint16_t id;
682  uint16_t type;
683  char name[32];
684  int32_t minimum;
685  int32_t maximum;
686  uint32_t step;
687  int32_t default_value;
688  uint32_t flags; };
689 
696  uint16_t ctrl_class;
697  uint16_t id;
698  uint16_t type;
699  char name[32];
700  int64_t minimum;
701  int64_t maximum;
702  uint64_t step;
703  int64_t default_value;
704  uint32_t flags;
705  uint32_t elem_size;
706  uint32_t elems;
707  uint32_t nr_of_dims;
708  uint32_t dims[V4L2_CTRL_MAX_DIMS];
709 };
710 
717  uint16_t ctrl_class;
718  uint16_t id;
719  uint32_t index;
720  union {
721  char name[32];
722  int64_t value;
723  };
724 } __attribute__ ((packed));
725 
731 struct v4l2_control {
732  uint16_t id;
733  int32_t value;
734 };
735 
742  uint16_t id;
743  uint16_t size;
744  union {
745  int32_t value;
746  int64_t value64;
747  char *string;
748  uint8_t *p_u8;
749  uint16_t *p_u16;
750  uint32_t *p_u32;
751  void *ptr;
752  };
753 } __attribute__ ((packed));
754 
761  union {
762  uint16_t ctrl_class;
763  uint16_t which;
764  };
765  uint16_t count;
766  uint16_t error_idx;
768 };
769 
772 /****************************************************************************
773  * Public Function Prototypes
774  ****************************************************************************/
775 
790 int video_initialize(FAR const char *devpath);
791 
799 int video_uninitialize(void);
800 
805 #ifdef __cplusplus
806 }
807 #endif
808 #endif /* __INCLUDE_NUTTX_VIDEO_H */
uint16_t id
Definition: video.h:86
v4l2_buf_mode
Definition: video.h:398
uint16_t width
Definition: video.h:568
parameter of ioctl(VIDIOC_G_CTRL / VIDIOC_S_CTRL)
Definition: video.h:731
Definition: video.h:366
uint16_t memory
Definition: video.h:458
v4l2_field
Definition: video.h:383
int32_t maximum
Definition: video.h:685
uint32_t mode
Definition: video.h:413
parameter of ioctl(VIDIOC_QUERYCTRL)
Definition: video.h:679
Definition: video.h:653
uint16_t subimg_width
Definition: video.h:590
uint16_t max_height
Definition: video.h:499
uint32_t buf_type
Definition: video.h:566
uint16_t count
Definition: video.h:765
uint32_t ycbcr_enc
Definition: video.h:607
Definition: video.h:553
uint32_t index
Definition: video.h:719
Definition: video.h:663
Definition: video.h:484
int64_t maximum
Definition: video.h:701
Definition: video.h:494
Definition: video.h:367
uint32_t index
Definition: video.h:565
uint32_t count
Definition: video.h:409
uint32_t pixel_format
Definition: video.h:511
uint16_t step_height
Definition: video.h:500
uint32_t field
Definition: video.h:599
Definition: video.h:356
uint32_t pixelformat
Definition: video.h:479
uint16_t max_width
Definition: video.h:496
Definition: video.h:661
parameter of ioctl(VIDIOC_S_FMT)
Definition: video.h:620
int video_uninitialize(void)
uint32_t type
Definition: video.h:573
uint16_t id
Definition: video.h:681
Definition: video.h:539
uint8_t * p_u8
Definition: video.h:748
Definition: video.h:386
Definition: video.h:378
v4l2_frmivaltypes
Definition: video.h:538
uint16_t type
Definition: video.h:476
uint16_t height
Definition: video.h:584
uint16_t min_height
Definition: video.h:498
uint32_t bytesused
Definition: video.h:451
int64_t default_value
Definition: video.h:703
int64_t value
Definition: video.h:722
uint32_t flags
Definition: video.h:688
uint32_t buf_type
Definition: video.h:510
Definition: video.h:353
int32_t minimum
Definition: video.h:684
uint16_t type
Definition: video.h:698
parameter of ioctl(VIDIOC_ENUM_FMT)
Definition: video.h:474
uint64_t step
Definition: video.h:702
Definition: video.h:391
Definition: video.h:360
Definition: video.h:388
uint16_t flags
Definition: video.h:452
Definition: video.h:387
uint16_t ctrl_class
Definition: video.h:680
uint32_t subimg_pixel_format
Definition: video.h:522
uint32_t nr_of_dims
Definition: video.h:707
parameter of ioctl(VIDIOC_ENUM_FRAMEINTERVALS)
Definition: video.h:564
uint32_t bytesperline
Definition: video.h:600
Definition: video.h:357
uint16_t ctrl_class
Definition: video.h:717
uint32_t sizeimage
Definition: video.h:601
parameter of ioctl(VIDIOC_QUERYMENU)
Definition: video.h:716
int64_t value64
Definition: video.h:746
Definition: video.h:668
uint32_t elem_size
Definition: video.h:705
uint32_t * p_u32
Definition: video.h:750
Definition: video.h:350
uint16_t step_width
Definition: video.h:497
Definition: video.h:417
Definition: video.h:662
Definition: video.h:399
uint32_t flags
Definition: video.h:605
Definition: video.h:546
uint16_t height
Definition: video.h:491
unsigned long userptr
Definition: video.h:461
Definition: video.h:659
uint32_t type
Definition: video.h:512
Definition: video.h:355
Definition: video.h:655
Definition: video.h:376
uint16_t ctrl_class
Definition: video.h:762
uint32_t pixelformat
Definition: video.h:585
Definition: video.h:354
Definition: video.h:392
parameter of ioctl(VIDIOC_G_EXT_CTRLS / VIDIOC_S_EXT_CTRLS)
Definition: video.h:760
uint32_t numerator
Definition: video.h:547
#define V4L2_CTRL_MAX_DIMS
Definition: video.h:322
__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:582
v4l2_memory
Definition: video.h:374
uint16_t subimg_width
Definition: video.h:571
int32_t default_value
Definition: video.h:687
uint16_t ctrl_class
Definition: video.h:696
v4l2_buf_type
Definition: video.h:347
Definition: video.h:362
uint16_t error_idx
Definition: video.h:766
v4l2_ctrl_type
Definition: video.h:652
Definition: video.h:489
Definition: video.h:741
uint32_t denominator
Definition: video.h:548
Definition: video.h:660
uint32_t type
Definition: video.h:411
Definition: video.h:384
uint32_t type
Definition: video.h:621
Definition: video.h:375
uint32_t memory
Definition: video.h:412
uint32_t subimg_pixelformat
Definition: video.h:480
Definition: video.h:658
uint16_t subimg_height
Definition: video.h:593
Definition: video.h:368
uint32_t subimg_type
Definition: video.h:523
Definition: video.h:352
uint16_t * p_u16
Definition: video.h:749
uint16_t type
Definition: video.h:682
uint32_t flags
Definition: video.h:704
Definition: video.h:664
int64_t value
Definition: video.h:90
uint32_t elems
Definition: video.h:706
Definition: video.h:348
Definition: video.h:657
char name[32]
Definition: video.h:89
int video_initialize(FAR const char *devpath)
Parameter of ioctl(VIDIOC_QBUF) and ioctl(VIDIOC_DQBUF). Currently, support only index...
Definition: video.h:448
Definition: video.h:389
uint16_t field
Definition: video.h:455
uint16_t size
Definition: video.h:743
Definition: video.h:390
uint16_t height
Definition: video.h:569
Definition: video.h:670
Definition: video.h:393
Definition: video.h:541
parameter of ioctl(VIDIOC_QUERY_EXT_CTRL)
Definition: video.h:695
uint32_t pixel_format
Definition: video.h:567
Definition: video.h:667
uint32_t step
Definition: video.h:686
uint16_t id
Definition: video.h:718
struct v4l2_ext_control * controls
Definition: video.h:767
uint32_t xfer_func
Definition: video.h:611
parameter of ioctl(VIDIOC_REQBUFS)
Definition: video.h:408
uint32_t index
Definition: video.h:509
uint16_t id
Definition: video.h:742
uint16_t index
Definition: video.h:449
Definition: video.h:669
Definition: video.h:377
Definition: video.h:428
Definition: video.h:540
Definition: video.h:400
Definition: video.h:485
Definition: video.h:628
uint32_t length
Definition: video.h:465
uint16_t min_width
Definition: video.h:495
v4l2_frmsizetypes
Definition: video.h:483
uint16_t id
Definition: video.h:697
Definition: video.h:385
uint32_t quantization
Definition: video.h:610
Definition: video.h:486
uint16_t width
Definition: video.h:583
uint16_t width
Definition: video.h:490
uint32_t subimg_pixelformat
Definition: video.h:596
Definition: video.h:364
parameter of ioctl(VIDIOC_S_PARM)
Definition: video.h:642
uint16_t index
Definition: video.h:475
uint16_t subimg_height
Definition: video.h:572
int64_t minimum
Definition: video.h:700
parameter of ioctl(VIDIOC_ENUM_FRAMESIZES)
Definition: video.h:508
uint16_t sequence
Definition: video.h:457
Definition: video.h:656
Definition: video.h:654
#define V4L2_FMT_DSC_MAX
Definition: video.h:318
uint32_t priv
Definition: video.h:604
int32_t value
Definition: video.h:745
uint16_t type
Definition: video.h:450
uint32_t colorspace
Definition: video.h:603
uint32_t hsv_enc
Definition: video.h:608
Definition: video.h:358
uint32_t subimg_pixel_format
Definition: video.h:570