Adding SPDIF out for Zynthian V5

I´m completely new to Zynthian and assembled the kit yesterday with success. Interestingly, the bottom case has a 9.5mm hole on the front side near the left edge, which is currently not used. I think about a SPDIF output extension with WM8804 in hardware mode.Could someone please tell me the digital audio frame format that is used for the output DAC, I would like to capture it for the SPDIF transmitter. Thank you!

The RPI digital audio output is I2S. You would need a chip that converts i2S to spdif. I’ve found this in AliExpress:

It uses a wm8805.

I never tried to feed a i2S stream to 2 output devices, but it should be possible in theory.


1 Like

Welcome @travelrec. I hope you enjoy a long stay in Zynthianland. It is where dreams come true!

I am intrigued by this mystery hole. Can you provide a photo?

I think he means the slot for the ribbon cable, right?
Welcome to zynthianland, @travelrec !!

I mean this hole. I think it shouldn´t be there, but it is and I want to make it somewhat useful.
Will check out the signal. I think, the tricky point is the absence of master clock which most of the SPDIF transmitters need. Will try…

Ha! You seem to have a special case! I thought I was the only one with that case :smile:.

You can get I2S to SPDIFF converters as described by @jofemodo. These use the serial clock and the word select to detect timing and the serial data for the actual sample data.

Hello riban, the converters @jofemodo mentioned are not visible in my country. Do you have a part number / name of the boards?

If I understand it right, WM8804 and WM8805 need at least one SPDIF input signal for reference, to create an appropriate timing for the output SPDIF via internal PLL. But there is no SPDIF for reference in the zynthian. What I need is that the SPDIF transmitter synchronizes itself internally from the L/R clock. Think WM880x will don´t do this.

OK, I think I need a SRC between the zynthian L/R_CLK, B_CLK, S_DATA and the SPDIF transmitter. Found a module with CS8421 @ AliExpress. Will reply as soon as the beast is working :slight_smile: Thanks!

No! You don’t need a SRC. Zynthian can be configured to run at various samplerates. If you configure the Zynthian soundcard to the desired samplerate, e.g. 44100 fps then add a I2C to SPDIF converter to the same I2S pins that the Zynthian uses, you will get a SPDIF signal at that samplerate. SPDIF is a fairly simple protocol (very similar to AES3) and the converter will use the I2S clock to define it’s samplerate (unless the SPDIF converter has its own SRC).

You would only need to clock such a device with an external clock reference if you were feeding it into a system that was hard locked to another clock. Most amplifiers should lock to their incoming SPDIF or perform SRC.

Hello riban, I´m not sure about this. The CS8406 needs a master clock and the WM8804 needs a crystal AND a master clock, which is in the range of 11.2896 Mhz for 44.1kHz up to 24.576 Mhz for 96kHz. The master clock is 256x fs and must be synchronous to L/R clock, at least for the CS8406. On the HifiBerry Digi+, master clock is connected to the WM8804, which comes from RasPi GPIO16. I don´t know if master clock can be enabled on zynthian too or already is enabled. This would indeed eliminate the need for a SRC.

Just prepared PCB for CS8406-CSZ and Sharp GP1FA352TZ Toslink transmitter.


@riban: Do you know something about enabling I2S master clock on one of the RPi GPIOs? Thank you!

Zynthian is based on the RPi hardware and Debian OS. An ALSA soundcard driver is loaded to enable I2S. When this happens, any audio sent to the ALSA driver will trigger the I2S data pin to modulate whilst the I2S clock pulses away at its appropriate frame rate. This is why I had previously suggested you don’t need SPDIF clock or SRC. The official hardware, e.g. V5 is automatically detected by the firmware and I2S is enabled. The I2S clock will start pulsing.

1 Like

Hello and thank you for the info. But I2S clock (aka Bit clock or PCM CLK) is not the master clock. I2S pins (as seen from the plain serial interface) “PCM DOUT”, “PCM CLK” and “PCM FS” are mandatory for I2S DACs, PCM DIN is used for ADCs. SPDIF transmitters additionally need the master clock for their modulators, apart from the general I2S signals. That´s why I ask. Hifiberry Digi+ uses GPIO16, as I wrote above, so Hifiberry driver or overlay or whatever activates this pin to toggle with 11…13MHz. But maybe the ALSA soundcard driver already activates GPIO16…? I don´t know yet.

I am not finding that in the CS8406 datasheet. Can you show me where you see the need for this 11…13MHz clock? If it is required and Hifiberry overlay enables it then can you just use that overlay?

Also you have chosen an obsolete chip which may prove challenging to source parts.

[Edit] Ah! OMCK. Sorry! Yes this is set by hardware config to be a multiple of the frame rate. This is low-level driver stuff. You will need to use an existing overlay / driver or write your own.

Yes, OMCK on CS8406. WM8804 still needs it. All SPDIF standalone transmitters I know are obsolete now, since modern CPUs / SOCs intergrate SPDIF in the core.
Don´t know now if the HiFiberry Digi+ overlay will work with the rest of Zynthian stuff. I´m not Debian expert and I don´t know how to write / integrate self written drivers. Seems I need to try for myself. Thank you anyway.

1 Like


PCBs arrived, just soldered the parts.

Waiting for the SRC module to arrive. Since the Pi is not able to deliver the master clock of 12.288MHz, the SRC is needed to generate the master clock from the plain I2S signal.

Hello again. The S/PDIF output works now. I realized, that the needed master clock is available on the output DAC, even it is not available on the RasPi4. So, I found all the needed signals on the PCM5242 and I routed them to the SPDIF transceiver via enamelled copper wire.

Because of the master clock is generated with 512x fs, I needed to hardwire a mode pin on the SPDIF transceiver to accept this rate. If I would have known this from the beginning, I could have prepared the breakout board somewhat better. Output sample rate on Zynthian I have set to 48kHz.

Anyway, it´s possible now to record the sound of the Zynthian digitally with DAT or PC soundcard while having analog sound on the mixer console or headphones. And the hole on the front of the case makes sense now. That´s what I want. :slight_smile: