Merge remote-tracking branch 'remotes/aosp/android-3.0' into develop-3.0
[firefly-linux-kernel-4.4.55.git] / include / linux / videodev2.h
index 82ae492f0b230e401205aed6784626aee6367be8..bd8478566a705e413c2d488624bcf017115c7287 100644 (file)
@@ -70,6 +70,7 @@
  * Moved from videodev.h
  */
 #define VIDEO_MAX_FRAME               32
+#define VIDEO_MAX_PLANES               8
 
 #ifndef __KERNEL__
 
@@ -157,9 +158,23 @@ enum v4l2_buf_type {
        /* Experimental */
        V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
 #endif
+       V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
+       V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE  = 10,
        V4L2_BUF_TYPE_PRIVATE              = 0x80,
 };
 
+#define V4L2_TYPE_IS_MULTIPLANAR(type)                 \
+       ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE   \
+        || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
+
+#define V4L2_TYPE_IS_OUTPUT(type)                              \
+       ((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT                   \
+        || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE         \
+        || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY               \
+        || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY        \
+        || (type) == V4L2_BUF_TYPE_VBI_OUTPUT                  \
+        || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT)
+
 enum v4l2_tuner_type {
        V4L2_TUNER_RADIO             = 1,
        V4L2_TUNER_ANALOG_TV         = 2,
@@ -245,6 +260,11 @@ struct v4l2_capability {
 #define V4L2_CAP_HW_FREQ_SEEK          0x00000400  /* Can do hardware frequency seek  */
 #define V4L2_CAP_RDS_OUTPUT            0x00000800  /* Is an RDS encoder */
 
+/* Is a video capture device that supports multiplanar formats */
+#define V4L2_CAP_VIDEO_CAPTURE_MPLANE  0x00001000
+/* Is a video output device that supports multiplanar formats */
+#define V4L2_CAP_VIDEO_OUTPUT_MPLANE   0x00002000
+
 #define V4L2_CAP_TUNER                 0x00010000  /* has a tuner */
 #define V4L2_CAP_AUDIO                 0x00020000  /* has audio support */
 #define V4L2_CAP_RADIO                 0x00040000  /* is a radio device */
@@ -288,8 +308,12 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y4      v4l2_fourcc('Y', '0', '4', ' ') /*  4  Greyscale     */
 #define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /*  6  Greyscale     */
 #define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10  Greyscale     */
+#define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12  Greyscale     */
 #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16  Greyscale     */
 
+/* Grey bit-packed formats */
+#define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
+
 /* Palette formats */
 #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
 
@@ -312,6 +336,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_YUV420  v4l2_fourcc('Y', 'U', '1', '2') /* 12  YUV 4:2:0     */
 #define V4L2_PIX_FMT_HI240   v4l2_fourcc('H', 'I', '2', '4') /*  8  8-bit color   */
 #define V4L2_PIX_FMT_HM12    v4l2_fourcc('H', 'M', '1', '2') /*  8  YUV 4:2:0 16x16 macroblocks */
+#define V4L2_PIX_FMT_M420    v4l2_fourcc('M', '4', '2', '0') /* 12  YUV 4:2:0 2 lines y, 1 line uv interleaved */
 
 /* two planes -- one Y, one Cr + Cb interleaved  */
 #define V4L2_PIX_FMT_NV12    v4l2_fourcc('N', 'V', '1', '2') /* 12  Y/CbCr 4:2:0  */
@@ -319,6 +344,13 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_NV16    v4l2_fourcc('N', 'V', '1', '6') /* 16  Y/CbCr 4:2:2  */
 #define V4L2_PIX_FMT_NV61    v4l2_fourcc('N', 'V', '6', '1') /* 16  Y/CrCb 4:2:2  */
 
+/* two non contiguous planes - one Y, one Cr + Cb interleaved  */
+#define V4L2_PIX_FMT_NV12M   v4l2_fourcc('N', 'M', '1', '2') /* 12  Y/CbCr 4:2:0  */
+#define V4L2_PIX_FMT_NV12MT  v4l2_fourcc('T', 'M', '1', '2') /* 12  Y/CbCr 4:2:0 64x32 macroblocks */
+
+/* three non contiguous planes - Y, Cb, Cr */
+#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12  YUV420 planar */
+
 /* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
 #define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B', 'A', '8', '1') /*  8  BGBG.. GRGR.. */
 #define V4L2_PIX_FMT_SGBRG8  v4l2_fourcc('G', 'B', 'R', 'G') /*  8  GBGB.. RGRG.. */
@@ -328,6 +360,10 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10  GBGB.. RGRG.. */
 #define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10  GRGR.. BGBG.. */
 #define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10  RGRG.. GBGB.. */
+#define V4L2_PIX_FMT_SBGGR12 v4l2_fourcc('B', 'G', '1', '2') /* 12  BGBG.. GRGR.. */
+#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12  GBGB.. RGRG.. */
+#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12  GRGR.. BGBG.. */
+#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12  RGRG.. GBGB.. */
        /* 10bit raw bayer DPCM compressed to 8 bits */
 #define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
        /*
@@ -363,6 +399,9 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_OV518    v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */
 #define V4L2_PIX_FMT_STV0680  v4l2_fourcc('S', '6', '8', '0') /* stv0680 bayer */
 #define V4L2_PIX_FMT_TM6000   v4l2_fourcc('T', 'M', '6', '0') /* tm5600/tm60x0 */
+#define V4L2_PIX_FMT_CIT_YYVYUY v4l2_fourcc('C', 'I', 'T', 'V') /* one line of Y then 1 line of VYUY */
+#define V4L2_PIX_FMT_KONICA420  v4l2_fourcc('K', 'O', 'N', 'I') /* YUV420 planar in blocks of 256 pixels */
+#define V4L2_PIX_FMT_JPGL      v4l2_fourcc('J', 'P', 'G', 'L') /* JPEG-Lite */
 
 /*
  *     F O R M A T   E N U M E R A T I O N
@@ -515,6 +554,62 @@ struct v4l2_requestbuffers {
        __u32                   reserved[2];
 };
 
+/**
+ * struct v4l2_plane - plane info for multi-planar buffers
+ * @bytesused:         number of bytes occupied by data in the plane (payload)
+ * @length:            size of this plane (NOT the payload) in bytes
+ * @mem_offset:                when memory in the associated struct v4l2_buffer is
+ *                     V4L2_MEMORY_MMAP, equals the offset from the start of
+ *                     the device memory for this plane (or is a "cookie" that
+ *                     should be passed to mmap() called on the video node)
+ * @userptr:           when memory is V4L2_MEMORY_USERPTR, a userspace pointer
+ *                     pointing to this plane
+ * @data_offset:       offset in the plane to the start of data; usually 0,
+ *                     unless there is a header in front of the data
+ *
+ * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
+ * with two planes can have one plane for Y, and another for interleaved CbCr
+ * components. Each plane can reside in a separate memory buffer, or even in
+ * a completely separate memory node (e.g. in embedded devices).
+ */
+struct v4l2_plane {
+       __u32                   bytesused;
+       __u32                   length;
+       union {
+               __u32           mem_offset;
+               unsigned long   userptr;
+       } m;
+       __u32                   data_offset;
+       __u32                   reserved[11];
+};
+
+/**
+ * struct v4l2_buffer - video buffer info
+ * @index:     id number of the buffer
+ * @type:      buffer type (type == *_MPLANE for multiplanar buffers)
+ * @bytesused: number of bytes occupied by data in the buffer (payload);
+ *             unused (set to 0) for multiplanar buffers
+ * @flags:     buffer informational flags
+ * @field:     field order of the image in the buffer
+ * @timestamp: frame timestamp
+ * @timecode:  frame timecode
+ * @sequence:  sequence count of this frame
+ * @memory:    the method, in which the actual video data is passed
+ * @offset:    for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
+ *             offset from the start of the device memory for this plane,
+ *             (or a "cookie" that should be passed to mmap() as offset)
+ * @userptr:   for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
+ *             a userspace pointer pointing to this buffer
+ * @planes:    for multiplanar buffers; userspace pointer to the array of plane
+ *             info structs for this buffer
+ * @length:    size in bytes of the buffer (NOT its payload) for single-plane
+ *             buffers (when type != *_MPLANE); number of elements in the
+ *             planes array for multi-plane buffers
+ * @input:     input number from which the video data has has been captured
+ *
+ * Contains data exchanged by application and driver using one of the Streaming
+ * I/O methods.
+ */
 struct v4l2_buffer {
        __u32                   index;
        enum v4l2_buf_type      type;
@@ -530,6 +625,7 @@ struct v4l2_buffer {
        union {
                __u32           offset;
                unsigned long   userptr;
+               struct v4l2_plane *planes;
        } m;
        __u32                   length;
        __u32                   input;
@@ -1045,8 +1141,11 @@ enum v4l2_colorfx {
 
 #define V4L2_CID_CHROMA_GAIN                    (V4L2_CID_BASE+36)
 
+#define V4L2_CID_ILLUMINATORS_1                        (V4L2_CID_BASE+37)
+#define V4L2_CID_ILLUMINATORS_2                        (V4L2_CID_BASE+38)
+
 /* last CID + 1 */
-#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+37)
+#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+39)
 
 /*  MPEG-class control IDs defined by V4L2 */
 #define V4L2_CID_MPEG_BASE                     (V4L2_CTRL_CLASS_MPEG | 0x900)
@@ -1370,6 +1469,8 @@ struct v4l2_modulator {
 #define V4L2_TUNER_CAP_SAP             0x0020
 #define V4L2_TUNER_CAP_LANG1           0x0040
 #define V4L2_TUNER_CAP_RDS             0x0080
+#define V4L2_TUNER_CAP_RDS_BLOCK_IO    0x0100
+#define V4L2_TUNER_CAP_RDS_CONTROLS    0x0200
 
 /*  Flags for the 'rxsubchans' field */
 #define V4L2_TUNER_SUB_MONO            0x0001
@@ -1399,7 +1500,8 @@ struct v4l2_hw_freq_seek {
        enum v4l2_tuner_type  type;
        __u32                 seek_upward;
        __u32                 wrap_around;
-       __u32                 reserved[8];
+       __u32                 spacing;
+       __u32                 reserved[7];
 };
 
 /*
@@ -1621,12 +1723,56 @@ struct v4l2_mpeg_vbi_fmt_ivtv {
  *     A G G R E G A T E   S T R U C T U R E S
  */
 
-/*     Stream data format
+/**
+ * struct v4l2_plane_pix_format - additional, per-plane format definition
+ * @sizeimage:         maximum size in bytes required for data, for which
+ *                     this plane will be used
+ * @bytesperline:      distance in bytes between the leftmost pixels in two
+ *                     adjacent lines
+ */
+struct v4l2_plane_pix_format {
+       __u32           sizeimage;
+       __u16           bytesperline;
+       __u16           reserved[7];
+} __attribute__ ((packed));
+
+/**
+ * struct v4l2_pix_format_mplane - multiplanar format definition
+ * @width:             image width in pixels
+ * @height:            image height in pixels
+ * @pixelformat:       little endian four character code (fourcc)
+ * @field:             field order (for interlaced video)
+ * @colorspace:                supplemental to pixelformat
+ * @plane_fmt:         per-plane information
+ * @num_planes:                number of planes for this format
+ */
+struct v4l2_pix_format_mplane {
+       __u32                           width;
+       __u32                           height;
+       __u32                           pixelformat;
+       enum v4l2_field                 field;
+       enum v4l2_colorspace            colorspace;
+
+       struct v4l2_plane_pix_format    plane_fmt[VIDEO_MAX_PLANES];
+       __u8                            num_planes;
+       __u8                            reserved[11];
+} __attribute__ ((packed));
+
+/**
+ * struct v4l2_format - stream data format
+ * @type:      type of the data stream
+ * @pix:       definition of an image format
+ * @pix_mp:    definition of a multiplanar image format
+ * @win:       definition of an overlaid image
+ * @vbi:       raw VBI capture or output parameters
+ * @sliced:    sliced VBI capture or output parameters
+ * @raw_data:  placeholder for future extensions and custom formats
  */
 struct v4l2_format {
        enum v4l2_buf_type type;
        union {
                struct v4l2_pix_format          pix;     /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
+               struct v4l2_pix_format_mplane   pix_mp;  /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
                struct v4l2_window              win;     /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
                struct v4l2_vbi_format          vbi;     /* V4L2_BUF_TYPE_VBI_CAPTURE */
                struct v4l2_sliced_vbi_format   sliced;  /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
@@ -1634,7 +1780,6 @@ struct v4l2_format {
        } fmt;
 };
 
-
 /*     Stream type-dependent parameters
  */
 struct v4l2_streamparm {
@@ -1807,16 +1952,6 @@ struct v4l2_dbg_chip_ident {
 /* Reminder: when adding new ioctls please add support for them to
    drivers/media/video/v4l2-compat-ioctl32.c as well! */
 
-#ifdef __OLD_VIDIOC_
-/* for compatibility, will go away some day */
-#define VIDIOC_OVERLAY_OLD             _IOWR('V', 14, int)
-#define VIDIOC_S_PARM_OLD               _IOW('V', 22, struct v4l2_streamparm)
-#define VIDIOC_S_CTRL_OLD               _IOW('V', 28, struct v4l2_control)
-#define VIDIOC_G_AUDIO_OLD             _IOWR('V', 33, struct v4l2_audio)
-#define VIDIOC_G_AUDOUT_OLD            _IOWR('V', 49, struct v4l2_audioout)
-#define VIDIOC_CROPCAP_OLD              _IOR('V', 58, struct v4l2_cropcap)
-#endif
-
 #define BASE_VIDIOC_PRIVATE    192             /* 192-255 are private */
 
 #endif /* __LINUX_VIDEODEV2_H */