Raspberry as generic i2s master at 384kHz

2020-09-17 Update: prebuild patched modules are available for moOde.

In November 2017 the Raspberry Linux kernel is updated to support the 384kHz for the i2s bus. Before that time the stock kernel was limited to 192kHz and the generic i2s master driver rpi-dac still is.

With i2s bus the Pi can be used as master or slave. In case the Pi is used as a generic i2s master, the rpi-dac driver can be used. Only this driver is limited to 192kHz by the using of the pcm1794a codec.

This a little bit confusion confusing a generic driver but it use the pcm1794a codec. Therefor also limited to the pcm1794 sample formats and rates.

The use-case for the 384kHz support, is the use of an i2s reclocker connected to a DDDAC1794 NOS. The DDDAC1794 use a PCM1794, according to standard specs it only support up till 192kHz. Only when oversampling and digital filters are disabled, it seems you can go at least up to 384kHz.
Any application note or specification which support this behavior would be welcome!

If you are using rpi-dac you can check this by running alsacap:

$ alsacap
*** Scanning for playback devices ***
Card 0, ID `sndrpirpidac', name `snd_rpi_rpi_dac'
  Device 0, ID `RPi-DAC HiFi pcm1794a-codec-0', name `RPi-DAC HiFi pcm1794a-codec-0', 1 subdevices (1 available)
    2 channels, sampling rate 8000..192000 Hz
    Sample formats: S16_LE, S24_LE
    Buffer size range from 64 to 131072
    Period size range from 32 to 65536

      Subdevice 0, name `subdevice

If you are willing to build your own kernel/drivers, you can enable 384kHz support by changing one line:

diff --git a/sound/soc/codecs/pcm1794a.c b/sound/soc/codecs/pcm1794a.c
index 36b5b6c26655..271e79feba6b 100644
--- a/sound/soc/codecs/pcm1794a.c
+++ b/sound/soc/codecs/pcm1794a.c
@@ -26,7 +26,7 @@ static struct snd_soc_dai_driver pcm1794a_dai = {
        .playback = {
                .channels_min = 2,
                .channels_max = 2,
-               .rates = SNDRV_PCM_RATE_8000_192000,
+               .rates = SNDRV_PCM_RATE_8000_384000,
                .formats = SNDRV_PCM_FMTBIT_S16_LE |
                           SNDRV_PCM_FMTBIT_S24_LE
        },

After the you patched the driver and use it, alsacap should should the new max sample rate:

$ alsacap
*** Scanning for playback devices ***
Card 0, ID `sndrpirpidac', name `snd_rpi_rpi_dac'
  Device 0, ID `RPi-DAC HiFi pcm1794a-codec-0', name `RPi-DAC HiFi pcm1794a-codec-0', 1 subdevices (1 available)
    2 channels, sampling rate 8000..384000 Hz
    Sample formats: S16_LE, S24_LE
    Buffer size range from 64 to 131072
    Period size range from 32 to 65536

Installing a patched module

In the my git repo you can find prebuild modules for the following raspberry pi kernels:

  • 5.4.51-v7+
  • 5.4.51-v7l+
  • 5.4.61-v7+
  • 5.4.61-v7l+

The prebuilds match the kernels from moOde release 6.7.1 and the upcoming 7.

The repo also includes an install procedure for installing the prebuilds or building your own.

Leave a Reply

Your email address will not be published.