doc-rst: linux_tv: fix remaining lack of escapes
[deliverable/linux.git] / Documentation / linux_tv / media / v4l / func-select.rst
CommitLineData
5377d91f
MH
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _func-select:
4
5*************
6V4L2 select()
7*************
8
9*man v4l2-select(2)*
10
11Synchronous I/O multiplexing
12
13
14Synopsis
15========
16
17.. code-block:: c
18
19 #include <sys/time.h>
20 #include <sys/types.h>
21 #include <unistd.h>
22
23
b7e67f6c 24.. cpp:function:: int select( int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout )
5377d91f
MH
25
26Description
27===========
28
29With the :c:func:`select()` function applications can suspend
30execution until the driver has captured data or is ready to accept data
31for output.
32
33When streaming I/O has been negotiated this function waits until a
34buffer has been filled or displayed and can be dequeued with the
af4a4d0d 35:ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl. When buffers are already in
5377d91f
MH
36the outgoing queue of the driver the function returns immediately.
37
38On success :c:func:`select()` returns the total number of bits set in
acf309a2 39:c:func:`struct fd_set`. When the function timed out it returns
5377d91f
MH
40a value of zero. On failure it returns -1 and the ``errno`` variable is
41set appropriately. When the application did not call
7347081e
MCC
42:ref:`VIDIOC_QBUF` or
43:ref:`VIDIOC_STREAMON` yet the :c:func:`select()`
5377d91f 44function succeeds, setting the bit of the file descriptor in ``readfds``
af4a4d0d 45or ``writefds``, but subsequent :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>`
5377d91f
MH
46calls will fail. [1]_
47
48When use of the :c:func:`read()` function has been negotiated and the
49driver does not capture yet, the :c:func:`select()` function starts
50capturing. When that fails, :c:func:`select()` returns successful and
51a subsequent :c:func:`read()` call, which also attempts to start
52capturing, will return an appropriate error code. When the driver
53captures continuously (as opposed to, for example, still images) and
54data is already available the :c:func:`select()` function returns
55immediately.
56
57When use of the :c:func:`write()` function has been negotiated the
58:c:func:`select()` function just waits until the driver is ready for a
59non-blocking :c:func:`write()` call.
60
61All drivers implementing the :c:func:`read()` or :c:func:`write()`
62function or streaming I/O must also support the :c:func:`select()`
63function.
64
65For more details see the :c:func:`select()` manual page.
66
67
68Return Value
69============
70
71On success, :c:func:`select()` returns the number of descriptors
72contained in the three returned descriptor sets, which will be zero if
73the timeout expired. On error -1 is returned, and the ``errno`` variable
74is set appropriately; the sets and ``timeout`` are undefined. Possible
75error codes are:
76
77EBADF
78 One or more of the file descriptor sets specified a file descriptor
79 that is not open.
80
81EBUSY
82 The driver does not support multiple read or write streams and the
83 device is already in use.
84
85EFAULT
86 The ``readfds``, ``writefds``, ``exceptfds`` or ``timeout`` pointer
87 references an inaccessible memory area.
88
89EINTR
90 The call was interrupted by a signal.
91
92EINVAL
93 The ``nfds`` argument is less than zero or greater than
94 ``FD_SETSIZE``.
95
96.. [1]
97 The Linux kernel implements :c:func:`select()` like the
98 :ref:`poll() <func-poll>` function, but :c:func:`select()` cannot
99 return a ``POLLERR``.
This page took 0.032702 seconds and 5 git commands to generate.