1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
13 CEC_DQEVENT - Dequeue a CEC event
18 .. c:macro:: CEC_DQEVENT
20 ``int ioctl(int fd, CEC_DQEVENT, struct cec_event *argp)``
26 File descriptor returned by :c:func:`open()`.
33 CEC devices can send asynchronous events. These can be retrieved by
34 calling :c:func:`CEC_DQEVENT`. If the file descriptor is in
35 non-blocking mode and no event is pending, then it will return -1 and
36 set errno to the ``EAGAIN`` error code.
38 The internal event queues are per-filehandle and per-event type. If
39 there is no more room in a queue then the last event is overwritten with
40 the new one. This means that intermediate results can be thrown away but
41 that the latest event is always available. This also means that is it
42 possible to read two successive events that have the same value (e.g.
43 two :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` events with
44 the same state). In that case the intermediate state changes were lost but
45 it is guaranteed that the state did change in between the two events.
47 .. tabularcolumns:: |p{1.2cm}|p{2.9cm}|p{13.4cm}|
49 .. c:type:: cec_event_state_change
51 .. flat-table:: struct cec_event_state_change
58 - The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
59 valid physical address is set.
62 - The current set of claimed logical addresses. This is 0 if no logical
63 addresses are claimed or if ``phys_addr`` is ``CEC_PHYS_ADDR_INVALID``.
64 If bit 15 is set (``1 << CEC_LOG_ADDR_UNREGISTERED``) then this device
65 has the unregistered logical address. In that case all other bits are 0.
68 - If non-zero, then HDMI connector information is available.
69 This field is only valid if ``CEC_CAP_CONNECTOR_INFO`` is set. If that
70 capability is set and ``have_conn_info`` is zero, then that indicates
71 that the HDMI connector device is not instantiated, either because
72 the HDMI driver is still configuring the device or because the HDMI
75 .. c:type:: cec_event_lost_msgs
77 .. tabularcolumns:: |p{1.0cm}|p{2.0cm}|p{14.5cm}|
79 .. flat-table:: struct cec_event_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.
96 .. tabularcolumns:: |p{1.0cm}|p{4.4cm}|p{2.5cm}|p{9.6cm}|
100 .. flat-table:: struct cec_event
107 - Timestamp of the event in ns.
109 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock.
111 To access the same clock from userspace use :c:func:`clock_gettime`.
114 - The CEC event type, see :ref:`cec-events`.
117 - Event flags, see :ref:`cec-event-flags`.
120 * - struct cec_event_state_change
122 - The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>`
124 * - struct cec_event_lost_msgs
126 - The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>`
131 .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
135 .. flat-table:: CEC Events Types
140 * .. _`CEC-EVENT-STATE-CHANGE`:
142 - ``CEC_EVENT_STATE_CHANGE``
144 - Generated when the CEC Adapter's state changes. When open() is
145 called an initial event will be generated for that filehandle with
146 the CEC Adapter's state at that time.
147 * .. _`CEC-EVENT-LOST-MSGS`:
149 - ``CEC_EVENT_LOST_MSGS``
151 - Generated if one or more CEC messages were lost because the
152 application didn't dequeue CEC messages fast enough.
153 * .. _`CEC-EVENT-PIN-CEC-LOW`:
155 - ``CEC_EVENT_PIN_CEC_LOW``
157 - Generated if the CEC pin goes from a high voltage to a low voltage.
158 Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
160 * .. _`CEC-EVENT-PIN-CEC-HIGH`:
162 - ``CEC_EVENT_PIN_CEC_HIGH``
164 - Generated if the CEC pin goes from a low voltage to a high voltage.
165 Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
167 * .. _`CEC-EVENT-PIN-HPD-LOW`:
169 - ``CEC_EVENT_PIN_HPD_LOW``
171 - Generated if the HPD pin goes from a high voltage to a low voltage.
172 Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
173 capability set. When open() is called, the HPD pin can be read and
174 if the HPD is low, then an initial event will be generated for that
176 * .. _`CEC-EVENT-PIN-HPD-HIGH`:
178 - ``CEC_EVENT_PIN_HPD_HIGH``
180 - Generated if the HPD pin goes from a low voltage to a high voltage.
181 Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
182 capability set. When open() is called, the HPD pin can be read and
183 if the HPD is high, then an initial event will be generated for that
185 * .. _`CEC-EVENT-PIN-5V-LOW`:
187 - ``CEC_EVENT_PIN_5V_LOW``
189 - Generated if the 5V pin goes from a high voltage to a low voltage.
190 Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
191 capability set. When open() is called, the 5V pin can be read and
192 if the 5V is low, then an initial event will be generated for that
194 * .. _`CEC-EVENT-PIN-5V-HIGH`:
196 - ``CEC_EVENT_PIN_5V_HIGH``
198 - Generated if the 5V pin goes from a low voltage to a high voltage.
199 Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
200 capability set. When open() is called, the 5V pin can be read and
201 if the 5V is high, then an initial event will be generated for that
204 .. tabularcolumns:: |p{6.0cm}|p{0.6cm}|p{10.9cm}|
208 .. flat-table:: CEC Event Flags
213 * .. _`CEC-EVENT-FL-INITIAL-STATE`:
215 - ``CEC_EVENT_FL_INITIAL_STATE``
217 - Set for the initial events that are generated when the device is
218 opened. See the table above for which events do this. This allows
219 applications to learn the initial state of the CEC adapter at
221 * .. _`CEC-EVENT-FL-DROPPED-EVENTS`:
223 - ``CEC_EVENT_FL_DROPPED_EVENTS``
225 - Set if one or more events of the given event type have been dropped.
226 This is an indication that the application cannot keep up.
232 On success 0 is returned, on error -1 and the ``errno`` variable is set
233 appropriately. The generic error codes are described at the
234 :ref:`Generic Error Codes <gen-errors>` chapter.
236 The :ref:`ioctl CEC_DQEVENT <CEC_DQEVENT>` can return the following
240 This is returned when the filehandle is in non-blocking mode and there
241 are no pending events.
244 An interrupt (e.g. Ctrl-C) arrived while in blocking mode waiting for