#978025 linux-image-5.10.x: alsa audio output problems on RPi since 5.10 kernel

#978025#5
Date:
2020-12-24 17:02:50 UTC
From:
To:
On my RPi3B+ (named rpi-mpd) I have the following sound cards:
$ cat /proc/asound/cards
 0 [ALSA           ]: bcm2835_alsa - bcm2835 ALSA
                      bcm2835 ALSA
 1 [vc4hdmi        ]: vc4-hdmi - vc4-hdmi
                      vc4-hdmi

My RPi is connected to my AV receiver via a (good quality) HDMI cable.
I have only alsa installed on this machine, no pulse audio.

When I play a (.flac) file with mpd with the "ALSA" card, the playback
quality is consistently worse than with the 5.9 kernel.
Some 'only' have some noise (~static sound) along the music, others are
quite horrible.
What is odd, is that it's the same tracks that are 'not good' and 'horrible'.
I have one album both in .flac and in .mp3 format and they exibit the same
behaviour on the same tracks.
This happens across albums and music styles (pop and classical).
These issue are a regression compared to 5.9.


There are also other audio issues, but those happen also with the 5.9
kernel.
When I have "vc4hdmi" selected as soundcard, I get the following in my
mpd.log file and then it doesn't play at all.
It could (very well) be that my mpd config is incorrect for that audio
card.

Dec 24 16:06 : exception: Failed to open "vc4hdmi" (alsa); Failed to
open ALSA device "default": Invalid argument
Dec 24 16:06 : exception: Failed to open "vc4hdmi" (alsa); Failed to
open ALSA device "default": Invalid argument
Dec 24 16:06 : player: problems opening audio device while playing
"CDs/BLØF/Omarm/01.De_Mooiste_Verliezers.flac"
ALSA lib pcm_direct.c:1206:(snd1_pcm_direct_initialize_slave) requested
or auto-format is not available
ALSA lib pcm_dmix.c:1087:(snd_pcm_dmix_open) unable to initialize slave


When I invoke 'aplay' directly on the command line, I get sth similar:

diederik@rpi-mpd:~$ aplay -c 2 -r 48000 /dev/urandom
ALSA lib pcm_direct.c:1206:(snd1_pcm_direct_initialize_slave) requested
or auto-format is not available
ALSA lib pcm_dmix.c:1087:(snd_pcm_dmix_open) unable to initialize slave
aplay: main:830: audio open error: Invalid argument


I don't believe that multichannel audio is supported, although looking
through RPi forums/bug trackers I get the feeling that the hardware
*could* support it. I just never got it to work properly.
At one time I thought to have it working with pulseaudio, but on closer
inspection it seems that the stereo sound is just replicated to more
outputs.

Cheers,
  Diederik

#978025#10
Date:
2021-01-23 19:16:45 UTC
From:
To:
Just played various tracks with this (new) kernel and they all play fine :)
Don't know what the status (or purpose) is of "vc4hdmi", but this bug was
about that sound was distorted via the ALSA soundcard.

Thanks!

#978025#15
Date:
2021-02-05 11:36:58 UTC
From:
To:
Control: found -1 5.10.12-1
Control: retitle -1 "linux-image-5.10.x: alsa audio output problems on RPi since 5.10 kernel"

Upgraded my rpi-mpd device to 5.10.12-1 and the problem is back :(
It also contained various/lots of other upgraded components, but when I
reboot into 5.10.9-1, the audio still plays fine.

#978025#24
Date:
2021-02-05 12:16:04 UTC
From:
To:
Control: retitle -1 linux-image-5.10.x: alsa audio output problems on RPi since 5.10 kernel
#978025#31
Date:
2021-02-08 11:18:59 UTC
From:
To:

#978025#38
Date:
2021-02-08 11:53:11 UTC
From:
To:
Control: forwarded -1 https://lists.infradead.org/pipermail/linux-rpi-kernel/2021-February/008002.html
#978025#45
Date:
2021-03-28 00:48:59 UTC
From:
To:
Hi all,

From: Stefan Wahren <stefan.wahren@i2se.com>
Subject: Re: Sound issues with the 5.10.x kernel (alsa)
Date: Mon, 8 Feb 2021 13:22:56 +0100

I think the root cause of this issue is that both vc4.ko and snd_bcm2835.ko
try to provide ALSA sinks to HDMI audio outputs from RPi.
Why do the two drivers provide the same functionality for the same device?
It seems nonsense.
There must be some coordination between vc4.ko and snd_bcm2835.ko
on who provides ALSA sinks of RPi HDMI output.

The non-coordination that both drivers provide different ALSA sinks of the same
device already causes another symptom as
http://lists.infradead.org/pipermail/linux-rpi-kernel/2021-March/008077.html

Best regards, Ryutaroh Matsumoto

#978025#50
Date:
2021-03-28 05:58:13 UTC
From:
To:
Giving "enable_hdmi=0" to snd_bcm2835.ko does not improve the situation,
while module_blacklisting snd_bcm2835 suppresses all the symptoms reported.
snd_bcm2835.ko in 5.10.24 seems having a bug ignoring "enable_hdmi=0".

Best regards, Ryutaroh

#978025#55
Date:
2021-03-28 09:29:12 UTC
From:
To:
Hi,

Am 28.03.21 um 07:58 schrieb Ryutaroh Matsumoto:
i assume you set this option in the config.txt? This shouldn't have any
affect for the mainline kernel / DT.

#978025#60
Date:
2021-03-28 23:13:25 UTC
From:
To:
Hi Stefan, thank you for your response.

I am aware of that...
I did "snd_bcm2835 enable_hdmi=0" in /etc/modules.
"modinfo snd_bcm2835" shows as below. Doesn't it indicate snd_bcm2835 having
an option enable_hdmi???

It seems that the contention of grabbing HDMI audio output between vc4.ko
and snd_bcm2835.ko can be addressed if snd_bcm2835.ko honors the
option enable_hdmi with its default =0, but currently enable_hdmi seems
having no effect in behavior of snd_bcm2835...

# modinfo snd_bcm2835
filename:       /lib/modules/5.10.0-5-rt-arm64/kernel/drivers/staging/vc04_services/bcm2835-audio/snd-bcm2835.ko
alias:          platform:bcm2835_audio
license:        GPL
description:    Alsa driver for BCM2835 chip
author:         Dom Cobley
depends:        snd-pcm,vchiq,snd
staging:        Y
intree:         Y
name:           snd_bcm2835
vermagic:       5.10.0-5-rt-arm64 SMP preempt_rt mod_unload modversions aarch64
sig_id:         PKCS#7
signer:         Debian Secure Boot CA
sig_key:        4B:6E:F5:AB:CA:66:98:25:17:8E:05:2C:84:66:7C:CB:C0:53:1F:8C
sig_hashalgo:   sha256
signature:      omitted, too long.
parm:           force_bulk:Force use of vchiq bulk for audio (bool)
parm:           enable_hdmi:Enables HDMI virtual audio device (bool)
parm:           enable_headphones:Enables Headphones virtual audio device (bool)
parm:           enable_compat_alsa:Enables ALSA compatibility virtual audio device (bool)
parm:           num_channels:Number of audio channels (default: 8) (int)

Best regards, Ryutaroh

#978025#65
Date:
2021-03-28 23:17:36 UTC
From:
To:
I include my config.txt on RPi4B for reference...
arm_64bit=1
enable_uart=1
upstream_kernel=1
kernel=vmlinuz-5.10.0-5-rt-arm64
initramfs initrd.img-5.10.0-5-rt-arm64
disable_fw_kms_setup=1
disable_overscan=1
hdmi_enable_4kp60=1

Best regards, Ryutaroh Matsumoto

#978025#70
Date:
2021-05-13 13:19:45 UTC
From:
To:
Some progress has been made in the 'upstream' thread and in a related thread
on the upstream ML where I managed to get audio playing properly:
https://lists.infradead.org/pipermail/linux-rpi-kernel/2021-April/008115.html

But my goal has always been to have a networked sound server which also
supports multi-channel audio (for movies f.e.) and I doubt that will come to
fruitition. At least properly. The discussion was also mostly between me and
Ryutaroh Matsumoto (thank!), while 'upstream' or RPF didn't seem interested.

It now looks like that I have realized what I (always) wanted, but with a
Rock64. See bug #987576 and the related MR.
Consequently I no longer have interest in seeing this bug fixed, hence closing.
If someone else wants to pick it up at some point, the upstream ML may have
some pointers in the Feb-April 2021 archives.

Cheers,
  Diederik