@@ -80,56 +80,40 @@ do_overlay() {
80
80
}
81
81
82
82
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}' )
89
86
90
87
RPI_HATS=" seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
91
88
overlay=" "
92
89
93
- if [ " x${is_1a} " == " x1a " ] && [ " x${is_35} " == " x" ] ; then
90
+ if [ " x${is_1a} " != " x " ] && [ " x${is_35} " == " x" ] ; then
94
91
echo " install 2mic"
95
92
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
103
95
fi
104
96
105
- if [ " x${is_3b} " == " x3b " ] && [ " x${is_35} " == " x" ] ; then
97
+ if [ " x${is_3b} " != " x " ] && [ " x${is_35} " == " x" ] ; then
106
98
echo " install 4mic"
107
99
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
115
102
fi
116
103
117
- if [ " x${is_3b} " == " x3b " ] && [ " x${is_35} " == " x35 " ] ; then
104
+ if [ " x${is_3b} " != " x " ] && [ " x${is_35} " != " x " ] ; then
118
105
echo " install 6mic"
119
106
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
127
109
fi
128
110
129
111
if [ " $overlay " ]; then
130
-
131
112
echo Install $overlay ...
132
- dtoverlay $overlay
113
+
114
+ # Remove old configuration
115
+ rm /etc/asound.conf
116
+ rm /var/lib/alsa/asound.state
133
117
134
118
kernel_ver=$( get_kernel_version)
135
119
# echo kernel_ver=$kernel_ver
@@ -145,7 +129,14 @@ if [ "$overlay" ]; then
145
129
do_overlay $i 1
146
130
fi
147
131
done
132
+ else
133
+ dtoverlay $overlay
148
134
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
149
140
fi
150
141
151
142
alsactl restore
0 commit comments