← Documents Documentation/admin-guide/media/cec.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Media

HDMI CEC

Linux HDMI CEC hardware·utility, adapter·USB dongle 설정, HPD 시험, GPIO debugger, Extron driver를 설명합니다.

Source pathDocumentation/admin-guide/media/cec.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

지원 장치와 utility

cec.rst:1-155

Mainline hardware, CEC tool, 실제 동작하는 DP-to-HDMI adapter를 정리합니다.

Dongle 설정과 HPD 시험

cec.rst:156-308

Udev·systemd·EDID 자동화와 HPD 없는 CEC wake-up 시험법을 설명합니다.

Debugger와 Extron driver

cec.rst:309-467

Raspberry Pi CEC debugger 배선·DTS와 Extron module option을 정리합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ========
4 HDMI CEC
5 ========
6
7 Supported hardware in mainline
8 ==============================
9
10 HDMI Transmitters:
11
12 - Exynos4
13 - Exynos5
14 - STIH4xx HDMI CEC
15 - V4L2 adv7511 (same HW, but a different driver from the drm adv7511)
16 - stm32
17 - Allwinner A10 (sun4i)
18 - Raspberry Pi
19 - dw-hdmi (Synopsis IP)
20 - amlogic (meson ao-cec and ao-cec-g12a)
21 - drm adv7511/adv7533
22 - omap4
23 - tegra
24 - rk3288, rk3399
25 - tda998x
26 - DisplayPort CEC-Tunneling-over-AUX on i915, nouveau and amdgpu
27 - ChromeOS EC CEC
28 - CEC for SECO boards (UDOO x86).
29 - Chrontel CH7322
30
31
32 HDMI Receivers:
33
34 - adv7604/11/12
35 - adv7842
36 - tc358743
37
38 USB Dongles (see below for additional information on how to use these
39 dongles):
40
41 - Pulse-Eight: the pulse8-cec driver implements the following module option:
42 ``persistent_config``: by default this is off, but when set to 1 the driver
43 will store the current settings to the device's internal eeprom and restore
44 it the next time the device is connected to the USB port.
45
46 - RainShadow Tech. Note: this driver does not support the persistent_config
47 module option of the Pulse-Eight driver. The hardware supports it, but I
48 have no plans to add this feature. But I accept patches :-)
49
50 - Extron DA HD 4K PLUS HDMI Distribution Amplifier. See
51 :ref:`extron_da_hd_4k_plus` for more information.
52
53 Miscellaneous:
54
55 - vivid: emulates a CEC receiver and CEC transmitter.
56 Can be used to test CEC applications without actual CEC hardware.
57
58 - cec-gpio. If the CEC pin is hooked up to a GPIO pin then
59 you can control the CEC line through this driver. This supports error
60 injection as well.
61
62 - cec-gpio and Allwinner A10 (or any other driver that uses the CEC pin
63 framework to drive the CEC pin directly): the CEC pin framework uses
64 high-resolution timers. These timers are affected by NTP daemons that
65 speed up or slow down the clock to sync with the official time. The
66 chronyd server will by default increase or decrease the clock by
67 1/12th. This will cause the CEC timings to go out of spec. To fix this,
68 add a 'maxslewrate 40000' line to chronyd.conf. This limits the clock
69 frequency change to 1/25th, which keeps the CEC timings within spec.
70
71
72 Utilities
73 =========
74
75 Utilities are available here: https://git.linuxtv.org/v4l-utils.git
76
77 ``utils/cec-ctl``: control a CEC device
78
79 ``utils/cec-compliance``: test compliance of a remote CEC device
80
81 ``utils/cec-follower``: emulate a CEC follower device
82
83 Note that ``cec-ctl`` has support for the CEC Hospitality Profile as is
84 used in some hotel displays. See http://www.htng.org.
85
86 Note that the libcec library (https://github.com/Pulse-Eight/libcec) supports
87 the linux CEC framework.
88
89 If you want to get the CEC specification, then look at the References of
90 the HDMI wikipedia page: https://en.wikipedia.org/wiki/HDMI. CEC is part
91 of the HDMI specification. HDMI 1.3 is freely available (very similar to
92 HDMI 1.4 w.r.t. CEC) and should be good enough for most things.
93
94
95 DisplayPort to HDMI Adapters with working CEC
96 =============================================
97
98 Background: most adapters do not support the CEC Tunneling feature,
99 and of those that do many did not actually connect the CEC pin.
100 Unfortunately, this means that while a CEC device is created, it
101 is actually all alone in the world and will never be able to see other
102 CEC devices.
103
104 This is a list of known working adapters that have CEC Tunneling AND
105 that properly connected the CEC pin. If you find adapters that work
106 but are not in this list, then drop me a note.
107
108 To test: hook up your DP-to-HDMI adapter to a CEC capable device
109 (typically a TV), then run::
110
111 cec-ctl --playback # Configure the PC as a CEC Playback device
112 cec-ctl -S # Show the CEC topology
113
114 The ``cec-ctl -S`` command should show at least two CEC devices,
115 ourselves and the CEC device you are connected to (i.e. typically the TV).
116
117 General note: I have only seen this work with the Parade PS175, PS176 and
118 PS186 chipsets and the MegaChips 2900. While MegaChips 28x0 claims CEC support,
119 I have never seen it work.
120
121 USB-C to HDMI
122 -------------
123
124 Samsung Multiport Adapter EE-PW700: https://www.samsung.com/ie/support/model/EE-PW700BBEGWW/
125
126 Kramer ADC-U31C/HF: https://www.kramerav.com/product/ADC-U31C/HF
127
128 Club3D CAC-2504: https://www.club-3d.com/en/detail/2449/usb_3.1_type_c_to_hdmi_2.0_uhd_4k_60hz_active_adapter/
129
130 DisplayPort to HDMI
131 -------------------
132
133 Club3D CAC-1080: https://www.club-3d.com/en/detail/2442/displayport_1.4_to_hdmi_2.0b_hdr/
134
135 CableCreation (SKU: CD0712): https://www.cablecreation.com/products/active-displayport-to-hdmi-adapter-4k-hdr
136
137 HP DisplayPort to HDMI True 4k Adapter (P/N 2JA63AA): https://www.hp.com/us-en/shop/pdp/hp-displayport-to-hdmi-true-4k-adapter
138
139 Mini-DisplayPort to HDMI
140 ------------------------
141
142 Club3D CAC-1180: https://www.club-3d.com/en/detail/2443/mini_displayport_1.4_to_hdmi_2.0b_hdr/
143
144 Note that passive adapters will never work, you need an active adapter.
145
146 The Club3D adapters in this list are all MegaChips 2900 based. Other Club3D adapters
147 are PS176 based and do NOT have the CEC pin hooked up, so only the three Club3D
148 adapters above are known to work.
149
150 I suspect that MegaChips 2900 based designs in general are likely to work
151 whereas with the PS176 it is more hit-and-miss (mostly miss). The PS186 is
152 likely to have the CEC pin hooked up, it looks like they changed the reference
153 design for that chipset.
154
155
156 USB CEC Dongles
157 ===============
158
159 These dongles appear as ``/dev/ttyACMX`` devices and need the ``inputattach``
160 utility to create the ``/dev/cecX`` devices. Support for the Pulse-Eight
161 has been added to ``inputattach`` 1.6.0. Support for the Rainshadow Tech has
162 been added to ``inputattach`` 1.6.1.
163
164 You also need udev rules to automatically start systemd services::
165
166 SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="2548", ATTRS{idProduct}=="1002", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="pulse8-cec-inputattach@%k.service"
167 SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="2548", ATTRS{idProduct}=="1001", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="pulse8-cec-inputattach@%k.service"
168 SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="ff59", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rainshadow-cec-inputattach@%k.service"
169
170 and these systemd services:
171
172 For Pulse-Eight make /lib/systemd/system/pulse8-cec-inputattach@.service::
173
174 [Unit]
175 Description=inputattach for pulse8-cec device on %I
176
177 [Service]
178 Type=simple
179 ExecStart=/usr/bin/inputattach --pulse8-cec /dev/%I
180
181 For the RainShadow Tech make /lib/systemd/system/rainshadow-cec-inputattach@.service::
182
183 [Unit]
184 Description=inputattach for rainshadow-cec device on %I
185
186 [Service]
187 Type=simple
188 ExecStart=/usr/bin/inputattach --rainshadow-cec /dev/%I
189
190
191 For proper suspend/resume support create: /lib/systemd/system/restart-cec-inputattach.service::
192
193 [Unit]
194 Description=restart inputattach for cec devices
195 After=suspend.target
196
197 [Service]
198 Type=forking
199 ExecStart=/bin/bash -c 'for d in /dev/serial/by-id/usb-Pulse-Eight*; do /usr/bin/inputattach --daemon --pulse8-cec $d; done; for d in /dev/serial/by-id/usb-RainShadow_Tech*; do /usr/bin/inputattach --daemon --rainshadow-cec $d; done'
200
201 [Install]
202 WantedBy=suspend.target
203
204 And run ``systemctl enable restart-cec-inputattach``.
205
206 To automatically set the physical address of the CEC device whenever the
207 EDID changes, you can use ``cec-ctl`` with the ``-E`` option::
208
209 cec-ctl -E /sys/class/drm/card0-DP-1/edid
210
211 This assumes the dongle is connected to the card0-DP-1 output (``xrandr`` will tell
212 you which output is used) and it will poll for changes to the EDID and update
213 the Physical Address whenever they occur.
214
215 To automatically run this command you can use cron. Edit crontab with
216 ``crontab -e`` and add this line::
217
218 @reboot /usr/local/bin/cec-ctl -E /sys/class/drm/card0-DP-1/edid
219
220 This only works for display drivers that expose the EDID in ``/sys/class/drm``,
221 such as the i915 driver.
222
223
224 CEC Without HPD
225 ===============
226
227 Some displays when in standby mode have no HDMI Hotplug Detect signal, but
228 CEC is still enabled so connected devices can send an <Image View On> CEC
229 message in order to wake up such displays. Unfortunately, not all CEC
230 adapters can support this. An example is the Odroid-U3 SBC that has a
231 level-shifter that is powered off when the HPD signal is low, thus
232 blocking the CEC pin. Even though the SoC can use CEC without a HPD,
233 the level-shifter will prevent this from functioning.
234
235 There is a CEC capability flag to signal this: ``CEC_CAP_NEEDS_HPD``.
236 If set, then the hardware cannot wake up displays with this behavior.
237
238 Note for CEC application implementers: the <Image View On> message must
239 be the first message you send, don't send any other messages before.
240 Certain very bad but unfortunately not uncommon CEC implementations
241 get very confused if they receive anything else but this message and
242 they won't wake up.
243
244 When writing a driver it can be tricky to test this. There are two
245 ways to do this:
246
247 1) Get a Pulse-Eight USB CEC dongle, connect an HDMI cable from your
248 device to the Pulse-Eight, but do not connect the Pulse-Eight to
249 the display.
250
251 Now configure the Pulse-Eight dongle::
252
253 cec-ctl -p0.0.0.0 --tv
254
255 and start monitoring::
256
257 sudo cec-ctl -M
258
259 On the device you are testing run::
260
261 cec-ctl --playback
262
263 It should report a physical address of f.f.f.f. Now run this
264 command::
265
266 cec-ctl -t0 --image-view-on
267
268 The Pulse-Eight should see the <Image View On> message. If not,
269 then something (hardware and/or software) is preventing the CEC
270 message from going out.
271
272 To make sure you have the wiring correct just connect the
273 Pulse-Eight to a CEC-enabled display and run the same command
274 on your device: now there is a HPD, so you should see the command
275 arriving at the Pulse-Eight.
276
277 2) If you have another linux device supporting CEC without HPD, then
278 you can just connect your device to that device. Yes, you can connect
279 two HDMI outputs together. You won't have a HPD (which is what we
280 want for this test), but the second device can monitor the CEC pin.
281
282 Otherwise use the same commands as in 1.
283
284 If CEC messages do not come through when there is no HPD, then you
285 need to figure out why. Typically it is either a hardware restriction
286 or the software powers off the CEC core when the HPD goes low. The
287 first cannot be corrected of course, the second will likely required
288 driver changes.
289
290
291 Microcontrollers & CEC
292 ======================
293
294 We have seen some CEC implementations in displays that use a microcontroller
295 to sample the bus. This does not have to be a problem, but some implementations
296 have timing issues. This is hard to discover unless you can hook up a low-level
297 CEC debugger (see the next section).
298
299 You will see cases where the CEC transmitter holds the CEC line high or low for
300 a longer time than is allowed. For directed messages this is not a problem since
301 if that happens the message will not be Acked and it will be retransmitted.
302 For broadcast messages no such mechanism exists.
303
304 It's not clear what to do about this. It is probably wise to transmit some
305 broadcast messages twice to reduce the chance of them being lost. Specifically
306 <Standby> and <Active Source> are candidates for that.
307
308
309 Making a CEC debugger
310 =====================
311
312 By using a Raspberry Pi 4B and some cheap components you can make
313 your own low-level CEC debugger.
314
315 The critical component is one of these HDMI female-female passthrough connectors
316 (full soldering type 1):
317
318 https://elabbay.myshopify.com/collections/camera/products/hdmi-af-af-v1a-hdmi-type-a-female-to-hdmi-type-a-female-pass-through-adapter-breakout-board?variant=45533926147
319
320 The video quality is variable and certainly not enough to pass-through 4kp60
321 (594 MHz) video. You might be able to support 4kp30, but more likely you will
322 be limited to 1080p60 (148.5 MHz). But for CEC testing that is fine.
323
324 You need a breadboard and some breadboard wires:
325
326 http://www.dx.com/p/diy-40p-male-to-female-male-to-male-female-to-female-dupont-line-wire-3pcs-356089#.WYLOOXWGN7I
327
328 If you want to monitor the HPD and/or 5V lines as well, then you need one of
329 these 5V to 3.3V level shifters:
330
331 https://www.adafruit.com/product/757
332
333 (This is just where I got these components, there are many other places you
334 can get similar things).
335
336 The ground pin of the HDMI connector needs to be connected to a ground
337 pin of the Raspberry Pi, of course.
338
339 The CEC pin of the HDMI connector needs to be connected to these pins:
340 GPIO 6 and GPIO 7. The optional HPD pin of the HDMI connector should
341 be connected via the level shifter to these pins: GPIO 23 and GPIO 12.
342 The optional 5V pin of the HDMI connector should be connected via the
343 level shifter to these pins: GPIO 25 and GPIO 22. Monitoring the HPD and
344 5V lines is not necessary, but it is helpful.
345
346 This device tree addition in ``arch/arm/boot/dts/bcm2711-rpi-4-b.dts``
347 will hook up the cec-gpio driver correctly::
348
349 cec@6 {
350 compatible = "cec-gpio";
351 cec-gpios = <&gpio 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
352 hpd-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>;
353 v5-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>;
354 };
355
356 cec@7 {
357 compatible = "cec-gpio";
358 cec-gpios = <&gpio 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
359 hpd-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
360 v5-gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
361 };
362
363 If you haven't hooked up the HPD and/or 5V lines, then just delete those
364 lines.
365
366 This dts change will enable two cec GPIO devices: I typically use one to
367 send/receive CEC commands and the other to monitor. If you monitor using
368 an unconfigured CEC adapter then it will use GPIO interrupts which makes
369 monitoring very accurate.
370
371 If you just want to monitor traffic, then a single instance is sufficient.
372 The minimum configuration is one HDMI female-female passthrough connector
373 and two female-female breadboard wires: one for connecting the HDMI ground
374 pin to a ground pin on the Raspberry Pi, and the other to connect the HDMI
375 CEC pin to GPIO 6 on the Raspberry Pi.
376
377 The documentation on how to use the error injection is here: :ref:`cec_pin_error_inj`.
378
379 ``cec-ctl --monitor-pin`` will do low-level CEC bus sniffing and analysis.
380 You can also store the CEC traffic to file using ``--store-pin`` and analyze
381 it later using ``--analyze-pin``.
382
383 You can also use this as a full-fledged CEC device by configuring it
384 using ``cec-ctl --tv -p0.0.0.0`` or ``cec-ctl --playback -p1.0.0.0``.
385
386 .. _extron_da_hd_4k_plus:
387
388 Extron DA HD 4K PLUS CEC Adapter driver
389 =======================================
390
391 This driver is for the Extron DA HD 4K PLUS series of HDMI Distribution
392 Amplifiers: https://www.extron.com/product/dahd4kplusseries
393
394 The 2, 4 and 6 port models are supported.
395
396 Firmware version 1.02.0001 or higher is required.
397
398 Note that older Extron hardware revisions have a problem with the CEC voltage,
399 which may mean that CEC will not work. This is fixed in hardware revisions
400 E34814 and up.
401
402 The CEC support has two modes: the first is a manual mode where userspace has
403 to manually control CEC for the HDMI Input and all HDMI Outputs. While this gives
404 full control, it is also complicated.
405
406 The second mode is an automatic mode, which is selected if the module option
407 ``vendor_id`` is set. In that case the driver controls CEC and CEC messages
408 received in the input will be distributed to the outputs. It is still possible
409 to use the /dev/cecX devices to talk to the connected devices directly, but it is
410 the driver that configures everything and deals with things like Hotplug Detect
411 changes.
412
413 The driver also takes care of the EDIDs: /dev/videoX devices are created to
414 read the EDIDs and (for the HDMI Input port) to set the EDID.
415
416 By default userspace is responsible to set the EDID for the HDMI Input
417 according to the EDIDs of the connected displays. But if the ``manufacturer_name``
418 module option is set, then the driver will take care of setting the EDID
419 of the HDMI Input based on the supported resolutions of the connected displays.
420 Currently the driver only supports resolutions 1080p60 and 4kp60: if all connected
421 displays support 4kp60, then it will advertise 4kp60 on the HDMI input, otherwise
422 it will fall back to an EDID that just reports 1080p60.
423
424 The status of the Extron is reported in ``/sys/kernel/debug/cec/cecX/status``.
425
426 The extron-da-hd-4k-plus driver implements the following module options:
427
428 ``debug``
429 ---------
430
431 If set to 1, then all serial port traffic is shown.
432
433 ``vendor_id``
434 -------------
435
436 The CEC Vendor ID to report to connected displays.
437
438 If set, then the driver will take care of distributing CEC messages received
439 on the input to the HDMI outputs. This is done for the following CEC messages:
440
441 - <Standby>
442 - <Image View On> and <Text View On>
443 - <Give Device Power Status>
444 - <Set System Audio Mode>
445 - <Request Current Latency>
446
447 If not set, then userspace is responsible for this, and it will have to
448 configure the CEC devices for HDMI Input and the HDMI Outputs manually.
449
450 ``manufacturer_name``
451 ---------------------
452
453 A three character manufacturer name that is used in the EDID for the HDMI
454 Input. If not set, then userspace is responsible for configuring an EDID.
455 If set, then the driver will update the EDID automatically based on the
456 resolutions supported by the connected displays, and it will not be possible
457 anymore to manually set the EDID for the HDMI Input.
458
459 ``hpd_never_low``
460 -----------------
461
462 If set, then the Hotplug Detect pin of the HDMI Input will always be high,
463 even if nothing is connected to the HDMI Outputs. If not set (the default)
464 then the Hotplug Detect pin of the HDMI input will go low if all the detected
465 Hotplug Detect pins of the HDMI Outputs are also low.
466
467 This option may be changed dynamically.
468

3. 한국어 전문 번역

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

Mainline에서 지원하는 HDMI CEC hardware

1-70

Mainline Linux의 HDMI CEC framework는 다음 hardware를 지원합니다.

분류지원 hardware
HDMI transmitterExynos4, Exynos5, STIH4xx HDMI CEC, V4L2 adv7511, stm32, Allwinner A10(sun4i), Raspberry Pi, dw-hdmi(Synopsis IP), amlogic(meson ao-cec/ao-cec-g12a), drm adv7511/adv7533, omap4, tegra, rk3288/rk3399, tda998x, i915·nouveau·amdgpu의 DisplayPort CEC-Tunneling-over-AUX, ChromeOS EC CEC, SECO board(UDOO x86), Chrontel CH7322
HDMI receiveradv7604/11/12, adv7842, tc358743
USB donglePulse-Eight, RainShadow Tech, Extron DA HD 4K PLUS HDMI Distribution Amplifier
기타실제 CEC hardware 없이 receiver와 transmitter를 흉내 내는 vivid, GPIO pin으로 CEC line을 제어하고 error injection도 지원하는 cec-gpio

Pulse-Eight `pulse8-cec` driver의 `persistent_config` module option은 기본적으로 꺼져 있습니다. 1로 설정하면 현재 설정을 장치 내부 EEPROM에 저장하고 다음 USB 연결 때 복원합니다. RainShadow Tech hardware도 이를 지원하지만 해당 driver에는 이 option이 구현되어 있지 않습니다.

CEC pin framework를 직접 사용하는 `cec-gpio`, Allwinner A10 등의 driver는 high-resolution timer에 의존합니다. NTP daemon이 clock을 빠르게 하거나 느리게 하면 timing이 specification을 벗어날 수 있습니다.

`chronyd`는 기본적으로 clock을 1/12만큼 증감할 수 있으므로 `chronyd.conf`에 `maxslewrate 40000`을 추가해 변화를 1/25로 제한하면 CEC timing을 specification 안에 유지할 수 있습니다.

CEC utility와 specification

71-94
Utility용도
`utils/cec-ctl`CEC 장치를 제어합니다.
`utils/cec-compliance`원격 CEC 장치의 specification 준수 여부를 시험합니다.
`utils/cec-follower`CEC follower 장치를 emulate합니다.

`cec-ctl`은 일부 hotel display에서 쓰는 CEC Hospitality Profile을 지원하고, `libcec` library도 Linux CEC framework를 지원합니다.

CEC는 HDMI specification의 일부입니다. 무료로 구할 수 있는 HDMI 1.3은 CEC 관점에서 HDMI 1.4와 매우 비슷해 대부분의 작업에 충분합니다.

CEC가 동작하는 DisplayPort-to-HDMI adapter

95-155

대부분의 adapter는 CEC Tunneling을 지원하지 않고, 지원한다고 해도 CEC pin을 실제로 연결하지 않은 제품이 많습니다. 이 경우 CEC device node는 생겨도 다른 CEC 장치를 발견할 수 없습니다.

DP-to-HDMI adapter를 TV 같은 CEC 지원 장치에 연결한 뒤 다음 명령으로 PC를 playback device로 설정하고 topology를 확인합니다.

cec-ctl --playback	# Configure the PC as a CEC Playback device
cec-ctl -S		# Show the CEC topology

`cec-ctl -S` 출력에는 자신과 연결 대상, 보통 TV인 CEC 장치가 최소 두 개 나타나야 합니다.

동작이 확인된 chipset은 Parade PS175, PS176, PS186과 MegaChips 2900입니다. MegaChips 28x0은 CEC 지원을 주장하지만 실제 동작은 확인되지 않았습니다.

Adapter 형태동작 확인 제품
USB-C to HDMISamsung Multiport Adapter EE-PW700, Kramer ADC-U31C/HF, Club3D CAC-2504
DisplayPort to HDMIClub3D CAC-1080, CableCreation CD0712, HP DisplayPort to HDMI True 4k Adapter(2JA63AA)
Mini-DisplayPort to HDMIClub3D CAC-1180

Passive adapter는 동작하지 않으므로 active adapter가 필요합니다. 목록의 Club3D 제품은 모두 MegaChips 2900 기반입니다. 다른 PS176 기반 Club3D adapter는 CEC pin이 연결되지 않아 위 세 제품만 동작이 확인되었습니다. MegaChips 2900 설계는 대체로 동작할 가능성이 높고 PS176은 성공 사례가 드물며 PS186은 reference design 변경으로 CEC pin이 연결됐을 가능성이 큽니다.

USB CEC dongle의 udev·systemd 설정

156-223

USB CEC dongle은 `/dev/ttyACMX`로 나타나며 `inputattach` utility가 `/dev/cecX`를 생성해야 합니다. Pulse-Eight 지원은 `inputattach` 1.6.0, RainShadow Tech 지원은 1.6.1에 추가되었습니다.

Systemd service를 자동 시작하려면 다음 udev rule이 필요합니다.

SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="2548", ATTRS{idProduct}=="1002", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="pulse8-cec-inputattach@%k.service"
SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="2548", ATTRS{idProduct}=="1001", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="pulse8-cec-inputattach@%k.service"
SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="ff59", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rainshadow-cec-inputattach@%k.service"

Pulse-Eight용 `/lib/systemd/system/pulse8-cec-inputattach@.service`는 다음과 같습니다.

[Unit]
Description=inputattach for pulse8-cec device on %I

[Service]
Type=simple
ExecStart=/usr/bin/inputattach --pulse8-cec /dev/%I

RainShadow Tech용 `/lib/systemd/system/rainshadow-cec-inputattach@.service`는 다음과 같습니다.

[Unit]
Description=inputattach for rainshadow-cec device on %I

[Service]
Type=simple
ExecStart=/usr/bin/inputattach --rainshadow-cec /dev/%I

Suspend/resume 뒤 `inputattach`를 다시 시작하려면 `/lib/systemd/system/restart-cec-inputattach.service`를 만듭니다.

[Unit]
Description=restart inputattach for cec devices
After=suspend.target

[Service]
Type=forking
ExecStart=/bin/bash -c 'for d in /dev/serial/by-id/usb-Pulse-Eight*; do /usr/bin/inputattach --daemon --pulse8-cec $d; done; for d in /dev/serial/by-id/usb-RainShadow_Tech*; do /usr/bin/inputattach --daemon --rainshadow-cec $d; done'

[Install]
WantedBy=suspend.target

그다음 `systemctl enable restart-cec-inputattach`를 실행합니다.

EDID가 바뀔 때 CEC physical address를 자동 갱신하려면 `cec-ctl -E`를 사용합니다.

cec-ctl -E /sys/class/drm/card0-DP-1/edid

이 예는 dongle이 `card0-DP-1` output에 연결됐다고 가정합니다. 실제 output은 `xrandr`로 확인할 수 있고, 명령은 EDID 변경을 polling해 Physical Address를 갱신합니다.

Cron으로 자동 실행하려면 `crontab -e`에 다음 줄을 추가합니다.

@reboot /usr/local/bin/cec-ctl -E /sys/class/drm/card0-DP-1/edid

이 방식은 i915처럼 EDID를 `/sys/class/drm`에 노출하는 display driver에서만 동작합니다.

HPD가 없을 때의 CEC 동작과 시험

224-289

일부 display는 standby 상태에서 HDMI Hotplug Detect(HPD) signal을 내리지 않지만 CEC는 계속 켜 두어 연결 장치가 `<Image View On>` message로 display를 깨울 수 있게 합니다. 모든 CEC adapter가 이를 지원하지는 않습니다.

예를 들어 Odroid-U3 SBC는 HPD가 low일 때 level shifter 전원이 꺼져 CEC pin을 막습니다. SoC가 HPD 없이 CEC를 쓸 수 있어도 board hardware 때문에 동작하지 않습니다.

`CEC_CAP_NEEDS_HPD` capability flag가 설정돼 있으면 hardware가 이 동작으로 display를 깨울 수 없다는 뜻입니다.

CEC application은 다른 message보다 `<Image View On>`을 반드시 먼저 보내야 합니다. 일부 결함 있는 구현은 다른 message를 먼저 받으면 혼란에 빠져 wake-up하지 않습니다.

Driver를 시험하는 첫 방법은 Pulse-Eight USB CEC dongle을 이용하는 것입니다.

순서연결·검증 내용
1시험 장치의 HDMI cable을 Pulse-Eight에 연결하되 Pulse-Eight는 display에 연결하지 않습니다.
2Pulse-Eight를 TV logical device와 physical address `0.0.0.0`으로 설정합니다.
3Pulse-Eight monitoring을 시작합니다.
4시험 장치를 playback device로 설정합니다. Physical address는 `f.f.f.f`로 보고되어야 합니다.
5`<Image View On>`을 logical address 0으로 보내 Pulse-Eight가 message를 보는지 확인합니다.
cec-ctl -p0.0.0.0 --tv
sudo cec-ctl -M
cec-ctl --playback
cec-ctl -t0 --image-view-on

Pulse-Eight가 `<Image View On>`을 보지 못하면 hardware 또는 software가 CEC 송신을 막는 것입니다. Wiring 확인을 위해 Pulse-Eight를 CEC display에 연결하면 HPD가 생기므로 같은 명령이 도착해야 합니다.

두 번째 방법은 HPD 없이 CEC를 지원하는 다른 Linux 장치에 시험 장치를 직접 연결하는 것입니다. HDMI output 두 개를 서로 연결해 HPD 없이 두 번째 장치가 CEC pin을 monitor하게 할 수 있습니다.

HPD가 없을 때 message가 통과하지 않으면 hardware 제한인지, HPD가 low일 때 software가 CEC core 전원을 끄는지 확인해야 합니다. Hardware 제한은 고칠 수 없지만 후자는 driver 변경으로 수정할 수 있습니다.

Microcontroller 기반 CEC timing

290-308

일부 display의 CEC 구현은 microcontroller로 bus를 sampling합니다. 자체가 문제는 아니지만 일부 구현에는 low-level CEC debugger가 있어야 발견할 수 있는 timing 문제가 있습니다.

CEC transmitter가 허용 범위보다 오래 line을 high 또는 low로 유지할 수 있습니다. Directed message는 ACK를 받지 못해 재전송되므로 큰 문제가 아니지만 broadcast message에는 그런 복구 mechanism이 없습니다.

손실 가능성을 줄이기 위해 `<Standby>`와 `<Active Source>` 같은 broadcast message는 두 번 전송하는 것이 합리적일 수 있습니다.

Raspberry Pi 4B CEC debugger 제작

309-385

Raspberry Pi 4B와 저렴한 부품으로 low-level CEC debugger를 만들 수 있습니다. 핵심 부품은 full-soldering type 1 HDMI female-to-female passthrough connector입니다.

Passthrough board의 video 품질은 일정하지 않고 4kp60(594 MHz)은 통과시키기 어렵습니다. 4kp30 가능성은 있지만 대개 1080p60(148.5 MHz)으로 제한됩니다. CEC 시험에는 충분합니다.

HDMI signalRaspberry Pi 연결
GroundRaspberry Pi ground pin
CECGPIO 6 및 GPIO 7
HPD(선택)5V-to-3.3V level shifter를 거쳐 GPIO 23 및 GPIO 12
5V(선택)5V-to-3.3V level shifter를 거쳐 GPIO 25 및 GPIO 22

`arch/arm/boot/dts/bcm2711-rpi-4-b.dts`에 다음 node를 추가하면 `cec-gpio` driver를 올바르게 연결합니다.

cec@6 {
	compatible = "cec-gpio";
	cec-gpios = <&gpio 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
	hpd-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>;
	v5-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>;
};

cec@7 {
	compatible = "cec-gpio";
	cec-gpios = <&gpio 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
	hpd-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
	v5-gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
};

HPD 또는 5V line을 연결하지 않았다면 대응하는 `hpd-gpios` 또는 `v5-gpios` 줄을 삭제합니다. 이 DTS 변경은 CEC GPIO 장치 두 개를 만들며, 하나는 송수신에 다른 하나는 monitoring에 사용할 수 있습니다. 설정하지 않은 CEC adapter로 monitor하면 GPIO interrupt를 써서 매우 정확합니다.

Traffic monitoring만 필요하면 instance 하나면 충분합니다. 최소 구성은 HDMI passthrough connector 하나와 female-to-female wire 두 개로, ground와 CEC pin(GPIO 6)만 연결합니다.

Error injection 사용법은 `cec_pin_error_inj` 문서를 참고합니다. `cec-ctl --monitor-pin`은 low-level CEC bus sniffing과 분석을 수행하고, `--store-pin`으로 저장한 뒤 `--analyze-pin`으로 분석할 수 있습니다.

`cec-ctl --tv -p0.0.0.0` 또는 `cec-ctl --playback -p1.0.0.0`으로 설정하면 완전한 CEC 장치로도 사용할 수 있습니다.

Extron DA HD 4K PLUS CEC adapter driver

386-425

이 driver는 Extron DA HD 4K PLUS HDMI Distribution Amplifier의 2·4·6 port model을 지원합니다. Firmware 1.02.0001 이상이 필요합니다.

오래된 hardware revision에는 CEC voltage 문제가 있어 CEC가 동작하지 않을 수 있습니다. 이 문제는 hardware revision E34814 이상에서 수정되었습니다.

Manual mode에서는 userspace가 HDMI Input과 모든 HDMI Output의 CEC를 직접 제어해 완전한 control을 얻지만 설정이 복잡합니다.

`vendor_id` module option을 설정하면 automatic mode가 선택됩니다. Driver가 CEC를 설정하고 input에서 받은 message를 output으로 분배하며 Hotplug Detect 변경도 처리합니다. `/dev/cecX`로 연결 장치에 직접 message를 보낼 수 있습니다.

Driver는 EDID도 관리하며 `/dev/videoX` node를 만들어 EDID를 읽고 HDMI Input에서는 설정할 수도 있게 합니다. 기본적으로 userspace가 연결 display의 EDID에 따라 input EDID를 설정합니다.

`manufacturer_name`을 설정하면 driver가 연결 display의 지원 resolution을 바탕으로 HDMI Input EDID를 자동 생성합니다. 현재 1080p60과 4kp60만 지원하며 모든 display가 4kp60을 지원할 때만 4kp60을 광고하고, 아니면 1080p60 EDID로 fallback합니다.

Extron 상태는 `/sys/kernel/debug/cec/cecX/status`에서 확인합니다.

Extron driver module option

426-467
Option동작
`debug`1로 설정하면 모든 serial-port traffic을 표시합니다.
`vendor_id`연결 display에 보고할 CEC Vendor ID입니다. 설정하면 input에서 받은 지정 CEC message를 HDMI output으로 분배합니다. 설정하지 않으면 userspace가 input과 output CEC device를 직접 구성해야 합니다.
`manufacturer_name`HDMI Input EDID에 넣을 세 글자 manufacturer name입니다. 설정하면 driver가 연결 display resolution에 맞춰 EDID를 자동 갱신하고 input EDID를 수동 설정할 수 없게 됩니다.
`hpd_never_low`설정하면 output에 아무것도 연결되지 않아도 HDMI Input HPD를 항상 high로 유지합니다. 기본값에서는 감지된 모든 output HPD가 low이면 input HPD도 low가 됩니다. Runtime에 변경할 수 있습니다.

`vendor_id`가 분배하는 message는 `<Standby>`, `<Image View On>`, `<Text View On>`, `<Give Device Power Status>`, `<Set System Audio Mode>`, `<Request Current Latency>`입니다.