Home | History | Annotate | Download | only in spec
      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
      2 <HTML
      3 ><HEAD
      4 ><TITLE
      5 >V4L2 poll()</TITLE
      6 ><META
      7 NAME="GENERATOR"
      8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
      9 REL="HOME"
     10 TITLE="Video for Linux Two API Specification"
     11 HREF="book1.htm"><LINK
     12 REL="UP"
     13 TITLE="Function Reference"
     14 HREF="r7624.htm"><LINK
     15 REL="PREVIOUS"
     16 TITLE="V4L2 open()"
     17 HREF="r14090.htm"><LINK
     18 REL="NEXT"
     19 TITLE="V4L2 read()"
     20 HREF="r14264.htm"></HEAD
     21 ><BODY
     22 CLASS="REFENTRY"
     23 BGCOLOR="#FFFFFF"
     24 TEXT="#000000"
     25 LINK="#0000FF"
     26 VLINK="#840084"
     27 ALINK="#0000FF"
     28 ><DIV
     29 CLASS="NAVHEADER"
     30 ><TABLE
     31 SUMMARY="Header navigation table"
     32 WIDTH="100%"
     33 BORDER="0"
     34 CELLPADDING="0"
     35 CELLSPACING="0"
     36 ><TR
     37 ><TH
     38 COLSPAN="3"
     39 ALIGN="center"
     40 >Video for Linux Two API Specification: Revision 0.24</TH
     41 ></TR
     42 ><TR
     43 ><TD
     44 WIDTH="10%"
     45 ALIGN="left"
     46 VALIGN="bottom"
     47 ><A
     48 HREF="r14090.htm"
     49 ACCESSKEY="P"
     50 >Prev</A
     51 ></TD
     52 ><TD
     53 WIDTH="80%"
     54 ALIGN="center"
     55 VALIGN="bottom"
     56 ></TD
     57 ><TD
     58 WIDTH="10%"
     59 ALIGN="right"
     60 VALIGN="bottom"
     61 ><A
     62 HREF="r14264.htm"
     63 ACCESSKEY="N"
     64 >Next</A
     65 ></TD
     66 ></TR
     67 ></TABLE
     68 ><HR
     69 ALIGN="LEFT"
     70 WIDTH="100%"></DIV
     71 ><H1
     72 ><A
     73 NAME="FUNC-POLL"
     74 ></A
     75 >V4L2 poll()</H1
     76 ><DIV
     77 CLASS="REFNAMEDIV"
     78 ><A
     79 NAME="AEN14173"
     80 ></A
     81 ><H2
     82 >Name</H2
     83 >v4l2-poll&nbsp;--&nbsp;Wait for some event on a file descriptor</DIV
     84 ><DIV
     85 CLASS="REFSYNOPSISDIV"
     86 ><A
     87 NAME="AEN14176"
     88 ></A
     89 ><H2
     90 >Synopsis</H2
     91 ><DIV
     92 CLASS="FUNCSYNOPSIS"
     93 ><P
     94 ></P
     95 ><A
     96 NAME="AEN14177"
     97 ></A
     98 ><PRE
     99 CLASS="FUNCSYNOPSISINFO"
    100 >#include &lt;sys/poll.h&gt;</PRE
    101 ><P
    102 ><CODE
    103 ><CODE
    104 CLASS="FUNCDEF"
    105 >int poll</CODE
    106 >(struct pollfd *ufds, unsigned int nfds, int timeout);</CODE
    107 ></P
    108 ><P
    109 ></P
    110 ></DIV
    111 ></DIV
    112 ><DIV
    113 CLASS="REFSECT1"
    114 ><A
    115 NAME="AEN14188"
    116 ></A
    117 ><H2
    118 >Description</H2
    119 ><P
    120 >With the <CODE
    121 CLASS="FUNCTION"
    122 >poll()</CODE
    123 > function applications
    124 can suspend execution until the driver has captured data or is ready
    125 to accept data for output.</P
    126 ><P
    127 >When streaming I/O has been negotiated this function waits
    128 until a buffer has been filled or displayed and can be dequeued with
    129 the <A
    130 HREF="r12878.htm"
    131 ><CODE
    132 CLASS="CONSTANT"
    133 >VIDIOC_DQBUF</CODE
    134 ></A
    135 > ioctl. When buffers are already in the outgoing
    136 queue of the driver the function returns immediately.</P
    137 ><P
    138 >On success <CODE
    139 CLASS="FUNCTION"
    140 >poll()</CODE
    141 > returns the number of
    142 file descriptors that have been selected (that is, file descriptors
    143 for which the <CODE
    144 CLASS="STRUCTFIELD"
    145 >revents</CODE
    146 > field of the
    147 respective <CODE
    148 CLASS="STRUCTNAME"
    149 >pollfd</CODE
    150 > structure is non-zero).
    151 Capture devices set the <CODE
    152 CLASS="CONSTANT"
    153 >POLLIN</CODE
    154 > and
    155 <CODE
    156 CLASS="CONSTANT"
    157 >POLLRDNORM</CODE
    158 > flags in the
    159 <CODE
    160 CLASS="STRUCTFIELD"
    161 >revents</CODE
    162 > field, output devices the
    163 <CODE
    164 CLASS="CONSTANT"
    165 >POLLOUT</CODE
    166 > and <CODE
    167 CLASS="CONSTANT"
    168 >POLLWRNORM</CODE
    169 >
    170 flags. When the function timed out it returns a value of zero, on
    171 failure it returns <SPAN
    172 CLASS="RETURNVALUE"
    173 >-1</SPAN
    174 > and the
    175 <CODE
    176 CLASS="VARNAME"
    177 >errno</CODE
    178 > variable is set appropriately. When the
    179 application did not call <A
    180 HREF="r12878.htm"
    181 ><CODE
    182 CLASS="CONSTANT"
    183 >VIDIOC_QBUF</CODE
    184 ></A
    185 > or <A
    186 HREF="r13817.htm"
    187 ><CODE
    188 CLASS="CONSTANT"
    189 >VIDIOC_STREAMON</CODE
    190 ></A
    191 > yet the
    192 <CODE
    193 CLASS="FUNCTION"
    194 >poll()</CODE
    195 > function succeeds, but sets the
    196 <CODE
    197 CLASS="CONSTANT"
    198 >POLLERR</CODE
    199 > flag in the
    200 <CODE
    201 CLASS="STRUCTFIELD"
    202 >revents</CODE
    203 > field.</P
    204 ><P
    205 >When use of the <CODE
    206 CLASS="FUNCTION"
    207 >read()</CODE
    208 > function has
    209 been negotiated and the driver does not capture yet, the
    210 <CODE
    211 CLASS="FUNCTION"
    212 >poll</CODE
    213 > function starts capturing. When that fails
    214 it returns a <CODE
    215 CLASS="CONSTANT"
    216 >POLLERR</CODE
    217 > as above. Otherwise it waits
    218 until data has been captured and can be read. When the driver captures
    219 continuously (as opposed to, for example, still images) the function
    220 may return immediately.</P
    221 ><P
    222 >When use of the <CODE
    223 CLASS="FUNCTION"
    224 >write()</CODE
    225 > function has
    226 been negotiated the <CODE
    227 CLASS="FUNCTION"
    228 >poll</CODE
    229 > function just waits
    230 until the driver is ready for a non-blocking
    231 <CODE
    232 CLASS="FUNCTION"
    233 >write()</CODE
    234 > call.</P
    235 ><P
    236 >All drivers implementing the <CODE
    237 CLASS="FUNCTION"
    238 >read()</CODE
    239 > or
    240 <CODE
    241 CLASS="FUNCTION"
    242 >write()</CODE
    243 > function or streaming I/O must also
    244 support the <CODE
    245 CLASS="FUNCTION"
    246 >poll()</CODE
    247 > function.</P
    248 ><P
    249 >For more details see the
    250 <CODE
    251 CLASS="FUNCTION"
    252 >poll()</CODE
    253 > manual page.</P
    254 ></DIV
    255 ><DIV
    256 CLASS="REFSECT1"
    257 ><A
    258 NAME="AEN14227"
    259 ></A
    260 ><H2
    261 >Return Value</H2
    262 ><P
    263 >On success, <CODE
    264 CLASS="FUNCTION"
    265 >poll()</CODE
    266 > returns the number
    267 structures which have non-zero <CODE
    268 CLASS="STRUCTFIELD"
    269 >revents</CODE
    270 >
    271 fields, or zero if the call timed out. On error
    272 <SPAN
    273 CLASS="RETURNVALUE"
    274 >-1</SPAN
    275 > is returned, and the
    276 <CODE
    277 CLASS="VARNAME"
    278 >errno</CODE
    279 > variable is set appropriately:</P
    280 ><P
    281 ></P
    282 ><DIV
    283 CLASS="VARIABLELIST"
    284 ><DL
    285 ><DT
    286 ><SPAN
    287 CLASS="ERRORCODE"
    288 >EBADF</SPAN
    289 ></DT
    290 ><DD
    291 ><P
    292 >One or more of the <CODE
    293 CLASS="PARAMETER"
    294 >ufds</CODE
    295 > members
    296 specify an invalid file descriptor.</P
    297 ></DD
    298 ><DT
    299 ><SPAN
    300 CLASS="ERRORCODE"
    301 >EBUSY</SPAN
    302 ></DT
    303 ><DD
    304 ><P
    305 >The driver does not support multiple read or write
    306 streams and the device is already in use.</P
    307 ></DD
    308 ><DT
    309 ><SPAN
    310 CLASS="ERRORCODE"
    311 >EFAULT</SPAN
    312 ></DT
    313 ><DD
    314 ><P
    315 ><CODE
    316 CLASS="PARAMETER"
    317 >ufds</CODE
    318 > references an inaccessible
    319 memory area.</P
    320 ></DD
    321 ><DT
    322 ><SPAN
    323 CLASS="ERRORCODE"
    324 >EINTR</SPAN
    325 ></DT
    326 ><DD
    327 ><P
    328 >The call was interrupted by a signal.</P
    329 ></DD
    330 ><DT
    331 ><SPAN
    332 CLASS="ERRORCODE"
    333 >EINVAL</SPAN
    334 ></DT
    335 ><DD
    336 ><P
    337 >The <CODE
    338 CLASS="PARAMETER"
    339 >nfds</CODE
    340 > argument is greater
    341 than <CODE
    342 CLASS="CONSTANT"
    343 >OPEN_MAX</CODE
    344 >.</P
    345 ></DD
    346 ></DL
    347 ></DIV
    348 ></DIV
    349 ><DIV
    350 CLASS="NAVFOOTER"
    351 ><HR
    352 ALIGN="LEFT"
    353 WIDTH="100%"><TABLE
    354 SUMMARY="Footer navigation table"
    355 WIDTH="100%"
    356 BORDER="0"
    357 CELLPADDING="0"
    358 CELLSPACING="0"
    359 ><TR
    360 ><TD
    361 WIDTH="33%"
    362 ALIGN="left"
    363 VALIGN="top"
    364 ><A
    365 HREF="r14090.htm"
    366 ACCESSKEY="P"
    367 >Prev</A
    368 ></TD
    369 ><TD
    370 WIDTH="34%"
    371 ALIGN="center"
    372 VALIGN="top"
    373 ><A
    374 HREF="book1.htm"
    375 ACCESSKEY="H"
    376 >Home</A
    377 ></TD
    378 ><TD
    379 WIDTH="33%"
    380 ALIGN="right"
    381 VALIGN="top"
    382 ><A
    383 HREF="r14264.htm"
    384 ACCESSKEY="N"
    385 >Next</A
    386 ></TD
    387 ></TR
    388 ><TR
    389 ><TD
    390 WIDTH="33%"
    391 ALIGN="left"
    392 VALIGN="top"
    393 >V4L2 open()</TD
    394 ><TD
    395 WIDTH="34%"
    396 ALIGN="center"
    397 VALIGN="top"
    398 ><A
    399 HREF="r7624.htm"
    400 ACCESSKEY="U"
    401 >Up</A
    402 ></TD
    403 ><TD
    404 WIDTH="33%"
    405 ALIGN="right"
    406 VALIGN="top"
    407 >V4L2 read()</TD
    408 ></TR
    409 ></TABLE
    410 ></DIV
    411 ></BODY
    412 ></HTML
    413 >
    414