func-select.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <refentry id="func-select">
  2. <refmeta>
  3. <refentrytitle>V4L2 select()</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>v4l2-select</refname>
  8. <refpurpose>Synchronous I/O multiplexing</refpurpose>
  9. </refnamediv>
  10. <refsynopsisdiv>
  11. <funcsynopsis>
  12. <funcsynopsisinfo>
  13. #include &lt;sys/time.h&gt;
  14. #include &lt;sys/types.h&gt;
  15. #include &lt;unistd.h&gt;</funcsynopsisinfo>
  16. <funcprototype>
  17. <funcdef>int <function>select</function></funcdef>
  18. <paramdef>int <parameter>nfds</parameter></paramdef>
  19. <paramdef>fd_set *<parameter>readfds</parameter></paramdef>
  20. <paramdef>fd_set *<parameter>writefds</parameter></paramdef>
  21. <paramdef>fd_set *<parameter>exceptfds</parameter></paramdef>
  22. <paramdef>struct timeval *<parameter>timeout</parameter></paramdef>
  23. </funcprototype>
  24. </funcsynopsis>
  25. </refsynopsisdiv>
  26. <refsect1>
  27. <title>Description</title>
  28. <para>With the <function>select()</function> function applications
  29. can suspend execution until the driver has captured data or is ready
  30. to accept data for output.</para>
  31. <para>When streaming I/O has been negotiated this function waits
  32. until a buffer has been filled or displayed and can be dequeued with
  33. the &VIDIOC-DQBUF; ioctl. When buffers are already in the outgoing
  34. queue of the driver the function returns immediately.</para>
  35. <para>On success <function>select()</function> returns the total
  36. number of bits set in the <structname>fd_set</structname>s. When the
  37. function timed out it returns a value of zero. On failure it returns
  38. <returnvalue>-1</returnvalue> and the <varname>errno</varname>
  39. variable is set appropriately. When the application did not call
  40. &VIDIOC-QBUF; or &VIDIOC-STREAMON; yet the
  41. <function>select()</function> function succeeds, setting the bit of
  42. the file descriptor in <parameter>readfds</parameter> or
  43. <parameter>writefds</parameter>, but subsequent &VIDIOC-DQBUF; calls
  44. will fail.<footnote><para>The Linux kernel implements
  45. <function>select()</function> like the &func-poll; function, but
  46. <function>select()</function> cannot return a
  47. <constant>POLLERR</constant>.</para>
  48. </footnote></para>
  49. <para>When use of the <function>read()</function> function has
  50. been negotiated and the driver does not capture yet, the
  51. <function>select()</function> function starts capturing. When that
  52. fails, <function>select()</function> returns successful and a
  53. subsequent <function>read()</function> call, which also attempts to
  54. start capturing, will return an appropriate error code. When the
  55. driver captures continuously (as opposed to, for example, still
  56. images) and data is already available the
  57. <function>select()</function> function returns immediately.</para>
  58. <para>When use of the <function>write()</function> function has
  59. been negotiated the <function>select()</function> function just waits
  60. until the driver is ready for a non-blocking
  61. <function>write()</function> call.</para>
  62. <para>All drivers implementing the <function>read()</function> or
  63. <function>write()</function> function or streaming I/O must also
  64. support the <function>select()</function> function.</para>
  65. <para>For more details see the <function>select()</function>
  66. manual page.</para>
  67. </refsect1>
  68. <refsect1>
  69. <title>Return Value</title>
  70. <para>On success, <function>select()</function> returns the number
  71. of descriptors contained in the three returned descriptor sets, which
  72. will be zero if the timeout expired. On error
  73. <returnvalue>-1</returnvalue> is returned, and the
  74. <varname>errno</varname> variable is set appropriately; the sets and
  75. <parameter>timeout</parameter> are undefined. Possible error codes
  76. are:</para>
  77. <variablelist>
  78. <varlistentry>
  79. <term><errorcode>EBADF</errorcode></term>
  80. <listitem>
  81. <para>One or more of the file descriptor sets specified a
  82. file descriptor that is not open.</para>
  83. </listitem>
  84. </varlistentry>
  85. <varlistentry>
  86. <term><errorcode>EBUSY</errorcode></term>
  87. <listitem>
  88. <para>The driver does not support multiple read or write
  89. streams and the device is already in use.</para>
  90. </listitem>
  91. </varlistentry>
  92. <varlistentry>
  93. <term><errorcode>EFAULT</errorcode></term>
  94. <listitem>
  95. <para>The <parameter>readfds</parameter>,
  96. <parameter>writefds</parameter>, <parameter>exceptfds</parameter> or
  97. <parameter>timeout</parameter> pointer references an inaccessible memory
  98. area.</para>
  99. </listitem>
  100. </varlistentry>
  101. <varlistentry>
  102. <term><errorcode>EINTR</errorcode></term>
  103. <listitem>
  104. <para>The call was interrupted by a signal.</para>
  105. </listitem>
  106. </varlistentry>
  107. <varlistentry>
  108. <term><errorcode>EINVAL</errorcode></term>
  109. <listitem>
  110. <para>The <parameter>nfds</parameter> argument is less than
  111. zero or greater than <constant>FD_SETSIZE</constant>.</para>
  112. </listitem>
  113. </varlistentry>
  114. </variablelist>
  115. </refsect1>
  116. </refentry>