Linux: RPi4 I2C HDMI interface (/dev/i2c-2) not working from userspace

Created on 14 Aug 2019  路  22Comments  路  Source: raspberrypi/linux

Hi,

I'm in the process of migrating a project from RPI3b to RPI4 (4GB) due to a better GPU performance of the new platform.

One of the functions on RPI3 was turning on/of and changing the brightness of HDMI connected LCD via ddcutil command (details see https://www.ddcutil.com/raspberry/).

Unfortunately, on RPI4 I'm struggling with accessing /dev/i2c-2 HDMI1 I2C from userspace:

  • "ddcutil detect" command takes long, then outputs "No displays found".
  • "i2cdetect -y 2" also takes long to finish, there are no devices on the bus.

After either of those commands"dmesg" shows new errors:
[61839.796098] i2c-bcm2835 fe805000.i2c: i2c transfer timed out
[61840.836046] i2c-bcm2835 fe805000.i2c: i2c transfer timed out
[61854.116299] i2c-bcm2835 fe805000.i2c: i2c transfer timed out
(error messages repeat as you execute more commands using /dev/i2c-2)

Seems that there is a problem accessing i2c HDMI bus via /dev/i2c-2 from userspace.

root@mm-rpi4:/home/pi# ls -la /dev/i2c*
crw-rw---- 1 root i2c 89, 0 Aug 13 17:10 /dev/i2c-0
crw-rw---- 1 root i2c 89, 1 Aug 13 17:10 /dev/i2c-1
crw-rw---- 1 root i2c 89, 2 Aug 13 17:10 /dev/i2c-2

uname -a:
Linux mm-rpi4 4.19.65-v7l+ #1252 SMP Fri Aug 9 18:04:13 BST 2019 armv7l GNU/Linux

vcgencmd version:
Copyright (c) 2012 Broadcom
version 9f8431fb7839c7f00f52b81f5822ddab2b31d0db (clean) (release) (start)

ddcutil -V:
ddcutil 0.9.5

GPU i2c access shoud be disabled according to the /boot/config.txt:
hdmi_ignore_edid=0xa5000080 # (tried also =1)
hdmi_edid_file=1
hdmi_ignore_cec=1
dtparam=i2c2_iknowwhatimdoing
dtoverlay=vc4-fkms-v3d

Seems like something is blocking access via /dev/i2c-2. Either there is a wrong mapping of /dev/i2c-2 to HDMI ports (also there are 2 HDMI ports in new RPI4...) or GPU have "exclusive access" to i2c disallowing userspace access?

Any idea how to fix the problem? Thanks!

Most helpful comment

If you need to control HDMI connected LCD on RPI4 via DDC/CI commands (for example ddcutil) and can't wait for RPI4 drivers fix, you can try my "HDMI connector split" workaround which I've used for +3 months with no issues. You will need to solder a little bit...

Split HDMI cable from LCD into two branches:

a) DDC/CI branch which consists of HDMI Pins 15-18:
https://de.wikipedia.org/wiki/Datei:HDMI_Connector_Pins1.png

Important: you need to use 5V-to-3.3V I2C level shifter because HDMI uses 5V but RPI 3.3V levels:

[ HDMI monitor port ] _______/----- [ DDC/CI branch ] ----- [ 5to3VlevelShifter ] ----- [ RPI4-I2C-busX ]

b) HDMI branch - rest of the HDMI pins. I've soldered them back to new HDMI A male connector according to HDMI connector pinouts.

Then you can drive LCD HDMI monitor from you RPI4 via ddcutil with --bus argument. is the I2C RPI4 bus where you've connected DDC/CI branch from split HDMI cable.

All 22 comments

i2c-2 points to registers which no longer exist on 2711, we will remove that from device-tree.

On 2711 each HDMI block has a dedicated I2C controller with a different interface to the 2835 I2C generic controller. In theory this could be exposed to Linux and a new driver written although it would need to play nicely with firmware DDC reading etc.

However, in practice that might be problematic because when 4Kp60 is enabled the HDMI hardware state machine gets exclusive access to the I2C controller for maintaining the SCDC (Status and Control Data Channel) so the ARM/VPU lose access.

OK, I don't need 4Kp60 for this, 1080p on one display is sufficient. Would it be possible to access HDMI i2c from userspace as on old RPI3 so we can use ddcutil?

Possibly, but it's not likely to happen soon.

That's unfortunate. Could you give me some hints then so I can start making my own patch? Exposing HDMI1 / HDMI2 i2c registers via /dev/ and disabling HDMI DDC readings (like hdmi_ignore_edid option in RPI3 config.txt)? Where can I find some info?

@lurch Perhaps the HDMI I2C could be included in the datasheet ?

@lurch Perhaps the HDMI I2C could be included in the datasheet?

Let me know when we can continue, I want to move forward with my project.

In phase1 I want to make a quick module fix, so:

  • /dev/ic2-2 points to correct i2c register of HDMI0 port,
  • hdmi_ignore_edid parameter in config.txt disables GPU DDC reading of HDMI0 port.

Could you please share details for RPi4 so I can proceed?

We've had an internal discussion, and exposing I2C2 to user-code is fairly low priority at the moment (so I won't be adding it to the datasheet).

We've had an internal discussion, and exposing I2C2 to user-code is fairly low priority at the moment (so I won't be adding it to the datasheet).

Do I understand this correctly that raspberrypi team doesn't want to release specification of HDMI DDC-CI to I2C_2835 bridge publicly so we can implement "RPI4 HDMI I2C user-space device" ourselves?

Accessing HDMI I2C user from user-space is not going to work without firmware changes and there are other higher priority issues being worked on right now.

Please reread the page you referred to.
It references using dtoverlay=vc4-kms-v3d, which is where Linux has taken full control of i2c2, HDMI hardware, pixel valves, HVS, and various other things. This driver is not ready for Pi4 - you are running vc4-fkms-v3d (f for firmware) where the gpu firmware is still in control of all those hardware blocks. There is no inter-processor arbitration, therefore any attempt to do that will fail as the gpu will be waiting for those interrupts, and is likely to have lower interrupt latency than the ARM.

vc4-kms-v3d will come for the Pi4, but as timg236 has said, it's not at the top of the priority list yet.

any updates?

vc4-kms-v3d for Pi4 is being worked on, and the basics (including i2c) are up and running. I'd hope we'd be looking at alpha release some time in January.

If you need to control HDMI connected LCD on RPI4 via DDC/CI commands (for example ddcutil) and can't wait for RPI4 drivers fix, you can try my "HDMI connector split" workaround which I've used for +3 months with no issues. You will need to solder a little bit...

Split HDMI cable from LCD into two branches:

a) DDC/CI branch which consists of HDMI Pins 15-18:
https://de.wikipedia.org/wiki/Datei:HDMI_Connector_Pins1.png

Important: you need to use 5V-to-3.3V I2C level shifter because HDMI uses 5V but RPI 3.3V levels:

[ HDMI monitor port ] _______/----- [ DDC/CI branch ] ----- [ 5to3VlevelShifter ] ----- [ RPI4-I2C-busX ]

b) HDMI branch - rest of the HDMI pins. I've soldered them back to new HDMI A male connector according to HDMI connector pinouts.

Then you can drive LCD HDMI monitor from you RPI4 via ddcutil with --bus argument. is the I2C RPI4 bus where you've connected DDC/CI branch from split HDMI cable.

any news?

The early version was merged to our rpi-5.4.y kernel branch via #3515 back in March. That was v1 of the patches sent to the relevant kernel mailing lists.
v4 was sent on Wednesday, and I'm about to backport those patches to our branch.

If you have the 5.4 branch (available via rpi-update), then adding dtoverlay=vc4-kms-v3d will load the driver, and you should get /dev/i2c11 and /dev/i2c12 as the two I2C interfaces on the HDMI ports.

Please note that It is still in beta and being reviewed by mainline. There are known issues with the v1 patchset that can cause issues with the display not coming up and similar, so please be warned.

Minor observation. i2cdetect uses different mechanisms to "detect" I2C devices based on the address (0x30-0x37 and 0x50-0x5F use READ, otherws use QUICK).

It looks like only READ mode works at present on this controller, so use i2cdetect -r -y 11 to avoid getting incorrect detections.

@Everyone. Any tried to replicate the Bangom hardware solution? any picture step by step?

Hello, i installed the 5.4 kernel and now i have the dtoverlay=vc4-kms-v3d options. Nevertheless i don't get any /dev/i2c11 and /dev/i2c12.

i also tried youri2cdetect -r -y 11 but i can't actually find the modules in my sistem even if i have 5.4 kernel and the option above activated in config.txt.

Please can you support me to have those i2c interfaces working?

What's the current status of the implementation?

Vc4-kms-v3d is working on pi4. Almost all changes are merged into the mainline kernel, and those that aren't have been merged to our rpi-5.10.y branch. BRANCH=next rpi-update will get you a build of that 5.10 branch.

The observation at https://github.com/raspberrypi/linux/issues/3152#issuecomment-656665996 still applies.

I'm able to switch my monitor input source using ddcutil without an issue now. Thanks for your work @6by9!

dawidtomczyk, can I just confirm that ddcutil is working for you on a pi 4 without any extra workarounds?

EDIT: Got it working! Thank you all! Really useful thread!

Was this page helpful?
0 / 5 - 0 ratings