Merge tag 'nfs-for-4.21-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
[sfrench/cifs-2.6.git] / Documentation / media / uapi / cec / cec-ioc-dqevent.rst
1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/media/uapi/fdl-appendix.rst.
7 ..
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10 .. _CEC_DQEVENT:
11
12 *****************
13 ioctl CEC_DQEVENT
14 *****************
15
16 Name
17 ====
18
19 CEC_DQEVENT - Dequeue a CEC event
20
21
22 Synopsis
23 ========
24
25 .. c:function:: int ioctl( int fd, CEC_DQEVENT, struct cec_event *argp )
26     :name: CEC_DQEVENT
27
28 Arguments
29 =========
30
31 ``fd``
32     File descriptor returned by :c:func:`open() <cec-open>`.
33
34 ``argp``
35
36
37 Description
38 ===========
39
40 CEC devices can send asynchronous events. These can be retrieved by
41 calling :c:func:`CEC_DQEVENT`. If the file descriptor is in
42 non-blocking mode and no event is pending, then it will return -1 and
43 set errno to the ``EAGAIN`` error code.
44
45 The internal event queues are per-filehandle and per-event type. If
46 there is no more room in a queue then the last event is overwritten with
47 the new one. This means that intermediate results can be thrown away but
48 that the latest event is always available. This also means that is it
49 possible to read two successive events that have the same value (e.g.
50 two :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` events with
51 the same state). In that case the intermediate state changes were lost but
52 it is guaranteed that the state did change in between the two events.
53
54 .. tabularcolumns:: |p{1.2cm}|p{2.9cm}|p{13.4cm}|
55
56 .. c:type:: cec_event_state_change
57
58 .. flat-table:: struct cec_event_state_change
59     :header-rows:  0
60     :stub-columns: 0
61     :widths:       1 1 8
62
63     * - __u16
64       - ``phys_addr``
65       - The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
66         valid physical address is set.
67     * - __u16
68       - ``log_addr_mask``
69       - The current set of claimed logical addresses. This is 0 if no logical
70         addresses are claimed or if ``phys_addr`` is ``CEC_PHYS_ADDR_INVALID``.
71         If bit 15 is set (``1 << CEC_LOG_ADDR_UNREGISTERED``) then this device
72         has the unregistered logical address. In that case all other bits are 0.
73
74
75 .. c:type:: cec_event_lost_msgs
76
77 .. tabularcolumns:: |p{1.0cm}|p{2.0cm}|p{14.5cm}|
78
79 .. flat-table:: struct cec_event_lost_msgs
80     :header-rows:  0
81     :stub-columns: 0
82     :widths:       1 1 16
83
84     * - __u32
85       - ``lost_msgs``
86       - Set to the number of lost messages since the filehandle was opened
87         or since the last time this event was dequeued for this
88         filehandle. The messages lost are the oldest messages. So when a
89         new message arrives and there is no more room, then the oldest
90         message is discarded to make room for the new one. The internal
91         size of the message queue guarantees that all messages received in
92         the last two seconds will be stored. Since messages should be
93         replied to within a second according to the CEC specification,
94         this is more than enough.
95
96
97 .. tabularcolumns:: |p{1.0cm}|p{4.4cm}|p{2.5cm}|p{9.6cm}|
98
99 .. c:type:: cec_event
100
101 .. flat-table:: struct cec_event
102     :header-rows:  0
103     :stub-columns: 0
104     :widths:       1 1 1 8
105
106     * - __u64
107       - ``ts``
108       - :cspan:`1`\ Timestamp of the event in ns.
109
110         The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock.
111
112         To access the same clock from userspace use :c:func:`clock_gettime`.
113     * - __u32
114       - ``event``
115       - :cspan:`1` The CEC event type, see :ref:`cec-events`.
116     * - __u32
117       - ``flags``
118       - :cspan:`1` Event flags, see :ref:`cec-event-flags`.
119     * - union
120       - (anonymous)
121       -
122       -
123     * -
124       - struct cec_event_state_change
125       - ``state_change``
126       - The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>`
127         event.
128     * -
129       - struct cec_event_lost_msgs
130       - ``lost_msgs``
131       - The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>`
132         event.
133
134
135 .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
136
137 .. _cec-events:
138
139 .. flat-table:: CEC Events Types
140     :header-rows:  0
141     :stub-columns: 0
142     :widths:       3 1 16
143
144     * .. _`CEC-EVENT-STATE-CHANGE`:
145
146       - ``CEC_EVENT_STATE_CHANGE``
147       - 1
148       - Generated when the CEC Adapter's state changes. When open() is
149         called an initial event will be generated for that filehandle with
150         the CEC Adapter's state at that time.
151     * .. _`CEC-EVENT-LOST-MSGS`:
152
153       - ``CEC_EVENT_LOST_MSGS``
154       - 2
155       - Generated if one or more CEC messages were lost because the
156         application didn't dequeue CEC messages fast enough.
157     * .. _`CEC-EVENT-PIN-CEC-LOW`:
158
159       - ``CEC_EVENT_PIN_CEC_LOW``
160       - 3
161       - Generated if the CEC pin goes from a high voltage to a low voltage.
162         Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
163         capability set.
164     * .. _`CEC-EVENT-PIN-CEC-HIGH`:
165
166       - ``CEC_EVENT_PIN_CEC_HIGH``
167       - 4
168       - Generated if the CEC pin goes from a low voltage to a high voltage.
169         Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
170         capability set.
171     * .. _`CEC-EVENT-PIN-HPD-LOW`:
172
173       - ``CEC_EVENT_PIN_HPD_LOW``
174       - 5
175       - Generated if the HPD pin goes from a high voltage to a low voltage.
176         Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
177         capability set. When open() is called, the HPD pin can be read and
178         if the HPD is low, then an initial event will be generated for that
179         filehandle.
180     * .. _`CEC-EVENT-PIN-HPD-HIGH`:
181
182       - ``CEC_EVENT_PIN_HPD_HIGH``
183       - 6
184       - Generated if the HPD pin goes from a low voltage to a high voltage.
185         Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
186         capability set. When open() is called, the HPD pin can be read and
187         if the HPD is high, then an initial event will be generated for that
188         filehandle.
189     * .. _`CEC-EVENT-PIN-5V-LOW`:
190
191       - ``CEC_EVENT_PIN_5V_LOW``
192       - 6
193       - Generated if the 5V pin goes from a high voltage to a low voltage.
194         Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
195         capability set. When open() is called, the 5V pin can be read and
196         if the 5V is low, then an initial event will be generated for that
197         filehandle.
198     * .. _`CEC-EVENT-PIN-5V-HIGH`:
199
200       - ``CEC_EVENT_PIN_5V_HIGH``
201       - 7
202       - Generated if the 5V pin goes from a low voltage to a high voltage.
203         Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
204         capability set. When open() is called, the 5V pin can be read and
205         if the 5V is high, then an initial event will be generated for that
206         filehandle.
207
208
209 .. tabularcolumns:: |p{6.0cm}|p{0.6cm}|p{10.9cm}|
210
211 .. _cec-event-flags:
212
213 .. flat-table:: CEC Event Flags
214     :header-rows:  0
215     :stub-columns: 0
216     :widths:       3 1 8
217
218     * .. _`CEC-EVENT-FL-INITIAL-STATE`:
219
220       - ``CEC_EVENT_FL_INITIAL_STATE``
221       - 1
222       - Set for the initial events that are generated when the device is
223         opened. See the table above for which events do this. This allows
224         applications to learn the initial state of the CEC adapter at
225         open() time.
226     * .. _`CEC-EVENT-FL-DROPPED-EVENTS`:
227
228       - ``CEC_EVENT_FL_DROPPED_EVENTS``
229       - 2
230       - Set if one or more events of the given event type have been dropped.
231         This is an indication that the application cannot keep up.
232
233
234
235 Return Value
236 ============
237
238 On success 0 is returned, on error -1 and the ``errno`` variable is set
239 appropriately. The generic error codes are described at the
240 :ref:`Generic Error Codes <gen-errors>` chapter.
241
242 The :ref:`ioctl CEC_DQEVENT <CEC_DQEVENT>` can return the following
243 error codes:
244
245 EAGAIN
246     This is returned when the filehandle is in non-blocking mode and there
247     are no pending events.
248
249 ERESTARTSYS
250     An interrupt (e.g. Ctrl-C) arrived while in blocking mode waiting for
251     events to arrive.