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 select()</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 read()"
     17 HREF="r14264.htm"><LINK
     18 REL="NEXT"
     19 TITLE="V4L2 write()"
     20 HREF="r14496.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="r14264.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="r14496.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-SELECT"
     74 ></A
     75 >V4L2 select()</H1
     76 ><DIV
     77 CLASS="REFNAMEDIV"
     78 ><A
     79 NAME="AEN14394"
     80 ></A
     81 ><H2
     82 >Name</H2
     83 >v4l2-select&nbsp;--&nbsp;Synchronous I/O multiplexing</DIV
     84 ><DIV
     85 CLASS="REFSYNOPSISDIV"
     86 ><A
     87 NAME="AEN14397"
     88 ></A
     89 ><H2
     90 >Synopsis</H2
     91 ><DIV
     92 CLASS="FUNCSYNOPSIS"
     93 ><P
     94 ></P
     95 ><A
     96 NAME="AEN14398"
     97 ></A
     98 ><PRE
     99 CLASS="FUNCSYNOPSISINFO"
    100 >#include &lt;sys/time.h&gt;
    101 #include &lt;sys/types.h&gt;
    102 #include &lt;unistd.h&gt;</PRE
    103 ><P
    104 ><CODE
    105 ><CODE
    106 CLASS="FUNCDEF"
    107 >int select</CODE
    108 >(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);</CODE
    109 ></P
    110 ><P
    111 ></P
    112 ></DIV
    113 ></DIV
    114 ><DIV
    115 CLASS="REFSECT1"
    116 ><A
    117 NAME="AEN14413"
    118 ></A
    119 ><H2
    120 >Description</H2
    121 ><P
    122 >With the <CODE
    123 CLASS="FUNCTION"
    124 >select()</CODE
    125 > function applications
    126 can suspend execution until the driver has captured data or is ready
    127 to accept data for output.</P
    128 ><P
    129 >When streaming I/O has been negotiated this function waits
    130 until a buffer has been filled or displayed and can be dequeued with
    131 the <A
    132 HREF="r12878.htm"
    133 ><CODE
    134 CLASS="CONSTANT"
    135 >VIDIOC_DQBUF</CODE
    136 ></A
    137 > ioctl. When buffers are already in the outgoing
    138 queue of the driver the function returns immediately.</P
    139 ><P
    140 >On success <CODE
    141 CLASS="FUNCTION"
    142 >select()</CODE
    143 > returns the total
    144 number of bits set in the <CODE
    145 CLASS="STRUCTNAME"
    146 >fd_set</CODE
    147 >s. When the
    148 function timed out it returns a value of zero. On failure it returns
    149 <SPAN
    150 CLASS="RETURNVALUE"
    151 >-1</SPAN
    152 > and the <CODE
    153 CLASS="VARNAME"
    154 >errno</CODE
    155 >
    156 variable is set appropriately. When the application did not call
    157 <A
    158 HREF="r12878.htm"
    159 ><CODE
    160 CLASS="CONSTANT"
    161 >VIDIOC_QBUF</CODE
    162 ></A
    163 > or <A
    164 HREF="r13817.htm"
    165 ><CODE
    166 CLASS="CONSTANT"
    167 >VIDIOC_STREAMON</CODE
    168 ></A
    169 > yet the
    170 <CODE
    171 CLASS="FUNCTION"
    172 >select()</CODE
    173 > function succeeds, setting the bit of
    174 the file descriptor in <CODE
    175 CLASS="PARAMETER"
    176 >readfds</CODE
    177 > or
    178 <CODE
    179 CLASS="PARAMETER"
    180 >writefds</CODE
    181 >, but subsequent <A
    182 HREF="r12878.htm"
    183 ><CODE
    184 CLASS="CONSTANT"
    185 >VIDIOC_DQBUF</CODE
    186 ></A
    187 > calls
    188 will fail.<A
    189 NAME="AEN14434"
    190 HREF="r14390.htm#FTN.AEN14434"
    191 ><SPAN
    192 CLASS="footnote"
    193 >[1]</SPAN
    194 ></A
    195 ></P
    196 ><P
    197 >When use of the <CODE
    198 CLASS="FUNCTION"
    199 >read()</CODE
    200 > function has
    201 been negotiated and the driver does not capture yet, the
    202 <CODE
    203 CLASS="FUNCTION"
    204 >select()</CODE
    205 > function starts capturing. When that
    206 fails, <CODE
    207 CLASS="FUNCTION"
    208 >select()</CODE
    209 > returns successful and a
    210 subsequent <CODE
    211 CLASS="FUNCTION"
    212 >read()</CODE
    213 > call, which also attempts to
    214 start capturing, will return an appropriate error code. When the
    215 driver captures continuously (as opposed to, for example, still
    216 images) and data is already available the
    217 <CODE
    218 CLASS="FUNCTION"
    219 >select()</CODE
    220 > function returns 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 >select()</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 >select()</CODE
    247 > function.</P
    248 ><P
    249 >For more details see the <CODE
    250 CLASS="FUNCTION"
    251 >select()</CODE
    252 >
    253 manual page.</P
    254 ></DIV
    255 ><DIV
    256 CLASS="REFSECT1"
    257 ><A
    258 NAME="AEN14457"
    259 ></A
    260 ><H2
    261 >Return Value</H2
    262 ><P
    263 >On success, <CODE
    264 CLASS="FUNCTION"
    265 >select()</CODE
    266 > returns the number
    267 of descriptors contained in the three returned descriptor sets, which
    268 will be zero if the timeout expired. On error
    269 <SPAN
    270 CLASS="RETURNVALUE"
    271 >-1</SPAN
    272 > is returned, and the
    273 <CODE
    274 CLASS="VARNAME"
    275 >errno</CODE
    276 > variable is set appropriately; the sets and
    277 <CODE
    278 CLASS="PARAMETER"
    279 >timeout</CODE
    280 > are undefined. Possible error codes
    281 are:</P
    282 ><P
    283 ></P
    284 ><DIV
    285 CLASS="VARIABLELIST"
    286 ><DL
    287 ><DT
    288 ><SPAN
    289 CLASS="ERRORCODE"
    290 >EBADF</SPAN
    291 ></DT
    292 ><DD
    293 ><P
    294 >One or more of the file descriptor sets specified a
    295 file descriptor that is not open.</P
    296 ></DD
    297 ><DT
    298 ><SPAN
    299 CLASS="ERRORCODE"
    300 >EBUSY</SPAN
    301 ></DT
    302 ><DD
    303 ><P
    304 >The driver does not support multiple read or write
    305 streams and the device is already in use.</P
    306 ></DD
    307 ><DT
    308 ><SPAN
    309 CLASS="ERRORCODE"
    310 >EFAULT</SPAN
    311 ></DT
    312 ><DD
    313 ><P
    314 >The <CODE
    315 CLASS="PARAMETER"
    316 >readfds</CODE
    317 >,
    318 <CODE
    319 CLASS="PARAMETER"
    320 >writefds</CODE
    321 >, <CODE
    322 CLASS="PARAMETER"
    323 >exceptfds</CODE
    324 > or
    325 <CODE
    326 CLASS="PARAMETER"
    327 >timeout</CODE
    328 > pointer references an inaccessible memory
    329 area.</P
    330 ></DD
    331 ><DT
    332 ><SPAN
    333 CLASS="ERRORCODE"
    334 >EINTR</SPAN
    335 ></DT
    336 ><DD
    337 ><P
    338 >The call was interrupted by a signal.</P
    339 ></DD
    340 ><DT
    341 ><SPAN
    342 CLASS="ERRORCODE"
    343 >EINVAL</SPAN
    344 ></DT
    345 ><DD
    346 ><P
    347 >The <CODE
    348 CLASS="PARAMETER"
    349 >nfds</CODE
    350 > argument is less than
    351 zero or greater than <CODE
    352 CLASS="CONSTANT"
    353 >FD_SETSIZE</CODE
    354 >.</P
    355 ></DD
    356 ></DL
    357 ></DIV
    358 ></DIV
    359 ><H2
    360 CLASS="FOOTNOTES"
    361 >Notes</H2
    362 ><TABLE
    363 BORDER="0"
    364 CLASS="FOOTNOTES"
    365 WIDTH="100%"
    366 ><TR
    367 ><TD
    368 ALIGN="LEFT"
    369 VALIGN="TOP"
    370 WIDTH="5%"
    371 ><A
    372 NAME="FTN.AEN14434"
    373 HREF="r14390.htm#AEN14434"
    374 ><SPAN
    375 CLASS="footnote"
    376 >[1]</SPAN
    377 ></A
    378 ></TD
    379 ><TD
    380 ALIGN="LEFT"
    381 VALIGN="TOP"
    382 WIDTH="95%"
    383 ><P
    384 >The Linux kernel implements
    385 <CODE
    386 CLASS="FUNCTION"
    387 >select()</CODE
    388 > like the <A
    389 HREF="r14169.htm"
    390 ><CODE
    391 CLASS="FUNCTION"
    392 >poll()</CODE
    393 ></A
    394 > function, but
    395 <CODE
    396 CLASS="FUNCTION"
    397 >select()</CODE
    398 > cannot return a
    399 <CODE
    400 CLASS="CONSTANT"
    401 >POLLERR</CODE
    402 >.</P
    403 ></TD
    404 ></TR
    405 ></TABLE
    406 ><DIV
    407 CLASS="NAVFOOTER"
    408 ><HR
    409 ALIGN="LEFT"
    410 WIDTH="100%"><TABLE
    411 SUMMARY="Footer navigation table"
    412 WIDTH="100%"
    413 BORDER="0"
    414 CELLPADDING="0"
    415 CELLSPACING="0"
    416 ><TR
    417 ><TD
    418 WIDTH="33%"
    419 ALIGN="left"
    420 VALIGN="top"
    421 ><A
    422 HREF="r14264.htm"
    423 ACCESSKEY="P"
    424 >Prev</A
    425 ></TD
    426 ><TD
    427 WIDTH="34%"
    428 ALIGN="center"
    429 VALIGN="top"
    430 ><A
    431 HREF="book1.htm"
    432 ACCESSKEY="H"
    433 >Home</A
    434 ></TD
    435 ><TD
    436 WIDTH="33%"
    437 ALIGN="right"
    438 VALIGN="top"
    439 ><A
    440 HREF="r14496.htm"
    441 ACCESSKEY="N"
    442 >Next</A
    443 ></TD
    444 ></TR
    445 ><TR
    446 ><TD
    447 WIDTH="33%"
    448 ALIGN="left"
    449 VALIGN="top"
    450 >V4L2 read()</TD
    451 ><TD
    452 WIDTH="34%"
    453 ALIGN="center"
    454 VALIGN="top"
    455 ><A
    456 HREF="r7624.htm"
    457 ACCESSKEY="U"
    458 >Up</A
    459 ></TD
    460 ><TD
    461 WIDTH="33%"
    462 ALIGN="right"
    463 VALIGN="top"
    464 >V4L2 write()</TD
    465 ></TR
    466 ></TABLE
    467 ></DIV
    468 ></BODY
    469 ></HTML
    470 >
    471