Merge branch 'driver-api' into doc/4.9
[cascardo/linux.git] / Documentation / media / uapi / cec / cec-ioc-dqevent.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 .. _CEC_DQEVENT:
4
5 *****************
6 ioctl CEC_DQEVENT
7 *****************
8
9 Name
10 ====
11
12 CEC_DQEVENT - Dequeue a CEC event
13
14
15 Synopsis
16 ========
17
18 .. c:function:: int ioctl( int fd, int request, struct cec_event *argp )
19    :name: CEC_DQEVENT
20
21 Arguments
22 =========
23
24 ``fd``
25     File descriptor returned by :ref:`open() <cec-func-open>`.
26
27 ``request``
28     CEC_DQEVENT
29
30 ``argp``
31
32
33 Description
34 ===========
35
36 .. note:: This documents the proposed CEC API. This API is not yet finalized
37    and is currently only available as a staging kernel module.
38
39 CEC devices can send asynchronous events. These can be retrieved by
40 calling :c:func:`CEC_DQEVENT`. If the file descriptor is in
41 non-blocking mode and no event is pending, then it will return -1 and
42 set errno to the ``EAGAIN`` error code.
43
44 The internal event queues are per-filehandle and per-event type. If
45 there is no more room in a queue then the last event is overwritten with
46 the new one. This means that intermediate results can be thrown away but
47 that the latest event is always available. This also means that is it
48 possible to read two successive events that have the same value (e.g.
49 two :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` events with
50 the same state). In that case the intermediate state changes were lost but
51 it is guaranteed that the state did change in between the two events.
52
53
54 .. _cec-event-state-change_s:
55
56 .. flat-table:: struct cec_event_state_change
57     :header-rows:  0
58     :stub-columns: 0
59     :widths:       1 1 8
60
61
62     -  .. row 1
63
64        -  __u16
65
66        -  ``phys_addr``
67
68        -  The current physical address.
69
70     -  .. row 2
71
72        -  __u16
73
74        -  ``log_addr_mask``
75
76        -  The current set of claimed logical addresses.
77
78
79
80 .. _cec-event-lost-msgs_s:
81
82 .. flat-table:: struct cec_event_lost_msgs
83     :header-rows:  0
84     :stub-columns: 0
85     :widths:       1 1 16
86
87
88     -  .. row 1
89
90        -  __u32
91
92        -  ``lost_msgs``
93
94        -  Set to the number of lost messages since the filehandle was opened
95           or since the last time this event was dequeued for this
96           filehandle. The messages lost are the oldest messages. So when a
97           new message arrives and there is no more room, then the oldest
98           message is discarded to make room for the new one. The internal
99           size of the message queue guarantees that all messages received in
100           the last two seconds will be stored. Since messages should be
101           replied to within a second according to the CEC specification,
102           this is more than enough.
103
104
105
106 .. _cec-event:
107
108 .. flat-table:: struct cec_event
109     :header-rows:  0
110     :stub-columns: 0
111     :widths:       1 1 1 8
112
113
114     -  .. row 1
115
116        -  __u64
117
118        -  ``ts``
119
120        -  Timestamp of the event in ns.
121           The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
122           the same clock from userspace use :c:func:`clock_gettime(2)`.
123
124        -
125
126     -  .. row 2
127
128        -  __u32
129
130        -  ``event``
131
132        -  The CEC event type, see :ref:`cec-events`.
133
134        -
135
136     -  .. row 3
137
138        -  __u32
139
140        -  ``flags``
141
142        -  Event flags, see :ref:`cec-event-flags`.
143
144        -
145
146     -  .. row 4
147
148        -  union
149
150        -  (anonymous)
151
152        -
153        -
154
155     -  .. row 5
156
157        -
158        -  struct cec_event_state_change
159
160        -  ``state_change``
161
162        -  The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>`
163           event.
164
165     -  .. row 6
166
167        -
168        -  struct cec_event_lost_msgs
169
170        -  ``lost_msgs``
171
172        -  The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>`
173           event.
174
175
176
177 .. _cec-events:
178
179 .. flat-table:: CEC Events Types
180     :header-rows:  0
181     :stub-columns: 0
182     :widths:       3 1 16
183
184
185     -  .. _`CEC-EVENT-STATE-CHANGE`:
186
187        -  ``CEC_EVENT_STATE_CHANGE``
188
189        -  1
190
191        -  Generated when the CEC Adapter's state changes. When open() is
192           called an initial event will be generated for that filehandle with
193           the CEC Adapter's state at that time.
194
195     -  .. _`CEC-EVENT-LOST-MSGS`:
196
197        -  ``CEC_EVENT_LOST_MSGS``
198
199        -  2
200
201        -  Generated if one or more CEC messages were lost because the
202           application didn't dequeue CEC messages fast enough.
203
204
205
206 .. _cec-event-flags:
207
208 .. flat-table:: CEC Event Flags
209     :header-rows:  0
210     :stub-columns: 0
211     :widths:       3 1 8
212
213
214     -  .. _`CEC-EVENT-FL-INITIAL-VALUE`:
215
216        -  ``CEC_EVENT_FL_INITIAL_VALUE``
217
218        -  1
219
220        -  Set for the initial events that are generated when the device is
221           opened. See the table above for which events do this. This allows
222           applications to learn the initial state of the CEC adapter at
223           open() time.
224
225
226
227 Return Value
228 ============
229
230 On success 0 is returned, on error -1 and the ``errno`` variable is set
231 appropriately. The generic error codes are described at the
232 :ref:`Generic Error Codes <gen-errors>` chapter.