diff options
author | Pawel Osciak <pawel@osciak.com> | 2011-01-07 01:41:33 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 20:31:35 -0300 |
commit | 53b5d5749b6fcca37c7ad60cd40feafadd390b70 (patch) | |
tree | 136a77c82f6913607af0ac575d66880b12bc65d2 /Documentation/DocBook | |
parent | c4c0a78d459f2e4fcc7c4f3621a34e71ec7970d0 (diff) |
[media] Add multi-planar API documentation
Add DocBook documentation for the new multi-planar API extensions to the
Video for Linux 2 API DocBook.
Signed-off-by: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation/DocBook')
-rw-r--r-- | Documentation/DocBook/media-entities.tmpl | 4 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/common.xml | 2 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/compat.xml | 11 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/dev-capture.xml | 13 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/dev-output.xml | 13 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/func-mmap.xml | 10 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/func-munmap.xml | 3 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/io.xml | 247 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/pixfmt.xml | 116 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/planar-apis.xml | 81 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/v4l2.xml | 21 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/vidioc-enum-fmt.xml | 2 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/vidioc-g-fmt.xml | 15 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/vidioc-qbuf.xml | 24 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/vidioc-querybuf.xml | 14 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/vidioc-querycap.xml | 24 |
16 files changed, 530 insertions, 70 deletions
diff --git a/Documentation/DocBook/media-entities.tmpl b/Documentation/DocBook/media-entities.tmpl index be34dcbe0d9..74923d74553 100644 --- a/Documentation/DocBook/media-entities.tmpl +++ b/Documentation/DocBook/media-entities.tmpl @@ -129,6 +129,7 @@ <!ENTITY v4l2-audioout "struct <link linkend='v4l2-audioout'>v4l2_audioout</link>"> <!ENTITY v4l2-bt-timings "struct <link linkend='v4l2-bt-timings'>v4l2_bt_timings</link>"> <!ENTITY v4l2-buffer "struct <link linkend='v4l2-buffer'>v4l2_buffer</link>"> +<!ENTITY v4l2-plane "struct <link linkend='v4l2-plane'>v4l2_plane</link>"> <!ENTITY v4l2-capability "struct <link linkend='v4l2-capability'>v4l2_capability</link>"> <!ENTITY v4l2-captureparm "struct <link linkend='v4l2-captureparm'>v4l2_captureparm</link>"> <!ENTITY v4l2-clip "struct <link linkend='v4l2-clip'>v4l2_clip</link>"> @@ -167,6 +168,8 @@ <!ENTITY v4l2-output "struct <link linkend='v4l2-output'>v4l2_output</link>"> <!ENTITY v4l2-outputparm "struct <link linkend='v4l2-outputparm'>v4l2_outputparm</link>"> <!ENTITY v4l2-pix-format "struct <link linkend='v4l2-pix-format'>v4l2_pix_format</link>"> +<!ENTITY v4l2-pix-format-mplane "struct <link linkend='v4l2-pix-format-mplane'>v4l2_pix_format_mplane</link>"> +<!ENTITY v4l2-plane-pix-format "struct <link linkend='v4l2-plane-pix-format'>v4l2_plane_pix_format</link>"> <!ENTITY v4l2-queryctrl "struct <link linkend='v4l2-queryctrl'>v4l2_queryctrl</link>"> <!ENTITY v4l2-querymenu "struct <link linkend='v4l2-querymenu'>v4l2_querymenu</link>"> <!ENTITY v4l2-rect "struct <link linkend='v4l2-rect'>v4l2_rect</link>"> @@ -202,6 +205,7 @@ <!-- Subsections --> <!ENTITY sub-biblio SYSTEM "v4l/biblio.xml"> <!ENTITY sub-common SYSTEM "v4l/common.xml"> +<!ENTITY sub-planar-apis SYSTEM "v4l/planar-apis.xml"> <!ENTITY sub-compat SYSTEM "v4l/compat.xml"> <!ENTITY sub-controls SYSTEM "v4l/controls.xml"> <!ENTITY sub-dev-capture SYSTEM "v4l/dev-capture.xml"> diff --git a/Documentation/DocBook/v4l/common.xml b/Documentation/DocBook/v4l/common.xml index cea23e1c4fc..dbab79c215c 100644 --- a/Documentation/DocBook/v4l/common.xml +++ b/Documentation/DocBook/v4l/common.xml @@ -846,6 +846,8 @@ conversion routine or library for integration into applications.</para> </section> </section> + &sub-planar-apis; + <section id="crop"> <title>Image Cropping, Insertion and Scaling</title> diff --git a/Documentation/DocBook/v4l/compat.xml b/Documentation/DocBook/v4l/compat.xml index c9ce61d981f..223c24c536b 100644 --- a/Documentation/DocBook/v4l/compat.xml +++ b/Documentation/DocBook/v4l/compat.xml @@ -2353,6 +2353,17 @@ that used it. It was originally scheduled for removal in 2.6.35. </listitem> </orderedlist> </section> + <section> + <title>V4L2 in Linux 2.6.38</title> + <orderedlist> + <listitem> + <para>Multi-planar API added. Does not affect the compatibility of + current drivers and applications. See + <link linkend="planar-apis">multi-planar API</link> + for details.</para> + </listitem> + </orderedlist> + </section> <section id="other"> <title>Relation of V4L2 to other Linux multimedia APIs</title> diff --git a/Documentation/DocBook/v4l/dev-capture.xml b/Documentation/DocBook/v4l/dev-capture.xml index 32807e43f17..2237c661f26 100644 --- a/Documentation/DocBook/v4l/dev-capture.xml +++ b/Documentation/DocBook/v4l/dev-capture.xml @@ -18,7 +18,8 @@ files are used for video output devices.</para> <title>Querying Capabilities</title> <para>Devices supporting the video capture interface set the -<constant>V4L2_CAP_VIDEO_CAPTURE</constant> flag in the +<constant>V4L2_CAP_VIDEO_CAPTURE</constant> or +<constant>V4L2_CAP_VIDEO_CAPTURE_MPLANE</constant> flag in the <structfield>capabilities</structfield> field of &v4l2-capability; returned by the &VIDIOC-QUERYCAP; ioctl. As secondary device functions they may also support the <link linkend="overlay">video overlay</link> @@ -64,9 +65,11 @@ linkend="crop" />.</para> <para>To query the current image format applications set the <structfield>type</structfield> field of a &v4l2-format; to -<constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> and call the +<constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> or +<constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant> and call the &VIDIOC-G-FMT; ioctl with a pointer to this structure. Drivers fill -the &v4l2-pix-format; <structfield>pix</structfield> member of the +the &v4l2-pix-format; <structfield>pix</structfield> or the +&v4l2-pix-format-mplane; <structfield>pix_mp</structfield> member of the <structfield>fmt</structfield> union.</para> <para>To request different parameters applications set the @@ -84,8 +87,8 @@ adjust the parameters and finally return the actual parameters as without disabling I/O or possibly time consuming hardware preparations.</para> - <para>The contents of &v4l2-pix-format; are discussed in <xref -linkend="pixfmt" />. See also the specification of the + <para>The contents of &v4l2-pix-format; and &v4l2-pix-format-mplane; +are discussed in <xref linkend="pixfmt" />. See also the specification of the <constant>VIDIOC_G_FMT</constant>, <constant>VIDIOC_S_FMT</constant> and <constant>VIDIOC_TRY_FMT</constant> ioctls for details. Video capture devices must implement both the diff --git a/Documentation/DocBook/v4l/dev-output.xml b/Documentation/DocBook/v4l/dev-output.xml index 63c3c20e5a7..919e22c5385 100644 --- a/Documentation/DocBook/v4l/dev-output.xml +++ b/Documentation/DocBook/v4l/dev-output.xml @@ -17,7 +17,8 @@ files are used for video capture devices.</para> <title>Querying Capabilities</title> <para>Devices supporting the video output interface set the -<constant>V4L2_CAP_VIDEO_OUTPUT</constant> flag in the +<constant>V4L2_CAP_VIDEO_OUTPUT</constant> or +<constant>V4L2_CAP_VIDEO_OUTPUT_MPLANE</constant> flag in the <structfield>capabilities</structfield> field of &v4l2-capability; returned by the &VIDIOC-QUERYCAP; ioctl. As secondary device functions they may also support the <link linkend="raw-vbi">raw VBI @@ -60,9 +61,11 @@ linkend="crop" />.</para> <para>To query the current image format applications set the <structfield>type</structfield> field of a &v4l2-format; to -<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant> and call the +<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant> or +<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE</constant> and call the &VIDIOC-G-FMT; ioctl with a pointer to this structure. Drivers fill -the &v4l2-pix-format; <structfield>pix</structfield> member of the +the &v4l2-pix-format; <structfield>pix</structfield> or the +&v4l2-pix-format-mplane; <structfield>pix_mp</structfield> member of the <structfield>fmt</structfield> union.</para> <para>To request different parameters applications set the @@ -80,8 +83,8 @@ adjust the parameters and finally return the actual parameters as without disabling I/O or possibly time consuming hardware preparations.</para> - <para>The contents of &v4l2-pix-format; are discussed in <xref -linkend="pixfmt" />. See also the specification of the + <para>The contents of &v4l2-pix-format; and &v4l2-pix-format-mplane; +are discussed in <xref linkend="pixfmt" />. See also the specification of the <constant>VIDIOC_G_FMT</constant>, <constant>VIDIOC_S_FMT</constant> and <constant>VIDIOC_TRY_FMT</constant> ioctls for details. Video output devices must implement both the diff --git a/Documentation/DocBook/v4l/func-mmap.xml b/Documentation/DocBook/v4l/func-mmap.xml index 2e2fc3933ae..786732b64bb 100644 --- a/Documentation/DocBook/v4l/func-mmap.xml +++ b/Documentation/DocBook/v4l/func-mmap.xml @@ -45,7 +45,10 @@ just specify a <constant>NULL</constant> pointer here.</para> <listitem> <para>Length of the memory area to map. This must be the same value as returned by the driver in the &v4l2-buffer; -<structfield>length</structfield> field.</para> +<structfield>length</structfield> field for the +single-planar API, and the same value as returned by the driver +in the &v4l2-plane; <structfield>length</structfield> field for the +multi-planar API.</para> </listitem> </varlistentry> <varlistentry> @@ -106,7 +109,10 @@ flag.</para> <listitem> <para>Offset of the buffer in device memory. This must be the same value as returned by the driver in the &v4l2-buffer; -<structfield>m</structfield> union <structfield>offset</structfield> field.</para> +<structfield>m</structfield> union <structfield>offset</structfield> field for +the single-planar API, and the same value as returned by the driver +in the &v4l2-plane; <structfield>m</structfield> union +<structfield>mem_offset</structfield> field for the multi-planar API.</para> </listitem> </varlistentry> </variablelist> diff --git a/Documentation/DocBook/v4l/func-munmap.xml b/Documentation/DocBook/v4l/func-munmap.xml index 502ed49323b..e2c4190f9bb 100644 --- a/Documentation/DocBook/v4l/func-munmap.xml +++ b/Documentation/DocBook/v4l/func-munmap.xml @@ -37,7 +37,8 @@ <para>Length of the mapped buffer. This must be the same value as given to <function>mmap()</function> and returned by the driver in the &v4l2-buffer; <structfield>length</structfield> -field.</para> +field for the single-planar API and in the &v4l2-plane; +<structfield>length</structfield> field for the multi-planar API.</para> </listitem> </varlistentry> </variablelist> diff --git a/Documentation/DocBook/v4l/io.xml b/Documentation/DocBook/v4l/io.xml index a9750437000..227e7ac45a0 100644 --- a/Documentation/DocBook/v4l/io.xml +++ b/Documentation/DocBook/v4l/io.xml @@ -121,18 +121,22 @@ mapped.</para> <para>Before applications can access the buffers they must map them into their address space with the &func-mmap; function. The location of the buffers in device memory can be determined with the -&VIDIOC-QUERYBUF; ioctl. The <structfield>m.offset</structfield> and -<structfield>length</structfield> returned in a &v4l2-buffer; are -passed as sixth and second parameter to the -<function>mmap()</function> function. The offset and length values -must not be modified. Remember the buffers are allocated in physical -memory, as opposed to virtual memory which can be swapped out to disk. -Applications should free the buffers as soon as possible with the -&func-munmap; function.</para> +&VIDIOC-QUERYBUF; ioctl. In the single-planar API case, the +<structfield>m.offset</structfield> and <structfield>length</structfield> +returned in a &v4l2-buffer; are passed as sixth and second parameter to the +<function>mmap()</function> function. When using the multi-planar API, +struct &v4l2-buffer; contains an array of &v4l2-plane; structures, each +containing its own <structfield>m.offset</structfield> and +<structfield>length</structfield>. When using the multi-planar API, every +plane of every buffer has to be mapped separately, so the number of +calls to &func-mmap; should be equal to number of buffers times number of +planes in each buffer. The offset and length values must not be modified. +Remember, the buffers are allocated in physical memory, as opposed to virtual +memory, which can be swapped out to disk. Applications should free the buffers +as soon as possible with the &func-munmap; function.</para> <example> - <title>Mapping buffers</title> - + <title>Mapping buffers in the single-planar API</title> <programlisting> &v4l2-requestbuffers; reqbuf; struct { @@ -201,6 +205,88 @@ for (i = 0; i < reqbuf.count; i++) </programlisting> </example> + <example> + <title>Mapping buffers in the multi-planar API</title> + <programlisting> +&v4l2-requestbuffers; reqbuf; +/* Our current format uses 3 planes per buffer */ +#define FMT_NUM_PLANES = 3; + +struct { + void *start[FMT_NUM_PLANES]; + size_t length[FMT_NUM_PLANES]; +} *buffers; +unsigned int i, j; + +memset(&reqbuf, 0, sizeof(reqbuf)); +reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; +reqbuf.memory = V4L2_MEMORY_MMAP; +reqbuf.count = 20; + +if (ioctl(fd, &VIDIOC-REQBUFS;, &reqbuf) < 0) { + if (errno == EINVAL) + printf("Video capturing or mmap-streaming is not supported\n"); + else + perror("VIDIOC_REQBUFS"); + + exit(EXIT_FAILURE); +} + +/* We want at least five buffers. */ + +if (reqbuf.count < 5) { + /* You may need to free the buffers here. */ + printf("Not enough buffer memory\n"); + exit(EXIT_FAILURE); +} + +buffers = calloc(reqbuf.count, sizeof(*buffers)); +assert(buffers != NULL); + +for (i = 0; i < reqbuf.count; i++) { + &v4l2-buffer; buffer; + &v4l2-plane; planes[FMT_NUM_PLANES]; + + memset(&buffer, 0, sizeof(buffer)); + buffer.type = reqbuf.type; + buffer.memory = V4L2_MEMORY_MMAP; + buffer.index = i; + /* length in struct v4l2_buffer in multi-planar API stores the size + * of planes array. */ + buffer.length = FMT_NUM_PLANES; + buffer.m.planes = planes; + + if (ioctl(fd, &VIDIOC-QUERYBUF;, &buffer) < 0) { + perror("VIDIOC_QUERYBUF"); + exit(EXIT_FAILURE); + } + + /* Every plane has to be mapped separately */ + for (j = 0; j < FMT_NUM_PLANES; j++) { + buffers[i].length[j] = buffer.m.planes[j].length; /* remember for munmap() */ + + buffers[i].start[j] = mmap(NULL, buffer.m.planes[j].length, + PROT_READ | PROT_WRITE, /* recommended */ + MAP_SHARED, /* recommended */ + fd, buffer.m.planes[j].m.offset); + + if (MAP_FAILED == buffers[i].start[j]) { + /* If you do not exit here you should unmap() and free() + the buffers and planes mapped so far. */ + perror("mmap"); + exit(EXIT_FAILURE); + } + } +} + +/* Cleanup. */ + +for (i = 0; i < reqbuf.count; i++) + for (j = 0; j < FMT_NUM_PLANES; j++) + munmap(buffers[i].start[j], buffers[i].length[j]); + </programlisting> + </example> + <para>Conceptually streaming drivers maintain two buffer queues, an incoming and an outgoing queue. They separate the synchronous capture or output operation locked to a video clock from the application which is @@ -286,13 +372,13 @@ pointer method (not only memory mapping) is supported must be determined by calling the &VIDIOC-REQBUFS; ioctl.</para> <para>This I/O method combines advantages of the read/write and -memory mapping methods. Buffers are allocated by the application +memory mapping methods. Buffers (planes) are allocated by the application itself, and can reside for example in virtual or shared memory. Only pointers to data are exchanged, these pointers and meta-information -are passed in &v4l2-buffer;. The driver must be switched -into user pointer I/O mode by calling the &VIDIOC-REQBUFS; with the -desired buffer type. No buffers are allocated beforehands, -consequently they are not indexed and cannot be queried like mapped +are passed in &v4l2-buffer; (or in &v4l2-plane; in the multi-planar API case). +The driver must be switched into user pointer I/O mode by calling the +&VIDIOC-REQBUFS; with the desired buffer type. No buffers (planes) are allocated +beforehand, consequently they are not indexed and cannot be queried like mapped buffers with the <constant>VIDIOC_QUERYBUF</constant> ioctl.</para> <example> @@ -316,7 +402,7 @@ if (ioctl (fd, &VIDIOC-REQBUFS;, &reqbuf) == -1) { </programlisting> </example> - <para>Buffer addresses and sizes are passed on the fly with the + <para>Buffer (plane) addresses and sizes are passed on the fly with the &VIDIOC-QBUF; ioctl. Although buffers are commonly cycled, applications can pass different addresses and sizes at each <constant>VIDIOC_QBUF</constant> call. If required by the hardware the @@ -396,11 +482,18 @@ rest should be evident.</para> <title>Buffers</title> <para>A buffer contains data exchanged by application and -driver using one of the Streaming I/O methods. Only pointers to -buffers are exchanged, the data itself is not copied. These pointers, -together with meta-information like timestamps or field parity, are -stored in a struct <structname>v4l2_buffer</structname>, argument to -the &VIDIOC-QUERYBUF;, &VIDIOC-QBUF; and &VIDIOC-DQBUF; ioctl.</para> +driver using one of the Streaming I/O methods. In the multi-planar API, the +data is held in planes, while the buffer structure acts as a container +for the planes. Only pointers to buffers (planes) are exchanged, the data +itself is not copied. These pointers, together with meta-information like +timestamps or field parity, are stored in a struct +<structname>v4l2_buffer</structname>, argument to +the &VIDIOC-QUERYBUF;, &VIDIOC-QBUF; and &VIDIOC-DQBUF; ioctl. +In the multi-planar API, some plane-specific members of struct +<structname>v4l2_buffer</structname>, such as pointers and sizes for each +plane, are stored in struct <structname>v4l2_plane</structname> instead. +In that case, struct <structname>v4l2_buffer</structname> contains an array of +plane structures.</para> <para>Nominally timestamps refer to the first data byte transmitted. In practice however the wide range of hardware covered by the V4L2 API @@ -551,26 +644,40 @@ in accordance with the selected I/O method.</entry> <entry></entry> <entry>__u32</entry> <entry><structfield>offset</structfield></entry> - <entry>When <structfield>memory</structfield> is -<constant>V4L2_MEMORY_MMAP</constant> this is the offset of the buffer -from the start of the device memory. The value is returned by the -driver and apart of serving as parameter to the &func-mmap; function -not useful for applications. See <xref linkend="mmap" /> for details.</entry> + <entry>For the single-planar API and when +<structfield>memory</structfield> is <constant>V4L2_MEMORY_MMAP</constant> this +is the offset of the buffer from the start of the device memory. The value is +returned by the driver and apart of serving as parameter to the &func-mmap; +function not useful for applications. See <xref linkend="mmap" /> for details + </entry> </row> <row> <entry></entry> <entry>unsigned long</entry> <entry><structfield>userptr</structfield></entry> - <entry>When <structfield>memory</structfield> is -<constant>V4L2_MEMORY_USERPTR</constant> this is a pointer to the -buffer (casted to unsigned long type) in virtual memory, set by the -application. See <xref linkend="userp" /> for details.</entry> + <entry>For the single-planar API and when +<structfield>memory</structfield> is <constant>V4L2_MEMORY_USERPTR</constant> +this is a pointer to the buffer (casted to unsigned long type) in virtual +memory, set by the application. See <xref linkend="userp" /> for details. + </entry> + </row> + <row> + <entry></entry> + <entry>struct v4l2_plane</entry> + <entry><structfield>*planes</structfield></entry> + <entry>When using the multi-planar API, contains a userspace pointer + to an array of &v4l2-plane;. The size of the array should be put + in the <structfield>length</structfield> field of this + <structname>v4l2_buffer</structname> structure.</entry> </row> <row> <entry>__u32</entry> <entry><structfield>length</structfield></entry> <entry></entry> - <entry>Size of the buffer (not the payload) in bytes.</entry> + <entry>Size of the buffer (not the payload) in bytes for the + single-planar API. For the multi-planar API should contain the + number of elements in the <structfield>planes</structfield> array. + </entry> </row> <row> <entry>__u32</entry> @@ -596,6 +703,66 @@ should set this to 0.</entry> </tgroup> </table> + <table frame="none" pgwide="1" id="v4l2-plane"> + <title>struct <structname>v4l2_plane</structname></title> + <tgroup cols="4"> + &cs-ustr; + <tbody valign="top"> + <row> + <entry>__u32</entry> + <entry><structfield>bytesused</structfield></entry> + <entry></entry> + <entry>The number of bytes occupied by data in the plane + (its payload).</entry> + </row> + <row> + <entry>__u32</entry> + <entry><structfield>length</structfield></entry> + <entry></entry> + <entry>Size in bytes of the plane (not its payload).</entry> + </row> + <row> + <entry>union</entry> + <entry><structfield>m</structfield></entry> + <entry></entry> + <entry></entry> + </row> + <row> + <entry></entry> + <entry>__u32</entry> + <entry><structfield>mem_offset</structfield></entry> + <entry>When the memory type in the containing &v4l2-buffer; is + <constant>V4L2_MEMORY_MMAP</constant>, this is the value that + should be passed to &func-mmap;, similar to the + <structfield>offset</structfield> field in &v4l2-buffer;.</entry> + </row> + <row> + <entry></entry> + <entry>__unsigned long</entry> + <entry><structfield>userptr</structfield></entry> + <entry>When the memory type in the containing &v4l2-buffer; is + <constant>V4L2_MEMORY_USERPTR</constant>, this is a userspace + pointer to the memory allocated for this plane by an application. + </entry> + </row> + <row> + <entry>__u32</entry> + <entry><structfield>data_offset</structfield></entry> + <entry></entry> + <entry>Offset in bytes to video data in the plane, if applicable. + </entry> + </row> + <row> + <entry>__u32</entry> + <entry><structfield>reserved[11]</structfield></entry> + <entry></entry> + <entry>Reserved for future use. Should be zeroed by an + application.</entry> + </row> + </tbody> + </tgroup> + </table> + <table frame="none" pgwide="1" id="v4l2-buf-type"> <title>enum v4l2_buf_type</title> <tgroup cols="3"> @@ -604,13 +771,27 @@ should set this to 0.</entry> <row> <entry><constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant></entry> <entry>1</entry> - <entry>Buffer of a video capture stream, see <xref + <entry>Buffer of a single-planar video capture stream, see <xref + linkend="capture" />.</entry> + </row> + <row> + <entry><constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant> + </entry> + <entry>9</entry> + <entry>Buffer of a multi-planar video capture stream, see <xref linkend="capture" />.</entry> </row> <row> <entry><constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant></entry> <entry>2</entry> - <entry>Buffer of a video output stream, see <xref + <entry>Buffer of a single-planar video output stream, see <xref + linkend="output" />.</entry> + </row> + <row> + <entry><constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE</constant> + </entry> + <entry>10</entry> + <entry>Buffer of a multi-planar video output stream, see <xref linkend="output" />.</entry> </row> <row> diff --git a/Documentation/DocBook/v4l/pixfmt.xml b/Documentation/DocBook/v4l/pixfmt.xml index cfffc88d738..28f9c700f75 100644 --- a/Documentation/DocBook/v4l/pixfmt.xml +++ b/Documentation/DocBook/v4l/pixfmt.xml @@ -2,12 +2,16 @@ <para>The V4L2 API was primarily designed for devices exchanging image data with applications. The -<structname>v4l2_pix_format</structname> structure defines the format -and layout of an image in memory. Image formats are negotiated with -the &VIDIOC-S-FMT; ioctl. (The explanations here focus on video +<structname>v4l2_pix_format</structname> and <structname>v4l2_pix_format_mplane +</structname> structures define the format and layout of an image in memory. +The former is used with the single-planar API, while the latter is used with the +multi-planar version (see <xref linkend="planar-apis"/>). Image formats are +negotiated with the &VIDIOC-S-FMT; ioctl. (The explanations here focus on video capturing and output, for overlay frame buffer formats see also &VIDIOC-G-FBUF;.)</para> +<section> + <title>Single-planar format structure</title> <table pgwide="1" frame="none" id="v4l2-pix-format"> <title>struct <structname>v4l2_pix_format</structname></title> <tgroup cols="3"> @@ -106,6 +110,98 @@ set this field to zero.</entry> </tbody> </tgroup> </table> +</section> + +<section> + <title>Multi-planar format structures</title> + <para>The <structname>v4l2_plane_pix_format</structname> structures define + size and layout for each of the planes in a multi-planar format. + The <structname>v4l2_pix_format_mplane</structname> structure contains + information common to all planes (such as image width and height) and + an array of <structname>v4l2_plane_pix_format</structname> structures, + describing all planes of that format.</para> + <table pgwide="1" frame="none" id="v4l2-plane-pix-format"> + <title>struct <structname>vl42_plane_pix_format</structname></title> + <tgroup cols="3"> + &cs-str; + <tbody valign="top"> + <row> + <entry>__u32</entry> + <entry><structfield>sizeimage</structfield></entry> + <entry>Maximum size in bytes required for image data in this plane. + </entry> + </row> + <row> + <entry>__u16</entry> + <entry><structfield>bytesperline</structfield></entry> + <entry>Distance in bytes between the leftmost pixels in two adjacent + lines.</entry> + </row> + <row> + <entry>__u16</entry> + <entry><structfield>reserved[7]</structfield></entry> + <entry>Reserved for future extensions. Should be zeroed by the + application.</entry> + </row> + </tbody> + </tgroup> + </table> + <table pgwide="1" frame="none" id="v4l2-pix-format-mplane"> + <title>struct <structname>v4l2_pix_format_mplane</structname></title> + <tgroup cols="3"> + &cs-str; + <tbody valign="top"> + <row> + <entry>__u32</entry> + <entry><structfield>width</structfield></entry> + <entry>Image width in pixels.</entry> + </row> + <row> + <entry>__u32</entry> + <entry><structfield>height</structfield></entry> + <entry>Image height in pixels.</entry> + </row> + <row> + <entry>__u32</entry> + <entry><structfield>pixelformat</structfield></entry> + <entry>The pixel format. Both single- and multi-planar four character +codes can be used.</entry> + </row> + <row> + <entry>&v4l2-field;</entry> + <entry><structfield>field</structfield></entry> + <entry>See &v4l2-pix-format;.</entry> + </row> + <row> + <entry>&v4l2-colorspace;</entry> + <entry><structfield>colorspace</structfield></entry> + <entry>See &v4l2-pix-format;.</entry> + </row> + <row> + <entry>&v4l2-plane-pix-format;</entry> + <entry><structfield>plane_fmt[VIDEO_MAX_PLANES]</structfield></entry> + <entry>An array of structures describing format of each plane this + pixel format consists of. The number of valid entries in this array + has to be put in the <structfield>num_planes</structfield> + field.</entry> + </row> + <row> + <entry>__u8</entry> + <entry><structfield>num_planes</structfield></entry> + <entry>Number of planes (i.e. separate memory buffers) for this format + and the number of valid entries in the + <structfield>plane_fmt</structfield> array.</entry> + </row> + <row> + <entry>__u8</entry> + <entry><structfield>reserved[11]</structfield></entry> + <entry>Reserved for future extensions. Should be zeroed by the + application.</entry> + </row> + </tbody> + </tgroup> + </table> +</section> <section> <title>Standard Image Formats</title> @@ -142,11 +238,19 @@ leftmost pixel of the second row from the top, and so on. The last row has just as many pad bytes after it as the other rows.</para> <para>In V4L2 each format has an identifier which looks like -<constant>PIX_FMT_XXX</constant>, defined in the <filename>videodev2.h</filename> -header file. These identifiers -represent <link linkend="v4l2-fourcc">four character codes</link> +<constant>PIX_FMT_XXX</constant>, defined in the <link +linkend="videodev">videodev.h</link> header file. These identifiers +represent <link linkend="v4l2-fourcc">four character (FourCC) codes</link> which are also listed below, however they are not the same as those used in the Windows world.</para> + + <para>For some formats, data is stored in separate, discontiguous +memory buffers. Those formats are identified by a separate set of FourCC codes +and are referred to as "multi-planar formats". For example, a YUV422 frame is +normally stored in one memory buffer, but it can also be placed in two or three +separate buffers, with Y component in one buffer and CbCr components in another +in the 2-planar version or with each component in its own buffer in the +3-planar case. Those sub-buffers are referred to as "planes".</para> </section> <section id="colorspaces"> diff --git a/Documentation/DocBook/v4l/planar-apis.xml b/Documentation/DocBook/v4l/planar-apis.xml new file mode 100644 index 00000000000..8be7552b37d --- /dev/null +++ b/Documentation/DocBook/v4l/planar-apis.xml @@ -0,0 +1,81 @@ +<section id="planar-apis"> + <title>Single- and multi-planar APIs</title> + + <para>Some devices require data for each input or output video frame + to be placed in discontiguous memory buffers. In such cases one + video frame has to be addressed using more than one memory address, i.e. one + pointer per "plane". A plane is a sub-buffer of current frame. For examples + of such formats see <xref linkend="pixfmt" />.</para> + + <para>Initially, V4L2 API did not support multi-planar buffers and a set of + extensions has been introduced to handle them. Those extensions constitute + what is being referred to as the "multi-planar API".</para> + + <para>Some of the V4L2 API calls and structures are interpreted differently, + depending on whether single- or multi-planar API is being used. An application + can choose whether to use one or the other by passing a corresponding buffer + type to its ioctl calls. Multi-planar versions of buffer types are suffixed with + an `_MPLANE' string. For a list of available multi-planar buffer types |