Hi,
S/PDIF on GPIO21 of a Raspberry Pi is not a new idea: raspdif and rpi-i2s-spdif do it, and I learned a lot from both. What I was missing was a clean kernel driver that behaves like any other sound card on a current kernel, without /dev/mem and without a daemon next to Kodi. So I wrote one, and packaged it as a LibreELEC add-on.
https://github.com/ehb/rpi-gpio-spdif -- an ordinary ALSA card `SPDIFout` using the kernel's dmaengine. Hardware is just a TOSLINK transmitter module on GPIO21 (pin 40), 5 V and GND. In Kodi: AC3/DTS passthrough through the standard IEC958 controls, AC3 transcoding, and correct lip sync because the driver reports its delay.
It grew into a small set of independent pieces. How they fit together, with a recipe: https://github.com/ehb/pi-lockstep
- alsa-leadtap (https://github.com/ehb/alsa-leadtap): an ALSA plugin, also a Kodi add-on, that works in front of any sound card including HDMI. It hands out a copy of the audio a fixed time before it is heard, so Snapcast rooms stay in sync with the local output and the picture without hand-tuned latencies.
- wled-audiosync (https://github.com/ehb/wled-audiosync): sound-reactive WLED from that copy, no microphone, timed to what you hear.
- tvlight (https://github.com/ehb/tvlight): Kodi add-on for ambient light on WLED strips from the screen edges, without an HDMI grabber (Pi 4).
Everything is installable through "Install from zip file" from the Releases pages of the repositories; the driver zip for LibreELEC 12.2.1 is for the RPi4 image. After installing alsa-leadtap, restart Kodi once.
The question is about the driver: a self-built add-on breaks with every kernel update. For now GitHub Actions watches for new LibreELEC releases and builds a matching zip against that release's kernel. The driver also compiles against the kernel of current master (6.18), but has not been run there.
1. Would you consider it for `packages/linux-driver-addons` (or as a module in the RPi image)? I would maintain it for now, as long as I run it on a Pi myself. CONTRIBUTING says third-party drivers should come from whoever maintains them, so that may be a reason against it.
2. If not: is a zip per release from my own GitHub the right way for an out-of-tree module, or is there a preferred one?
Known limits: tested only on one Pi 4B with one receiver; not for the Pi 5 (different I2S block); only GPIO21.
Disclosure: the code was written with Claude Code (AI assistant) and reviewed by other models; I tested it on my hardware but have not reviewed every line myself.