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
See upstream -
https://github.com/raspberrypi/documentation/issues/1671https://github.com/raspberrypi/documentation/pull/1673
Quoted here:
* Only Device Tree nodes at the top level of the tree and children of
a bus node will be probed. For nodes added at run-time there is the
further limitation that the bus must register for notifications of
the addition and removal of children. However, there are exceptions
that break this rule and cause confusion: the kernel explicitly
scans the entire tree for some device types - clocks and interrupt
controller being the two main ones - in order to (for clocks)
initialise them early and/or (for interrupt controllers) in a
particular order. This search mechanism only happens during booting
and so doesn't work for nodes added by an overlay at run-time. It is
therefore recommended for overlays to place fixed-clock nodes in the
root of the tree unless it is guaranteed that the overlay will not
be used at run-time.
commit 294f69e662d1570703e9b56e95be37a9fd3afba5
Author: Joe Perches <joe@perches.com>
Date: Sat Oct 5 09:46:42 2019 -0700
compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use
See include/linux/compiler_attributes.h:
/*
* Add the pseudo keyword 'fallthrough' so case statement blocks
* must end with any of these keywords:
* break;
* fallthrough;
* goto <label>;
* return [expression];
*
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
*/
-if __has_attribute(__fallthrough__)
- define fallthrough __attribute__((__fallthrough__))
-else
- define fallthrough do {} while (0) /* fallthrough */
-endif
The whole warning is quite long but looks like this:
CC [M] seeed-voicecard/ac108.o
In file included from ./include/linux/printk.h:331,
from ./include/linux/kernel.h:15,
from ./include/linux/list.h:9,
from ./include/linux/module.h:12,
from seeed-voicecard/ac108.c:15:
seeed-voicecard/ac108.c: In function ‘ac108_set_fmt’:
./include/linux/dynamic_debug.h:122:52: warning: this statement may fall through [-Wimplicit-fallthrough=]
122 | #define __dynamic_func_call(id, fmt, func, ...) do { \
| ^
./include/linux/dynamic_debug.h:143:2: note: in expansion of macro ‘__dynamic_func_call’
143 | __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:157:2: note: in expansion of macro ‘_dynamic_func_call’
157 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
./include/linux/device.h:1795:2: note: in expansion of macro ‘dynamic_dev_dbg’
1795 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
seeed-voicecard/ac108.c:866:4: note: in expansion of macro ‘dev_dbg’
866 | dev_dbg(dai->dev, "used as slave when AC101 is master\n");
| ^~~~~~~
seeed-voicecard/ac108.c:868:2: note: here
868 | case SND_SOC_DAIFMT_CBS_CFS: /*AC108 Slave*/
| ^~~~
The semi-colon is needed, to prevent the comment being parsed as part of the "if {...}" statement.
The warning looks like this:
seeed-voicecard/wm8960.c: In function ‘wm8960_hw_params’:
seeed-voicecard/wm8960.c:752:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
752 | if ((iface & 0x3) != 0) {
| ^
seeed-voicecard/wm8960.c:757:2: note: here
757 | default:
| ^~~~~~~