From 64a207940fa194f5d1b2230df8134519e0d5e6f7 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 9 Aug 2020 10:06:21 +0100 Subject: [PATCH] Use logic from raspi-config to determine if bcm2835 routing option exists or not - 3 merged commits Number 1: mask amixer failures - some user have different numbered / multiple audio devices Number 2: remove "-c 1" and also protect with test for older kernel / alsa The "-c 1" was simply wrong. The default (-c 0) sound device of older kernel / alsa has a numid=3 selector for auto vs headphone vs hdmi . Newer kernel simply has multiple devices. Also, headphone is -c 0 . $ amixer contents numid=2,iface=MIXER,name='Headphone Playback Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=1,iface=MIXER,name='Headphone Playback Volume' ; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0 : values=-2000 | dBscale-min=-102.39dB,step=0.01dB,mute=1 TODO: For now, broadly dividing by kernel v4.x vs v5.x is good enough, but it would be nice to find out when / which kernel /alsa this is relevant. closes https://github.com/respeaker/seeed-voicecard/issues/240 Number 3: Use logic from raspi-config to determine if bcm2835 routing option exists or not The snd_bcm2835.enable_compat_alsa option: enable_compat_alsa:Enables ALSA compatibility virtual audio device (bool) is off these days, since the beginning of 2020 apparently. Reference: raspi-config (20200120) buster; urgency=medium * Add audio switching for discrete internal ALSA devices -- Simon Long Mon, 20 Jan 2020 11:38:37 +0000 --- seeed-voicecard | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seeed-voicecard b/seeed-voicecard index 1ae7e27..79a3551 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -150,5 +150,6 @@ fi alsactl restore #Force 3.5mm ('headphone') jack -amixer -c 1 cset numid=3 1 - +if aplay -l | grep -q "bcm2835 ALSA"; then + amixer cset numid=3 1 || true +fi