vidioc-reqbufs.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <refentry id="vidioc-reqbufs">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_REQBUFS</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_REQBUFS</refname>
  8. <refpurpose>Initiate Memory Mapping or User Pointer I/O</refpurpose>
  9. </refnamediv>
  10. <refsynopsisdiv>
  11. <funcsynopsis>
  12. <funcprototype>
  13. <funcdef>int <function>ioctl</function></funcdef>
  14. <paramdef>int <parameter>fd</parameter></paramdef>
  15. <paramdef>int <parameter>request</parameter></paramdef>
  16. <paramdef>struct v4l2_requestbuffers *<parameter>argp</parameter></paramdef>
  17. </funcprototype>
  18. </funcsynopsis>
  19. </refsynopsisdiv>
  20. <refsect1>
  21. <title>Arguments</title>
  22. <variablelist>
  23. <varlistentry>
  24. <term><parameter>fd</parameter></term>
  25. <listitem>
  26. <para>&fd;</para>
  27. </listitem>
  28. </varlistentry>
  29. <varlistentry>
  30. <term><parameter>request</parameter></term>
  31. <listitem>
  32. <para>VIDIOC_REQBUFS</para>
  33. </listitem>
  34. </varlistentry>
  35. <varlistentry>
  36. <term><parameter>argp</parameter></term>
  37. <listitem>
  38. <para></para>
  39. </listitem>
  40. </varlistentry>
  41. </variablelist>
  42. </refsect1>
  43. <refsect1>
  44. <title>Description</title>
  45. <para>This ioctl is used to initiate <link linkend="mmap">memory
  46. mapped</link> or <link linkend="userp">user pointer</link>
  47. I/O. Memory mapped buffers are located in device memory and must be
  48. allocated with this ioctl before they can be mapped into the
  49. application's address space. User buffers are allocated by
  50. applications themselves, and this ioctl is merely used to switch the
  51. driver into user pointer I/O mode.</para>
  52. <para>To allocate device buffers applications initialize three
  53. fields of a <structname>v4l2_requestbuffers</structname> structure.
  54. They set the <structfield>type</structfield> field to the respective
  55. stream or buffer type, the <structfield>count</structfield> field to
  56. the desired number of buffers, and <structfield>memory</structfield>
  57. must be set to <constant>V4L2_MEMORY_MMAP</constant>. When the ioctl
  58. is called with a pointer to this structure the driver attempts to
  59. allocate the requested number of buffers and stores the actual number
  60. allocated in the <structfield>count</structfield> field. It can be
  61. smaller than the number requested, even zero, when the driver runs out
  62. of free memory. A larger number is possible when the driver requires
  63. more buffers to function correctly.<footnote>
  64. <para>For example video output requires at least two buffers,
  65. one displayed and one filled by the application.</para>
  66. </footnote> When memory mapping I/O is not supported the ioctl
  67. returns an &EINVAL;.</para>
  68. <para>Applications can call <constant>VIDIOC_REQBUFS</constant>
  69. again to change the number of buffers, however this cannot succeed
  70. when any buffers are still mapped. A <structfield>count</structfield>
  71. value of zero frees all buffers, after aborting or finishing any DMA
  72. in progress, an implicit &VIDIOC-STREAMOFF;. <!-- mhs: I see no
  73. reason why munmap()ping one or even all buffers must imply
  74. streamoff.--></para>
  75. <para>To negotiate user pointer I/O, applications initialize only
  76. the <structfield>type</structfield> field and set
  77. <structfield>memory</structfield> to
  78. <constant>V4L2_MEMORY_USERPTR</constant>. When the ioctl is called
  79. with a pointer to this structure the driver prepares for user pointer
  80. I/O, when this I/O method is not supported the ioctl returns an
  81. &EINVAL;.</para>
  82. <table pgwide="1" frame="none" id="v4l2-requestbuffers">
  83. <title>struct <structname>v4l2_requestbuffers</structname></title>
  84. <tgroup cols="3">
  85. &cs-str;
  86. <tbody valign="top">
  87. <row>
  88. <entry>__u32</entry>
  89. <entry><structfield>count</structfield></entry>
  90. <entry>The number of buffers requested or granted. This
  91. field is only used when <structfield>memory</structfield> is set to
  92. <constant>V4L2_MEMORY_MMAP</constant>.</entry>
  93. </row>
  94. <row>
  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>
  100. </row>
  101. <row>
  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>
  107. </row>
  108. <row>
  109. <entry>__u32</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.</entry>
  114. </row>
  115. </tbody>
  116. </tgroup>
  117. </table>
  118. </refsect1>
  119. <refsect1>
  120. &return-value;
  121. <variablelist>
  122. <varlistentry>
  123. <term><errorcode>EBUSY</errorcode></term>
  124. <listitem>
  125. <para>The driver supports multiple opens and I/O is already
  126. in progress, or reallocation of buffers was attempted although one or
  127. more are still mapped.</para>
  128. </listitem>
  129. </varlistentry>
  130. <varlistentry>
  131. <term><errorcode>EINVAL</errorcode></term>
  132. <listitem>
  133. <para>The buffer type (<structfield>type</structfield> field) or the
  134. requested I/O method (<structfield>memory</structfield>) is not
  135. supported.</para>
  136. </listitem>
  137. </varlistentry>
  138. </variablelist>
  139. </refsect1>
  140. </refentry>
  141. <!--
  142. Local Variables:
  143. mode: sgml
  144. sgml-parent-document: "v4l2.sgml"
  145. indent-tabs-mode: nil
  146. End:
  147. -->