~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/userspace-api/media/v4l/func-poll.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2 .. c:namespace:: V4L
  3 
  4 .. _func-poll:
  5 
  6 ***********
  7 V4L2 poll()
  8 ***********
  9 
 10 Name
 11 ====
 12 
 13 v4l2-poll - Wait for some event on a file descriptor
 14 
 15 Synopsis
 16 ========
 17 
 18 .. code-block:: c
 19 
 20     #include <sys/poll.h>
 21 
 22 .. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
 23 
 24 Arguments
 25 =========
 26 
 27 
 28 Description
 29 ===========
 30 
 31 With the :c:func:`poll()` function applications can suspend execution
 32 until the driver has captured data or is ready to accept data for
 33 output.
 34 
 35 When streaming I/O has been negotiated this function waits until a
 36 buffer has been filled by the capture device and can be dequeued with
 37 the :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl. For output devices this
 38 function waits until the device is ready to accept a new buffer to be
 39 queued up with the :ref:`VIDIOC_QBUF <VIDIOC_QBUF>` ioctl for
 40 display. When buffers are already in the outgoing queue of the driver
 41 (capture) or the incoming queue isn't full (display) the function
 42 returns immediately.
 43 
 44 On success :c:func:`poll()` returns the number of file descriptors
 45 that have been selected (that is, file descriptors for which the
 46 ``revents`` field of the respective ``struct pollfd`` structure
 47 is non-zero). Capture devices set the ``POLLIN`` and ``POLLRDNORM``
 48 flags in the ``revents`` field, output devices the ``POLLOUT`` and
 49 ``POLLWRNORM`` flags. When the function timed out it returns a value of
 50 zero, on failure it returns -1 and the ``errno`` variable is set
 51 appropriately. When the application did not call
 52 :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>` the :c:func:`poll()`
 53 function succeeds, but sets the ``POLLERR`` flag in the ``revents``
 54 field. When the application has called
 55 :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>` for a capture device but
 56 hasn't yet called :ref:`VIDIOC_QBUF <VIDIOC_QBUF>`, the
 57 :c:func:`poll()` function succeeds and sets the ``POLLERR`` flag in
 58 the ``revents`` field. For output devices this same situation will cause
 59 :c:func:`poll()` to succeed as well, but it sets the ``POLLOUT`` and
 60 ``POLLWRNORM`` flags in the ``revents`` field.
 61 
 62 If an event occurred (see :ref:`VIDIOC_DQEVENT`)
 63 then ``POLLPRI`` will be set in the ``revents`` field and
 64 :c:func:`poll()` will return.
 65 
 66 When use of the :c:func:`read()` function has been negotiated and the
 67 driver does not capture yet, the :c:func:`poll()` function starts
 68 capturing. When that fails it returns a ``POLLERR`` as above. Otherwise
 69 it waits until data has been captured and can be read. When the driver
 70 captures continuously (as opposed to, for example, still images) the
 71 function may return immediately.
 72 
 73 When use of the :c:func:`write()` function has been negotiated and the
 74 driver does not stream yet, the :c:func:`poll()` function starts
 75 streaming. When that fails it returns a ``POLLERR`` as above. Otherwise
 76 it waits until the driver is ready for a non-blocking
 77 :c:func:`write()` call.
 78 
 79 If the caller is only interested in events (just ``POLLPRI`` is set in
 80 the ``events`` field), then :c:func:`poll()` will *not* start
 81 streaming if the driver does not stream yet. This makes it possible to
 82 just poll for events and not for buffers.
 83 
 84 All drivers implementing the :c:func:`read()` or :c:func:`write()`
 85 function or streaming I/O must also support the :c:func:`poll()`
 86 function.
 87 
 88 For more details see the :c:func:`poll()` manual page.
 89 
 90 Return Value
 91 ============
 92 
 93 On success, :c:func:`poll()` returns the number structures which have
 94 non-zero ``revents`` fields, or zero if the call timed out. On error -1
 95 is returned, and the ``errno`` variable is set appropriately:
 96 
 97 EBADF
 98     One or more of the ``ufds`` members specify an invalid file
 99     descriptor.
100 
101 EBUSY
102     The driver does not support multiple read or write streams and the
103     device is already in use.
104 
105 EFAULT
106     ``ufds`` references an inaccessible memory area.
107 
108 EINTR
109     The call was interrupted by a signal.
110 
111 EINVAL
112     The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
113     ``getrlimit()`` to obtain this value.

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php