blob: f8caa28a96d27a8d8d940730b35ec3df49c36912 [file] [log] [blame]
Markus Heisere2460b12016-07-08 20:55:42 +02001.. -*- coding: utf-8; mode: rst -*-
2
Markus Heiser21c62692016-07-08 20:55:43 +02003.. _CEC_DQEVENT:
Markus Heisere2460b12016-07-08 20:55:42 +02004
5*****************
6ioctl CEC_DQEVENT
7*****************
8
Markus Heiser21c62692016-07-08 20:55:43 +02009Name
10====
Markus Heisere2460b12016-07-08 20:55:42 +020011
Markus Heiser21c62692016-07-08 20:55:43 +020012CEC_DQEVENT - Dequeue a CEC event
Markus Heisere2460b12016-07-08 20:55:42 +020013
14
15Synopsis
16========
17
Markus Heiser9cd34762016-08-15 16:08:28 +020018.. c:function:: int ioctl( int fd, int request, struct cec_event *argp )
19 :name: CEC_DQEVENT
Markus Heisere2460b12016-07-08 20:55:42 +020020
21Arguments
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
33Description
34===========
35
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -030036.. note:: This documents the proposed CEC API. This API is not yet finalized
37 and is currently only available as a staging kernel module.
Markus Heisere2460b12016-07-08 20:55:42 +020038
39CEC devices can send asynchronous events. These can be retrieved by
Markus Heiser9cd34762016-08-15 16:08:28 +020040calling :c:func:`CEC_DQEVENT`. If the file descriptor is in
Markus Heisere2460b12016-07-08 20:55:42 +020041non-blocking mode and no event is pending, then it will return -1 and
Hans Verkuile5208ed2016-07-19 06:26:13 -030042set errno to the ``EAGAIN`` error code.
Markus Heisere2460b12016-07-08 20:55:42 +020043
44The internal event queues are per-filehandle and per-event type. If
45there is no more room in a queue then the last event is overwritten with
46the new one. This means that intermediate results can be thrown away but
47that the latest event is always available. This also means that is it
48possible to read two successive events that have the same value (e.g.
Mauro Carvalho Chehabcc0fe5c2016-07-13 10:22:38 -030049two :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` events with
50the same state). In that case the intermediate state changes were lost but
51it is guaranteed that the state did change in between the two events.
Markus Heisere2460b12016-07-08 20:55:42 +020052
53
Mauro Carvalho Chehab96f69e02016-07-09 10:25:05 -030054.. _cec-event-state-change_s:
Markus Heisere2460b12016-07-08 20:55:42 +020055
56.. flat-table:: struct cec_event_state_change
57 :header-rows: 0
58 :stub-columns: 0
Mauro Carvalho Chehabb2a58432016-07-08 17:59:27 -030059 :widths: 1 1 8
Markus Heisere2460b12016-07-08 20:55:42 +020060
61
62 - .. row 1
63
64 - __u16
65
66 - ``phys_addr``
67
Hans Verkuil277f9632016-08-10 06:00:53 -030068 - The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
69 valid physical address is set.
Markus Heisere2460b12016-07-08 20:55:42 +020070
71 - .. row 2
72
73 - __u16
74
75 - ``log_addr_mask``
76
Hans Verkuil277f9632016-08-10 06:00:53 -030077 - The current set of claimed logical addresses. This is 0 if no logical
78 addresses are claimed or if ``phys_addr`` is ``CEC_PHYS_ADDR_INVALID``.
79 If bit 15 is set (``1 << CEC_LOG_ADDR_UNREGISTERED``) then this device
80 has the unregistered logical address. In that case all other bits are 0.
Markus Heisere2460b12016-07-08 20:55:42 +020081
82
83
Mauro Carvalho Chehab96f69e02016-07-09 10:25:05 -030084.. _cec-event-lost-msgs_s:
Markus Heisere2460b12016-07-08 20:55:42 +020085
86.. flat-table:: struct cec_event_lost_msgs
87 :header-rows: 0
88 :stub-columns: 0
Mauro Carvalho Chehabb2a58432016-07-08 17:59:27 -030089 :widths: 1 1 16
Markus Heisere2460b12016-07-08 20:55:42 +020090
91
92 - .. row 1
93
94 - __u32
95
96 - ``lost_msgs``
97
98 - Set to the number of lost messages since the filehandle was opened
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -030099 or since the last time this event was dequeued for this
100 filehandle. The messages lost are the oldest messages. So when a
101 new message arrives and there is no more room, then the oldest
102 message is discarded to make room for the new one. The internal
103 size of the message queue guarantees that all messages received in
104 the last two seconds will be stored. Since messages should be
105 replied to within a second according to the CEC specification,
106 this is more than enough.
Markus Heisere2460b12016-07-08 20:55:42 +0200107
108
109
110.. _cec-event:
111
112.. flat-table:: struct cec_event
113 :header-rows: 0
114 :stub-columns: 0
Mauro Carvalho Chehabb2a58432016-07-08 17:59:27 -0300115 :widths: 1 1 1 8
Markus Heisere2460b12016-07-08 20:55:42 +0200116
117
118 - .. row 1
119
120 - __u64
121
122 - ``ts``
123
124 - Timestamp of the event in ns.
Hans Verkuile5208ed2016-07-19 06:26:13 -0300125 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
126 the same clock from userspace use :c:func:`clock_gettime(2)`.
Markus Heisere2460b12016-07-08 20:55:42 +0200127
128 -
129
130 - .. row 2
131
132 - __u32
133
134 - ``event``
135
136 - The CEC event type, see :ref:`cec-events`.
137
138 -
139
140 - .. row 3
141
142 - __u32
143
144 - ``flags``
145
146 - Event flags, see :ref:`cec-event-flags`.
147
148 -
149
150 - .. row 4
151
152 - union
153
154 - (anonymous)
155
156 -
157 -
158
159 - .. row 5
160
161 -
162 - struct cec_event_state_change
163
164 - ``state_change``
165
Mauro Carvalho Chehab96f69e02016-07-09 10:25:05 -0300166 - The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>`
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -0300167 event.
Markus Heisere2460b12016-07-08 20:55:42 +0200168
169 - .. row 6
170
171 -
172 - struct cec_event_lost_msgs
173
174 - ``lost_msgs``
175
Mauro Carvalho Chehab96f69e02016-07-09 10:25:05 -0300176 - The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>`
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -0300177 event.
Markus Heisere2460b12016-07-08 20:55:42 +0200178
179
180
181.. _cec-events:
182
183.. flat-table:: CEC Events Types
184 :header-rows: 0
185 :stub-columns: 0
Mauro Carvalho Chehabb2a58432016-07-08 17:59:27 -0300186 :widths: 3 1 16
Markus Heisere2460b12016-07-08 20:55:42 +0200187
188
Mauro Carvalho Chehab96f69e02016-07-09 10:25:05 -0300189 - .. _`CEC-EVENT-STATE-CHANGE`:
Markus Heisere2460b12016-07-08 20:55:42 +0200190
191 - ``CEC_EVENT_STATE_CHANGE``
192
193 - 1
194
195 - Generated when the CEC Adapter's state changes. When open() is
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -0300196 called an initial event will be generated for that filehandle with
197 the CEC Adapter's state at that time.
Markus Heisere2460b12016-07-08 20:55:42 +0200198
Mauro Carvalho Chehab96f69e02016-07-09 10:25:05 -0300199 - .. _`CEC-EVENT-LOST-MSGS`:
Markus Heisere2460b12016-07-08 20:55:42 +0200200
201 - ``CEC_EVENT_LOST_MSGS``
202
203 - 2
204
205 - Generated if one or more CEC messages were lost because the
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -0300206 application didn't dequeue CEC messages fast enough.
Markus Heisere2460b12016-07-08 20:55:42 +0200207
208
209
210.. _cec-event-flags:
211
212.. flat-table:: CEC Event Flags
213 :header-rows: 0
214 :stub-columns: 0
Mauro Carvalho Chehabb2a58432016-07-08 17:59:27 -0300215 :widths: 3 1 8
Markus Heisere2460b12016-07-08 20:55:42 +0200216
217
Mauro Carvalho Chehab96f69e02016-07-09 10:25:05 -0300218 - .. _`CEC-EVENT-FL-INITIAL-VALUE`:
Markus Heisere2460b12016-07-08 20:55:42 +0200219
220 - ``CEC_EVENT_FL_INITIAL_VALUE``
221
222 - 1
223
224 - Set for the initial events that are generated when the device is
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -0300225 opened. See the table above for which events do this. This allows
226 applications to learn the initial state of the CEC adapter at
227 open() time.
Markus Heisere2460b12016-07-08 20:55:42 +0200228
229
230
231Return Value
232============
233
234On success 0 is returned, on error -1 and the ``errno`` variable is set
235appropriately. The generic error codes are described at the
236:ref:`Generic Error Codes <gen-errors>` chapter.