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