aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/videodev2.h
diff options
context:
space:
mode:
authorPawel Osciak <p.osciak@samsung.com>2010-07-29 13:44:25 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 19:31:33 -0400
commitf8f3914cf922f5f9e1d60e9e10f6fb92742907ad (patch)
tree41441ca44b6dc88a18a1886935aa83b2f9ac30b4 /include/linux/videodev2.h
parent4ec02ea0d88d811f61e2c7765418eff770936871 (diff)
[media] v4l: Add multi-planar API definitions to the V4L2 API
Multi-planar API is as a backwards-compatible extension of the V4L2 API, which allows video buffers to consist of one or more planes. Planes are separate memory buffers; each has its own mapping, backed by usually separate physical memory buffers. Many different uses for the multi-planar API are possible, examples include: - embedded devices requiring video components to be placed in physically separate buffers, e.g. for Samsung S3C/S5P SoC series' video codec, Y and interleaved Cb/Cr components reside in buffers in different memory banks; - applications may receive (or choose to store) video data of one video buffer in separate memory buffers; such data would have to be temporarily copied together into one buffer before passing it to a V4L2 device; - applications or drivers may want to pass metadata related to a buffer and it may not be possible to place it in the same buffer, together with video data. [mchehab@redhat.com: CodingStyle fixes] Signed-off-by: Pawel Osciak <p.osciak@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/linux/videodev2.h')
-rw-r--r--include/linux/videodev2.h124
1 files changed, 122 insertions, 2 deletions
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 5f6f47044abf..bb0a3ae2ebd0 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -70,6 +70,7 @@
70 * Moved from videodev.h 70 * Moved from videodev.h
71 */ 71 */
72#define VIDEO_MAX_FRAME 32 72#define VIDEO_MAX_FRAME 32
73#define VIDEO_MAX_PLANES 8
73 74
74#ifndef __KERNEL__ 75#ifndef __KERNEL__
75 76
@@ -157,9 +158,23 @@ enum v4l2_buf_type {
157 /* Experimental */ 158 /* Experimental */
158 V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8, 159 V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
159#endif 160#endif
161 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
162 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
160 V4L2_BUF_TYPE_PRIVATE = 0x80, 163 V4L2_BUF_TYPE_PRIVATE = 0x80,
161}; 164};
162 165
166#define V4L2_TYPE_IS_MULTIPLANAR(type) \
167 ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \
168 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
169
170#define V4L2_TYPE_IS_OUTPUT(type) \
171 ((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT \
172 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE \
173 || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY \
174 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY \
175 || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \
176 || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT)
177
163enum v4l2_tuner_type { 178enum v4l2_tuner_type {
164 V4L2_TUNER_RADIO = 1, 179 V4L2_TUNER_RADIO = 1,
165 V4L2_TUNER_ANALOG_TV = 2, 180 V4L2_TUNER_ANALOG_TV = 2,
@@ -245,6 +260,11 @@ struct v4l2_capability {
245#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */ 260#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */
246#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */ 261#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */
247 262
263/* Is a video capture device that supports multiplanar formats */
264#define V4L2_CAP_VIDEO_CAPTURE_MPLANE 0x00001000
265/* Is a video output device that supports multiplanar formats */
266#define V4L2_CAP_VIDEO_OUTPUT_MPLANE 0x00002000
267
248#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ 268#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
249#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ 269#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
250#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ 270#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
@@ -517,6 +537,62 @@ struct v4l2_requestbuffers {
517 __u32 reserved[2]; 537 __u32 reserved[2];
518}; 538};
519 539
540/**
541 * struct v4l2_plane - plane info for multi-planar buffers
542 * @bytesused: number of bytes occupied by data in the plane (payload)
543 * @length: size of this plane (NOT the payload) in bytes
544 * @mem_offset: when memory in the associated struct v4l2_buffer is
545 * V4L2_MEMORY_MMAP, equals the offset from the start of
546 * the device memory for this plane (or is a "cookie" that
547 * should be passed to mmap() called on the video node)
548 * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
549 * pointing to this plane
550 * @data_offset: offset in the plane to the start of data; usually 0,
551 * unless there is a header in front of the data
552 *
553 * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
554 * with two planes can have one plane for Y, and another for interleaved CbCr
555 * components. Each plane can reside in a separate memory buffer, or even in
556 * a completely separate memory node (e.g. in embedded devices).
557 */
558struct v4l2_plane {
559 __u32 bytesused;
560 __u32 length;
561 union {
562 __u32 mem_offset;
563 unsigned long userptr;
564 } m;
565 __u32 data_offset;
566 __u32 reserved[11];
567};
568
569/**
570 * struct v4l2_buffer - video buffer info
571 * @index: id number of the buffer
572 * @type: buffer type (type == *_MPLANE for multiplanar buffers)
573 * @bytesused: number of bytes occupied by data in the buffer (payload);
574 * unused (set to 0) for multiplanar buffers
575 * @flags: buffer informational flags
576 * @field: field order of the image in the buffer
577 * @timestamp: frame timestamp
578 * @timecode: frame timecode
579 * @sequence: sequence count of this frame
580 * @memory: the method, in which the actual video data is passed
581 * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
582 * offset from the start of the device memory for this plane,
583 * (or a "cookie" that should be passed to mmap() as offset)
584 * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
585 * a userspace pointer pointing to this buffer
586 * @planes: for multiplanar buffers; userspace pointer to the array of plane
587 * info structs for this buffer
588 * @length: size in bytes of the buffer (NOT its payload) for single-plane
589 * buffers (when type != *_MPLANE); number of elements in the
590 * planes array for multi-plane buffers
591 * @input: input number from which the video data has has been captured
592 *
593 * Contains data exchanged by application and driver using one of the Streaming
594 * I/O methods.
595 */
520struct v4l2_buffer { 596struct v4l2_buffer {
521 __u32 index; 597 __u32 index;
522 enum v4l2_buf_type type; 598 enum v4l2_buf_type type;
@@ -532,6 +608,7 @@ struct v4l2_buffer {
532 union { 608 union {
533 __u32 offset; 609 __u32 offset;
534 unsigned long userptr; 610 unsigned long userptr;
611 struct v4l2_plane *planes;
535 } m; 612 } m;
536 __u32 length; 613 __u32 length;
537 __u32 input; 614 __u32 input;
@@ -1622,12 +1699,56 @@ struct v4l2_mpeg_vbi_fmt_ivtv {
1622 * A G G R E G A T E S T R U C T U R E S 1699 * A G G R E G A T E S T R U C T U R E S
1623 */ 1700 */
1624 1701
1625/* Stream data format 1702/**
1703 * struct v4l2_plane_pix_format - additional, per-plane format definition
1704 * @sizeimage: maximum size in bytes required for data, for which
1705 * this plane will be used
1706 * @bytesperline: distance in bytes between the leftmost pixels in two
1707 * adjacent lines
1708 */
1709struct v4l2_plane_pix_format {
1710 __u32 sizeimage;
1711 __u16 bytesperline;
1712 __u16 reserved[7];
1713} __attribute__ ((packed));
1714
1715/**
1716 * struct v4l2_pix_format_mplane - multiplanar format definition
1717 * @width: image width in pixels
1718 * @height: image height in pixels
1719 * @pixelformat: little endian four character code (fourcc)
1720 * @field: field order (for interlaced video)
1721 * @colorspace: supplemental to pixelformat
1722 * @plane_fmt: per-plane information
1723 * @num_planes: number of planes for this format
1724 */
1725struct v4l2_pix_format_mplane {
1726 __u32 width;
1727 __u32 height;
1728 __u32 pixelformat;
1729 enum v4l2_field field;
1730 enum v4l2_colorspace colorspace;
1731
1732 struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
1733 __u8 num_planes;
1734 __u8 reserved[11];
1735} __attribute__ ((packed));
1736
1737/**
1738 * struct v4l2_format - stream data format
1739 * @type: type of the data stream
1740 * @pix: definition of an image format
1741 * @pix_mp: definition of a multiplanar image format
1742 * @win: definition of an overlaid image
1743 * @vbi: raw VBI capture or output parameters
1744 * @sliced: sliced VBI capture or output parameters
1745 * @raw_data: placeholder for future extensions and custom formats
1626 */ 1746 */
1627struct v4l2_format { 1747struct v4l2_format {
1628 enum v4l2_buf_type type; 1748 enum v4l2_buf_type type;
1629 union { 1749 union {
1630 struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */ 1750 struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
1751 struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
1631 struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */ 1752 struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
1632 struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */ 1753 struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
1633 struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ 1754 struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
@@ -1635,7 +1756,6 @@ struct v4l2_format {
1635 } fmt; 1756 } fmt;
1636}; 1757};
1637 1758
1638
1639/* Stream type-dependent parameters 1759/* Stream type-dependent parameters
1640 */ 1760 */
1641struct v4l2_streamparm { 1761struct v4l2_streamparm {