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