Send HDMI CEC messages using cec-client

I was using cec-client on a Raspberry to send hdmi cec messages to my tv to turn it on and off. I’m now looking for a more powerfull SoC that can do the same things but faster. On the hardware page of the Rock Pi 4 I found that this device should also support hdmi cec and I was also able to install the cec-client using this command:

sudo apt-get install cec-utils

But the problem now is that the cec-client does not find any devices:

sudo cec-client -l
libCEC version: 4.0.2, compiled on Linux-4.4.0-142-generic … , features: P8_USB, DRM, P8_detect, randr
Found devices: NONE

I’m using the Ubuntu server image. Is there any tutorial how to get the cec-client to work on this board?

I guess the problem is that the Rock Pi 4 kernel is simply missing the configuration settings for the cec drivers. I found this issue there:

In the issue are two kernel config settings described that are not enabled in the rock pi 4 kernel:

CONFIG_MEDIA_CEC_SUPPORT: Device Drivers => Multimedia support => HDMI CEC support
CONFIG_DRM_DW_HDMI_CEC: Device Drivers => Graphics support => Display Interface Bridges

I’m now trying to build my own kernel with those two configurations set to “y” and will test if the cec-client works after booting this kernel.

I’ve managed to compile the kernel with the cec drivers. The cec0 device is showing up and I can use it, but the cec-ctl command doesn’t find my tv. (I know that cec works on my tv because it works with the Raspberry Pi)

Here is the output from sudo cec-compliance -v -T:

		CEC_ADAP_G_CAPS returned 0 (Success)
cec-compliance SHA                 : not available
		CEC_ADAP_G_PHYS_ADDR returned 0 (Success)
		CEC_ADAP_G_LOG_ADDRS returned 0 (Success)
Driver Info:
	Driver Name                : dwhdmi-rockchip
	Adapter Name               : dw_hdmi
	Capabilities               : 0x0000000e
		Logical Addresses
	Driver version             : 4.4.154
	Available Logical Addresses: 4
	Physical Address           :
	Logical Address Mask       : 0x0010
	CEC Version                : 2.0
	Vendor ID                  : 0x000c03
	Logical Addresses          : 1 (Allow RC Passthrough)

	  Logical Address          : 4 (Playback Device 1)
	    Primary Device Type    : Playback
	    Logical Address Type   : Playback
	    All Device Types       : Playback
	    RC TV Profile          : None
	    Device Features        :

Compliance test for device /dev/cec0:

    The test results mean the following:
        OK                  Supported correctly by the device.
        OK (Not Supported)  Not supported and not mandatory for the device.
        OK (Presumed)       Presumably supported.  Manually check to confirm.
        OK (Unexpected)     Supported correctly but is not expected to be supported for this device.
        OK (Refused)        Supported by the device, but was refused.
        FAIL                Failed and was expected to be supported by this device.

Find remote devices:
		MSG_POLL: Sequence: 670 Tx Timestamp: 2965.508s Length: 1
		MSG_POLL: Sequence: 671 Tx Timestamp: 2965.567s Length: 1
		MSG_POLL: Sequence: 672 Tx Timestamp: 2965.626s Length: 1
		MSG_POLL: Sequence: 673 Tx Timestamp: 2965.686s Length: 1
		MSG_POLL: Sequence: 674 Tx Timestamp: 2965.686s Length: 1
		MSG_POLL: Sequence: 675 Tx Timestamp: 2965.746s Length: 1
		MSG_POLL: Sequence: 676 Tx Timestamp: 2965.805s Length: 1
		MSG_POLL: Sequence: 677 Tx Timestamp: 2965.864s Length: 1
		MSG_POLL: Sequence: 678 Tx Timestamp: 2965.924s Length: 1
		MSG_POLL: Sequence: 679 Tx Timestamp: 2965.983s Length: 1
		MSG_POLL: Sequence: 680 Tx Timestamp: 2966.043s Length: 1
		MSG_POLL: Sequence: 681 Tx Timestamp: 2966.102s Length: 1
		MSG_POLL: Sequence: 682 Tx Timestamp: 2966.161s Length: 1
		MSG_POLL: Sequence: 683 Tx Timestamp: 2966.221s Length: 1
		MSG_POLL: Sequence: 684 Tx Timestamp: 2966.280s Length: 1
	Polling: OK

Network topology:

Total: 1, Succeeded: 1, Failed: 0, Warnings: 0

Normally the tv should now appear in the Network Topology as far as I understand. Any ideas what could be the problem?


I think we did not enable the CEC pin in the device tree. You can enable it with the following patch and try. I am sorry we don’t have a TV with CEC in the office so we can not test for you.

diff --git a/arch/arm64/boot/dts/rockchip/rockpi-4b-linux.dts b/arch/arm64/boot/dts/rockchip/rockpi-4b-linux.dts
index 9370a8d..217d8e0 100644
--- a/arch/arm64/boot/dts/rockchip/rockpi-4b-linux.dts
+++ b/arch/arm64/boot/dts/rockchip/rockpi-4b-linux.dts
@@ -295,6 +295,8 @@
 	#address-cells = <1>;
 	#size-cells = <0>;
 	#sound-dai-cells = <0>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&hdmi_i2c_xfer>, <&hdmi_cec>;
 	status = "okay";

1 Like

Thanks for the quick help, now everything works and I’m able to turn the tv on and off. Could you please implement those changes into the kernel? I could also send a pull request with my changes on GitHub.

1 Like

A PR would be awesome. We need your contribution!

I’ve just created a pull request here:

The HDMI CEC patch is merged and is enabled in the kernel since April, 2019. Thanks @TheNetStriker :slight_smile: