← Documents Documentation/userspace-api/media/cec/cec-ioc-dqevent.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / CEC

ioctl CEC_DQEVENT

CEC 비동기 event queue, state·lost-message payload, pin event와 flag 및 오류를 설명합니다.

Source pathDocumentation/userspace-api/media/cec/cec-ioc-dqevent.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

cec-ioc-dqevent.rst:1-245

filehandle·event type별 queue에서 최신 비동기 event를 꺼냅니다. overflow 시 중간 event가 유실될 수 있으므로 DROPPED_EVENTS flag와 payload의 최신 상태를 함께 처리해야 합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: CEC
3
4 .. _CEC_DQEVENT:
5
6 *****************
7 ioctl CEC_DQEVENT
8 *****************
9
10 Name
11 ====
12
13 CEC_DQEVENT - Dequeue a CEC event
14
15 Synopsis
16 ========
17
18 .. c:macro:: CEC_DQEVENT
19
20 ``int ioctl(int fd, CEC_DQEVENT, struct cec_event *argp)``
21
22 Arguments
23 =========
24
25 ``fd``
26 File descriptor returned by :c:func:`open()`.
27
28 ``argp``
29
30 Description
31 ===========
32
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.
37
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.
46
47 .. tabularcolumns:: |p{1.2cm}|p{2.9cm}|p{13.2cm}|
48
49 .. c:type:: cec_event_state_change
50
51 .. flat-table:: struct cec_event_state_change
52 :header-rows: 0
53 :stub-columns: 0
54 :widths: 1 1 8
55
56 * - __u16
57 - ``phys_addr``
58 - The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
59 valid physical address is set.
60 * - __u16
61 - ``log_addr_mask``
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.
66 * - __u16
67 - ``have_conn_info``
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
73 device was unbound.
74
75 .. c:type:: cec_event_lost_msgs
76
77 .. tabularcolumns:: |p{1.0cm}|p{2.0cm}|p{14.3cm}|
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 .. tabularcolumns:: |p{1.0cm}|p{4.4cm}|p{2.5cm}|p{9.2cm}|
97
98 .. c:type:: cec_event
99
100 .. flat-table:: struct cec_event
101 :header-rows: 0
102 :stub-columns: 0
103 :widths: 1 1 8
104
105 * - __u64
106 - ``ts``
107 - Timestamp of the event in ns.
108
109 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock.
110
111 To access the same clock from userspace use :c:func:`clock_gettime`.
112 * - __u32
113 - ``event``
114 - The CEC event type, see :ref:`cec-events`.
115 * - __u32
116 - ``flags``
117 - Event flags, see :ref:`cec-event-flags`.
118 * - union {
119 - (anonymous)
120 * - struct cec_event_state_change
121 - ``state_change``
122 - The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>`
123 event.
124 * - struct cec_event_lost_msgs
125 - ``lost_msgs``
126 - The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>`
127 event.
128 * - }
129 -
130
131 .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{10.8cm}|
132
133 .. _cec-events:
134
135 .. flat-table:: CEC Events Types
136 :header-rows: 0
137 :stub-columns: 0
138 :widths: 3 1 16
139
140 * .. _`CEC-EVENT-STATE-CHANGE`:
141
142 - ``CEC_EVENT_STATE_CHANGE``
143 - 1
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`:
148
149 - ``CEC_EVENT_LOST_MSGS``
150 - 2
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`:
154
155 - ``CEC_EVENT_PIN_CEC_LOW``
156 - 3
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``
159 capability set.
160 * .. _`CEC-EVENT-PIN-CEC-HIGH`:
161
162 - ``CEC_EVENT_PIN_CEC_HIGH``
163 - 4
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``
166 capability set.
167 * .. _`CEC-EVENT-PIN-HPD-LOW`:
168
169 - ``CEC_EVENT_PIN_HPD_LOW``
170 - 5
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
175 filehandle.
176 * .. _`CEC-EVENT-PIN-HPD-HIGH`:
177
178 - ``CEC_EVENT_PIN_HPD_HIGH``
179 - 6
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
184 filehandle.
185 * .. _`CEC-EVENT-PIN-5V-LOW`:
186
187 - ``CEC_EVENT_PIN_5V_LOW``
188 - 6
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
193 filehandle.
194 * .. _`CEC-EVENT-PIN-5V-HIGH`:
195
196 - ``CEC_EVENT_PIN_5V_HIGH``
197 - 7
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
202 filehandle.
203
204 .. tabularcolumns:: |p{6.0cm}|p{0.6cm}|p{10.7cm}|
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 * .. _`CEC-EVENT-FL-INITIAL-STATE`:
214
215 - ``CEC_EVENT_FL_INITIAL_STATE``
216 - 1
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
220 open() time.
221 * .. _`CEC-EVENT-FL-DROPPED-EVENTS`:
222
223 - ``CEC_EVENT_FL_DROPPED_EVENTS``
224 - 2
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.
227
228
229 Return Value
230 ============
231
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.
235
236 The :ref:`ioctl CEC_DQEVENT <CEC_DQEVENT>` can return the following
237 error codes:
238
239 EAGAIN
240 This is returned when the filehandle is in non-blocking mode and there
241 are no pending events.
242
243 ERESTARTSYS
244 An interrupt (e.g. Ctrl-C) arrived while in blocking mode waiting for
245 events to arrive.
246

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

이름, 선언과 인자

1-29

`CEC_DQEVENT`는 CEC 비동기 event 하나를 queue에서 꺼내는 ioctl입니다.

함수 형태는 `int ioctl(int fd, CEC_DQEVENT, struct cec_event *argp)`입니다. `fd`는 `open()`이 반환한 descriptor이고 `argp`는 event 결과 구조체 pointer입니다.

CEC_DQEVENT 호출
항목설명
requestCEC_DQEVENT
fd열린 CEC descriptor
argpstruct cec_event *

filehandle 전용 event queue에서 다음 event를 가져옵니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: CEC

.. _CEC_DQEVENT:

*****************
ioctl CEC_DQEVENT
*****************

Name
====

CEC_DQEVENT - Dequeue a CEC event

Synopsis
========

.. c:macro:: CEC_DQEVENT

``int ioctl(int fd, CEC_DQEVENT, struct cec_event *argp)``

Arguments
=========

``fd``
    File descriptor returned by :c:func:`open()`.

``argp``

비동기 queue와 overwrite 보장

30-46

CEC device는 비동기 event를 보낼 수 있고 응용 프로그램은 `CEC_DQEVENT`로 이를 가져옵니다.

descriptor가 nonblocking mode이고 pending event가 없으면 -1을 반환하며 `errno`를 `EAGAIN`으로 설정합니다.

내부 event queue는 filehandle별이면서 event type별입니다. queue에 공간이 없으면 마지막 event를 새 event로 덮어씁니다.

따라서 중간 결과는 버릴 수 있지만 가장 최신 event는 항상 얻을 수 있습니다.

같은 값을 가진 event 두 개를 연속으로 읽을 수도 있습니다. 예를 들어 같은 state의 `CEC_EVENT_STATE_CHANGE` 두 개 사이에서 중간 state change가 유실됐을 수 있지만, 두 event 사이에 실제 state가 변경됐음은 보장됩니다.

Event queue overflow
event type별 queue새 event 도착공간 확인가득 찼으면 마지막 event overwrite중간 결과 유실 가능최신 event 보존

중간 상태보다 최신 상태를 유지하는 방식입니다.

Description
===========

CEC devices can send asynchronous events. These can be retrieved by
calling :c:func:`CEC_DQEVENT`. If the file descriptor is in
non-blocking mode and no event is pending, then it will return -1 and
set errno to the ``EAGAIN`` error code.

The internal event queues are per-filehandle and per-event type. If
there is no more room in a queue then the last event is overwritten with
the new one. This means that intermediate results can be thrown away but
that the latest event is always available. This also means that is it
possible to read two successive events that have the same value (e.g.
two :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` events with
the same state). In that case the intermediate state changes were lost but
it is guaranteed that the state did change in between the two events.

struct cec_event_state_change

47-74

`phys_addr`는 현재 physical address이며 유효한 주소가 없으면 `CEC_PHYS_ADDR_INVALID`입니다.

`log_addr_mask`는 현재 claim한 logical address 집합입니다. claim한 address가 없거나 `phys_addr`가 invalid이면 0입니다.

bit 15, 즉 `1 << CEC_LOG_ADDR_UNREGISTERED`가 설정되면 device가 unregistered logical address를 가진 것이며 다른 bit는 모두 0입니다.

`have_conn_info`가 0이 아니면 HDMI connector 정보를 사용할 수 있습니다. 이 필드는 `CEC_CAP_CONNECTOR_INFO` capability가 있을 때만 유효합니다.

capability가 있는데 `have_conn_info`가 0이면 HDMI driver가 아직 device를 configure 중이거나 HDMI device가 unbind되어 connector device가 instantiate되지 않은 상태입니다.

State change payload
항목설명
phys_addr현재 physical address 또는 CEC_PHYS_ADDR_INVALID
log_addr_maskclaim한 logical address bitmask
bit 15Unregistered logical address
have_conn_infoHDMI connector 정보 가용 여부

address 상태와 connector 정보 가용성을 함께 전달합니다.

.. tabularcolumns:: |p{1.2cm}|p{2.9cm}|p{13.2cm}|

.. c:type:: cec_event_state_change

.. flat-table:: struct cec_event_state_change
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 8

    * - __u16
      - ``phys_addr``
      - The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
        valid physical address is set.
    * - __u16
      - ``log_addr_mask``
      - The current set of claimed logical addresses. This is 0 if no logical
        addresses are claimed or if ``phys_addr`` is ``CEC_PHYS_ADDR_INVALID``.
	If bit 15 is set (``1 << CEC_LOG_ADDR_UNREGISTERED``) then this device
	has the unregistered logical address. In that case all other bits are 0.
    * - __u16
      - ``have_conn_info``
      - If non-zero, then HDMI connector information is available.
        This field is only valid if ``CEC_CAP_CONNECTOR_INFO`` is set. If that
        capability is set and ``have_conn_info`` is zero, then that indicates
        that the HDMI connector device is not instantiated, either because
        the HDMI driver is still configuring the device or because the HDMI
        device was unbound.

struct cec_event_lost_msgs

75-95

`lost_msgs`는 filehandle을 연 뒤 또는 이 filehandle에서 마지막으로 해당 event를 dequeue한 뒤 유실된 message 수입니다.

message queue가 가득 찬 상태에서 새 message가 오면 가장 오래된 message를 버려 공간을 만듭니다.

내부 queue 크기는 최근 2초 동안 받은 모든 message를 저장하도록 보장합니다. CEC specification은 1초 안에 reply해야 한다고 요구하므로 이 크기는 충분합니다.

Lost message 계상
항목설명
lost_msgs 기준open 이후 또는 마지막 LOST_MSGS dequeue 이후
버리는 대상가장 오래된 message
보존 window최근 2초
CEC reply 요구1초 이내

가장 오래된 message를 버리고 최신 traffic을 유지합니다.

Message queue overflow
새 CEC messagemessage queue 가득 참oldest message 제거new message 저장lost_msgs 증가CEC_EVENT_LOST_MSGS

event queue와 달리 oldest message를 제거합니다.

.. c:type:: cec_event_lost_msgs

.. tabularcolumns:: |p{1.0cm}|p{2.0cm}|p{14.3cm}|

.. flat-table:: struct cec_event_lost_msgs
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 16

    * - __u32
      - ``lost_msgs``
      - Set to the number of lost messages since the filehandle was opened
	or since the last time this event was dequeued for this
	filehandle. The messages lost are the oldest messages. So when a
	new message arrives and there is no more room, then the oldest
	message is discarded to make room for the new one. The internal
	size of the message queue guarantees that all messages received in
	the last two seconds will be stored. Since messages should be
	replied to within a second according to the CEC specification,
	this is more than enough.

struct cec_event

96-130

`ts`는 nanosecond 단위 event timestamp이며 `CLOCK_MONOTONIC` clock에서 가져옵니다. 사용자 공간은 `clock_gettime()`으로 같은 clock에 접근할 수 있습니다.

`event`는 CEC event type이고 `flags`는 event flag입니다.

anonymous union의 `state_change` member는 `CEC_EVENT_STATE_CHANGE`가 보낸 새 adapter state를 담습니다.

`lost_msgs` member는 `CEC_EVENT_LOST_MSGS`가 보낸 유실 message 수를 담습니다.

struct cec_event
필드의미
__u64 tsCLOCK_MONOTONIC 기반 ns timestamp
__u32 eventCEC event type
__u32 flagsevent flag
state_change새 adapter state
lost_msgs유실 message 수

공통 metadata와 event별 payload union입니다.

.. tabularcolumns:: |p{1.0cm}|p{4.4cm}|p{2.5cm}|p{9.2cm}|

.. c:type:: cec_event

.. flat-table:: struct cec_event
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 8

    * - __u64
      - ``ts``
      - Timestamp of the event in ns.

	The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock.

	To access the same clock from userspace use :c:func:`clock_gettime`.
    * - __u32
      - ``event``
      - The CEC event type, see :ref:`cec-events`.
    * - __u32
      - ``flags``
      - Event flags, see :ref:`cec-event-flags`.
    * - union {
      - (anonymous)
    * - struct cec_event_state_change
      - ``state_change``
      - The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>`
	event.
    * - struct cec_event_lost_msgs
      - ``lost_msgs``
      - The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>`
	event.
    * - }
      -

State, lost-message와 CEC pin event

131-166

`CEC_EVENT_STATE_CHANGE` 값은 1이며 CEC adapter state가 바뀔 때 생성됩니다. `open()` 시점에도 해당 filehandle에 현재 adapter state를 담은 초기 event를 생성합니다.

`CEC_EVENT_LOST_MSGS` 값은 2이며 응용 프로그램이 CEC message를 충분히 빨리 dequeue하지 않아 하나 이상 유실됐을 때 생성됩니다.

`CEC_EVENT_PIN_CEC_LOW` 값은 3이며 CEC pin이 high voltage에서 low voltage로 바뀔 때 생성됩니다.

`CEC_EVENT_PIN_CEC_HIGH` 값은 4이며 CEC pin이 low에서 high로 바뀔 때 생성됩니다. 두 CEC pin event는 `CEC_CAP_MONITOR_PIN` capability가 있는 adapter에만 적용됩니다.

기본 CEC event type
Event조건
CEC_EVENT_STATE_CHANGE1adapter state 변경·open 초기 상태
CEC_EVENT_LOST_MSGS2message dequeue 지연으로 유실
CEC_EVENT_PIN_CEC_LOW3CEC pin high -> low
CEC_EVENT_PIN_CEC_HIGH4CEC pin low -> high

adapter 상태, message 유실과 CEC pin edge를 나타냅니다.

.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{10.8cm}|

.. _cec-events:

.. flat-table:: CEC Events Types
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 16

    * .. _`CEC-EVENT-STATE-CHANGE`:

      - ``CEC_EVENT_STATE_CHANGE``
      - 1
      - Generated when the CEC Adapter's state changes. When open() is
	called an initial event will be generated for that filehandle with
	the CEC Adapter's state at that time.
    * .. _`CEC-EVENT-LOST-MSGS`:

      - ``CEC_EVENT_LOST_MSGS``
      - 2
      - Generated if one or more CEC messages were lost because the
	application didn't dequeue CEC messages fast enough.
    * .. _`CEC-EVENT-PIN-CEC-LOW`:

      - ``CEC_EVENT_PIN_CEC_LOW``
      - 3
      - Generated if the CEC pin goes from a high voltage to a low voltage.
        Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
	capability set.
    * .. _`CEC-EVENT-PIN-CEC-HIGH`:

      - ``CEC_EVENT_PIN_CEC_HIGH``
      - 4
      - Generated if the CEC pin goes from a low voltage to a high voltage.
        Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
	capability set.

HPD와 5V pin event

167-203

`CEC_EVENT_PIN_HPD_LOW` 값은 5이며 HPD pin이 high에서 low로 바뀔 때 생성됩니다. `CEC_CAP_MONITOR_PIN`이 필요하고 `open()` 때 HPD가 low이면 초기 event도 생성합니다.

`CEC_EVENT_PIN_HPD_HIGH` 값은 원문에서 6으로 정의하며 HPD pin이 low에서 high로 바뀔 때 생성됩니다. `open()` 때 HPD가 high이면 초기 event를 생성합니다.

`CEC_EVENT_PIN_5V_LOW` 값도 원문에서 6으로 기재되어 있으며 5V pin이 high에서 low로 바뀔 때 생성됩니다. 원문의 numeric value를 그대로 보존합니다.

`CEC_EVENT_PIN_5V_HIGH` 값은 7이며 5V pin이 low에서 high로 바뀔 때 생성됩니다.

두 5V event도 `CEC_CAP_MONITOR_PIN`이 필요하며 `open()` 시 실제 5V pin 상태에 맞는 초기 event를 만들 수 있습니다.

HPD·5V event type
Event조건
CEC_EVENT_PIN_HPD_LOW5HPD high -> low
CEC_EVENT_PIN_HPD_HIGH6HPD low -> high
CEC_EVENT_PIN_5V_LOW65V high -> low, 원문 값
CEC_EVENT_PIN_5V_HIGH75V low -> high

원문에 기재된 numeric value와 edge 방향입니다.

    * .. _`CEC-EVENT-PIN-HPD-LOW`:

      - ``CEC_EVENT_PIN_HPD_LOW``
      - 5
      - Generated if the HPD pin goes from a high voltage to a low voltage.
	Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
	capability set. When open() is called, the HPD pin can be read and
	if the HPD is low, then an initial event will be generated for that
	filehandle.
    * .. _`CEC-EVENT-PIN-HPD-HIGH`:

      - ``CEC_EVENT_PIN_HPD_HIGH``
      - 6
      - Generated if the HPD pin goes from a low voltage to a high voltage.
	Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
	capability set. When open() is called, the HPD pin can be read and
	if the HPD is high, then an initial event will be generated for that
	filehandle.
    * .. _`CEC-EVENT-PIN-5V-LOW`:

      - ``CEC_EVENT_PIN_5V_LOW``
      - 6
      - Generated if the 5V pin goes from a high voltage to a low voltage.
	Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
	capability set. When open() is called, the 5V pin can be read and
	if the 5V is low, then an initial event will be generated for that
	filehandle.
    * .. _`CEC-EVENT-PIN-5V-HIGH`:

      - ``CEC_EVENT_PIN_5V_HIGH``
      - 7
      - Generated if the 5V pin goes from a low voltage to a high voltage.
	Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
	capability set. When open() is called, the 5V pin can be read and
	if the 5V is high, then an initial event will be generated for that
	filehandle.

CEC event flag

204-228

`CEC_EVENT_FL_INITIAL_STATE` 값은 1이며 device를 열 때 생성되는 초기 event에 설정됩니다. 응용 프로그램은 이 flag로 `open()` 시점의 CEC adapter 초기 상태를 알 수 있습니다.

`CEC_EVENT_FL_DROPPED_EVENTS` 값은 2이며 해당 event type의 event 하나 이상이 drop됐을 때 설정됩니다. 응용 프로그램이 event 발생 속도를 따라가지 못한다는 신호입니다.

CEC event flag
Flag의미
CEC_EVENT_FL_INITIAL_STATE1open() 시 생성한 초기 상태
CEC_EVENT_FL_DROPPED_EVENTS2같은 type event가 하나 이상 drop

초기 snapshot과 queue overflow를 구분합니다.

.. tabularcolumns:: |p{6.0cm}|p{0.6cm}|p{10.7cm}|

.. _cec-event-flags:

.. flat-table:: CEC Event Flags
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 8

    * .. _`CEC-EVENT-FL-INITIAL-STATE`:

      - ``CEC_EVENT_FL_INITIAL_STATE``
      - 1
      - Set for the initial events that are generated when the device is
	opened. See the table above for which events do this. This allows
	applications to learn the initial state of the CEC adapter at
	open() time.
    * .. _`CEC-EVENT-FL-DROPPED-EVENTS`:

      - ``CEC_EVENT_FL_DROPPED_EVENTS``
      - 2
      - Set if one or more events of the given event type have been dropped.
        This is an indication that the application cannot keep up.

반환값과 오류

229-245

성공하면 0, 오류이면 -1을 반환하고 `errno`를 설정합니다. 일반 오류는 Generic Error Codes 장을 참조합니다.

`EAGAIN`은 nonblocking filehandle에 pending event가 없을 때 반환합니다.

`ERESTARTSYS`는 blocking mode에서 event를 기다리는 동안 Ctrl-C 같은 interrupt가 도착했음을 뜻합니다.

CEC_DQEVENT 오류
항목설명
EAGAINnonblocking이며 pending event 없음
ERESTARTSYSblocking wait 중 interrupt

nonblocking empty queue와 blocking wait 중 interrupt를 구분합니다.

Return Value
============

On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.

The :ref:`ioctl CEC_DQEVENT <CEC_DQEVENT>` can return the following
error codes:

EAGAIN
    This is returned when the filehandle is in non-blocking mode and there
    are no pending events.

ERESTARTSYS
    An interrupt (e.g. Ctrl-C) arrived while in blocking mode waiting for
    events to arrive.