vidioc-qbuf.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <refentry id="vidioc-qbuf">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_QBUF, VIDIOC_DQBUF</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_QBUF</refname>
  8. <refname>VIDIOC_DQBUF</refname>
  9. <refpurpose>Exchange a buffer with the driver</refpurpose>
  10. </refnamediv>
  11. <refsynopsisdiv>
  12. <funcsynopsis>
  13. <funcprototype>
  14. <funcdef>int <function>ioctl</function></funcdef>
  15. <paramdef>int <parameter>fd</parameter></paramdef>
  16. <paramdef>int <parameter>request</parameter></paramdef>
  17. <paramdef>struct v4l2_buffer *<parameter>argp</parameter></paramdef>
  18. </funcprototype>
  19. </funcsynopsis>
  20. </refsynopsisdiv>
  21. <refsect1>
  22. <title>Arguments</title>
  23. <variablelist>
  24. <varlistentry>
  25. <term><parameter>fd</parameter></term>
  26. <listitem>
  27. <para>&fd;</para>
  28. </listitem>
  29. </varlistentry>
  30. <varlistentry>
  31. <term><parameter>request</parameter></term>
  32. <listitem>
  33. <para>VIDIOC_QBUF, VIDIOC_DQBUF</para>
  34. </listitem>
  35. </varlistentry>
  36. <varlistentry>
  37. <term><parameter>argp</parameter></term>
  38. <listitem>
  39. <para></para>
  40. </listitem>
  41. </varlistentry>
  42. </variablelist>
  43. </refsect1>
  44. <refsect1>
  45. <title>Description</title>
  46. <para>Applications call the <constant>VIDIOC_QBUF</constant> ioctl
  47. to enqueue an empty (capturing) or filled (output) buffer in the
  48. driver's incoming queue. The semantics depend on the selected I/O
  49. method.</para>
  50. <para>To enqueue a <link linkend="mmap">memory mapped</link>
  51. buffer applications set the <structfield>type</structfield> field of a
  52. &v4l2-buffer; to the same buffer type as previously &v4l2-format;
  53. <structfield>type</structfield> and &v4l2-requestbuffers;
  54. <structfield>type</structfield>, the <structfield>memory</structfield>
  55. field to <constant>V4L2_MEMORY_MMAP</constant> and the
  56. <structfield>index</structfield> field. Valid index numbers range from
  57. zero to the number of buffers allocated with &VIDIOC-REQBUFS;
  58. (&v4l2-requestbuffers; <structfield>count</structfield>) minus one. The
  59. contents of the struct <structname>v4l2_buffer</structname> returned
  60. by a &VIDIOC-QUERYBUF; ioctl will do as well. When the buffer is
  61. intended for output (<structfield>type</structfield> is
  62. <constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant> or
  63. <constant>V4L2_BUF_TYPE_VBI_OUTPUT</constant>) applications must also
  64. initialize the <structfield>bytesused</structfield>,
  65. <structfield>field</structfield> and
  66. <structfield>timestamp</structfield> fields. See <xref
  67. linkend="buffer" /> for details. When
  68. <constant>VIDIOC_QBUF</constant> is called with a pointer to this
  69. structure the driver sets the
  70. <constant>V4L2_BUF_FLAG_MAPPED</constant> and
  71. <constant>V4L2_BUF_FLAG_QUEUED</constant> flags and clears the
  72. <constant>V4L2_BUF_FLAG_DONE</constant> flag in the
  73. <structfield>flags</structfield> field, or it returns an
  74. &EINVAL;.</para>
  75. <para>To enqueue a <link linkend="userp">user pointer</link>
  76. buffer applications set the <structfield>type</structfield> field of a
  77. &v4l2-buffer; to the same buffer type as previously &v4l2-format;
  78. <structfield>type</structfield> and &v4l2-requestbuffers;
  79. <structfield>type</structfield>, the <structfield>memory</structfield>
  80. field to <constant>V4L2_MEMORY_USERPTR</constant> and the
  81. <structfield>m.userptr</structfield> field to the address of the
  82. buffer and <structfield>length</structfield> to its size. When the
  83. buffer is intended for output additional fields must be set as above.
  84. When <constant>VIDIOC_QBUF</constant> is called with a pointer to this
  85. structure the driver sets the <constant>V4L2_BUF_FLAG_QUEUED</constant>
  86. flag and clears the <constant>V4L2_BUF_FLAG_MAPPED</constant> and
  87. <constant>V4L2_BUF_FLAG_DONE</constant> flags in the
  88. <structfield>flags</structfield> field, or it returns an error code.
  89. This ioctl locks the memory pages of the buffer in physical memory,
  90. they cannot be swapped out to disk. Buffers remain locked until
  91. dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl are
  92. called, or until the device is closed.</para>
  93. <para>Applications call the <constant>VIDIOC_DQBUF</constant>
  94. ioctl to dequeue a filled (capturing) or displayed (output) buffer
  95. from the driver's outgoing queue. They just set the
  96. <structfield>type</structfield> and <structfield>memory</structfield>
  97. fields of a &v4l2-buffer; as above, when <constant>VIDIOC_DQBUF</constant>
  98. is called with a pointer to this structure the driver fills the
  99. remaining fields or returns an error code.</para>
  100. <para>By default <constant>VIDIOC_DQBUF</constant> blocks when no
  101. buffer is in the outgoing queue. When the
  102. <constant>O_NONBLOCK</constant> flag was given to the &func-open;
  103. function, <constant>VIDIOC_DQBUF</constant> returns immediately
  104. with an &EAGAIN; when no buffer is available.</para>
  105. <para>The <structname>v4l2_buffer</structname> structure is
  106. specified in <xref linkend="buffer" />.</para>
  107. </refsect1>
  108. <refsect1>
  109. &return-value;
  110. <variablelist>
  111. <varlistentry>
  112. <term><errorcode>EAGAIN</errorcode></term>
  113. <listitem>
  114. <para>Non-blocking I/O has been selected using
  115. <constant>O_NONBLOCK</constant> and no buffer was in the outgoing
  116. queue.</para>
  117. </listitem>
  118. </varlistentry>
  119. <varlistentry>
  120. <term><errorcode>EINVAL</errorcode></term>
  121. <listitem>
  122. <para>The buffer <structfield>type</structfield> is not
  123. supported, or the <structfield>index</structfield> is out of bounds,
  124. or no buffers have been allocated yet, or the
  125. <structfield>userptr</structfield> or
  126. <structfield>length</structfield> are invalid.</para>
  127. </listitem>
  128. </varlistentry>
  129. <varlistentry>
  130. <term><errorcode>ENOMEM</errorcode></term>
  131. <listitem>
  132. <para>Not enough physical or virtual memory was available to
  133. enqueue a user pointer buffer.</para>
  134. </listitem>
  135. </varlistentry>
  136. <varlistentry>
  137. <term><errorcode>EIO</errorcode></term>
  138. <listitem>
  139. <para><constant>VIDIOC_DQBUF</constant> failed due to an
  140. internal error. Can also indicate temporary problems like signal
  141. loss. Note the driver might dequeue an (empty) buffer despite
  142. returning an error, or even stop capturing.</para>
  143. </listitem>
  144. </varlistentry>
  145. </variablelist>
  146. </refsect1>
  147. </refentry>
  148. <!--
  149. Local Variables:
  150. mode: sgml
  151. sgml-parent-document: "v4l2.sgml"
  152. indent-tabs-mode: nil
  153. End:
  154. -->