1 <refentry id="vidioc-reqbufs">
3 <refentrytitle>ioctl VIDIOC_REQBUFS</refentrytitle>
8 <refname>VIDIOC_REQBUFS</refname>
9 <refpurpose>Initiate Memory Mapping or User Pointer I/O</refpurpose>
15 <funcdef>int <function>ioctl</function></funcdef>
16 <paramdef>int <parameter>fd</parameter></paramdef>
17 <paramdef>int <parameter>request</parameter></paramdef>
18 <paramdef>struct v4l2_requestbuffers *<parameter>argp</parameter></paramdef>
24 <title>Arguments</title>
28 <term><parameter>fd</parameter></term>
34 <term><parameter>request</parameter></term>
36 <para>VIDIOC_REQBUFS</para>
40 <term><parameter>argp</parameter></term>
49 <title>Description</title>
51 <para>This ioctl is used to initiate <link linkend="mmap">memory
52 mapped</link> or <link linkend="userp">user pointer</link>
53 I/O. Memory mapped buffers are located in device memory and must be
54 allocated with this ioctl before they can be mapped into the
55 application's address space. User buffers are allocated by
56 applications themselves, and this ioctl is merely used to switch the
57 driver into user pointer I/O mode.</para>
59 <para>To allocate device buffers applications initialize three
60 fields of a <structname>v4l2_requestbuffers</structname> structure.
61 They set the <structfield>type</structfield> field to the respective
62 stream or buffer type, the <structfield>count</structfield> field to
63 the desired number of buffers, and <structfield>memory</structfield>
64 must be set to <constant>V4L2_MEMORY_MMAP</constant>. When the ioctl
65 is called with a pointer to this structure the driver attempts to
66 allocate the requested number of buffers and stores the actual number
67 allocated in the <structfield>count</structfield> field. It can be
68 smaller than the number requested, even zero, when the driver runs out
69 of free memory. A larger number is possible when the driver requires
70 more buffers to function correctly.<footnote>
71 <para>For example video output requires at least two buffers,
72 one displayed and one filled by the application.</para>
73 </footnote> When memory mapping I/O is not supported the ioctl
74 returns an &EINVAL;.</para>
76 <para>Applications can call <constant>VIDIOC_REQBUFS</constant>
77 again to change the number of buffers, however this cannot succeed
78 when any buffers are still mapped. A <structfield>count</structfield>
79 value of zero frees all buffers, after aborting or finishing any DMA
80 in progress, an implicit &VIDIOC-STREAMOFF;. <!-- mhs: I see no
81 reason why munmap()ping one or even all buffers must imply
84 <para>To negotiate user pointer I/O, applications initialize only
85 the <structfield>type</structfield> field and set
86 <structfield>memory</structfield> to
87 <constant>V4L2_MEMORY_USERPTR</constant>. When the ioctl is called
88 with a pointer to this structure the driver prepares for user pointer
89 I/O, when this I/O method is not supported the ioctl returns an
92 <table pgwide="1" frame="none" id="v4l2-requestbuffers">
93 <title>struct <structname>v4l2_requestbuffers</structname></title>
99 <entry><structfield>count</structfield></entry>
100 <entry>The number of buffers requested or granted. This
101 field is only used when <structfield>memory</structfield> is set to
102 <constant>V4L2_MEMORY_MMAP</constant>.</entry>
105 <entry>&v4l2-buf-type;</entry>
106 <entry><structfield>type</structfield></entry>
107 <entry>Type of the stream or buffers, this is the same
108 as the &v4l2-format; <structfield>type</structfield> field. See <xref
109 linkend="v4l2-buf-type" /> for valid values.</entry>
112 <entry>&v4l2-memory;</entry>
113 <entry><structfield>memory</structfield></entry>
114 <entry>Applications set this field to
115 <constant>V4L2_MEMORY_MMAP</constant> or
116 <constant>V4L2_MEMORY_USERPTR</constant>.</entry>
120 <entry><structfield>reserved</structfield>[2]</entry>
121 <entry>A place holder for future extensions and custom
122 (driver defined) buffer types <constant>V4L2_BUF_TYPE_PRIVATE</constant> and
135 <term><errorcode>EBUSY</errorcode></term>
137 <para>The driver supports multiple opens and I/O is already
138 in progress, or reallocation of buffers was attempted although one or
139 more are still mapped.</para>
143 <term><errorcode>EINVAL</errorcode></term>
145 <para>The buffer type (<structfield>type</structfield> field) or the
146 requested I/O method (<structfield>memory</structfield>) is not
157 sgml-parent-document: "v4l2.sgml"
158 indent-tabs-mode: nil