mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-01-18 20:19:56 +01:00
MycroftOS: Changes for the respeaker driver setup including a
initial start to use pulseaudio <needs some testing>
This commit is contained in:
parent
7eb848f661
commit
46d6ec7e9c
@ -26,7 +26,7 @@ define RESPEAKER_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 0644 $(@D)/*.conf $(TARGET_DIR)/etc/voicecard
|
||||
$(INSTALL) -D -m 0644 $(@D)/*.state $(TARGET_DIR)/etc/voicecard
|
||||
$(INSTALL) -D -m 0755 $(@D)/seeed-voicecard $(TARGET_DIR)/usr/bin
|
||||
$(INSTALL) -D -m 0755 $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/respeaker/start-seeed-voicecard.sh \
|
||||
$(INSTALL) -D -m 0755 $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/respeaker/seeed-voicecard \
|
||||
$(TARGET_DIR)/usr/bin
|
||||
|
||||
$(INSTALL) -D -m 0644 $(@D)/seeed-2mic-voicecard.dtbo $(BINARIES_DIR)/rpi-firmware/overlays/
|
||||
|
167
buildroot-external/package/respeaker/seeed-voicecard
Executable file
167
buildroot-external/package/respeaker/seeed-voicecard
Executable file
@ -0,0 +1,167 @@
|
||||
#!/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
|
||||
#enable i2c interface
|
||||
dtparam i2c_arm=on
|
||||
modprobe i2c-dev
|
||||
|
||||
#enable spi interface
|
||||
dtparam spi=on
|
||||
|
||||
# Check if /boot folder exist
|
||||
if [ ! -d /boot ]; then
|
||||
mkdir -p /boot
|
||||
fi
|
||||
|
||||
# Check if /boot is mounted and mount it if not
|
||||
if mountpoint -q /boot; then
|
||||
mount -t vfat /dev/mmcblk0p1 /boot
|
||||
fi
|
||||
|
||||
_VER_RUN=
|
||||
function get_kernel_version() {
|
||||
local ZIMAGE IMG_OFFSET
|
||||
|
||||
_VER_RUN=""
|
||||
[ -z "$_VER_RUN" ] && {
|
||||
ZIMAGE=/boot/kernel.img
|
||||
IMG_OFFSET=$(LC_ALL=C grep -abo $'\x1f\x8b\x08\x00' $ZIMAGE | head -n 1 | cut -d ':' -f 1)
|
||||
_VER_RUN=$(dd if=$ZIMAGE obs=64K ibs=4 skip=$(( IMG_OFFSET / 4)) | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }')
|
||||
}
|
||||
echo "$_VER_RUN"
|
||||
return 0
|
||||
}
|
||||
|
||||
CONFIG=/boot/config.txt
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
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}')
|
||||
|
||||
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
|
||||
overlay=""
|
||||
|
||||
if [ "x${is_1a}" != "x" ] && [ "x${is_35}" == "x" ] ; then
|
||||
echo "install 2mic"
|
||||
overlay=seeed-2mic-voicecard
|
||||
asound_conf=/etc/voicecard/asound_2mic.conf
|
||||
asound_state=/etc/voicecard/wm8960_asound.state
|
||||
fi
|
||||
|
||||
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" == "x" ] ; then
|
||||
echo "install 4mic"
|
||||
overlay=seeed-4mic-voicecard
|
||||
asound_conf=/etc/voicecard/asound_4mic.conf
|
||||
asound_state=/etc/voicecard/ac108_asound.state
|
||||
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"
|
||||
overlay=seeed-8mic-voicecard
|
||||
asound_conf=/etc/voicecard/asound_6mic.conf
|
||||
asound_state=/etc/voicecard/ac108_6mic.state
|
||||
pulse_default=/etc/pulse/seeed-voicecard-8mic-default.pa
|
||||
pulse_daemon=/etc/pulse/seeed-voicecard-8mic-daemon.conf
|
||||
fi
|
||||
|
||||
if [ "$overlay" ]; then
|
||||
echo Install $overlay ...
|
||||
|
||||
# Remove old configuration
|
||||
rm /etc/asound.conf
|
||||
rm /var/lib/alsa/asound.state
|
||||
rm /etc/pulse/default.pa
|
||||
rm /etc/pulse/daemon.conf
|
||||
|
||||
kernel_ver=$(get_kernel_version)
|
||||
# echo kernel_ver=$kernel_ver
|
||||
|
||||
# TODO: dynamic dtoverlay Bug of v4.19.x
|
||||
# no DT node phandle inserted.
|
||||
if [[ "$kernel_ver" =~ ^4\.19.*$ ]]; then
|
||||
for i in $RPI_HATS; do
|
||||
if [ "$i" == "$overlay" ]; then
|
||||
do_overlay $overlay 0
|
||||
else
|
||||
echo Uninstall $i ...
|
||||
do_overlay $i 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
#make sure the driver loads correctly
|
||||
dtoverlay $overlay || true
|
||||
|
||||
echo "create $overlay asound configure file"
|
||||
ln -s $asound_conf /etc/asound.conf
|
||||
echo "create $overlay asound status file"
|
||||
ln -s $asound_state /var/lib/alsa/asound.state
|
||||
echo "create $overlay pulse default file"
|
||||
ln -s $pulse_default /etc/pulse/default.pa
|
||||
echo "create $overlay pulse daemon file"
|
||||
ln -s $pulsedaemon /etc/pulse/daemon.conf
|
||||
fi
|
||||
|
||||
alsactl restore
|
||||
|
||||
#Fore 3.5mm ('headphone') jack
|
||||
amixer cset numid=3 1
|
||||
|
||||
touch /var/lock/seeed-voicecard
|
@ -5,7 +5,7 @@ After=alsa-restore.service
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/start-seeed-voicecard.sh
|
||||
ExecStart=/usr/bin/seeed-voicecard
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Configure seeed-voicecard....
|
||||
#
|
||||
|
||||
echo "Starting seeed-voicecard..."
|
||||
mount -t configfs none /sys/kernel/config
|
||||
mkdir -p /boot
|
||||
mount -t vfat /dev/mmcblk0p1 /boot
|
||||
/usr/bin/seeed-voicecard
|
||||
touch /var/lock/seeed-voicecard
|
Loading…
Reference in New Issue
Block a user