DietPi (on RPi 3 and 4) no 24bit audio output via HDMI

Hi folks,

first I want to say hello to all forum members. This forum is really helpful for me until now.
But after installing DietPi to attach my two Onkyo AV reveivers (PR-SC5509 and TX-NR3009) to my roon core which is running on a MacMini 2012 (Win10 on Bootcamp) I did run into the following problem:
AV 1 is connected directly to the MacMini core via HDMI. AV 2 is in another room and connected to a RPi4 with 4GB running DietPi and roon bridge also via HDMI.
I was able to set up the very helpful roon-extension-onkyo service to integrate both AV-receivers in parallel for remote control via roon.
But using roon with AV 2 shows, that the RPi4 with DietPi and roon bridge downsample all 24bit audio to 16bit audio, which means a huge loss of quality.
Did I make my settings in DietPi or the RPi4 wrong or does the RPi4 (I did try it also with an RPi3b) simply not support 24bit audio via HDMI?

HDMI from the MacMini to AV 1 works up to 192kHz/24bit with no problems.

I do hope there is a solution and somebody out there will be able to help!
Thanks in advance.
Jan

Hey guys,
so many view but no one coming up with an idea? Please, I still do need some help! :cry:
greetings, Jan

24bits via Alsa driver on the Raspberry Pi 2,3,4 is a very dark chapter in the history of the raspberry pi.

There are no technical restrictions but since over 6 years nobody cared to enable this in the stable version of the Raspbian linux kernel and as it looks like neither with the DietPi based Linux kernel.

However it is possible to recompile the kernel with activated 24bit and support for sample rates up to 192khz. I just tried this with a RPI 2 and a RPI 4 last week and was successful for Stereo 2 channel signals. With multichannel 5.1 setup and Flac 24/96 6 channel files I got crackling and wrong channel assignments out of the box.
Here a careful fine tuning of buffer sizes seems necessary by the “kernel guys” which are obviously not in a hurry to get active since more than 5 years!

If 2 channel support is sufficient for you I can point you to the steps necessary for the RPI 2 and 3:
see here: https://www.diyaudio.com/forums/pc-based/334443-2-8-dsp-platform-using-raspberry-pi-hats.html#post5710184
I verified last week that these steps worked on a RPI 2 with Raspbian Lite. I assume that this also works with DietPI

To do this with a RPI 4 you have to make some changes:
the section in bcm2835-pcm.c has to look like this

static const struct snd_pcm_hardware snd_bcm2835_playback_spdif_hw = {
        .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
                 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
                 SNDRV_PCM_INFO_DRAIN_TRIGGER | SNDRV_PCM_INFO_SYNC_APPLPTR),
        .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE,
        .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_44100 |
        SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
        .rate_min = 44100,
        .rate_max = 192000,
        .channels_min = 2,
        .channels_max = 8,
        .buffer_bytes_max = 512 * 1024,
        .period_bytes_min = 1 * 1024,
        .period_bytes_max = 512 * 1024,
        .periods_min = 1,
        .periods_max = 128,
};

and the KERNEL variable needs to be set to kernel7l instead of kernel7 in the build_kernel.sh script

ensure that in /boot/config.txt the hdmi audio support is activated with this line

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

and plan for some time. The recompilation of the kernel takes roughly 2h on a PI

neither with the DietPi based Linux kernel.

Just to avoid any misunderstanding. There is no DietPi kernel. DietPi did not and will not create own kernel. For Raspberry Pi devices, DietPi is using Raspbian Lite as base image, including the kernel. Means, it is the exact same kernel as on standard Raspbian Lite.

Thanks for this clarification. Then this solution should work exactly the same as on Raspbian