Path: blob/master/Documentation/DocBook/v4l/func-poll.xml
10821 views
<refentry id="func-poll">1<refmeta>2<refentrytitle>V4L2 poll()</refentrytitle>3&manvol;4</refmeta>56<refnamediv>7<refname>v4l2-poll</refname>8<refpurpose>Wait for some event on a file descriptor</refpurpose>9</refnamediv>1011<refsynopsisdiv>12<funcsynopsis>13<funcsynopsisinfo>#include <sys/poll.h></funcsynopsisinfo>14<funcprototype>15<funcdef>int <function>poll</function></funcdef>16<paramdef>struct pollfd *<parameter>ufds</parameter></paramdef>17<paramdef>unsigned int <parameter>nfds</parameter></paramdef>18<paramdef>int <parameter>timeout</parameter></paramdef>19</funcprototype>20</funcsynopsis>21</refsynopsisdiv>2223<refsect1>24<title>Description</title>2526<para>With the <function>poll()</function> function applications27can suspend execution until the driver has captured data or is ready28to accept data for output.</para>2930<para>When streaming I/O has been negotiated this function waits31until a buffer has been filled or displayed and can be dequeued with32the &VIDIOC-DQBUF; ioctl. When buffers are already in the outgoing33queue of the driver the function returns immediately.</para>3435<para>On success <function>poll()</function> returns the number of36file descriptors that have been selected (that is, file descriptors37for which the <structfield>revents</structfield> field of the38respective <structname>pollfd</structname> structure is non-zero).39Capture devices set the <constant>POLLIN</constant> and40<constant>POLLRDNORM</constant> flags in the41<structfield>revents</structfield> field, output devices the42<constant>POLLOUT</constant> and <constant>POLLWRNORM</constant>43flags. When the function timed out it returns a value of zero, on44failure it returns <returnvalue>-1</returnvalue> and the45<varname>errno</varname> variable is set appropriately. When the46application did not call &VIDIOC-QBUF; or &VIDIOC-STREAMON; yet the47<function>poll()</function> function succeeds, but sets the48<constant>POLLERR</constant> flag in the49<structfield>revents</structfield> field.</para>5051<para>When use of the <function>read()</function> function has52been negotiated and the driver does not capture yet, the53<function>poll</function> function starts capturing. When that fails54it returns a <constant>POLLERR</constant> as above. Otherwise it waits55until data has been captured and can be read. When the driver captures56continuously (as opposed to, for example, still images) the function57may return immediately.</para>5859<para>When use of the <function>write()</function> function has60been negotiated the <function>poll</function> function just waits61until the driver is ready for a non-blocking62<function>write()</function> call.</para>6364<para>All drivers implementing the <function>read()</function> or65<function>write()</function> function or streaming I/O must also66support the <function>poll()</function> function.</para>6768<para>For more details see the69<function>poll()</function> manual page.</para>70</refsect1>7172<refsect1>73<title>Return Value</title>7475<para>On success, <function>poll()</function> returns the number76structures which have non-zero <structfield>revents</structfield>77fields, or zero if the call timed out. On error78<returnvalue>-1</returnvalue> is returned, and the79<varname>errno</varname> variable is set appropriately:</para>8081<variablelist>82<varlistentry>83<term><errorcode>EBADF</errorcode></term>84<listitem>85<para>One or more of the <parameter>ufds</parameter> members86specify an invalid file descriptor.</para>87</listitem>88</varlistentry>89<varlistentry>90<term><errorcode>EBUSY</errorcode></term>91<listitem>92<para>The driver does not support multiple read or write93streams and the device is already in use.</para>94</listitem>95</varlistentry>96<varlistentry>97<term><errorcode>EFAULT</errorcode></term>98<listitem>99<para><parameter>ufds</parameter> references an inaccessible100memory area.</para>101</listitem>102</varlistentry>103<varlistentry>104<term><errorcode>EINTR</errorcode></term>105<listitem>106<para>The call was interrupted by a signal.</para>107</listitem>108</varlistentry>109<varlistentry>110<term><errorcode>EINVAL</errorcode></term>111<listitem>112<para>The <parameter>nfds</parameter> argument is greater113than <constant>OPEN_MAX</constant>.</para>114</listitem>115</varlistentry>116</variablelist>117</refsect1>118</refentry>119120<!--121Local Variables:122mode: sgml123sgml-parent-document: "v4l2.sgml"124indent-tabs-mode: nil125End:126-->127128129