2017-09-27 05:14:19 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
echo "This script must be run as root (use sudo)" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
is_Raspberry=$(cat /proc/device-tree/model | awk '{print $1}')
|
|
|
|
if [ "x${is_Raspberry}" != "xRaspberry" ] ; then
|
|
|
|
echo "Sorry, this drivers only works on raspberry pi"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
uname_r=$(uname -r)
|
|
|
|
|
2019-05-21 06:18:25 +02:00
|
|
|
CONFIG=/boot/config.txt
|
2020-08-27 14:17:20 +02:00
|
|
|
[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt
|
|
|
|
|
2019-05-21 06:18:25 +02:00
|
|
|
get_overlay() {
|
|
|
|
ov=$1
|
|
|
|
if grep -q -E "^dtoverlay=$ov" $CONFIG; then
|
|
|
|
echo 0
|
|
|
|
else
|
|
|
|
echo 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
do_overlay() {
|
|
|
|
ov=$1
|
|
|
|
RET=$2
|
|
|
|
DEFAULT=--defaultno
|
|
|
|
CURRENT=0
|
|
|
|
if [ $(get_overlay $ov) -eq 0 ]; then
|
|
|
|
DEFAULT=
|
|
|
|
CURRENT=1
|
|
|
|
fi
|
|
|
|
if [ $RET -eq $CURRENT ]; then
|
|
|
|
ASK_TO_REBOOT=1
|
|
|
|
fi
|
|
|
|
if [ $RET -eq 0 ]; then
|
|
|
|
sed $CONFIG -i -e "s/^#dtoverlay=$ov/dtoverlay=$ov/"
|
|
|
|
if ! grep -q -E "^dtoverlay=$ov" $CONFIG; then
|
|
|
|
printf "dtoverlay=$ov\n" >> $CONFIG
|
|
|
|
fi
|
|
|
|
STATUS=enabled
|
|
|
|
elif [ $RET -eq 1 ]; then
|
|
|
|
sed $CONFIG -i -e "s/^dtoverlay=$ov/#dtoverlay=$ov/"
|
|
|
|
STATUS=disabled
|
|
|
|
else
|
|
|
|
return $RET
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-05-22 04:39:09 +02:00
|
|
|
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
|
2017-09-27 05:14:19 +02:00
|
|
|
|
2018-02-01 08:58:36 +01:00
|
|
|
echo "remove dtbos"
|
2019-05-22 04:39:09 +02:00
|
|
|
for i in $RPI_HATS; do
|
|
|
|
dtoverlay -r $i
|
|
|
|
done
|
2020-08-27 14:15:03 +02:00
|
|
|
OVERLAYS=/boot/overlays
|
|
|
|
[ -d /boot/firmware/overlays ] && OVERLAYS=/boot/firmware/overlays
|
|
|
|
|
|
|
|
rm ${OVERLAYS}/seeed-2mic-voicecard.dtbo || true
|
|
|
|
rm ${OVERLAYS}/seeed-4mic-voicecard.dtbo || true
|
|
|
|
rm ${OVERLAYS}/seeed-8mic-voicecard.dtbo || true
|
2017-09-27 05:14:19 +02:00
|
|
|
|
2018-02-01 08:58:36 +01:00
|
|
|
echo "remove alsa configs"
|
|
|
|
rm -rf /etc/voicecard/ || true
|
2017-09-27 05:14:19 +02:00
|
|
|
|
2018-02-01 08:58:36 +01:00
|
|
|
echo "disabled seeed-voicecard.service "
|
|
|
|
systemctl disable seeed-voicecard.service
|
2017-09-27 05:14:19 +02:00
|
|
|
|
2018-04-04 11:36:18 +02:00
|
|
|
echo "remove seeed-voicecard"
|
2018-02-01 08:58:36 +01:00
|
|
|
rm /usr/bin/seeed-voicecard || true
|
|
|
|
rm /lib/systemd/system/seeed-voicecard.service || true
|
2017-09-27 05:14:19 +02:00
|
|
|
|
2018-02-01 08:58:36 +01:00
|
|
|
echo "remove dkms"
|
|
|
|
rm -rf /var/lib/dkms/seeed-voicecard || true
|
2017-09-27 05:14:19 +02:00
|
|
|
|
2018-02-01 08:58:36 +01:00
|
|
|
echo "remove kernel modules"
|
|
|
|
rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-wm8960.ko || true
|
|
|
|
rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-ac108.ko || true
|
2018-04-04 11:36:18 +02:00
|
|
|
rm /lib/modules/${uname_r}/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true
|
2017-09-27 05:14:19 +02:00
|
|
|
|
2019-05-21 06:18:25 +02:00
|
|
|
echo "remove $CONFIG configuration"
|
|
|
|
for i in $RPI_HATS; do
|
|
|
|
echo Uninstall $i ...
|
|
|
|
do_overlay $i 1
|
|
|
|
done
|
|
|
|
|
2017-09-27 05:14:19 +02:00
|
|
|
echo "------------------------------------------------------"
|
|
|
|
echo "Please reboot your raspberry pi to apply all settings"
|
|
|
|
echo "Thank you!"
|
|
|
|
echo "------------------------------------------------------"
|