Fix: removing asound.conf when detecting i2c addresses

This commit is contained in:
turmary 2019-05-22 10:39:09 +08:00
parent 0ea5d2bd98
commit da5f90473b
2 changed files with 27 additions and 33 deletions

View file

@ -80,56 +80,40 @@ do_overlay() {
}
is_1a=$(i2cdetect -y 1 0x1a 0x1a | grep 1a | awk '{print $2}')
is_35=$(i2cdetect -y 1 0x35 0x35 | grep 35 | awk '{print $2}')
is_3b=$(i2cdetect -y 1 0x3b 0x3b | grep 3b | awk '{print $2}')
rm /etc/asound.conf
rm /var/lib/alsa/asound.state
is_1a=$(i2cdetect -y 1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}')
is_35=$(i2cdetect -y 1 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}')
is_3b=$(i2cdetect -y 1 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}')
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
overlay=""
if [ "x${is_1a}" == "x1a" ] && [ "x${is_35}" == "x" ] ; then
if [ "x${is_1a}" != "x" ] && [ "x${is_35}" == "x" ] ; then
echo "install 2mic"
overlay=seeed-2mic-voicecard
rm /etc/asound.conf
rm /var/lib/alsa/asound.state
echo "create 2mic asound configure file"
ln -s /etc/voicecard/asound_2mic.conf /etc/asound.conf
echo "create 2mic asound status file"
ln -s /etc/voicecard/wm8960_asound.state /var/lib/alsa/asound.state
asound_conf=/etc/voicecard/asound_2mic.conf
asound_state=/etc/voicecard/wm8960_asound.state
fi
if [ "x${is_3b}" == "x3b" ] && [ "x${is_35}" == "x" ] ; then
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" == "x" ] ; then
echo "install 4mic"
overlay=seeed-4mic-voicecard
rm /etc/asound.conf
rm /var/lib/alsa/asound.state
echo "create 4mic asound configure file"
ln -s /etc/voicecard/asound_4mic.conf /etc/asound.conf
echo "create 4mic asound status file"
ln -s /etc/voicecard/ac108_asound.state /var/lib/alsa/asound.state
asound_conf=/etc/voicecard/asound_4mic.conf
asound_state=/etc/voicecard/ac108_asound.state
fi
if [ "x${is_3b}" == "x3b" ] && [ "x${is_35}" == "x35" ] ; then
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" != "x" ] ; then
echo "install 6mic"
overlay=seeed-8mic-voicecard
rm /etc/asound.conf
rm /var/lib/alsa/asound.state
echo "create 6mic asound configure file"
ln -s /etc/voicecard/asound_6mic.conf /etc/asound.conf
echo "create 6mic asound status file"
ln -s /etc/voicecard/ac108_6mic.state /var/lib/alsa/asound.state
asound_conf=/etc/voicecard/asound_6mic.conf
asound_state=/etc/voicecard/ac108_6mic.state
fi
if [ "$overlay" ]; then
echo Install $overlay ...
dtoverlay $overlay
# Remove old configuration
rm /etc/asound.conf
rm /var/lib/alsa/asound.state
kernel_ver=$(get_kernel_version)
# echo kernel_ver=$kernel_ver
@ -145,7 +129,14 @@ if [ "$overlay" ]; then
do_overlay $i 1
fi
done
else
dtoverlay $overlay
fi
echo "create $overlay asound configure file"
ln -s $asound_conf /etc/asound.conf
echo "create $overlay asound status file"
ln -s $asound_state /var/lib/alsa/asound.state
fi
alsactl restore

View file

@ -49,8 +49,12 @@ do_overlay() {
fi
}
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
echo "remove dtbos"
for i in $RPI_HATS; do
dtoverlay -r $i
done
rm /boot/overlays/seeed-2mic-voicecard.dtbo || true
rm /boot/overlays/seeed-4mic-voicecard.dtbo || true
rm /boot/overlays/seeed-8mic-voicecard.dtbo || true
@ -74,7 +78,6 @@ rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-ac108.ko || true
rm /lib/modules/${uname_r}/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true
echo "remove $CONFIG configuration"
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
for i in $RPI_HATS; do
echo Uninstall $i ...
do_overlay $i 1