vidioc-reqbufs.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 mapped</link>,
  46. <link linkend="userp">user pointer</link> or <link
  47. linkend="dmabuf">DMABUF</link> based I/O. Memory mapped buffers are located in
  48. device memory and must be allocated with this ioctl before they can be mapped
  49. into the application's address space. User buffers are allocated by
  50. applications themselves, and this ioctl is merely used to switch the driver
  51. into user pointer I/O mode and to setup some internal structures.
  52. Similarly, DMABUF buffers are allocated by applications through a device
  53. driver, and this ioctl only configures the driver into DMABUF I/O mode without
  54. performing any direct allocation.</para>
  55. <para>To allocate device buffers applications initialize all fields of the
  56. <structname>v4l2_requestbuffers</structname> structure. They set the
  57. <structfield>type</structfield> field to the respective stream or buffer type,
  58. the <structfield>count</structfield> field to the desired number of buffers,
  59. <structfield>memory</structfield> must be set to the requested I/O method and
  60. the <structfield>reserved</structfield> array must be zeroed. When the ioctl is
  61. called with a pointer to this structure the driver will attempt to allocate the
  62. requested number of buffers and it stores the actual number allocated in the
  63. <structfield>count</structfield> field. It can be smaller than the number
  64. requested, even zero, when the driver runs out of free memory. A larger number
  65. is also possible when the driver requires more buffers to function correctly.
  66. For example video output requires at least two buffers, one displayed and one
  67. filled by the application.</para>
  68. <para>When the I/O method is not supported the ioctl
  69. returns an &EINVAL;.</para>
  70. <para>Applications can call <constant>VIDIOC_REQBUFS</constant>
  71. again to change the number of buffers, however this cannot succeed
  72. when any buffers are still mapped. A <structfield>count</structfield>
  73. value of zero frees all buffers, after aborting or finishing any DMA
  74. in progress, an implicit &VIDIOC-STREAMOFF;. <!-- mhs: I see no
  75. reason why munmap()ping one or even all buffers must imply
  76. streamoff.--></para>
  77. <table pgwide="1" frame="none" id="v4l2-requestbuffers">
  78. <title>struct <structname>v4l2_requestbuffers</structname></title>
  79. <tgroup cols="3">
  80. &cs-str;
  81. <tbody valign="top">
  82. <row>
  83. <entry>__u32</entry>
  84. <entry><structfield>count</structfield></entry>
  85. <entry>The number of buffers requested or granted.</entry>
  86. </row>
  87. <row>
  88. <entry>__u32</entry>
  89. <entry><structfield>type</structfield></entry>
  90. <entry>Type of the stream or buffers, this is the same
  91. as the &v4l2-format; <structfield>type</structfield> field. See <xref
  92. linkend="v4l2-buf-type" /> for valid values.</entry>
  93. </row>
  94. <row>
  95. <entry>__u32</entry>
  96. <entry><structfield>memory</structfield></entry>
  97. <entry>Applications set this field to
  98. <constant>V4L2_MEMORY_MMAP</constant>,
  99. <constant>V4L2_MEMORY_DMABUF</constant> or
  100. <constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
  101. />.</entry>
  102. </row>
  103. <row>
  104. <entry>__u32</entry>
  105. <entry><structfield>reserved</structfield>[2]</entry>
  106. <entry>A place holder for future extensions. Drivers and applications
  107. must set the array to zero.</entry>
  108. </row>
  109. </tbody>
  110. </tgroup>
  111. </table>
  112. </refsect1>
  113. <refsect1>
  114. &return-value;
  115. <variablelist>
  116. <varlistentry>
  117. <term><errorcode>EINVAL</errorcode></term>
  118. <listitem>
  119. <para>The buffer type (<structfield>type</structfield> field) or the
  120. requested I/O method (<structfield>memory</structfield>) is not
  121. supported.</para>
  122. </listitem>
  123. </varlistentry>
  124. </variablelist>
  125. </refsect1>
  126. </refentry>