Skip to content

Commit da5f904

Browse files
committed
Fix: removing asound.conf when detecting i2c addresses
1 parent 0ea5d2b commit da5f904

File tree

2 files changed

+27
-33
lines changed

2 files changed

+27
-33
lines changed

seeed-voicecard

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,56 +80,40 @@ do_overlay() {
8080
}
8181

8282

83-
is_1a=$(i2cdetect -y 1 0x1a 0x1a | grep 1a | awk '{print $2}')
84-
is_35=$(i2cdetect -y 1 0x35 0x35 | grep 35 | awk '{print $2}')
85-
is_3b=$(i2cdetect -y 1 0x3b 0x3b | grep 3b | awk '{print $2}')
86-
87-
rm /etc/asound.conf
88-
rm /var/lib/alsa/asound.state
83+
is_1a=$(i2cdetect -y 1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}')
84+
is_35=$(i2cdetect -y 1 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}')
85+
is_3b=$(i2cdetect -y 1 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}')
8986

9087
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
9188
overlay=""
9289

93-
if [ "x${is_1a}" == "x1a" ] && [ "x${is_35}" == "x" ] ; then
90+
if [ "x${is_1a}" != "x" ] && [ "x${is_35}" == "x" ] ; then
9491
echo "install 2mic"
9592
overlay=seeed-2mic-voicecard
96-
rm /etc/asound.conf
97-
rm /var/lib/alsa/asound.state
98-
echo "create 2mic asound configure file"
99-
ln -s /etc/voicecard/asound_2mic.conf /etc/asound.conf
100-
101-
echo "create 2mic asound status file"
102-
ln -s /etc/voicecard/wm8960_asound.state /var/lib/alsa/asound.state
93+
asound_conf=/etc/voicecard/asound_2mic.conf
94+
asound_state=/etc/voicecard/wm8960_asound.state
10395
fi
10496

105-
if [ "x${is_3b}" == "x3b" ] && [ "x${is_35}" == "x" ] ; then
97+
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" == "x" ] ; then
10698
echo "install 4mic"
10799
overlay=seeed-4mic-voicecard
108-
rm /etc/asound.conf
109-
rm /var/lib/alsa/asound.state
110-
echo "create 4mic asound configure file"
111-
ln -s /etc/voicecard/asound_4mic.conf /etc/asound.conf
112-
113-
echo "create 4mic asound status file"
114-
ln -s /etc/voicecard/ac108_asound.state /var/lib/alsa/asound.state
100+
asound_conf=/etc/voicecard/asound_4mic.conf
101+
asound_state=/etc/voicecard/ac108_asound.state
115102
fi
116103

117-
if [ "x${is_3b}" == "x3b" ] && [ "x${is_35}" == "x35" ] ; then
104+
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" != "x" ] ; then
118105
echo "install 6mic"
119106
overlay=seeed-8mic-voicecard
120-
rm /etc/asound.conf
121-
rm /var/lib/alsa/asound.state
122-
echo "create 6mic asound configure file"
123-
ln -s /etc/voicecard/asound_6mic.conf /etc/asound.conf
124-
125-
echo "create 6mic asound status file"
126-
ln -s /etc/voicecard/ac108_6mic.state /var/lib/alsa/asound.state
107+
asound_conf=/etc/voicecard/asound_6mic.conf
108+
asound_state=/etc/voicecard/ac108_6mic.state
127109
fi
128110

129111
if [ "$overlay" ]; then
130-
131112
echo Install $overlay ...
132-
dtoverlay $overlay
113+
114+
# Remove old configuration
115+
rm /etc/asound.conf
116+
rm /var/lib/alsa/asound.state
133117

134118
kernel_ver=$(get_kernel_version)
135119
# echo kernel_ver=$kernel_ver
@@ -145,7 +129,14 @@ if [ "$overlay" ]; then
145129
do_overlay $i 1
146130
fi
147131
done
132+
else
133+
dtoverlay $overlay
148134
fi
135+
136+
echo "create $overlay asound configure file"
137+
ln -s $asound_conf /etc/asound.conf
138+
echo "create $overlay asound status file"
139+
ln -s $asound_state /var/lib/alsa/asound.state
149140
fi
150141

151142
alsactl restore

uninstall.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ do_overlay() {
4949
fi
5050
}
5151

52+
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
5253

5354
echo "remove dtbos"
55+
for i in $RPI_HATS; do
56+
dtoverlay -r $i
57+
done
5458
rm /boot/overlays/seeed-2mic-voicecard.dtbo || true
5559
rm /boot/overlays/seeed-4mic-voicecard.dtbo || true
5660
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
7478
rm /lib/modules/${uname_r}/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true
7579

7680
echo "remove $CONFIG configuration"
77-
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
7881
for i in $RPI_HATS; do
7982
echo Uninstall $i ...
8083
do_overlay $i 1

0 commit comments

Comments
 (0)