vidioc-reqbufs.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 and to setup some internal structures.</para>
  52. <para>To allocate device buffers applications initialize all
  53. fields of the <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, <structfield>memory</structfield>
  57. must be set to the requested I/O method and the <structfield>reserved</structfield> array
  58. must be zeroed. When the ioctl
  59. is called with a pointer to this structure the driver will attempt to allocate
  60. the requested number of buffers and it stores the actual number
  61. allocated in the <structfield>count</structfield> field. It can be
  62. smaller than the number requested, even zero, when the driver runs out
  63. of free memory. A larger number is also possible when the driver requires
  64. more buffers to function correctly. For example video output requires at least two buffers,
  65. one displayed and one filled by the application.</para>
  66. <para>When the I/O method 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. <table pgwide="1" frame="none" id="v4l2-requestbuffers">
  76. <title>struct <structname>v4l2_requestbuffers</structname></title>
  77. <tgroup cols="3">
  78. &cs-str;
  79. <tbody valign="top">
  80. <row>
  81. <entry>__u32</entry>
  82. <entry><structfield>count</structfield></entry>
  83. <entry>The number of buffers requested or granted.</entry>
  84. </row>
  85. <row>
  86. <entry>&v4l2-buf-type;</entry>
  87. <entry><structfield>type</structfield></entry>
  88. <entry>Type of the stream or buffers, this is the same
  89. as the &v4l2-format; <structfield>type</structfield> field. See <xref
  90. linkend="v4l2-buf-type" /> for valid values.</entry>
  91. </row>
  92. <row>
  93. <entry>&v4l2-memory;</entry>
  94. <entry><structfield>memory</structfield></entry>
  95. <entry>Applications set this field to
  96. <constant>V4L2_MEMORY_MMAP</constant> or
  97. <constant>V4L2_MEMORY_USERPTR</constant>.</entry>
  98. </row>
  99. <row>
  100. <entry>__u32</entry>
  101. <entry><structfield>reserved</structfield>[2]</entry>
  102. <entry>A place holder for future extensions and custom
  103. (driver defined) buffer types <constant>V4L2_BUF_TYPE_PRIVATE</constant> and
  104. higher. This array should be zeroed by applications.</entry>
  105. </row>
  106. </tbody>
  107. </tgroup>
  108. </table>
  109. </refsect1>
  110. <refsect1>
  111. &return-value;
  112. <variablelist>
  113. <varlistentry>
  114. <term><errorcode>EINVAL</errorcode></term>
  115. <listitem>
  116. <para>The buffer type (<structfield>type</structfield> field) or the
  117. requested I/O method (<structfield>memory</structfield>) is not
  118. supported.</para>
  119. </listitem>
  120. </varlistentry>
  121. </variablelist>
  122. </refsect1>
  123. </refentry>