Index | Thread | Search

From:
Jonathan Matthew <jonathan@d14n.org>
Subject:
fix dwhdmi builtin i2c adapter
To:
tech@openbsd.org
Cc:
kettenis@openbsd.org
Date:
Sun, 23 Mar 2025 23:07:45 +1000

Download raw body.

Thread
Looking into rkdwhdmi(4) a bit, I found that the builtin i2c adapter in the
dwhdmi code is lacking ic_acquire_bus and ic_release_bus functions, which
are called unconditionally by the drm edid code (see i2c_master_xfer() in
drm_linux.c), so if you have an rkdwhdmi device with no ddc-i2c-bus property,
like most RK356x devices, it crashes during drm mode probing.

Can we assume that if the HDMI DDC bus is connected to the builtin i2c
in the HDMI TX device, we don't need to do anything to acquire or release
the bus?

ok?


Index: dwhdmi.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/dwhdmi.c,v
diff -u -p -r1.5 dwhdmi.c
--- dwhdmi.c	16 Jan 2024 23:37:50 -0000	1.5
+++ dwhdmi.c	23 Mar 2025 12:01:21 -0000
@@ -251,6 +251,17 @@ enum dwhdmi_dai_mixer_ctrl {
 };
 
 int
+dwhdmi_ddc_acquire_bus(void *priv, int flags)
+{
+	return 0;
+}
+
+void
+dwhdmi_ddc_release_bus(void *priv, int flags)
+{
+}
+
+int
 dwhdmi_ddc_exec(void *priv, i2c_op_t op, i2c_addr_t addr,
     const void *cmdbuf, size_t cmdlen, void *buf, size_t len, int flags)
 {
@@ -871,6 +882,8 @@ dwhdmi_attach(struct dwhdmi_softc *sc)
 
 		memset(ic, 0, sizeof(*ic));
 		ic->ic_cookie = sc;
+		ic->ic_acquire_bus = dwhdmi_ddc_acquire_bus;
+		ic->ic_release_bus = dwhdmi_ddc_release_bus;
 		ic->ic_exec = dwhdmi_ddc_exec;
 		sc->sc_ic = ic;
 	}