2019-09-11 16:06:10 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Copyright (c) 2018 Baozhu Zuo <zuobaozhu@gmail.com>
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
# THE SOFTWARE.
|
|
|
|
|
|
|
|
set -x
|
|
|
|
exec 1>/var/log/$(basename $0).log 2>&1
|
2019-09-16 12:42:24 +02:00
|
|
|
|
2020-08-27 13:13:42 +02:00
|
|
|
OVERLAYS=/boot/overlays
|
2019-09-11 16:06:10 +02:00
|
|
|
#enable i2c interface
|
2020-08-27 13:13:42 +02:00
|
|
|
dtparam -d $OVERLAYS i2c_arm=on
|
2019-09-11 16:06:10 +02:00
|
|
|
modprobe i2c-dev
|
|
|
|
|
|
|
|
#enable spi interface
|
2020-08-27 13:13:42 +02:00
|
|
|
dtparam -d $OVERLAYS spi=on
|
2019-09-11 16:06:10 +02:00
|
|
|
|
|
|
|
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}')
|
|
|
|
|
2021-02-05 16:10:50 +01:00
|
|
|
# Set default configurations
|
2019-09-11 16:06:10 +02:00
|
|
|
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
|
|
|
|
overlay=""
|
2021-02-05 16:10:50 +01:00
|
|
|
asound_state=/var/lib/alsa/default-asound.state
|
|
|
|
pulse_default=/etc/pulse/pulseaudio-system.pa
|
|
|
|
pulse_daemon=/etc/pulse/pulseaudio-daemon.conf
|
|
|
|
|
|
|
|
# Remove old configurations
|
|
|
|
rm /var/lib/alsa/asound.state
|
2021-02-08 11:19:49 +01:00
|
|
|
rm /etc/voicecard/asound.state
|
2021-02-05 16:10:50 +01:00
|
|
|
rm /etc/pulse/system.pa
|
|
|
|
rm /etc/pulse/daemon.conf
|
2019-09-11 16:06:10 +02:00
|
|
|
|
|
|
|
if [ "x${is_1a}" != "x" ] && [ "x${is_35}" == "x" ] ; then
|
2021-02-05 16:10:50 +01:00
|
|
|
echo "install wm8960"
|
|
|
|
modprobe snd-soc-wm8960
|
|
|
|
overlay=wm8960-soundcard
|
2019-11-17 14:30:43 +01:00
|
|
|
asound_state=/etc/voicecard/wm8960_asound.state
|
2019-09-11 16:06:10 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" == "x" ] ; then
|
|
|
|
echo "install 4mic"
|
2021-02-05 16:10:50 +01:00
|
|
|
modprobe snd-soc-seeed-voicecard
|
|
|
|
modprobe snd-soc-ac108
|
2019-09-11 16:06:10 +02:00
|
|
|
overlay=seeed-4mic-voicecard
|
2019-11-17 14:30:43 +01:00
|
|
|
asound_state=/etc/voicecard/ac108_asound.state
|
2019-09-11 16:06:10 +02:00
|
|
|
pulse_default=/etc/pulse/seeed-voicecard-4mic-default.pa
|
|
|
|
pulse_daemon=/etc/pulse/seeed-voicecard-4mic-daemon.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" != "x" ] ; then
|
|
|
|
echo "install 6mic"
|
2021-02-05 16:10:50 +01:00
|
|
|
modprobe snd-soc-seeed-voicecard
|
|
|
|
modprobe snd-soc-ac108
|
2019-09-11 16:06:10 +02:00
|
|
|
overlay=seeed-8mic-voicecard
|
2019-11-17 14:30:43 +01:00
|
|
|
asound_state=/etc/voicecard/ac108_6mic.state
|
2019-09-11 16:06:10 +02:00
|
|
|
pulse_default=/etc/pulse/seeed-voicecard-8mic-default.pa
|
|
|
|
pulse_daemon=/etc/pulse/seeed-voicecard-8mic-daemon.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$overlay" ]; then
|
2021-02-05 16:10:50 +01:00
|
|
|
echo Loading $overlay ...
|
2019-09-11 16:06:10 +02:00
|
|
|
|
2021-02-05 16:10:50 +01:00
|
|
|
# Make sure the driver loads correctly
|
2020-08-27 13:13:42 +02:00
|
|
|
dtoverlay -d $OVERLAYS $overlay || true
|
2021-02-25 11:36:19 +01:00
|
|
|
fi
|
2019-09-11 16:06:10 +02:00
|
|
|
|
2021-02-25 11:36:19 +01:00
|
|
|
# Install soundstate
|
|
|
|
echo "create $overlay asound status file"
|
|
|
|
ln -s $asound_state /etc/voicecard/asound.state
|
2019-11-17 14:30:43 +01:00
|
|
|
|
2021-02-25 11:36:19 +01:00
|
|
|
# Install pulseaudio files
|
|
|
|
echo "create $overlay pulse system file"
|
|
|
|
ln -s $pulse_default /etc/pulse/system.pa
|
|
|
|
echo "create $overlay pulse daemon file"
|
|
|
|
ln -s $pulse_daemon /etc/pulse/daemon.conf
|
2019-09-11 16:06:10 +02:00
|
|
|
|
2021-02-08 11:19:49 +01:00
|
|
|
alsactl -E HOME=/run/alsa -f /etc/voicecard/asound.state restore
|