162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci========
462306a36Sopenharmony_ciHDMI CEC
562306a36Sopenharmony_ci========
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciSupported hardware in mainline
862306a36Sopenharmony_ci==============================
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciHDMI Transmitters:
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci- Exynos4
1362306a36Sopenharmony_ci- Exynos5
1462306a36Sopenharmony_ci- STIH4xx HDMI CEC
1562306a36Sopenharmony_ci- V4L2 adv7511 (same HW, but a different driver from the drm adv7511)
1662306a36Sopenharmony_ci- stm32
1762306a36Sopenharmony_ci- Allwinner A10 (sun4i)
1862306a36Sopenharmony_ci- Raspberry Pi
1962306a36Sopenharmony_ci- dw-hdmi (Synopsis IP)
2062306a36Sopenharmony_ci- amlogic (meson ao-cec and ao-cec-g12a)
2162306a36Sopenharmony_ci- drm adv7511/adv7533
2262306a36Sopenharmony_ci- omap4
2362306a36Sopenharmony_ci- tegra
2462306a36Sopenharmony_ci- rk3288, rk3399
2562306a36Sopenharmony_ci- tda998x
2662306a36Sopenharmony_ci- DisplayPort CEC-Tunneling-over-AUX on i915, nouveau and amdgpu
2762306a36Sopenharmony_ci- ChromeOS EC CEC
2862306a36Sopenharmony_ci- CEC for SECO boards (UDOO x86).
2962306a36Sopenharmony_ci- Chrontel CH7322
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ciHDMI Receivers:
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci- adv7604/11/12
3562306a36Sopenharmony_ci- adv7842
3662306a36Sopenharmony_ci- tc358743
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciUSB Dongles (see below for additional information on how to use these
3962306a36Sopenharmony_cidongles):
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci- Pulse-Eight: the pulse8-cec driver implements the following module option:
4262306a36Sopenharmony_ci  ``persistent_config``: by default this is off, but when set to 1 the driver
4362306a36Sopenharmony_ci  will store the current settings to the device's internal eeprom and restore
4462306a36Sopenharmony_ci  it the next time the device is connected to the USB port.
4562306a36Sopenharmony_ci- RainShadow Tech. Note: this driver does not support the persistent_config
4662306a36Sopenharmony_ci  module option of the Pulse-Eight driver. The hardware supports it, but I
4762306a36Sopenharmony_ci  have no plans to add this feature. But I accept patches :-)
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciMiscellaneous:
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci- vivid: emulates a CEC receiver and CEC transmitter.
5262306a36Sopenharmony_ci  Can be used to test CEC applications without actual CEC hardware.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci- cec-gpio. If the CEC pin is hooked up to a GPIO pin then
5562306a36Sopenharmony_ci  you can control the CEC line through this driver. This supports error
5662306a36Sopenharmony_ci  injection as well.
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci- cec-gpio and Allwinner A10 (or any other driver that uses the CEC pin
5962306a36Sopenharmony_ci  framework to drive the CEC pin directly): the CEC pin framework uses
6062306a36Sopenharmony_ci  high-resolution timers. These timers are affected by NTP daemons that
6162306a36Sopenharmony_ci  speed up or slow down the clock to sync with the official time. The
6262306a36Sopenharmony_ci  chronyd server will by default increase or decrease the clock by
6362306a36Sopenharmony_ci  1/12th. This will cause the CEC timings to go out of spec. To fix this,
6462306a36Sopenharmony_ci  add a 'maxslewrate 40000' line to chronyd.conf. This limits the clock
6562306a36Sopenharmony_ci  frequency change to 1/25th, which keeps the CEC timings within spec.
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciUtilities
6962306a36Sopenharmony_ci=========
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciUtilities are available here: https://git.linuxtv.org/v4l-utils.git
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci``utils/cec-ctl``: control a CEC device
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci``utils/cec-compliance``: test compliance of a remote CEC device
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci``utils/cec-follower``: emulate a CEC follower device
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ciNote that ``cec-ctl`` has support for the CEC Hospitality Profile as is
8062306a36Sopenharmony_ciused in some hotel displays. See http://www.htng.org.
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ciNote that the libcec library (https://github.com/Pulse-Eight/libcec) supports
8362306a36Sopenharmony_cithe linux CEC framework.
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ciIf you want to get the CEC specification, then look at the References of
8662306a36Sopenharmony_cithe HDMI wikipedia page: https://en.wikipedia.org/wiki/HDMI. CEC is part
8762306a36Sopenharmony_ciof the HDMI specification. HDMI 1.3 is freely available (very similar to
8862306a36Sopenharmony_ciHDMI 1.4 w.r.t. CEC) and should be good enough for most things.
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ciDisplayPort to HDMI Adapters with working CEC
9262306a36Sopenharmony_ci=============================================
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ciBackground: most adapters do not support the CEC Tunneling feature,
9562306a36Sopenharmony_ciand of those that do many did not actually connect the CEC pin.
9662306a36Sopenharmony_ciUnfortunately, this means that while a CEC device is created, it
9762306a36Sopenharmony_ciis actually all alone in the world and will never be able to see other
9862306a36Sopenharmony_ciCEC devices.
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ciThis is a list of known working adapters that have CEC Tunneling AND
10162306a36Sopenharmony_cithat properly connected the CEC pin. If you find adapters that work
10262306a36Sopenharmony_cibut are not in this list, then drop me a note.
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ciTo test: hook up your DP-to-HDMI adapter to a CEC capable device
10562306a36Sopenharmony_ci(typically a TV), then run::
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci	cec-ctl --playback	# Configure the PC as a CEC Playback device
10862306a36Sopenharmony_ci	cec-ctl -S		# Show the CEC topology
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ciThe ``cec-ctl -S`` command should show at least two CEC devices,
11162306a36Sopenharmony_ciourselves and the CEC device you are connected to (i.e. typically the TV).
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ciGeneral note: I have only seen this work with the Parade PS175, PS176 and
11462306a36Sopenharmony_ciPS186 chipsets and the MegaChips 2900. While MegaChips 28x0 claims CEC support,
11562306a36Sopenharmony_ciI have never seen it work.
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ciUSB-C to HDMI
11862306a36Sopenharmony_ci-------------
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ciSamsung Multiport Adapter EE-PW700: https://www.samsung.com/ie/support/model/EE-PW700BBEGWW/
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ciKramer ADC-U31C/HF: https://www.kramerav.com/product/ADC-U31C/HF
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ciClub3D CAC-2504: https://www.club-3d.com/en/detail/2449/usb_3.1_type_c_to_hdmi_2.0_uhd_4k_60hz_active_adapter/
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ciDisplayPort to HDMI
12762306a36Sopenharmony_ci-------------------
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ciClub3D CAC-1080: https://www.club-3d.com/en/detail/2442/displayport_1.4_to_hdmi_2.0b_hdr/
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ciCableCreation (SKU: CD0712): https://www.cablecreation.com/products/active-displayport-to-hdmi-adapter-4k-hdr
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ciHP DisplayPort to HDMI True 4k Adapter (P/N 2JA63AA): https://www.hp.com/us-en/shop/pdp/hp-displayport-to-hdmi-true-4k-adapter
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ciMini-DisplayPort to HDMI
13662306a36Sopenharmony_ci------------------------
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ciClub3D CAC-1180: https://www.club-3d.com/en/detail/2443/mini_displayport_1.4_to_hdmi_2.0b_hdr/
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ciNote that passive adapters will never work, you need an active adapter.
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ciThe Club3D adapters in this list are all MegaChips 2900 based. Other Club3D adapters
14362306a36Sopenharmony_ciare PS176 based and do NOT have the CEC pin hooked up, so only the three Club3D
14462306a36Sopenharmony_ciadapters above are known to work.
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ciI suspect that MegaChips 2900 based designs in general are likely to work
14762306a36Sopenharmony_ciwhereas with the PS176 it is more hit-and-miss (mostly miss). The PS186 is
14862306a36Sopenharmony_cilikely to have the CEC pin hooked up, it looks like they changed the reference
14962306a36Sopenharmony_cidesign for that chipset.
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ciUSB CEC Dongles
15362306a36Sopenharmony_ci===============
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ciThese dongles appear as ``/dev/ttyACMX`` devices and need the ``inputattach``
15662306a36Sopenharmony_ciutility to create the ``/dev/cecX`` devices. Support for the Pulse-Eight
15762306a36Sopenharmony_cihas been added to ``inputattach`` 1.6.0. Support for the Rainshadow Tech has
15862306a36Sopenharmony_cibeen added to ``inputattach`` 1.6.1.
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ciYou also need udev rules to automatically start systemd services::
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci	SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="2548", ATTRS{idProduct}=="1002", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="pulse8-cec-inputattach@%k.service"
16362306a36Sopenharmony_ci	SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="2548", ATTRS{idProduct}=="1001", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="pulse8-cec-inputattach@%k.service"
16462306a36Sopenharmony_ci	SUBSYSTEM=="tty", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="ff59", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rainshadow-cec-inputattach@%k.service"
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ciand these systemd services:
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ciFor Pulse-Eight make /lib/systemd/system/pulse8-cec-inputattach@.service::
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci	[Unit]
17162306a36Sopenharmony_ci	Description=inputattach for pulse8-cec device on %I
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci	[Service]
17462306a36Sopenharmony_ci	Type=simple
17562306a36Sopenharmony_ci	ExecStart=/usr/bin/inputattach --pulse8-cec /dev/%I
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ciFor the RainShadow Tech make /lib/systemd/system/rainshadow-cec-inputattach@.service::
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci	[Unit]
18062306a36Sopenharmony_ci	Description=inputattach for rainshadow-cec device on %I
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci	[Service]
18362306a36Sopenharmony_ci	Type=simple
18462306a36Sopenharmony_ci	ExecStart=/usr/bin/inputattach --rainshadow-cec /dev/%I
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ciFor proper suspend/resume support create: /lib/systemd/system/restart-cec-inputattach.service::
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci	[Unit]
19062306a36Sopenharmony_ci	Description=restart inputattach for cec devices
19162306a36Sopenharmony_ci	After=suspend.target
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci	[Service]
19462306a36Sopenharmony_ci	Type=forking
19562306a36Sopenharmony_ci	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'
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci	[Install]
19862306a36Sopenharmony_ci	WantedBy=suspend.target
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ciAnd run ``systemctl enable restart-cec-inputattach``.
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ciTo automatically set the physical address of the CEC device whenever the
20362306a36Sopenharmony_ciEDID changes, you can use ``cec-ctl`` with the ``-E`` option::
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci	cec-ctl -E /sys/class/drm/card0-DP-1/edid
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ciThis assumes the dongle is connected to the card0-DP-1 output (``xrandr`` will tell
20862306a36Sopenharmony_ciyou which output is used) and it will poll for changes to the EDID and update
20962306a36Sopenharmony_cithe Physical Address whenever they occur.
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ciTo automatically run this command you can use cron. Edit crontab with
21262306a36Sopenharmony_ci``crontab -e`` and add this line::
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci	@reboot /usr/local/bin/cec-ctl -E /sys/class/drm/card0-DP-1/edid
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ciThis only works for display drivers that expose the EDID in ``/sys/class/drm``,
21762306a36Sopenharmony_cisuch as the i915 driver.
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ciCEC Without HPD
22162306a36Sopenharmony_ci===============
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ciSome displays when in standby mode have no HDMI Hotplug Detect signal, but
22462306a36Sopenharmony_ciCEC is still enabled so connected devices can send an <Image View On> CEC
22562306a36Sopenharmony_cimessage in order to wake up such displays. Unfortunately, not all CEC
22662306a36Sopenharmony_ciadapters can support this. An example is the Odroid-U3 SBC that has a
22762306a36Sopenharmony_cilevel-shifter that is powered off when the HPD signal is low, thus
22862306a36Sopenharmony_ciblocking the CEC pin. Even though the SoC can use CEC without a HPD,
22962306a36Sopenharmony_cithe level-shifter will prevent this from functioning.
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ciThere is a CEC capability flag to signal this: ``CEC_CAP_NEEDS_HPD``.
23262306a36Sopenharmony_ciIf set, then the hardware cannot wake up displays with this behavior.
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ciNote for CEC application implementers: the <Image View On> message must
23562306a36Sopenharmony_cibe the first message you send, don't send any other messages before.
23662306a36Sopenharmony_ciCertain very bad but unfortunately not uncommon CEC implementations
23762306a36Sopenharmony_ciget very confused if they receive anything else but this message and
23862306a36Sopenharmony_cithey won't wake up.
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ciWhen writing a driver it can be tricky to test this. There are two
24162306a36Sopenharmony_ciways to do this:
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci1) Get a Pulse-Eight USB CEC dongle, connect an HDMI cable from your
24462306a36Sopenharmony_ci   device to the Pulse-Eight, but do not connect the Pulse-Eight to
24562306a36Sopenharmony_ci   the display.
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci   Now configure the Pulse-Eight dongle::
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci	cec-ctl -p0.0.0.0 --tv
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci   and start monitoring::
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci	sudo cec-ctl -M
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci   On the device you are testing run::
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci	cec-ctl --playback
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci   It should report a physical address of f.f.f.f. Now run this
26062306a36Sopenharmony_ci   command::
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	cec-ctl -t0 --image-view-on
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ci   The Pulse-Eight should see the <Image View On> message. If not,
26562306a36Sopenharmony_ci   then something (hardware and/or software) is preventing the CEC
26662306a36Sopenharmony_ci   message from going out.
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ci   To make sure you have the wiring correct just connect the
26962306a36Sopenharmony_ci   Pulse-Eight to a CEC-enabled display and run the same command
27062306a36Sopenharmony_ci   on your device: now there is a HPD, so you should see the command
27162306a36Sopenharmony_ci   arriving at the Pulse-Eight.
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci2) If you have another linux device supporting CEC without HPD, then
27462306a36Sopenharmony_ci   you can just connect your device to that device. Yes, you can connect
27562306a36Sopenharmony_ci   two HDMI outputs together. You won't have a HPD (which is what we
27662306a36Sopenharmony_ci   want for this test), but the second device can monitor the CEC pin.
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_ci   Otherwise use the same commands as in 1.
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ciIf CEC messages do not come through when there is no HPD, then you
28162306a36Sopenharmony_cineed to figure out why. Typically it is either a hardware restriction
28262306a36Sopenharmony_cior the software powers off the CEC core when the HPD goes low. The
28362306a36Sopenharmony_cifirst cannot be corrected of course, the second will likely required
28462306a36Sopenharmony_cidriver changes.
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ciMicrocontrollers & CEC
28862306a36Sopenharmony_ci======================
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ciWe have seen some CEC implementations in displays that use a microcontroller
29162306a36Sopenharmony_cito sample the bus. This does not have to be a problem, but some implementations
29262306a36Sopenharmony_cihave timing issues. This is hard to discover unless you can hook up a low-level
29362306a36Sopenharmony_ciCEC debugger (see the next section).
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ciYou will see cases where the CEC transmitter holds the CEC line high or low for
29662306a36Sopenharmony_cia longer time than is allowed. For directed messages this is not a problem since
29762306a36Sopenharmony_ciif that happens the message will not be Acked and it will be retransmitted.
29862306a36Sopenharmony_ciFor broadcast messages no such mechanism exists.
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ciIt's not clear what to do about this. It is probably wise to transmit some
30162306a36Sopenharmony_cibroadcast messages twice to reduce the chance of them being lost. Specifically
30262306a36Sopenharmony_ci<Standby> and <Active Source> are candidates for that.
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci
30562306a36Sopenharmony_ciMaking a CEC debugger
30662306a36Sopenharmony_ci=====================
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ciBy using a Raspberry Pi 4B and some cheap components you can make
30962306a36Sopenharmony_ciyour own low-level CEC debugger.
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_ciThe critical component is one of these HDMI female-female passthrough connectors
31262306a36Sopenharmony_ci(full soldering type 1):
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_cihttps://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
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ciThe video quality is variable and certainly not enough to pass-through 4kp60
31762306a36Sopenharmony_ci(594 MHz) video. You might be able to support 4kp30, but more likely you will
31862306a36Sopenharmony_cibe limited to 1080p60 (148.5 MHz). But for CEC testing that is fine.
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_ciYou need a breadboard and some breadboard wires:
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_cihttp://www.dx.com/p/diy-40p-male-to-female-male-to-male-female-to-female-dupont-line-wire-3pcs-356089#.WYLOOXWGN7I
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ciIf you want to monitor the HPD and/or 5V lines as well, then you need one of
32562306a36Sopenharmony_cithese 5V to 3.3V level shifters:
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_cihttps://www.adafruit.com/product/757
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci(This is just where I got these components, there are many other places you
33062306a36Sopenharmony_cican get similar things).
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ciThe ground pin of the HDMI connector needs to be connected to a ground
33362306a36Sopenharmony_cipin of the Raspberry Pi, of course.
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ciThe CEC pin of the HDMI connector needs to be connected to these pins:
33662306a36Sopenharmony_ciGPIO 6 and GPIO 7. The optional HPD pin of the HDMI connector should
33762306a36Sopenharmony_cibe connected via the level shifter to these pins: GPIO 23 and GPIO 12.
33862306a36Sopenharmony_ciThe optional 5V pin of the HDMI connector should be connected via the
33962306a36Sopenharmony_cilevel shifter to these pins: GPIO 25 and GPIO 22. Monitoring the HPD and
34062306a36Sopenharmony_ci5V lines is not necessary, but it is helpful.
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ciThis device tree addition in ``arch/arm/boot/dts/bcm2711-rpi-4-b.dts``
34362306a36Sopenharmony_ciwill hook up the cec-gpio driver correctly::
34462306a36Sopenharmony_ci
34562306a36Sopenharmony_ci	cec@6 {
34662306a36Sopenharmony_ci		compatible = "cec-gpio";
34762306a36Sopenharmony_ci		cec-gpios = <&gpio 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
34862306a36Sopenharmony_ci		hpd-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>;
34962306a36Sopenharmony_ci		v5-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>;
35062306a36Sopenharmony_ci	};
35162306a36Sopenharmony_ci
35262306a36Sopenharmony_ci	cec@7 {
35362306a36Sopenharmony_ci		compatible = "cec-gpio";
35462306a36Sopenharmony_ci		cec-gpios = <&gpio 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
35562306a36Sopenharmony_ci		hpd-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
35662306a36Sopenharmony_ci		v5-gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
35762306a36Sopenharmony_ci	};
35862306a36Sopenharmony_ci
35962306a36Sopenharmony_ciIf you haven't hooked up the HPD and/or 5V lines, then just delete those
36062306a36Sopenharmony_cilines.
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ciThis dts change will enable two cec GPIO devices: I typically use one to
36362306a36Sopenharmony_cisend/receive CEC commands and the other to monitor. If you monitor using
36462306a36Sopenharmony_cian unconfigured CEC adapter then it will use GPIO interrupts which makes
36562306a36Sopenharmony_cimonitoring very accurate.
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ciIf you just want to monitor traffic, then a single instance is sufficient.
36862306a36Sopenharmony_ciThe minimum configuration is one HDMI female-female passthrough connector
36962306a36Sopenharmony_ciand two female-female breadboard wires: one for connecting the HDMI ground
37062306a36Sopenharmony_cipin to a ground pin on the Raspberry Pi, and the other to connect the HDMI
37162306a36Sopenharmony_ciCEC pin to GPIO 6 on the Raspberry Pi.
37262306a36Sopenharmony_ci
37362306a36Sopenharmony_ciThe documentation on how to use the error injection is here: :ref:`cec_pin_error_inj`.
37462306a36Sopenharmony_ci
37562306a36Sopenharmony_ci``cec-ctl --monitor-pin`` will do low-level CEC bus sniffing and analysis.
37662306a36Sopenharmony_ciYou can also store the CEC traffic to file using ``--store-pin`` and analyze
37762306a36Sopenharmony_ciit later using ``--analyze-pin``.
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ciYou can also use this as a full-fledged CEC device by configuring it
38062306a36Sopenharmony_ciusing ``cec-ctl --tv -p0.0.0.0`` or ``cec-ctl --playback -p1.0.0.0``.
381