use seeed-voicecard service to manager all the card

Changes to be committed:
	modified:   install.sh
	modified:   uninstall.sh
This commit is contained in:
Baozhu Zuo 2018-02-01 15:58:36 +08:00
parent 7170b7fcb2
commit 8b84b891cd
2 changed files with 39 additions and 113 deletions

View File

@ -11,13 +11,8 @@ if [ "x${is_Raspberry}" != "xRaspberry" ] ; then
exit 1 exit 1
fi fi
ver="0.2" ver="0.3"
card=$1
if [ "x${card}" = "x" ] ; then
echo "Usage: ./install 2mic|4mic"
exit 1
fi
# we create a dir with this version to ensure that 'dkms remove' won't delete # we create a dir with this version to ensure that 'dkms remove' won't delete
# the sources during kernel updates # the sources during kernel updates
@ -51,21 +46,25 @@ function install_module {
mkdir -p /var/lib/dkms/$mod/$ver/$marker mkdir -p /var/lib/dkms/$mod/$ver/$marker
} }
if [ ! -f "/boot/overlays/seeed-4mic-voicecard.dtbo" ] && [ ! -f "/lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-ac108.ko" ] ; then
install_module "./" "seeed-voicecard"
cp seeed-2mic-voicecard.dtbo /boot/overlays
cp seeed-4mic-voicecard.dtbo /boot/overlays
install -D ac108_plugin/libasound_module_pcm_ac108.so /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so
else
echo "card driver already installed"
fi
install_module "./" "seeed-voicecard"
# install dtbos
cp seeed-2mic-voicecard.dtbo /boot/overlays
cp seeed-4mic-voicecard.dtbo /boot/overlays
#install alsa plugins
install -D ac108_plugin/libasound_module_pcm_ac108.so /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so
#set kernel moduels
grep -q "snd-soc-ac108" /etc/modules || \ grep -q "snd-soc-ac108" /etc/modules || \
echo "snd-soc-ac108" >> /etc/modules echo "snd-soc-ac108" >> /etc/modules
grep -q "snd-soc-wm8960" /etc/modules || \ grep -q "snd-soc-wm8960" /etc/modules || \
echo "snd-soc-wm8960" >> /etc/modules echo "snd-soc-wm8960" >> /etc/modules
#set dtoverlays
sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' /boot/config.txt || true
grep -q "dtoverlay=i2s-mmap" /boot/config.txt || \ grep -q "dtoverlay=i2s-mmap" /boot/config.txt || \
echo "dtoverlay=i2s-mmap" >> /boot/config.txt echo "dtoverlay=i2s-mmap" >> /boot/config.txt
@ -73,36 +72,15 @@ grep -q "dtoverlay=i2s-mmap" /boot/config.txt || \
grep -q "dtparam=i2s=on" /boot/config.txt || \ grep -q "dtparam=i2s=on" /boot/config.txt || \
echo "dtparam=i2s=on" >> /boot/config.txt echo "dtparam=i2s=on" >> /boot/config.txt
has_2mic=$(grep seeed-2mic-voicecard /boot/config.txt) #install config files
has_4mic=$(grep seeed-4mic-voicecard /boot/config.txt) mkdir /etc/voicecard || true
case "${card}" in cp *.conf /etc/voicecard
"2mic") cp *.state /etc/voicecard
echo "cp wm8960_asound.state /var/lib/alsa/asound.state"
cp wm8960_asound.state /var/lib/alsa/asound.state
cp asound_2mic.conf /etc/asound.conf cp seeed-voicecard /usr/bin/
if [ "x${has_4mic}" != x ] ; then cp seeed-voicecard.service /lib/systemd/system/
echo "has 4mic before, now remove it" systemctl enable seeed-voicecard.service
sed -i "s/dtoverlay=seeed-4mic-voicecard//g" /boot/config.txt
fi
grep -q "dtoverlay=seeed-2mic-voicecard" /boot/config.txt || \
echo "dtoverlay=seeed-2mic-voicecard" >> /boot/config.txt
;;
"4mic")
echo "cp ac108_asound.state /var/lib/alsa/asound.state"
cp ac108_asound.state /var/lib/alsa/asound.state
cp asound_4mic.conf /etc/asound.conf
if [ "x${has_2mic}" != x ] ; then
echo "has 2mic before, now remove it"
sed -i "s/dtoverlay=seeed-2mic-voicecard//g" /boot/config.txt
fi
grep -q "dtoverlay=seeed-4mic-voicecard" /boot/config.txt || \
echo "dtoverlay=seeed-4mic-voicecard" >> /boot/config.txt
;;
*)
echo "Please use 2mic or 4mic"
;;
esac
echo "------------------------------------------------------" echo "------------------------------------------------------"
echo "Please reboot your raspberry pi to apply all settings" echo "Please reboot your raspberry pi to apply all settings"

View File

@ -12,81 +12,29 @@ if [ "x${is_Raspberry}" != "xRaspberry" ] ; then
fi fi
uname_r=$(uname -r) uname_r=$(uname -r)
card=$1
if [ x${card} = "x" ] ; then
echo "Usage: ./uninstall 2mic|4mic"
exit 1
fi
if [ x${card} = "x2mic" ] ; then
echo "delete dtoverlay=seeed-2mic-voicecard in /boot/config.txt"
sed -i "s/dtoverlay=seeed-2mic-voicecard//g" /boot/config.txt
if [ -f /boot/overlays/seeed-2mic-voicecard.dtbo ] ; then
echo "remove seeed-2mic-voicecard.dtbo in /boot/overlays"
rm /boot/overlays/seeed-2mic-voicecard.dtbo
fi
if [ -f /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-wm8960.ko ] ; then echo "remove dtbos"
echo "remove snd-soc-wm8960.ko" rm /boot/overlays/seeed-2mic-voicecard.dtbo || true
rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-wm8960.ko rm /boot/overlays/seeed-4mic-voicecard.dtbo || true
fi rm /boot/overlays/seeed-6mic-voicecard.dtbo || true
if [ -d /var/lib/dkms/seeed-voicecard ] ; then echo "remove alsa configs"
echo "remove seeed-voicecard dkms" rm -rf /etc/voicecard/ || true
rm -rf /var/lib/dkms/seeed-voicecard
fi
echo "delete snd-soc-wm8960 in /etc/modules" echo "disabled seeed-voicecard.service "
sed -i "s/snd-soc-wm8960//g" /etc/modules systemctl disable seeed-voicecard.service
if [ -f /var/lib/alsa/asound.state ] ; then echo "remove seeed-vocecard"
echo "remove wm8960_asound.state" rm /usr/bin/seeed-voicecard || true
rm /var/lib/alsa/asound.state rm /lib/systemd/system/seeed-voicecard.service || true
fi
if [ -f /etc/asound.conf ] ; then echo "remove dkms"
echo "remove asound_2mic.conf" rm -rf /var/lib/dkms/seeed-voicecard || true
rm /etc/asound.conf
fi
fi
if [ x${card} = "x4mic" ] ; then echo "remove kernel modules"
echo "delete dtoverlay=seeed-4mic-voicecard in /boot/config.txt" rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-wm8960.ko || true
sed -i "s/dtoverlay=seeed-4mic-voicecard//g" /boot/config.txt rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-ac108.ko || true
if [ -f /boot/overlays/seeed-4mic-voicecard.dtbo ] ; then
echo "remove seeed-4mic-voicecard.dtbo in /boot/overlays"
rm /boot/overlays/seeed-4mic-voicecard.dtbo
fi
if [ -f /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-ac108.ko ] ; then
echo "remove snd-soc-ac108.ko"
rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-ac108.ko
fi
if [ -d /var/lib/dkms/seeed-voicecard ] ; then
echo "remove seeed-voicecard dkms"
rm -rf /var/lib/dkms/seeed-voicecard
fi
echo "delete snd-soc-ac108 in /etc/modules"
sed -i "s/snd-soc-ac108//g" /etc/modules
if [ -f /var/lib/alsa/asound.state ] ; then
echo "remove ac108_asound.state"
rm /var/lib/alsa/asound.state
fi
if [ -f /etc/asound.conf ] ; then
echo "remove asound_4mic.conf"
rm /etc/asound.conf
fi
if [ -f /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so ] ; then
echo "remove libasound_module_pcm_ac108.so in /usr/lib/arm-linux-gnueabihf/alsa-lib/ "
rm /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so
fi
fi
echo "------------------------------------------------------" echo "------------------------------------------------------"
echo "Please reboot your raspberry pi to apply all settings" echo "Please reboot your raspberry pi to apply all settings"