Commit 995f5fef authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB: media-spec: Fix documentation mistakes regarding I/O streaming

The media spec contains several errors in the description of the
I/O streaming ioctls, in particular with respect to the userptr
I/O method.

The most important change is that you really need to set count
and index in v4l2_requestbuffer and v4l2_buffer when dealing with
user pointer streaming.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 340dde81
...@@ -589,7 +589,8 @@ number of a video input as in &v4l2-input; field ...@@ -589,7 +589,8 @@ number of a video input as in &v4l2-input; field
<entry></entry> <entry></entry>
<entry>A place holder for future extensions and custom <entry>A place holder for future extensions and custom
(driver defined) buffer types (driver defined) buffer types
<constant>V4L2_BUF_TYPE_PRIVATE</constant> and higher.</entry> <constant>V4L2_BUF_TYPE_PRIVATE</constant> and higher. Applications
should set this to 0.</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
......
...@@ -54,12 +54,10 @@ to enqueue an empty (capturing) or filled (output) buffer in the ...@@ -54,12 +54,10 @@ to enqueue an empty (capturing) or filled (output) buffer in the
driver's incoming queue. The semantics depend on the selected I/O driver's incoming queue. The semantics depend on the selected I/O
method.</para> method.</para>
<para>To enqueue a <link linkend="mmap">memory mapped</link> <para>To enqueue a buffer applications set the <structfield>type</structfield>
buffer applications set the <structfield>type</structfield> field of a field of a &v4l2-buffer; to the same buffer type as was previously used
&v4l2-buffer; to the same buffer type as previously &v4l2-format; with &v4l2-format; <structfield>type</structfield> and &v4l2-requestbuffers;
<structfield>type</structfield> and &v4l2-requestbuffers; <structfield>type</structfield>. Applications must also set the
<structfield>type</structfield>, the <structfield>memory</structfield>
field to <constant>V4L2_MEMORY_MMAP</constant> and the
<structfield>index</structfield> field. Valid index numbers range from <structfield>index</structfield> field. Valid index numbers range from
zero to the number of buffers allocated with &VIDIOC-REQBUFS; zero to the number of buffers allocated with &VIDIOC-REQBUFS;
(&v4l2-requestbuffers; <structfield>count</structfield>) minus one. The (&v4l2-requestbuffers; <structfield>count</structfield>) minus one. The
...@@ -70,8 +68,19 @@ intended for output (<structfield>type</structfield> is ...@@ -70,8 +68,19 @@ intended for output (<structfield>type</structfield> is
<constant>V4L2_BUF_TYPE_VBI_OUTPUT</constant>) applications must also <constant>V4L2_BUF_TYPE_VBI_OUTPUT</constant>) applications must also
initialize the <structfield>bytesused</structfield>, initialize the <structfield>bytesused</structfield>,
<structfield>field</structfield> and <structfield>field</structfield> and
<structfield>timestamp</structfield> fields. See <xref <structfield>timestamp</structfield> fields, see <xref
linkend="buffer" /> for details. When linkend="buffer" /> for details.
Applications must also set <structfield>flags</structfield> to 0. If a driver
supports capturing from specific video inputs and you want to specify a video
input, then <structfield>flags</structfield> should be set to
<constant>V4L2_BUF_FLAG_INPUT</constant> and the field
<structfield>input</structfield> must be initialized to the desired input.
The <structfield>reserved</structfield> field must be set to 0.
</para>
<para>To enqueue a <link linkend="mmap">memory mapped</link>
buffer applications set the <structfield>memory</structfield>
field to <constant>V4L2_MEMORY_MMAP</constant>. When
<constant>VIDIOC_QBUF</constant> is called with a pointer to this <constant>VIDIOC_QBUF</constant> is called with a pointer to this
structure the driver sets the structure the driver sets the
<constant>V4L2_BUF_FLAG_MAPPED</constant> and <constant>V4L2_BUF_FLAG_MAPPED</constant> and
...@@ -81,14 +90,10 @@ structure the driver sets the ...@@ -81,14 +90,10 @@ structure the driver sets the
&EINVAL;.</para> &EINVAL;.</para>
<para>To enqueue a <link linkend="userp">user pointer</link> <para>To enqueue a <link linkend="userp">user pointer</link>
buffer applications set the <structfield>type</structfield> field of a buffer applications set the <structfield>memory</structfield>
&v4l2-buffer; to the same buffer type as previously &v4l2-format; field to <constant>V4L2_MEMORY_USERPTR</constant>, the
<structfield>type</structfield> and &v4l2-requestbuffers;
<structfield>type</structfield>, the <structfield>memory</structfield>
field to <constant>V4L2_MEMORY_USERPTR</constant> and the
<structfield>m.userptr</structfield> field to the address of the <structfield>m.userptr</structfield> field to the address of the
buffer and <structfield>length</structfield> to its size. When the buffer and <structfield>length</structfield> to its size.
buffer is intended for output additional fields must be set as above.
When <constant>VIDIOC_QBUF</constant> is called with a pointer to this When <constant>VIDIOC_QBUF</constant> is called with a pointer to this
structure the driver sets the <constant>V4L2_BUF_FLAG_QUEUED</constant> structure the driver sets the <constant>V4L2_BUF_FLAG_QUEUED</constant>
flag and clears the <constant>V4L2_BUF_FLAG_MAPPED</constant> and flag and clears the <constant>V4L2_BUF_FLAG_MAPPED</constant> and
...@@ -96,13 +101,14 @@ flag and clears the <constant>V4L2_BUF_FLAG_MAPPED</constant> and ...@@ -96,13 +101,14 @@ flag and clears the <constant>V4L2_BUF_FLAG_MAPPED</constant> and
<structfield>flags</structfield> field, or it returns an error code. <structfield>flags</structfield> field, or it returns an error code.
This ioctl locks the memory pages of the buffer in physical memory, This ioctl locks the memory pages of the buffer in physical memory,
they cannot be swapped out to disk. Buffers remain locked until they cannot be swapped out to disk. Buffers remain locked until
dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl are dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is
called, or until the device is closed.</para> called, or until the device is closed.</para>
<para>Applications call the <constant>VIDIOC_DQBUF</constant> <para>Applications call the <constant>VIDIOC_DQBUF</constant>
ioctl to dequeue a filled (capturing) or displayed (output) buffer ioctl to dequeue a filled (capturing) or displayed (output) buffer
from the driver's outgoing queue. They just set the from the driver's outgoing queue. They just set the
<structfield>type</structfield> and <structfield>memory</structfield> <structfield>type</structfield>, <structfield>memory</structfield>
and <structfield>reserved</structfield>
fields of a &v4l2-buffer; as above, when <constant>VIDIOC_DQBUF</constant> fields of a &v4l2-buffer; as above, when <constant>VIDIOC_DQBUF</constant>
is called with a pointer to this structure the driver fills the is called with a pointer to this structure the driver fills the
remaining fields or returns an error code.</para> remaining fields or returns an error code.</para>
......
...@@ -54,12 +54,13 @@ buffer at any time after buffers have been allocated with the ...@@ -54,12 +54,13 @@ buffer at any time after buffers have been allocated with the
&VIDIOC-REQBUFS; ioctl.</para> &VIDIOC-REQBUFS; ioctl.</para>
<para>Applications set the <structfield>type</structfield> field <para>Applications set the <structfield>type</structfield> field
of a &v4l2-buffer; to the same buffer type as previously of a &v4l2-buffer; to the same buffer type as was previously used with
&v4l2-format; <structfield>type</structfield> and &v4l2-requestbuffers; &v4l2-format; <structfield>type</structfield> and &v4l2-requestbuffers;
<structfield>type</structfield>, and the <structfield>index</structfield> <structfield>type</structfield>, and the <structfield>index</structfield>
field. Valid index numbers range from zero field. Valid index numbers range from zero
to the number of buffers allocated with &VIDIOC-REQBUFS; to the number of buffers allocated with &VIDIOC-REQBUFS;
(&v4l2-requestbuffers; <structfield>count</structfield>) minus one. (&v4l2-requestbuffers; <structfield>count</structfield>) minus one.
The <structfield>reserved</structfield> field should to set to 0.
After calling <constant>VIDIOC_QUERYBUF</constant> with a pointer to After calling <constant>VIDIOC_QUERYBUF</constant> with a pointer to
this structure drivers return an error code or fill the rest of this structure drivers return an error code or fill the rest of
the structure.</para> the structure.</para>
...@@ -68,8 +69,8 @@ the structure.</para> ...@@ -68,8 +69,8 @@ the structure.</para>
<constant>V4L2_BUF_FLAG_MAPPED</constant>, <constant>V4L2_BUF_FLAG_MAPPED</constant>,
<constant>V4L2_BUF_FLAG_QUEUED</constant> and <constant>V4L2_BUF_FLAG_QUEUED</constant> and
<constant>V4L2_BUF_FLAG_DONE</constant> flags will be valid. The <constant>V4L2_BUF_FLAG_DONE</constant> flags will be valid. The
<structfield>memory</structfield> field will be set to <structfield>memory</structfield> field will be set to the current
<constant>V4L2_MEMORY_MMAP</constant>, the <structfield>m.offset</structfield> I/O method, the <structfield>m.offset</structfield>
contains the offset of the buffer from the start of the device memory, contains the offset of the buffer from the start of the device memory,
the <structfield>length</structfield> field its size. The driver may the <structfield>length</structfield> field its size. The driver may
or may not set the remaining fields and flags, they are meaningless in or may not set the remaining fields and flags, they are meaningless in
......
...@@ -54,23 +54,23 @@ I/O. Memory mapped buffers are located in device memory and must be ...@@ -54,23 +54,23 @@ I/O. Memory mapped buffers are located in device memory and must be
allocated with this ioctl before they can be mapped into the allocated with this ioctl before they can be mapped into the
application's address space. User buffers are allocated by application's address space. User buffers are allocated by
applications themselves, and this ioctl is merely used to switch the applications themselves, and this ioctl is merely used to switch the
driver into user pointer I/O mode.</para> driver into user pointer I/O mode and to setup some internal structures.</para>
<para>To allocate device buffers applications initialize three <para>To allocate device buffers applications initialize all
fields of a <structname>v4l2_requestbuffers</structname> structure. fields of the <structname>v4l2_requestbuffers</structname> structure.
They set the <structfield>type</structfield> field to the respective They set the <structfield>type</structfield> field to the respective
stream or buffer type, the <structfield>count</structfield> field to stream or buffer type, the <structfield>count</structfield> field to
the desired number of buffers, and <structfield>memory</structfield> the desired number of buffers, <structfield>memory</structfield>
must be set to <constant>V4L2_MEMORY_MMAP</constant>. When the ioctl must be set to the requested I/O method and the reserved array
is called with a pointer to this structure the driver attempts to must be zeroed. When the ioctl
allocate the requested number of buffers and stores the actual number is called with a pointer to this structure the driver will attempt to allocate
the requested number of buffers and it stores the actual number
allocated in the <structfield>count</structfield> field. It can be allocated in the <structfield>count</structfield> field. It can be
smaller than the number requested, even zero, when the driver runs out smaller than the number requested, even zero, when the driver runs out
of free memory. A larger number is possible when the driver requires of free memory. A larger number is also possible when the driver requires
more buffers to function correctly.<footnote> more buffers to function correctly. For example video output requires at least two buffers,
<para>For example video output requires at least two buffers,
one displayed and one filled by the application.</para> one displayed and one filled by the application.</para>
</footnote> When memory mapping I/O is not supported the ioctl <para>When the I/O method is not supported the ioctl
returns an &EINVAL;.</para> returns an &EINVAL;.</para>
<para>Applications can call <constant>VIDIOC_REQBUFS</constant> <para>Applications can call <constant>VIDIOC_REQBUFS</constant>
...@@ -81,14 +81,6 @@ in progress, an implicit &VIDIOC-STREAMOFF;. <!-- mhs: I see no ...@@ -81,14 +81,6 @@ in progress, an implicit &VIDIOC-STREAMOFF;. <!-- mhs: I see no
reason why munmap()ping one or even all buffers must imply reason why munmap()ping one or even all buffers must imply
streamoff.--></para> streamoff.--></para>
<para>To negotiate user pointer I/O, applications initialize only
the <structfield>type</structfield> field and set
<structfield>memory</structfield> to
<constant>V4L2_MEMORY_USERPTR</constant>. When the ioctl is called
with a pointer to this structure the driver prepares for user pointer
I/O, when this I/O method is not supported the ioctl returns an
&EINVAL;.</para>
<table pgwide="1" frame="none" id="v4l2-requestbuffers"> <table pgwide="1" frame="none" id="v4l2-requestbuffers">
<title>struct <structname>v4l2_requestbuffers</structname></title> <title>struct <structname>v4l2_requestbuffers</structname></title>
<tgroup cols="3"> <tgroup cols="3">
...@@ -97,9 +89,7 @@ I/O, when this I/O method is not supported the ioctl returns an ...@@ -97,9 +89,7 @@ I/O, when this I/O method is not supported the ioctl returns an
<row> <row>
<entry>__u32</entry> <entry>__u32</entry>
<entry><structfield>count</structfield></entry> <entry><structfield>count</structfield></entry>
<entry>The number of buffers requested or granted. This <entry>The number of buffers requested or granted.</entry>
field is only used when <structfield>memory</structfield> is set to
<constant>V4L2_MEMORY_MMAP</constant>.</entry>
</row> </row>
<row> <row>
<entry>&v4l2-buf-type;</entry> <entry>&v4l2-buf-type;</entry>
...@@ -120,7 +110,7 @@ as the &v4l2-format; <structfield>type</structfield> field. See <xref ...@@ -120,7 +110,7 @@ as the &v4l2-format; <structfield>type</structfield> field. See <xref
<entry><structfield>reserved</structfield>[2]</entry> <entry><structfield>reserved</structfield>[2]</entry>
<entry>A place holder for future extensions and custom <entry>A place holder for future extensions and custom
(driver defined) buffer types <constant>V4L2_BUF_TYPE_PRIVATE</constant> and (driver defined) buffer types <constant>V4L2_BUF_TYPE_PRIVATE</constant> and
higher.</entry> higher. This array should be zeroed by applications.</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment