Getting Hardware/Full KMS vc4-kms-v3ed Driver Sound Working on pi400

Hello All,

I am posting this here instead of “Troubleshooting” because I am not at all certain that this is a bug. This may very likely just be me not fully understanding how the system works.

The end-goal here is to have an Amiberry Amiga emulation running on a pi400, using the Hardware/Full KMS driver vc4-kms-v3ed, not the vc4-fkms-v3ed Firmware driver, for sound.

I did find the previous Forum discussion, started by Lollly2997, on this precise topic and the associated v9.2 GitHub link. That post ended in Mar 2024 with the comment “…it works wonderfully kms directly hdmi set dietpi 9.2.1 and amiberry 5.6.6…”. But, I am still unable to get this operational (now on DietPi 10.3.3 and Amiberry 8.1.5).

For simplicity, I have eliminated Amiberry entirely and am now working with a pure minimal image of DietPi (“DietPi_RPi234-ARMv8-Trixie.img.xz”):

DietPi version:
G_DIETPI_VERSION_CORE=10
G_DIETPI_VERSION_SUB=3
G_DIETPI_VERSION_RC=3
G_GITBRANCH=‘master’
G_GITOWNER=‘MichaIng’
G_LIVE_PATCH_STATUS[0]=‘applied’
G_LIVE_PATCH_STATUS[1]=‘applied’
G_LIVE_PATCH_STATUS[2]=‘applied’

Distro version:
trixie 0

Kernel version:
Linux DietPi 6.12.75+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.75-1+rpt1 (2026-03-11) aarch64 GNU/Linux

Architecture:
arm64

SBC model:
RPi 400 (aarch64)

Power supply used:
5.1V 3A Raspberry Pi Foundation

SD card used:
Micro Center MicroSD

During initial boot Passwords were set, the UART disabled, Audio Enabled (and rpi-bcm-hdmi selected as Sound Card), Language/Regional Options set, NTP Mirror set, and Console font increased (to humor my optometrist).

After reboot, Network Adapters were set. At this point, in a default state with respect to sound, everything is operational:

root@DietPi:~# tail -5 /boot/firmware/config.txt
#over_voltage_min=0
#arm_freq_min=300
#core_freq_min=250
#sdram_freq_min=400
arm_64bit=1

root@DietPi:~# cat /etc/asound.conf
pcm.!default {
type hw
card 0
device 0
}

ctl.!default {
type hw
card 0
}

root@DietPi:~# ls -l /root/.asoundrc
ls: cannot access ‘/root/.asoundrc’: No such file or directory

root@DietPi:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: b1 [bcm2835 HDMI 1], device 1: bcm2835 HDMI 1 [bcm2835 HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0

root@DietPi:~# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
hw:CARD=b1,DEV=0
bcm2835 HDMI 1, bcm2835 HDMI 1
Direct hardware device without any conversions
hw:CARD=b1,DEV=1
bcm2835 HDMI 1, bcm2835 HDMI 1
Direct hardware device without any conversions
plughw:CARD=b1,DEV=0
bcm2835 HDMI 1, bcm2835 HDMI 1
Hardware device with all software conversions
plughw:CARD=b1,DEV=1
bcm2835 HDMI 1, bcm2835 HDMI 1
Hardware device with all software conversions
sysdefault:CARD=b1
bcm2835 HDMI 1, bcm2835 HDMI 1
Default Audio Device
dmix:CARD=b1,DEV=0
bcm2835 HDMI 1, bcm2835 HDMI 1
Direct sample mixing device
dmix:CARD=b1,DEV=1
bcm2835 HDMI 1, bcm2835 HDMI 1
Direct sample mixing device

root@DietPi:~# speaker-test

speaker-test 1.2.14

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 512 to 65536
Period size range from 512 to 65536
Periods = 4
was set period_size = 12000
was set buffer_size = 48000
0 - Front Left
Time per period = 2.010543
0 - Front Left
Time per period = 2.999979
0 - Front Left
^C

If the line dtoverlay=vc4-kms-v3d is then manually added to the end of /boot/firmware/config.txt (which is what the Amiberry installer does) and the system rebooted, the aplay outputs change radically, and sound system Errors out:

root@DietPi:~# tail -5 /boot/firmware/config.txt
#arm_freq_min=300
#core_freq_min=250
#sdram_freq_min=400
arm_64bit=1
dtoverlay=vc4-kms-v3d

root@DietPi:~# cat /etc/asound.conf
pcm.!default {
type hw
card 0
device 0
}

ctl.!default {
type hw
card 0
}

root@DietPi:~# ls -l /root/.asoundrc
ls: cannot access ‘/root/.asoundrc’: No such file or directory

root@DietPi:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0

root@DietPi:~# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
sysdefault
Default Audio Device
hw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Hardware device with all software conversions
sysdefault:CARD=vc4hdmi0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Default Audio Device
hdmi:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
HDMI Audio Output
dmix:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct sample mixing device
hw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Hardware device with all software conversions
sysdefault:CARD=vc4hdmi1
vc4-hdmi-1, MAI PCM i2s-hifi-0
Default Audio Device
hdmi:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
HDMI Audio Output
dmix:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct sample mixing device

root@DietPi:~# speaker-test

speaker-test 1.2.14

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Playback open error: -524,Unknown error 524
root@DietPi:~#

If /etc/asound.conf is removed (mv /etc/asound.conf /root/) and the system rebooted, there is a slight change to the aplay -L output, but the output of aplay -l and the Error resulting from speaker-test remain unchanged:

root@DietPi:~# tail -5 /boot/firmware/config.txt
#arm_freq_min=300
#core_freq_min=250
#sdram_freq_min=400
arm_64bit=1
dtoverlay=vc4-kms-v3d

root@DietPi:~# cat /etc/asound.conf
cat: /etc/asound.conf: No such file or directory

root@DietPi:~# ls -l /root/.asoundrc
ls: cannot access ‘/root/.asoundrc’: No such file or directory

root@DietPi:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0

root@DietPi:~# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default
Default Audio Device
sysdefault
Default Audio Device
hw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Hardware device with all software conversions
default:CARD=vc4hdmi0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Default Audio Device
sysdefault:CARD=vc4hdmi0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Default Audio Device
hdmi:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
HDMI Audio Output
dmix:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct sample mixing device
hw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Hardware device with all software conversions
default:CARD=vc4hdmi1
vc4-hdmi-1, MAI PCM i2s-hifi-0
Default Audio Device
sysdefault:CARD=vc4hdmi1
vc4-hdmi-1, MAI PCM i2s-hifi-0
Default Audio Device
hdmi:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
HDMI Audio Output
dmix:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct sample mixing device

root@DietPi:~# speaker-test

speaker-test 1.2.14

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Playback open error: -524,Unknown error 524
root@DietPi:~#

If asound.conf is put back (mv /root/asound.conf /etc/), the dtoverlay=vc4-kms-v3d line edited to dtoverlay=vc4-fkms-v3d, and the system rebooted the sound system functions and all outputs are precisely as they were “out-of-the-box”. To me, this suggests that the behind-the-scenes default is actually the Firmware/Fake KMS…

Bottom Line: I can get the Amiberry build operational by either commenting out the dtoverlay=vc4-kms-v3d or by changing it to dtoverlay=vc4-fkms-v3d, but the sound quality for the Amiga emulation is not the greatest (staticky). I also know that I can play around with the “Interpolation” Options in the Amiberry “Sound” UI to improve the quality, but I would like to be building on the best foundation (the Hardware KMS driver). Besides, it is my understanding that the Firmware KMS driver is currently considered outdated/deprecated.

What am I missing/doing wrong here, please?

Maybe something @MichaIng can have a look at

Generally, vc4-fkms-v3d shouldn’t be used anymore, and KMS/DRM is strictly needed for Amiberry to work. That again implies that not the Broadcom audio codec is used for HDMI audio, but the KMS/DRM subsystem handles this. This at least means some internal differences, different controls, different defaults etc.

It is possible that the KMS/DRM driver is more picky regarding the output format. Worth to test the auto-conversion plugin (see dietpi-config audio options) with speaker-test.

In Amiberry, one can select an audio device explicitly, or use the system default. The latter only works with a proper /etc/asound.conf, and might as well require the auto-conversion plugin. I am not sure whether Amiberry (the SDL3 ALSA audio plugin) can handle the VC4 HDMI audio device properly. Also I remember, the RPi alsa-utils package ships some ALSA configs to explicitly make this HDMI audio stack work, and I am not sure whether these are pulled in when selecting the bare ALSA device in Amiberry.

Let me just test on RPi 5 …

EDIT: Reviewing the logic, actually /etc/asound.conf should intentionally NOT be used, as it overrides the system default added by alsa-utils for the VC4 HDMI audio driver. If you choose rpi-bcm2835-hdmi in dietpi-config audio options, /etc/asound.conf should not be created. And in Amiberry, you need to use the system default audio device, as this is carefully configured in /usr/share/alsa/cards/vc4-hdmi.conf.

EDIT2: So when selecting rpi-bcm2835-hdmi as sound card in dietpi-config, and attaching a HDIM screen, speaker-test works, without auto-conversion. So the default ALSA device works. I did not test it with Amiberry, as I would need to fiddle again with an Amiga ROM and/or supported game. I really need a good default stack/config to quickly test an actual game with audio and everything, rather than the emulator GUI only :sweat_smile:.

Hello,

First off, thank you for taking the time to look at this.

I can only imagine all of the various test setups you have, so don’t worry about testing with Amiberry in the mix. Please let’s just compare behavior on pure minimal images.

If I follow the steps you listed (Enable/Install ALSA, choose rpi-bcm2835-hdmi in dietpi-config Audio Options, and reboot when prompted), I agree with you that speaker-test works without auto-conversion and that there is good audio output via the HDMI Port. But, this still leaves two questions:

  1. Why, in my environment, does the above process create an unexpected /etc/asound.conf file?
  2. Why does adding the line dtoverlay=vc4-kms-v3d to the end of /boot/firmware/config.txt cause the above operational sound system to then error out (with or without the unexpected /etc/asound.conf file in place)?

If KMS/DRM is not enabled yet, e.g. by installing Amiberry, the Boardcom sound driver snd_bcm2835 is used, and set as default with /etc/asound.conf. Only if KMS/DRM is enabled, the VC4 HDMI driver that belongs to the KMS/DRM stack is used, which requires /etc/asound.conf to be removed.

aplay -l shows you hence different output, depending on whether KMS/DRM is enabled or not:

  • bcm2835 HDMI 1 if snd_bcm2835 is used
  • vc4hdmi0 and in case vc4hdmi1, if KMS/DRM is enabled, hence the VC4 HDMI driver is used

Because enabling KMS/DRM implicitly enables the VC4 HDMI driver, which does not work when set as default via /etc/asound.conf, as this bypasses the /usr/share/alsa/cards/vc4-hdmi.conf config. If you move /etc/asound.conf out of the way, is should work, but since the snd_bcm2835 driver is still loaded, it might interfere. Check whether aplay -l lists any other cards aside of vc4hdmi0 and vc4hdmi1, and check which one speaker-test tries to use. Ah, and since there are two HDMI ports, there are two respective output devices. Probably you are using/it is outputting to the wrong port? I did not test the effect of switching ports, actually, maybe I was just lucky to pick the right one.

dietpi-config does some driver handling automatically, based on whether KMS/DRM is enabled or not, blacklists the snd_bcm2835 module in case, disables or enables the HDMI audio or 3.5 mm analogue device, based on whether rpi-bcm2835-hdmi or rpi-bcm2835-3.5mm or rpi-bcm2835-auto were selected (on models which have a 3.5mm jack at all). That way we try to assure that the selected sound card is always card 0 and the default.

Well, that’s got it. Your detailed explanation in the previous post was exactly what I needed to get this running. As I had suspected at the start, this is not a bug. It is indeed me not properly understanding how the system works. My root issue: Order-of-Operations (or, more truthfully, Operator Error).

Ensuring that the dtoverlay=vc4-kms-v3d line exists at the end of the /boot/firmware/config.txt file before Enabling Audio/Installing ALSA was the lynchpin. The steps I needed to take to get KMS Audio running on my pure minimal image were as follows:

  1. Disable Audio/Purge ALSA via dietpi-config
  2. Edit /boot/firmware/config.txt and set dtoverlay=vc4-kms-v3d
  3. Reboot
  4. Enable Audio/Install ALSA via dietpi-config
  5. Select rpi-bcm-hdmi as Sound Card via dietpi-config
  6. Exit dietpi-config and reboot when prompted

I had been Enabling Audio/Installing ALSA as soon as I gained access to the dietpi-config menu option in the very initial installation menus. One needs to hold off on this until one gains access to the CLI to edit /boot/firmware/config.txt.

Installing Amiberry on top of the above known-working KMS Audio system changes the line in /boot/firmware/config.txt to be dtoverlay=vc4-kms-v3d,noaudio; but editing this back to dtoverlay=vc4-kms-v3d and rebooting brings the KMS Audio system right back. That gets me to my end-goal of a DietPi Amiberry Amiga emulation on a pi400, using the Hardware/Full KMS driver for sound.

Great. The reboot between adding dtoverlay=vc4-kms-v3d and selecting the sound card should not be needed, but does not hurt either.

I recognized that when KMS/DRM is enabled by e.g. the Amiberry installation, while the Broadcom audio driver is disabled (like on RPi 5 in general, or on other models if DRM/KMS + HDMI-only is enabled), it falsely adds noaudio. It did take dtparam=audio=off as sign that onboard audio is disabled in general, while this disables only the Broadcom driver. I adjusted the logic: dietpi-set_hardware: better handle KMS/DRM and VC4 HDMI audio switch · MichaIng/DietPi@f68206f · GitHub
This also switches back and forth between both HDMI audio drivers, when toggling KMS/DRM. So if Broadcom HDMI audio was enabled before, then Amiberry gets installed, which enables KMS/DRM, it switches to VC4 HDMI audio automatically.

Otherwise, until now, the easiest order would have been to install Amiberry first, then select onboard HDMI audio.