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 and to setup some internal structures.</para>
59 <para>To allocate device buffers applications initialize all
60 fields of the <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, <structfield>memory</structfield>
64 must be set to the requested I/O method and the <structfield>reserved</structfield> array
65 must be zeroed. When the ioctl
66 is called with a pointer to this structure the driver will attempt to allocate
67 the requested number of buffers and it stores the actual number
68 allocated in the <structfield>count</structfield> field. It can be
69 smaller than the number requested, even zero, when the driver runs out
70 of free memory. A larger number is also possible when the driver requires
71 more buffers to function correctly. For example video output requires at least two buffers,
72 one displayed and one filled by the application.</para>
73 <para>When the I/O method 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 <table pgwide="1" frame="none" id="v4l2-requestbuffers">
85 <title>struct <structname>v4l2_requestbuffers</structname></title>
91 <entry><structfield>count</structfield></entry>
92 <entry>The number of buffers requested or granted.</entry>
95 <entry>&v4l2-buf-type;</entry>
96 <entry><structfield>type</structfield></entry>
97 <entry>Type of the stream or buffers, this is the same
98 as the &v4l2-format; <structfield>type</structfield> field. See <xref
99 linkend="v4l2-buf-type" /> for valid values.</entry>
102 <entry>&v4l2-memory;</entry>
103 <entry><structfield>memory</structfield></entry>
104 <entry>Applications set this field to
105 <constant>V4L2_MEMORY_MMAP</constant> or
106 <constant>V4L2_MEMORY_USERPTR</constant>.</entry>
110 <entry><structfield>reserved</structfield>[2]</entry>
111 <entry>A place holder for future extensions and custom
112 (driver defined) buffer types <constant>V4L2_BUF_TYPE_PRIVATE</constant> and
113 higher. This array should be zeroed by applications.</entry>
125 <term><errorcode>EINVAL</errorcode></term>
127 <para>The buffer type (<structfield>type</structfield> field) or the
128 requested I/O method (<structfield>memory</structfield>) is not