← Documents Documentation/userspace-api/media/cec/cec-ioc-adap-g-log-addrs.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / CEC

ioctl CEC_ADAP_G_LOG_ADDRS와 CEC_ADAP_S_LOG_ADDRS

CEC logical address 조회·설정, cec_log_addrs 필드와 flag, version·device type 상수 및 오류를 설명합니다.

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

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

1. 요약·해설

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

요약·해설

cec-ioc-adap-g-log-addrs.rst:1-367

두 ioctl은 같은 `cec_log_addrs` 구조체로 CEC logical address 상태를 조회하거나 새 주소를 claim합니다. 설정은 `CEC_CAP_LOG_ADDRS`와 initiator mode가 필요하고, `num_log_addrs=0`은 address 제거와 기본 metadata reset을 뜻합니다.

구조체는 실제 claim 결과, CEC version, vendor·OSD 정보, device type과 CEC 2.0 feature를 함께 전달합니다. 응용 프로그램은 요청 수와 driver가 실제 확보한 수가 다를 수 있음을 처리해야 합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: CEC
3
4 .. _CEC_ADAP_LOG_ADDRS:
5 .. _CEC_ADAP_G_LOG_ADDRS:
6 .. _CEC_ADAP_S_LOG_ADDRS:
7
8 ****************************************************
9 ioctls CEC_ADAP_G_LOG_ADDRS and CEC_ADAP_S_LOG_ADDRS
10 ****************************************************
11
12 Name
13 ====
14
15 CEC_ADAP_G_LOG_ADDRS, CEC_ADAP_S_LOG_ADDRS - Get or set the logical addresses
16
17 Synopsis
18 ========
19
20 .. c:macro:: CEC_ADAP_G_LOG_ADDRS
21
22 ``int ioctl(int fd, CEC_ADAP_G_LOG_ADDRS, struct cec_log_addrs *argp)``
23
24 .. c:macro:: CEC_ADAP_S_LOG_ADDRS
25
26 ``int ioctl(int fd, CEC_ADAP_S_LOG_ADDRS, struct cec_log_addrs *argp)``
27
28 Arguments
29 =========
30
31 ``fd``
32 File descriptor returned by :c:func:`open()`.
33
34 ``argp``
35 Pointer to struct :c:type:`cec_log_addrs`.
36
37 Description
38 ===========
39
40 To query the current CEC logical addresses, applications call
41 :ref:`ioctl CEC_ADAP_G_LOG_ADDRS <CEC_ADAP_G_LOG_ADDRS>` with a pointer to a
42 struct :c:type:`cec_log_addrs` where the driver stores the logical addresses.
43
44 To set new logical addresses, applications fill in
45 struct :c:type:`cec_log_addrs` and call :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
46 with a pointer to this struct. The :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
47 is only available if ``CEC_CAP_LOG_ADDRS`` is set (the ``ENOTTY`` error code is
48 returned otherwise). The :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
49 can only be called by a file descriptor in initiator mode (see :ref:`CEC_S_MODE`), if not
50 the ``EBUSY`` error code will be returned.
51
52 To clear existing logical addresses set ``num_log_addrs`` to 0. All other fields
53 will be ignored in that case. The adapter will go to the unconfigured state and the
54 ``cec_version``, ``vendor_id`` and ``osd_name`` fields are all reset to their default
55 values (CEC version 2.0, no vendor ID and an empty OSD name).
56
57 If the physical address is valid (see :ref:`ioctl CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>`),
58 then this ioctl will block until all requested logical
59 addresses have been claimed. If the file descriptor is in non-blocking mode then it will
60 not wait for the logical addresses to be claimed, instead it just returns 0.
61
62 A :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` event is sent when the
63 logical addresses are claimed or cleared.
64
65 Attempting to call :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>` when
66 logical address types are already defined will return with error ``EBUSY``.
67
68 .. c:type:: cec_log_addrs
69
70 .. tabularcolumns:: |p{1.0cm}|p{8.0cm}|p{8.0cm}|
71
72 .. cssclass:: longtable
73
74 .. flat-table:: struct cec_log_addrs
75 :header-rows: 0
76 :stub-columns: 0
77 :widths: 1 1 16
78
79 * - __u8
80 - ``log_addr[CEC_MAX_LOG_ADDRS]``
81 - The actual logical addresses that were claimed. This is set by the
82 driver. If no logical address could be claimed, then it is set to
83 ``CEC_LOG_ADDR_INVALID``. If this adapter is Unregistered, then
84 ``log_addr[0]`` is set to 0xf and all others to
85 ``CEC_LOG_ADDR_INVALID``.
86 * - __u16
87 - ``log_addr_mask``
88 - The bitmask of all logical addresses this adapter has claimed. If
89 this adapter is Unregistered then ``log_addr_mask`` sets bit 15
90 and clears all other bits. If this adapter is not configured at
91 all, then ``log_addr_mask`` is set to 0. Set by the driver.
92 * - __u8
93 - ``cec_version``
94 - The CEC version that this adapter shall use. See
95 :ref:`cec-versions`. Used to implement the
96 ``CEC_MSG_CEC_VERSION`` and ``CEC_MSG_REPORT_FEATURES`` messages.
97 Note that :ref:`CEC_OP_CEC_VERSION_1_3A <CEC-OP-CEC-VERSION-1-3A>` is not allowed by the CEC
98 framework.
99 * - __u8
100 - ``num_log_addrs``
101 - Number of logical addresses to set up. Must be ≤
102 ``available_log_addrs`` as returned by
103 :ref:`CEC_ADAP_G_CAPS`. All arrays in
104 this structure are only filled up to index
105 ``available_log_addrs``-1. The remaining array elements will be
106 ignored. Note that the CEC 2.0 standard allows for a maximum of 2
107 logical addresses, although some hardware has support for more.
108 ``CEC_MAX_LOG_ADDRS`` is 4. The driver will return the actual
109 number of logical addresses it could claim, which may be less than
110 what was requested. If this field is set to 0, then the CEC
111 adapter shall clear all claimed logical addresses and all other
112 fields will be ignored.
113 * - __u32
114 - ``vendor_id``
115 - The vendor ID is a 24-bit number that identifies the specific
116 vendor or entity. Based on this ID vendor specific commands may be
117 defined. If you do not want a vendor ID then set it to
118 ``CEC_VENDOR_ID_NONE``.
119 * - __u32
120 - ``flags``
121 - Flags. See :ref:`cec-log-addrs-flags` for a list of available flags.
122 * - char
123 - ``osd_name[15]``
124 - The On-Screen Display name as is returned by the
125 ``CEC_MSG_SET_OSD_NAME`` message.
126 * - __u8
127 - ``primary_device_type[CEC_MAX_LOG_ADDRS]``
128 - Primary device type for each logical address. See
129 :ref:`cec-prim-dev-types` for possible types.
130 * - __u8
131 - ``log_addr_type[CEC_MAX_LOG_ADDRS]``
132 - Logical address types. See :ref:`cec-log-addr-types` for
133 possible types. The driver will update this with the actual
134 logical address type that it claimed (e.g. it may have to fallback
135 to :ref:`CEC_LOG_ADDR_TYPE_UNREGISTERED <CEC-LOG-ADDR-TYPE-UNREGISTERED>`).
136 * - __u8
137 - ``all_device_types[CEC_MAX_LOG_ADDRS]``
138 - CEC 2.0 specific: the bit mask of all device types. See
139 :ref:`cec-all-dev-types-flags`. It is used in the CEC 2.0
140 ``CEC_MSG_REPORT_FEATURES`` message. For CEC 1.4 you can either leave
141 this field to 0, or fill it in according to the CEC 2.0 guidelines to
142 give the CEC framework more information about the device type, even
143 though the framework won't use it directly in the CEC message.
144 * - __u8
145 - ``features[CEC_MAX_LOG_ADDRS][12]``
146 - Features for each logical address. It is used in the CEC 2.0
147 ``CEC_MSG_REPORT_FEATURES`` message. The 12 bytes include both the
148 RC Profile and the Device Features. For CEC 1.4 you can either leave
149 this field to all 0, or fill it in according to the CEC 2.0 guidelines to
150 give the CEC framework more information about the device type, even
151 though the framework won't use it directly in the CEC message.
152
153 .. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.5cm}|
154
155 .. _cec-log-addrs-flags:
156
157 .. flat-table:: Flags for struct cec_log_addrs
158 :header-rows: 0
159 :stub-columns: 0
160 :widths: 3 1 4
161
162 * .. _`CEC-LOG-ADDRS-FL-ALLOW-UNREG-FALLBACK`:
163
164 - ``CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK``
165 - 1
166 - By default if no logical address of the requested type can be claimed, then
167 it will go back to the unconfigured state. If this flag is set, then it will
168 fallback to the Unregistered logical address. Note that if the Unregistered
169 logical address was explicitly requested, then this flag has no effect.
170 * .. _`CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU`:
171
172 - ``CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU``
173 - 2
174 - By default the ``CEC_MSG_USER_CONTROL_PRESSED`` and ``CEC_MSG_USER_CONTROL_RELEASED``
175 messages are only passed on to the follower(s), if any. If this flag is set,
176 then these messages are also passed on to the remote control input subsystem
177 and will appear as keystrokes. This features needs to be enabled explicitly.
178 If CEC is used to enter e.g. passwords, then you may not want to enable this
179 to avoid trivial snooping of the keystrokes.
180 * .. _`CEC-LOG-ADDRS-FL-CDC-ONLY`:
181
182 - ``CEC_LOG_ADDRS_FL_CDC_ONLY``
183 - 4
184 - If this flag is set, then the device is CDC-Only. CDC-Only CEC devices
185 are CEC devices that can only handle CDC messages.
186
187 All other messages are ignored.
188
189 .. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.5cm}|
190
191 .. _cec-versions:
192
193 .. flat-table:: CEC Versions
194 :header-rows: 0
195 :stub-columns: 0
196 :widths: 3 1 4
197
198 * .. _`CEC-OP-CEC-VERSION-1-3A`:
199
200 - ``CEC_OP_CEC_VERSION_1_3A``
201 - 4
202 - CEC version according to the HDMI 1.3a standard.
203 * .. _`CEC-OP-CEC-VERSION-1-4B`:
204
205 - ``CEC_OP_CEC_VERSION_1_4B``
206 - 5
207 - CEC version according to the HDMI 1.4b standard.
208 * .. _`CEC-OP-CEC-VERSION-2-0`:
209
210 - ``CEC_OP_CEC_VERSION_2_0``
211 - 6
212 - CEC version according to the HDMI 2.0 standard.
213
214 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
215
216 .. _cec-prim-dev-types:
217
218 .. flat-table:: CEC Primary Device Types
219 :header-rows: 0
220 :stub-columns: 0
221 :widths: 3 1 4
222
223 * .. _`CEC-OP-PRIM-DEVTYPE-TV`:
224
225 - ``CEC_OP_PRIM_DEVTYPE_TV``
226 - 0
227 - Use for a TV.
228 * .. _`CEC-OP-PRIM-DEVTYPE-RECORD`:
229
230 - ``CEC_OP_PRIM_DEVTYPE_RECORD``
231 - 1
232 - Use for a recording device.
233 * .. _`CEC-OP-PRIM-DEVTYPE-TUNER`:
234
235 - ``CEC_OP_PRIM_DEVTYPE_TUNER``
236 - 3
237 - Use for a device with a tuner.
238 * .. _`CEC-OP-PRIM-DEVTYPE-PLAYBACK`:
239
240 - ``CEC_OP_PRIM_DEVTYPE_PLAYBACK``
241 - 4
242 - Use for a playback device.
243 * .. _`CEC-OP-PRIM-DEVTYPE-AUDIOSYSTEM`:
244
245 - ``CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM``
246 - 5
247 - Use for an audio system (e.g. an audio/video receiver).
248 * .. _`CEC-OP-PRIM-DEVTYPE-SWITCH`:
249
250 - ``CEC_OP_PRIM_DEVTYPE_SWITCH``
251 - 6
252 - Use for a CEC switch.
253 * .. _`CEC-OP-PRIM-DEVTYPE-VIDEOPROC`:
254
255 - ``CEC_OP_PRIM_DEVTYPE_VIDEOPROC``
256 - 7
257 - Use for a video processor device.
258
259 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
260
261 .. _cec-log-addr-types:
262
263 .. flat-table:: CEC Logical Address Types
264 :header-rows: 0
265 :stub-columns: 0
266 :widths: 3 1 16
267
268 * .. _`CEC-LOG-ADDR-TYPE-TV`:
269
270 - ``CEC_LOG_ADDR_TYPE_TV``
271 - 0
272 - Use for a TV.
273 * .. _`CEC-LOG-ADDR-TYPE-RECORD`:
274
275 - ``CEC_LOG_ADDR_TYPE_RECORD``
276 - 1
277 - Use for a recording device.
278 * .. _`CEC-LOG-ADDR-TYPE-TUNER`:
279
280 - ``CEC_LOG_ADDR_TYPE_TUNER``
281 - 2
282 - Use for a tuner device.
283 * .. _`CEC-LOG-ADDR-TYPE-PLAYBACK`:
284
285 - ``CEC_LOG_ADDR_TYPE_PLAYBACK``
286 - 3
287 - Use for a playback device.
288 * .. _`CEC-LOG-ADDR-TYPE-AUDIOSYSTEM`:
289
290 - ``CEC_LOG_ADDR_TYPE_AUDIOSYSTEM``
291 - 4
292 - Use for an audio system device.
293 * .. _`CEC-LOG-ADDR-TYPE-SPECIFIC`:
294
295 - ``CEC_LOG_ADDR_TYPE_SPECIFIC``
296 - 5
297 - Use for a second TV or for a video processor device.
298 * .. _`CEC-LOG-ADDR-TYPE-UNREGISTERED`:
299
300 - ``CEC_LOG_ADDR_TYPE_UNREGISTERED``
301 - 6
302 - Use this if you just want to remain unregistered. Used for pure
303 CEC switches or CDC-only devices (CDC: Capability Discovery and
304 Control).
305
306
307 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
308
309 .. _cec-all-dev-types-flags:
310
311 .. flat-table:: CEC All Device Types Flags
312 :header-rows: 0
313 :stub-columns: 0
314 :widths: 3 1 4
315
316 * .. _`CEC-OP-ALL-DEVTYPE-TV`:
317
318 - ``CEC_OP_ALL_DEVTYPE_TV``
319 - 0x80
320 - This supports the TV type.
321 * .. _`CEC-OP-ALL-DEVTYPE-RECORD`:
322
323 - ``CEC_OP_ALL_DEVTYPE_RECORD``
324 - 0x40
325 - This supports the Recording type.
326 * .. _`CEC-OP-ALL-DEVTYPE-TUNER`:
327
328 - ``CEC_OP_ALL_DEVTYPE_TUNER``
329 - 0x20
330 - This supports the Tuner type.
331 * .. _`CEC-OP-ALL-DEVTYPE-PLAYBACK`:
332
333 - ``CEC_OP_ALL_DEVTYPE_PLAYBACK``
334 - 0x10
335 - This supports the Playback type.
336 * .. _`CEC-OP-ALL-DEVTYPE-AUDIOSYSTEM`:
337
338 - ``CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM``
339 - 0x08
340 - This supports the Audio System type.
341 * .. _`CEC-OP-ALL-DEVTYPE-SWITCH`:
342
343 - ``CEC_OP_ALL_DEVTYPE_SWITCH``
344 - 0x04
345 - This supports the CEC Switch or Video Processing type.
346
347
348 Return Value
349 ============
350
351 On success 0 is returned, on error -1 and the ``errno`` variable is set
352 appropriately. The generic error codes are described at the
353 :ref:`Generic Error Codes <gen-errors>` chapter.
354
355 The :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>` can return the following
356 error codes:
357
358 ENOTTY
359 The ``CEC_CAP_LOG_ADDRS`` capability wasn't set, so this ioctl is not supported.
360
361 EBUSY
362 The CEC adapter is currently configuring itself, or it is already configured and
363 ``num_log_addrs`` is non-zero, or another filehandle is in exclusive follower or
364 initiator mode, or the filehandle is in mode ``CEC_MODE_NO_INITIATOR``.
365
366 EINVAL
367 The contents of struct :c:type:`cec_log_addrs` is invalid.
368

3. 한국어 전문 번역

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

이름, 선언과 인자

1-36

`CEC_ADAP_G_LOG_ADDRS`와 `CEC_ADAP_S_LOG_ADDRS`는 CEC adapter의 logical address를 각각 가져오고 설정하는 ioctl입니다.

조회 함수 형태는 `int ioctl(int fd, CEC_ADAP_G_LOG_ADDRS, struct cec_log_addrs *argp)`이고 설정 함수 형태는 request만 `CEC_ADAP_S_LOG_ADDRS`로 다릅니다.

`fd`는 `open()`이 반환한 file descriptor이고 `argp`는 `struct cec_log_addrs`를 가리키는 pointer입니다.

Logical address ioctl
항목설명
CEC_ADAP_G_LOG_ADDRS현재 logical address 조회
CEC_ADAP_S_LOG_ADDRS새 logical address 설정
fd열린 CEC device descriptor
argpstruct cec_log_addrs *

같은 구조체를 조회 결과와 설정 입력에 사용합니다.

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

.. _CEC_ADAP_LOG_ADDRS:
.. _CEC_ADAP_G_LOG_ADDRS:
.. _CEC_ADAP_S_LOG_ADDRS:

****************************************************
ioctls CEC_ADAP_G_LOG_ADDRS and CEC_ADAP_S_LOG_ADDRS
****************************************************

Name
====

CEC_ADAP_G_LOG_ADDRS, CEC_ADAP_S_LOG_ADDRS - Get or set the logical addresses

Synopsis
========

.. c:macro:: CEC_ADAP_G_LOG_ADDRS

``int ioctl(int fd, CEC_ADAP_G_LOG_ADDRS, struct cec_log_addrs *argp)``

.. c:macro:: CEC_ADAP_S_LOG_ADDRS

``int ioctl(int fd, CEC_ADAP_S_LOG_ADDRS, struct cec_log_addrs *argp)``

Arguments
=========

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

``argp``
    Pointer to struct :c:type:`cec_log_addrs`.

조회·설정 동작과 상태 전환

37-67

현재 logical address를 조회할 때는 `cec_log_addrs` pointer로 `CEC_ADAP_G_LOG_ADDRS`를 호출하고 driver가 실제 address를 구조체에 저장합니다.

새 address를 설정할 때는 응용 프로그램이 구조체를 채운 뒤 `CEC_ADAP_S_LOG_ADDRS`를 호출합니다. 이 ioctl은 `CEC_CAP_LOG_ADDRS` capability가 있을 때만 지원하며, 없으면 `ENOTTY`를 반환합니다.

설정 ioctl은 initiator mode인 file descriptor에서만 호출할 수 있습니다. 그렇지 않으면 `EBUSY`를 반환합니다.

기존 logical address를 지우려면 `num_log_addrs`를 0으로 설정합니다. 이 경우 다른 필드는 무시하고 adapter는 unconfigured state로 이동합니다.

주소를 지우면 `cec_version`, `vendor_id`, `osd_name`은 각각 CEC version 2.0, vendor ID 없음, 빈 OSD 이름이라는 기본값으로 reset됩니다.

physical address가 유효하면 설정 ioctl은 요청한 logical address를 모두 claim할 때까지 block합니다. descriptor가 nonblocking mode이면 claim을 기다리지 않고 즉시 0을 반환합니다.

logical address가 claim되거나 지워지면 `CEC_EVENT_STATE_CHANGE` event를 보냅니다. logical address type이 이미 정의된 상태에서 다시 설정을 호출하면 `EBUSY`를 반환합니다.

설정 전제와 결과
항목설명
필수 capabilityCEC_CAP_LOG_ADDRS
필수 FD modeinitiator mode
주소 제거num_log_addrs = 0
blocking FD모든 요청 address claim까지 대기
nonblocking FD기다리지 않고 0 반환
상태 eventCEC_EVENT_STATE_CHANGE
이미 type 정의EBUSY

capability, mode와 현재 configuration 상태를 모두 확인해야 합니다.

Logical address 설정
CEC_CAP_LOG_ADDRS 확인initiator mode 확인cec_log_addrs 입력 작성CEC_ADAP_S_LOG_ADDRSphysical address가 유효하면 claimdriver가 실제 결과 반영CEC_EVENT_STATE_CHANGE

설정 요청에서 실제 claim과 state change event까지의 흐름입니다.

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

To query the current CEC logical addresses, applications call
:ref:`ioctl CEC_ADAP_G_LOG_ADDRS <CEC_ADAP_G_LOG_ADDRS>` with a pointer to a
struct :c:type:`cec_log_addrs` where the driver stores the logical addresses.

To set new logical addresses, applications fill in
struct :c:type:`cec_log_addrs` and call :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
with a pointer to this struct. The :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
is only available if ``CEC_CAP_LOG_ADDRS`` is set (the ``ENOTTY`` error code is
returned otherwise). The :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
can only be called by a file descriptor in initiator mode (see :ref:`CEC_S_MODE`), if not
the ``EBUSY`` error code will be returned.

To clear existing logical addresses set ``num_log_addrs`` to 0. All other fields
will be ignored in that case. The adapter will go to the unconfigured state and the
``cec_version``, ``vendor_id`` and ``osd_name`` fields are all reset to their default
values (CEC version 2.0, no vendor ID and an empty OSD name).

If the physical address is valid (see :ref:`ioctl CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>`),
then this ioctl will block until all requested logical
addresses have been claimed. If the file descriptor is in non-blocking mode then it will
not wait for the logical addresses to be claimed, instead it just returns 0.

A :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` event is sent when the
logical addresses are claimed or cleared.

Attempting to call :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>` when
logical address types are already defined will return with error ``EBUSY``.

cec_log_addrs의 address·version 필드

68-112

`log_addr[CEC_MAX_LOG_ADDRS]`는 실제 claim한 logical address 배열이며 driver가 설정합니다. claim하지 못한 원소는 `CEC_LOG_ADDR_INVALID`입니다.

adapter가 Unregistered이면 `log_addr[0]`은 `0xf`이고 나머지는 `CEC_LOG_ADDR_INVALID`입니다.

`log_addr_mask`는 adapter가 claim한 모든 logical address의 bitmask이며 driver가 설정합니다. Unregistered이면 bit 15만 설정하고, 전혀 configure되지 않았으면 0입니다.

`cec_version`은 adapter가 사용할 CEC version입니다. `CEC_MSG_CEC_VERSION`과 `CEC_MSG_REPORT_FEATURES` message 구현에 사용합니다. CEC framework는 `CEC_OP_CEC_VERSION_1_3A`를 허용하지 않습니다.

`num_log_addrs`는 설정할 logical address 수이며 `CEC_ADAP_G_CAPS`가 반환한 `available_log_addrs` 이하여야 합니다. 구조체의 모든 배열은 `available_log_addrs - 1` index까지만 사용하고 나머지는 무시합니다.

CEC 2.0 표준은 logical address 최대 2개를 허용하지만 일부 hardware는 더 많이 지원합니다. `CEC_MAX_LOG_ADDRS`는 4입니다.

driver는 실제 claim한 logical address 수를 반환하므로 요청 수보다 적을 수 있습니다. `num_log_addrs`가 0이면 claim한 address를 모두 지우고 나머지 필드를 무시합니다.

주소와 version 필드
필드의미
log_addr[4]driver가 claim한 실제 logical address
log_addr_maskclaim address bitmask, Unregistered는 bit 15
cec_versionmessage에 사용할 CEC version
num_log_addrs요청·실제 address 수, available_log_addrs 이하
CEC_MAX_LOG_ADDRS4
CEC 2.0 표준 최대2 logical addresses

요청값과 driver가 갱신하는 실제 결과를 구분합니다.

.. c:type:: cec_log_addrs

.. tabularcolumns:: |p{1.0cm}|p{8.0cm}|p{8.0cm}|

.. cssclass:: longtable

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

    * - __u8
      - ``log_addr[CEC_MAX_LOG_ADDRS]``
      - The actual logical addresses that were claimed. This is set by the
	driver. If no logical address could be claimed, then it is set to
	``CEC_LOG_ADDR_INVALID``. If this adapter is Unregistered, then
	``log_addr[0]`` is set to 0xf and all others to
	``CEC_LOG_ADDR_INVALID``.
    * - __u16
      - ``log_addr_mask``
      - The bitmask of all logical addresses this adapter has claimed. If
	this adapter is Unregistered then ``log_addr_mask`` sets bit 15
	and clears all other bits. If this adapter is not configured at
	all, then ``log_addr_mask`` is set to 0. Set by the driver.
    * - __u8
      - ``cec_version``
      - The CEC version that this adapter shall use. See
	:ref:`cec-versions`. Used to implement the
	``CEC_MSG_CEC_VERSION`` and ``CEC_MSG_REPORT_FEATURES`` messages.
	Note that :ref:`CEC_OP_CEC_VERSION_1_3A <CEC-OP-CEC-VERSION-1-3A>` is not allowed by the CEC
	framework.
    * - __u8
      - ``num_log_addrs``
      - Number of logical addresses to set up. Must be ≤
	``available_log_addrs`` as returned by
	:ref:`CEC_ADAP_G_CAPS`. All arrays in
	this structure are only filled up to index
	``available_log_addrs``-1. The remaining array elements will be
	ignored. Note that the CEC 2.0 standard allows for a maximum of 2
	logical addresses, although some hardware has support for more.
	``CEC_MAX_LOG_ADDRS`` is 4. The driver will return the actual
	number of logical addresses it could claim, which may be less than
	what was requested. If this field is set to 0, then the CEC
	adapter shall clear all claimed logical addresses and all other
	fields will be ignored.

vendor, OSD와 device feature 필드

113-152

`vendor_id`는 특정 vendor 또는 entity를 식별하는 24-bit 값입니다. 이 ID를 기반으로 vendor-specific command를 정의할 수 있고 ID를 원하지 않으면 `CEC_VENDOR_ID_NONE`을 설정합니다.

`flags`는 뒤에서 설명하는 logical address 설정 flag bitmask입니다. `osd_name[15]`는 `CEC_MSG_SET_OSD_NAME` message가 반환하는 On-Screen Display 이름입니다.

`primary_device_type[CEC_MAX_LOG_ADDRS]`는 각 logical address의 primary device type입니다.

`log_addr_type[CEC_MAX_LOG_ADDRS]`는 요청한 logical address type입니다. driver는 실제 claim한 type으로 이를 갱신하며 필요하면 `CEC_LOG_ADDR_TYPE_UNREGISTERED`로 fallback할 수 있습니다.

`all_device_types[CEC_MAX_LOG_ADDRS]`는 CEC 2.0의 모든 device type bitmask이며 `CEC_MSG_REPORT_FEATURES`에 사용됩니다.

CEC 1.4에서는 `all_device_types`를 0으로 두거나 CEC 2.0 지침에 따라 채워 framework에 더 많은 device type 정보를 줄 수 있습니다. 다만 framework는 이를 CEC message에서 직접 사용하지 않습니다.

`features[CEC_MAX_LOG_ADDRS][12]`는 각 logical address의 feature이며 12 byte에 RC Profile과 Device Features가 모두 들어갑니다. CEC 2.0의 `CEC_MSG_REPORT_FEATURES`에서 사용합니다.

CEC 1.4에서는 `features`를 모두 0으로 두거나 CEC 2.0 지침에 따라 채워 추가 정보를 제공할 수 있지만 framework가 message에서 직접 사용하지는 않습니다.

장치 식별·feature 필드
필드의미
vendor_id24-bit vendor/entity ID 또는 CEC_VENDOR_ID_NONE
flags설정 동작 flag
osd_name[15]On-Screen Display 이름
primary_device_type[4]각 address의 primary type
log_addr_type[4]요청 type, driver가 실제 type으로 갱신
all_device_types[4]CEC 2.0 device type bitmask
features[4][12]RC Profile + Device Features

logical address마다 device 유형과 CEC 2.0 feature를 지정합니다.

    * - __u32
      - ``vendor_id``
      - The vendor ID is a 24-bit number that identifies the specific
	vendor or entity. Based on this ID vendor specific commands may be
	defined. If you do not want a vendor ID then set it to
	``CEC_VENDOR_ID_NONE``.
    * - __u32
      - ``flags``
      - Flags. See :ref:`cec-log-addrs-flags` for a list of available flags.
    * - char
      - ``osd_name[15]``
      - The On-Screen Display name as is returned by the
	``CEC_MSG_SET_OSD_NAME`` message.
    * - __u8
      - ``primary_device_type[CEC_MAX_LOG_ADDRS]``
      - Primary device type for each logical address. See
	:ref:`cec-prim-dev-types` for possible types.
    * - __u8
      - ``log_addr_type[CEC_MAX_LOG_ADDRS]``
      - Logical address types. See :ref:`cec-log-addr-types` for
	possible types. The driver will update this with the actual
	logical address type that it claimed (e.g. it may have to fallback
	to :ref:`CEC_LOG_ADDR_TYPE_UNREGISTERED <CEC-LOG-ADDR-TYPE-UNREGISTERED>`).
    * - __u8
      - ``all_device_types[CEC_MAX_LOG_ADDRS]``
      - CEC 2.0 specific: the bit mask of all device types. See
	:ref:`cec-all-dev-types-flags`. It is used in the CEC 2.0
	``CEC_MSG_REPORT_FEATURES`` message. For CEC 1.4 you can either leave
	this field to 0, or fill it in according to the CEC 2.0 guidelines to
	give the CEC framework more information about the device type, even
	though the framework won't use it directly in the CEC message.
    * - __u8
      - ``features[CEC_MAX_LOG_ADDRS][12]``
      - Features for each logical address. It is used in the CEC 2.0
	``CEC_MSG_REPORT_FEATURES`` message. The 12 bytes include both the
	RC Profile and the Device Features. For CEC 1.4 you can either leave
        this field to all 0, or fill it in according to the CEC 2.0 guidelines to
        give the CEC framework more information about the device type, even
        though the framework won't use it directly in the CEC message.

struct cec_log_addrs flag

153-188

`CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK` 값은 1입니다. 기본적으로 요청한 type의 logical address를 claim하지 못하면 unconfigured state로 돌아가지만, 이 flag를 설정하면 Unregistered logical address로 fallback합니다.

Unregistered logical address를 명시적으로 요청했다면 이 flag는 효과가 없습니다.

`CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU` 값은 2입니다. 기본적으로 `CEC_MSG_USER_CONTROL_PRESSED`와 `CEC_MSG_USER_CONTROL_RELEASED`는 follower에게만 전달됩니다.

이 flag를 설정하면 두 message를 remote control input subsystem에도 전달하여 keystroke로 나타냅니다. 명시적으로 활성화해야 하며 CEC로 password 등을 입력한다면 keystroke 도청을 쉽게 만들 수 있으므로 활성화하지 않는 편이 좋을 수 있습니다.

`CEC_LOG_ADDRS_FL_CDC_ONLY` 값은 4입니다. 설정하면 device는 CDC-only로 동작하여 CDC message만 처리하고 다른 모든 message는 무시합니다.

Logical address flag
Flag동작
ALLOW_UNREG_FALLBACK1claim 실패 시 Unregistered fallback
ALLOW_RC_PASSTHRU2user-control message를 input subsystem에 전달
CDC_ONLY4CDC message만 처리

fallback, remote-control passthrough와 CDC-only 동작을 제어합니다.

.. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.5cm}|

.. _cec-log-addrs-flags:

.. flat-table:: Flags for struct cec_log_addrs
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * .. _`CEC-LOG-ADDRS-FL-ALLOW-UNREG-FALLBACK`:

      - ``CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK``
      - 1
      - By default if no logical address of the requested type can be claimed, then
	it will go back to the unconfigured state. If this flag is set, then it will
	fallback to the Unregistered logical address. Note that if the Unregistered
	logical address was explicitly requested, then this flag has no effect.
    * .. _`CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU`:

      - ``CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU``
      - 2
      - By default the ``CEC_MSG_USER_CONTROL_PRESSED`` and ``CEC_MSG_USER_CONTROL_RELEASED``
        messages are only passed on to the follower(s), if any. If this flag is set,
	then these messages are also passed on to the remote control input subsystem
	and will appear as keystrokes. This features needs to be enabled explicitly.
	If CEC is used to enter e.g. passwords, then you may not want to enable this
	to avoid trivial snooping of the keystrokes.
    * .. _`CEC-LOG-ADDRS-FL-CDC-ONLY`:

      - ``CEC_LOG_ADDRS_FL_CDC_ONLY``
      - 4
      - If this flag is set, then the device is CDC-Only. CDC-Only CEC devices
	are CEC devices that can only handle CDC messages.

	All other messages are ignored.

CEC version 값

189-213

`CEC_OP_CEC_VERSION_1_3A` 값은 4이며 HDMI 1.3a 표준의 CEC version을 뜻하지만 앞서 설명했듯 CEC framework에서 허용하지 않습니다.

`CEC_OP_CEC_VERSION_1_4B` 값은 5이며 HDMI 1.4b 표준의 CEC version입니다.

`CEC_OP_CEC_VERSION_2_0` 값은 6이며 HDMI 2.0 표준의 CEC version입니다.

CEC version 상수
상수표준
CEC_OP_CEC_VERSION_1_3A4HDMI 1.3a, framework에서 허용 안 함
CEC_OP_CEC_VERSION_1_4B5HDMI 1.4b
CEC_OP_CEC_VERSION_2_06HDMI 2.0

구조체의 cec_version에 사용하는 numeric value입니다.

.. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.5cm}|

.. _cec-versions:

.. flat-table:: CEC Versions
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * .. _`CEC-OP-CEC-VERSION-1-3A`:

      - ``CEC_OP_CEC_VERSION_1_3A``
      - 4
      - CEC version according to the HDMI 1.3a standard.
    * .. _`CEC-OP-CEC-VERSION-1-4B`:

      - ``CEC_OP_CEC_VERSION_1_4B``
      - 5
      - CEC version according to the HDMI 1.4b standard.
    * .. _`CEC-OP-CEC-VERSION-2-0`:

      - ``CEC_OP_CEC_VERSION_2_0``
      - 6
      - CEC version according to the HDMI 2.0 standard.

CEC primary device type

214-258

primary device type은 logical address별 대표 역할을 나타냅니다.

`CEC_OP_PRIM_DEVTYPE_TV`는 0, `CEC_OP_PRIM_DEVTYPE_RECORD`는 1, `CEC_OP_PRIM_DEVTYPE_TUNER`는 3입니다.

`CEC_OP_PRIM_DEVTYPE_PLAYBACK`은 4, `CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM`은 5이며 audio/video receiver 같은 audio system에 사용합니다.

`CEC_OP_PRIM_DEVTYPE_SWITCH`는 6으로 CEC switch에 사용하고 `CEC_OP_PRIM_DEVTYPE_VIDEOPROC`는 7로 video processor device에 사용합니다.

Primary device type
역할상수
TVCEC_OP_PRIM_DEVTYPE_TV0
RecordingCEC_OP_PRIM_DEVTYPE_RECORD1
TunerCEC_OP_PRIM_DEVTYPE_TUNER3
PlaybackCEC_OP_PRIM_DEVTYPE_PLAYBACK4
Audio SystemCEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM5
CEC SwitchCEC_OP_PRIM_DEVTYPE_SWITCH6
Video ProcessorCEC_OP_PRIM_DEVTYPE_VIDEOPROC7

CEC의 대표 device 역할과 값입니다.

.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|

.. _cec-prim-dev-types:

.. flat-table:: CEC Primary Device Types
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * .. _`CEC-OP-PRIM-DEVTYPE-TV`:

      - ``CEC_OP_PRIM_DEVTYPE_TV``
      - 0
      - Use for a TV.
    * .. _`CEC-OP-PRIM-DEVTYPE-RECORD`:

      - ``CEC_OP_PRIM_DEVTYPE_RECORD``
      - 1
      - Use for a recording device.
    * .. _`CEC-OP-PRIM-DEVTYPE-TUNER`:

      - ``CEC_OP_PRIM_DEVTYPE_TUNER``
      - 3
      - Use for a device with a tuner.
    * .. _`CEC-OP-PRIM-DEVTYPE-PLAYBACK`:

      - ``CEC_OP_PRIM_DEVTYPE_PLAYBACK``
      - 4
      - Use for a playback device.
    * .. _`CEC-OP-PRIM-DEVTYPE-AUDIOSYSTEM`:

      - ``CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM``
      - 5
      - Use for an audio system (e.g. an audio/video receiver).
    * .. _`CEC-OP-PRIM-DEVTYPE-SWITCH`:

      - ``CEC_OP_PRIM_DEVTYPE_SWITCH``
      - 6
      - Use for a CEC switch.
    * .. _`CEC-OP-PRIM-DEVTYPE-VIDEOPROC`:

      - ``CEC_OP_PRIM_DEVTYPE_VIDEOPROC``
      - 7
      - Use for a video processor device.

CEC logical address type

259-306

logical address type은 어떤 address 범주를 claim할지 지정합니다.

`CEC_LOG_ADDR_TYPE_TV`는 0, `CEC_LOG_ADDR_TYPE_RECORD`는 1, `CEC_LOG_ADDR_TYPE_TUNER`는 2, `CEC_LOG_ADDR_TYPE_PLAYBACK`은 3입니다.

`CEC_LOG_ADDR_TYPE_AUDIOSYSTEM`은 4이며 audio system device에 사용합니다.

`CEC_LOG_ADDR_TYPE_SPECIFIC`은 5이며 두 번째 TV 또는 video processor device에 사용합니다.

`CEC_LOG_ADDR_TYPE_UNREGISTERED`는 6입니다. 등록되지 않은 상태를 유지하고 싶을 때 사용하며 순수 CEC switch나 CDC-only device가 여기에 해당합니다. CDC는 Capability Discovery and Control입니다.

Logical address type
범주상수
TVCEC_LOG_ADDR_TYPE_TV0
RecordingCEC_LOG_ADDR_TYPE_RECORD1
TunerCEC_LOG_ADDR_TYPE_TUNER2
PlaybackCEC_LOG_ADDR_TYPE_PLAYBACK3
Audio SystemCEC_LOG_ADDR_TYPE_AUDIOSYSTEM4
SpecificCEC_LOG_ADDR_TYPE_SPECIFIC5
UnregisteredCEC_LOG_ADDR_TYPE_UNREGISTERED6

claim할 CEC logical address 범주입니다.

.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|

.. _cec-log-addr-types:

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

    * .. _`CEC-LOG-ADDR-TYPE-TV`:

      - ``CEC_LOG_ADDR_TYPE_TV``
      - 0
      - Use for a TV.
    * .. _`CEC-LOG-ADDR-TYPE-RECORD`:

      - ``CEC_LOG_ADDR_TYPE_RECORD``
      - 1
      - Use for a recording device.
    * .. _`CEC-LOG-ADDR-TYPE-TUNER`:

      - ``CEC_LOG_ADDR_TYPE_TUNER``
      - 2
      - Use for a tuner device.
    * .. _`CEC-LOG-ADDR-TYPE-PLAYBACK`:

      - ``CEC_LOG_ADDR_TYPE_PLAYBACK``
      - 3
      - Use for a playback device.
    * .. _`CEC-LOG-ADDR-TYPE-AUDIOSYSTEM`:

      - ``CEC_LOG_ADDR_TYPE_AUDIOSYSTEM``
      - 4
      - Use for an audio system device.
    * .. _`CEC-LOG-ADDR-TYPE-SPECIFIC`:

      - ``CEC_LOG_ADDR_TYPE_SPECIFIC``
      - 5
      - Use for a second TV or for a video processor device.
    * .. _`CEC-LOG-ADDR-TYPE-UNREGISTERED`:

      - ``CEC_LOG_ADDR_TYPE_UNREGISTERED``
      - 6
      - Use this if you just want to remain unregistered. Used for pure
	CEC switches or CDC-only devices (CDC: Capability Discovery and
	Control).

CEC all-device type flag

307-347

CEC 2.0의 all-device type field는 device가 지원하는 모든 역할을 bitmask로 표시합니다.

`CEC_OP_ALL_DEVTYPE_TV`는 `0x80`, `CEC_OP_ALL_DEVTYPE_RECORD`는 `0x40`, `CEC_OP_ALL_DEVTYPE_TUNER`는 `0x20`입니다.

`CEC_OP_ALL_DEVTYPE_PLAYBACK`은 `0x10`, `CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM`은 `0x08`입니다.

`CEC_OP_ALL_DEVTYPE_SWITCH`는 `0x04`이며 CEC Switch 또는 Video Processing 역할을 지원함을 뜻합니다.

All-device type bit
역할상수bit
TVCEC_OP_ALL_DEVTYPE_TV0x80
RecordingCEC_OP_ALL_DEVTYPE_RECORD0x40
TunerCEC_OP_ALL_DEVTYPE_TUNER0x20
PlaybackCEC_OP_ALL_DEVTYPE_PLAYBACK0x10
Audio SystemCEC_OP_ALL_DEVTYPE_AUDIOSYSTEM0x08
Switch·Video ProcessingCEC_OP_ALL_DEVTYPE_SWITCH0x04

여러 역할을 OR하여 all_device_types를 구성합니다.

.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|

.. _cec-all-dev-types-flags:

.. flat-table:: CEC All Device Types Flags
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * .. _`CEC-OP-ALL-DEVTYPE-TV`:

      - ``CEC_OP_ALL_DEVTYPE_TV``
      - 0x80
      - This supports the TV type.
    * .. _`CEC-OP-ALL-DEVTYPE-RECORD`:

      - ``CEC_OP_ALL_DEVTYPE_RECORD``
      - 0x40
      - This supports the Recording type.
    * .. _`CEC-OP-ALL-DEVTYPE-TUNER`:

      - ``CEC_OP_ALL_DEVTYPE_TUNER``
      - 0x20
      - This supports the Tuner type.
    * .. _`CEC-OP-ALL-DEVTYPE-PLAYBACK`:

      - ``CEC_OP_ALL_DEVTYPE_PLAYBACK``
      - 0x10
      - This supports the Playback type.
    * .. _`CEC-OP-ALL-DEVTYPE-AUDIOSYSTEM`:

      - ``CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM``
      - 0x08
      - This supports the Audio System type.
    * .. _`CEC-OP-ALL-DEVTYPE-SWITCH`:

      - ``CEC_OP_ALL_DEVTYPE_SWITCH``
      - 0x04
      - This supports the CEC Switch or Video Processing type.

반환값과 설정 오류

348-367

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

`ENOTTY`는 `CEC_CAP_LOG_ADDRS` capability가 없어 설정 ioctl을 지원하지 않음을 뜻합니다.

`EBUSY`는 adapter가 현재 자신을 configure 중이거나, 이미 configure됐는데 `num_log_addrs`가 0이 아니거나, 다른 filehandle이 exclusive follower 또는 initiator mode이거나, 현재 filehandle mode가 `CEC_MODE_NO_INITIATOR`일 때 반환합니다.

`EINVAL`은 `struct cec_log_addrs` 내용이 유효하지 않음을 뜻합니다.

CEC_ADAP_S_LOG_ADDRS 오류
항목설명
ENOTTYCEC_CAP_LOG_ADDRS 없음
EBUSYconfigure 중·이미 설정·exclusive mode 충돌·NO_INITIATOR
EINVALcec_log_addrs 내용이 유효하지 않음

capability, adapter 상태, filehandle mode와 구조체 유효성을 구분합니다.

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_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>` can return the following
error codes:

ENOTTY
    The ``CEC_CAP_LOG_ADDRS`` capability wasn't set, so this ioctl is not supported.

EBUSY
    The CEC adapter is currently configuring itself, or it is already configured and
    ``num_log_addrs`` is non-zero, or another filehandle is in exclusive follower or
    initiator mode, or the filehandle is in mode ``CEC_MODE_NO_INITIATOR``.

EINVAL
    The contents of struct :c:type:`cec_log_addrs` is invalid.