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 <simon@raspberrypi.org>  Mon, 20 Jan 2020 11:38:37 +0000
This commit is contained in:
Hin-Tak Leung 2020-08-09 10:06:21 +01:00
parent 35bc08973c
commit 64a207940f

View file

@ -150,5 +150,6 @@ fi
alsactl restore alsactl restore
#Force 3.5mm ('headphone') jack #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