func-poll.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <refentry id="func-poll">
  2. <refmeta>
  3. <refentrytitle>V4L2 poll()</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>v4l2-poll</refname>
  8. <refpurpose>Wait for some event on a file descriptor</refpurpose>
  9. </refnamediv>
  10. <refsynopsisdiv>
  11. <funcsynopsis>
  12. <funcsynopsisinfo>#include &lt;sys/poll.h&gt;</funcsynopsisinfo>
  13. <funcprototype>
  14. <funcdef>int <function>poll</function></funcdef>
  15. <paramdef>struct pollfd *<parameter>ufds</parameter></paramdef>
  16. <paramdef>unsigned int <parameter>nfds</parameter></paramdef>
  17. <paramdef>int <parameter>timeout</parameter></paramdef>
  18. </funcprototype>
  19. </funcsynopsis>
  20. </refsynopsisdiv>
  21. <refsect1>
  22. <title>Description</title>
  23. <para>With the <function>poll()</function> function applications
  24. can suspend execution until the driver has captured data or is ready
  25. to accept data for output.</para>
  26. <para>When streaming I/O has been negotiated this function waits
  27. until a buffer has been filled or displayed and can be dequeued with
  28. the &VIDIOC-DQBUF; ioctl. When buffers are already in the outgoing
  29. queue of the driver the function returns immediately.</para>
  30. <para>On success <function>poll()</function> returns the number of
  31. file descriptors that have been selected (that is, file descriptors
  32. for which the <structfield>revents</structfield> field of the
  33. respective <structname>pollfd</structname> structure is non-zero).
  34. Capture devices set the <constant>POLLIN</constant> and
  35. <constant>POLLRDNORM</constant> flags in the
  36. <structfield>revents</structfield> field, output devices the
  37. <constant>POLLOUT</constant> and <constant>POLLWRNORM</constant>
  38. flags. When the function timed out it returns a value of zero, on
  39. failure it returns <returnvalue>-1</returnvalue> and the
  40. <varname>errno</varname> variable is set appropriately. When the
  41. application did not call &VIDIOC-QBUF; or &VIDIOC-STREAMON; yet the
  42. <function>poll()</function> function succeeds, but sets the
  43. <constant>POLLERR</constant> flag in the
  44. <structfield>revents</structfield> field.</para>
  45. <para>When use of the <function>read()</function> function has
  46. been negotiated and the driver does not capture yet, the
  47. <function>poll</function> function starts capturing. When that fails
  48. it returns a <constant>POLLERR</constant> as above. Otherwise it waits
  49. until data has been captured and can be read. When the driver captures
  50. continuously (as opposed to, for example, still images) the function
  51. may return immediately.</para>
  52. <para>When use of the <function>write()</function> function has
  53. been negotiated the <function>poll</function> function just waits
  54. until the driver is ready for a non-blocking
  55. <function>write()</function> call.</para>
  56. <para>All drivers implementing the <function>read()</function> or
  57. <function>write()</function> function or streaming I/O must also
  58. support the <function>poll()</function> function.</para>
  59. <para>For more details see the
  60. <function>poll()</function> manual page.</para>
  61. </refsect1>
  62. <refsect1>
  63. <title>Return Value</title>
  64. <para>On success, <function>poll()</function> returns the number
  65. structures which have non-zero <structfield>revents</structfield>
  66. fields, or zero if the call timed out. On error
  67. <returnvalue>-1</returnvalue> is returned, and the
  68. <varname>errno</varname> variable is set appropriately:</para>
  69. <variablelist>
  70. <varlistentry>
  71. <term><errorcode>EBADF</errorcode></term>
  72. <listitem>
  73. <para>One or more of the <parameter>ufds</parameter> members
  74. specify an invalid file descriptor.</para>
  75. </listitem>
  76. </varlistentry>
  77. <varlistentry>
  78. <term><errorcode>EBUSY</errorcode></term>
  79. <listitem>
  80. <para>The driver does not support multiple read or write
  81. streams and the device is already in use.</para>
  82. </listitem>
  83. </varlistentry>
  84. <varlistentry>
  85. <term><errorcode>EFAULT</errorcode></term>
  86. <listitem>
  87. <para><parameter>ufds</parameter> references an inaccessible
  88. memory area.</para>
  89. </listitem>
  90. </varlistentry>
  91. <varlistentry>
  92. <term><errorcode>EINTR</errorcode></term>
  93. <listitem>
  94. <para>The call was interrupted by a signal.</para>
  95. </listitem>
  96. </varlistentry>
  97. <varlistentry>
  98. <term><errorcode>EINVAL</errorcode></term>
  99. <listitem>
  100. <para>The <parameter>nfds</parameter> argument is greater
  101. than <constant>OPEN_MAX</constant>.</para>
  102. </listitem>
  103. </varlistentry>
  104. </variablelist>
  105. </refsect1>
  106. </refentry>