1 .. -*- coding: utf-8; mode: rst -*-
11 Wait for some event on a file descriptor
22 .. cpp:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
27 With the :c:func:`poll()` function applications can suspend execution
28 until the driver has captured data or is ready to accept data for
31 When streaming I/O has been negotiated this function waits until a
32 buffer has been filled by the capture device and can be dequeued with
33 the :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl. For output devices this
34 function waits until the device is ready to accept a new buffer to be
35 queued up with the :ref:`VIDIOC_QBUF` ioctl for
36 display. When buffers are already in the outgoing queue of the driver
37 (capture) or the incoming queue isn't full (display) the function
40 On success :c:func:`poll()` returns the number of file descriptors
41 that have been selected (that is, file descriptors for which the
42 ``revents`` field of the respective :c:type:`struct pollfd` structure
43 is non-zero). Capture devices set the ``POLLIN`` and ``POLLRDNORM``
44 flags in the ``revents`` field, output devices the ``POLLOUT`` and
45 ``POLLWRNORM`` flags. When the function timed out it returns a value of
46 zero, on failure it returns -1 and the ``errno`` variable is set
47 appropriately. When the application did not call
48 :ref:`VIDIOC_STREAMON` the :c:func:`poll()`
49 function succeeds, but sets the ``POLLERR`` flag in the ``revents``
50 field. When the application has called
51 :ref:`VIDIOC_STREAMON` for a capture device but
52 hasn't yet called :ref:`VIDIOC_QBUF`, the
53 :c:func:`poll()` function succeeds and sets the ``POLLERR`` flag in
54 the ``revents`` field. For output devices this same situation will cause
55 :c:func:`poll()` to succeed as well, but it sets the ``POLLOUT`` and
56 ``POLLWRNORM`` flags in the ``revents`` field.
58 If an event occurred (see :ref:`VIDIOC_DQEVENT`)
59 then ``POLLPRI`` will be set in the ``revents`` field and
60 :c:func:`poll()` will return.
62 When use of the :c:func:`read()` function has been negotiated and the
63 driver does not capture yet, the :c:func:`poll()` function starts
64 capturing. When that fails it returns a ``POLLERR`` as above. Otherwise
65 it waits until data has been captured and can be read. When the driver
66 captures continuously (as opposed to, for example, still images) the
67 function may return immediately.
69 When use of the :c:func:`write()` function has been negotiated and the
70 driver does not stream yet, the :c:func:`poll()` function starts
71 streaming. When that fails it returns a ``POLLERR`` as above. Otherwise
72 it waits until the driver is ready for a non-blocking
73 :c:func:`write()` call.
75 If the caller is only interested in events (just ``POLLPRI`` is set in
76 the ``events`` field), then :c:func:`poll()` will *not* start
77 streaming if the driver does not stream yet. This makes it possible to
78 just poll for events and not for buffers.
80 All drivers implementing the :c:func:`read()` or :c:func:`write()`
81 function or streaming I/O must also support the :c:func:`poll()`
84 For more details see the :c:func:`poll()` manual page.
90 On success, :c:func:`poll()` returns the number structures which have
91 non-zero ``revents`` fields, or zero if the call timed out. On error -1
92 is returned, and the ``errno`` variable is set appropriately:
95 One or more of the ``ufds`` members specify an invalid file
99 The driver does not support multiple read or write streams and the
100 device is already in use.
103 ``ufds`` references an inaccessible memory area.
106 The call was interrupted by a signal.
109 The ``nfds`` argument is greater than ``OPEN_MAX``.
112 .. ------------------------------------------------------------------------------
113 .. This file was automatically converted from DocBook-XML with the dbxml
114 .. library (https://github.com/return42/sphkerneldoc). The origin XML comes
115 .. from the linux kernel, refer to:
117 .. * https://github.com/torvalds/linux/tree/master/Documentation/DocBook
118 .. ------------------------------------------------------------------------------