[WIP] Sound architecture changes.

Utilizing our new ovos-i2csound setup systemd
This commit is contained in:
j1nx 2021-05-10 13:31:27 +02:00
parent f38dd4d36c
commit f1d0de3f6c
14 changed files with 157 additions and 175 deletions

View File

@ -34,7 +34,7 @@ BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/raspberrypi4-64/post-image.s
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-miniuart-bt-overlay --aarch64"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/raspberrypi/linux/archive/41aaea1d7cb9548646858f8ff8e65ad53b27c66c.tar.gz"
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/raspberrypi/linux/archive/7d9d9693c2935bdb6af0089c16d39d91334ea182.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL)/board/raspberrypi/kernel.config"
BR2_LINUX_KERNEL_LZ4=y

View File

@ -6,7 +6,6 @@ After=pulseaudio.service NetworkManager.service systemd-timesyncd.service
User=mycroft
WorkingDirectory=/home/mycroft
Type=oneshot
ExecStartPre=-/usr/bin/sj201-reset-led
ExecStart=/bin/true
RemainAfterExit=yes

View File

@ -1,40 +0,0 @@
From 1ca3a1c09f33700eccb0277e1b0b1e809f98c00b Mon Sep 17 00:00:00 2001
From: j1nx <p.steenbergen@j1nx.nl>
Date: Thu, 4 Feb 2021 15:59:08 +0100
Subject: [PATCH 1/1] Do not build the wm8960 driver
---
Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index b9de7f4..34e3151 100644
--- a/Makefile
+++ b/Makefile
@@ -12,12 +12,12 @@ uname_r=$(shell uname -r)
ifneq ($(KERNELRELEASE),)
# $(warning KERNELVERSION=$(KERNELVERSION))
-snd-soc-wm8960-objs := wm8960.o
+#snd-soc-wm8960-objs := wm8960.o
snd-soc-ac108-objs := ac108.o ac101.o
snd-soc-seeed-voicecard-objs := seeed-voicecard.o
-obj-m += snd-soc-wm8960.o
+#obj-m += snd-soc-wm8960.o
obj-m += snd-soc-ac108.o
obj-m += snd-soc-seeed-voicecard.o
@@ -41,7 +41,7 @@ clean:
install:
sudo cp snd-soc-ac108.ko ${DEST}/sound/soc/codecs/
- sudo cp snd-soc-wm8960.ko ${DEST}/sound/soc/codecs/
+# sudo cp snd-soc-wm8960.ko ${DEST}/sound/soc/codecs/
sudo cp snd-soc-seeed-voicecard.ko ${DEST}/sound/soc/bcm/
sudo depmod -a
--
2.20.1

View File

@ -1,2 +1,2 @@
# Locally computed
sha256 9a97eb4e53398761b26104bd43018d1563efb133d7ac67e0e5ea25d15ab45e66 respeaker-50dbe24b7839fb4d82d01693ca15fa631b5a761d.tar.gz
sha256 596c59811ef71e549e2ce7551adac4c39106f7e84ed7a13629a946928d24e948 respeaker-c8d97904ceacf848346029f176c23cc74addb733.tar.gz

View File

@ -4,7 +4,7 @@
#
################################################################################
RESPEAKER_VERSION = 50dbe24b7839fb4d82d01693ca15fa631b5a761d
RESPEAKER_VERSION = c8d97904ceacf848346029f176c23cc74addb733
RESPEAKER_SITE = $(call github,HinTak,seeed-voicecard,$(RESPEAKER_VERSION))
RESPEAKER_LICENSE = GNU General Public License v3.0
RESPEAKER_DEPENDENCIES = rpi-firmware dtc
@ -12,15 +12,11 @@ RESPEAKER_DEPENDENCIES = rpi-firmware dtc
$(eval $(kernel-module))
define RESPEAKER_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0644 $(BR2_EXTERNAL_OPENVOICEOS_PATH)/package/respeaker/seeed-voicecard.service \
$(TARGET_DIR)/usr/lib/systemd/system/seeed-voicecard.service
mkdir -p $(TARGET_DIR)/etc/voicecard
$(INSTALL) -D -m 0644 $(@D)/*.state $(TARGET_DIR)/etc/voicecard
$(INSTALL) -D -m 0755 $(BR2_EXTERNAL_OPENVOICEOS_PATH)/package/respeaker/seeed-voicecard \
$(TARGET_DIR)/usr/bin
$(INSTALL) -D -m 0644 $(@D)/seeed-2mic-voicecard.dtbo $(BINARIES_DIR)/overlays/
$(INSTALL) -D -m 0644 $(@D)/seeed-4mic-voicecard.dtbo $(BINARIES_DIR)/overlays/
$(INSTALL) -D -m 0644 $(@D)/seeed-8mic-voicecard.dtbo $(BINARIES_DIR)/overlays/

View File

@ -1,95 +0,0 @@
#!/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
OVERLAYS=/boot/overlays
#enable i2c interface
dtparam -d $OVERLAYS i2c_arm=on
modprobe i2c-dev
#enable spi interface
dtparam -d $OVERLAYS spi=on
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}')
# Set default configurations
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
overlay=""
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
rm /etc/voicecard/asound.state
rm /etc/pulse/system.pa
rm /etc/pulse/daemon.conf
if [ "x${is_1a}" != "x" ] && [ "x${is_35}" == "x" ] ; then
echo "install wm8960"
modprobe snd-soc-wm8960
overlay=wm8960-soundcard
asound_state=/etc/voicecard/wm8960_asound.state
fi
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" == "x" ] ; then
echo "install 4mic"
modprobe snd-soc-seeed-voicecard
modprobe snd-soc-ac108
overlay=seeed-4mic-voicecard
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"
modprobe snd-soc-seeed-voicecard
modprobe snd-soc-ac108
overlay=seeed-8mic-voicecard
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 Loading $overlay ...
# Make sure the driver loads correctly
dtoverlay -d $OVERLAYS $overlay || true
fi
# Install soundstate
echo "create $overlay asound status file"
ln -s $asound_state /etc/voicecard/asound.state
# 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
alsactl -E HOME=/run/alsa -f /etc/voicecard/asound.state restore

View File

@ -1,11 +0,0 @@
[Unit]
Description=Seeed Voicecard service
After=alsa-restore.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/seeed-voicecard
[Install]
WantedBy=sysinit.target

View File

@ -29,9 +29,6 @@ define XVF3510_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/resources/clk_dac_setup/setup_mclk \
$(TARGET_DIR)/usr/sbin
$(INSTALL) -D -m 0644 $(BR2_EXTERNAL_OPENVOICEOS_PATH)/package/xvf3510/xvf3510.service \
$(TARGET_DIR)/usr/lib/systemd/system/xvf3510.service
$(INSTALL) -D -m 755 $(BR2_EXTERNAL_OPENVOICEOS_PATH)/package/xvf3510/xvf3510-start \
$(TARGET_DIR)/usr/sbin/xvf3510-start
$(INSTALL) -D -m 755 $(BR2_EXTERNAL_OPENVOICEOS_PATH)/package/xvf3510/xvf3510-stop \

View File

@ -1,13 +0,0 @@
[Unit]
Description=Setup audio environment for xvf3510
After=systemd-modules-load.service
Requires=systemd-modules-load.service
[Service]
Type=oneshot
ExecStart=xvf3510-start
ExecStop=xvf3510-stop
RemainAfterExit=True
[Install]
WantedBy=multi-user.target

View File

@ -5,7 +5,6 @@ enable brcm_bt.service
enable bluetooth.service
enable pulseaudio.service
enable avahi-daemon.service
enable seeed-voicecard.service
enable NetworkManager.service
enable ovos-splash-start.service
@ -30,4 +29,3 @@ disable snapclient.service
disable snapserver.service
disable spotifyd.service
disable nodered.service
disable xvf3510.service

View File

@ -0,0 +1,12 @@
[Unit]
Description=I2C Sound configuration service
After=alsa-restore.service
Requires=dev-i2c\x2d1.device
After=dev-i2c\x2d1.device
Requires=systemd-modules-load.service
After=systemd-modules-load.service
Before=pulseaudio.service
[Service]
Type=oneshot
ExecStart=/usr/libexec/ovos-i2csound

View File

@ -0,0 +1 @@
SUBSYSTEM=="i2c-dev", TAG+="systemd", ENV{SYSTEMD_WANTS}="i2csound.service"

View File

@ -0,0 +1,138 @@
#!/bin/sh
##########################################################################
# ovos-i2csound
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
set -e
exec 1>/var/log/$(basename $0).log 2>&1
# Set default configurations
OVERLAYS=/boot/overlays
OVERLAY=""
ASOUND_STATE=/var/lib/alsa/default-asound.state
PULSE_SYSTEM=/etc/pulse/pulseaudio-system.pa
PULSE_DAEMON=/etc/pulse/pulseaudio-daemon.conf
# Set known hat overlay variables
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
# Scanning the I2C bus for know addresses
is_1a=$(i2cdetect -y 1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}') # ReSpeaker 2-mic / WM8960
if [ is_1a == "1a" ] || [ is_1a == "UU" ] ; then
0x1a="found"
fi
is_35=$(i2cdetect -y 1 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}') # ReSpeaker 4-mic squared
if [ is_35 == "35" ] || [ is_35 == "UU" ] ; then
0x35="found"
fi
is_3b=$(i2cdetect -y 1 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}') # ReSpeaker 4-mic lineair / 6-mic
if [ is_3b == "3b" ] || [ is_3b == "UU" ] ; then
0x3b="found"
fi
is_4b=$(i2cdetect -y -a 1 0x4b 0x4b | egrep "(4b|UU)" | awk '{print $2}') # Adafruit
if [ is_4b == "4b" ] || [ is_4b == "UU" ] ; then
0x4b="found"
fi
is_2c=$(i2cdetect -y 1 0x2c 0x2c | egrep "(2c|UU)" | awk '{print $2}') # XMOS XVF3510
if [ is_2c == "2c" ] || [ is_2c == "UU" ] ; then
0x2c="found"
fi
is_2f=$(i2cdetect -y 1 0x2f 0x2f | egrep "(2f|UU)" | awk '{print $2}') # TAS5860
if [ is_2f == "2f" ] || [ is_2f == "UU" ] ; then
0x2f="found"
fi
is_04=$(i2cdetect -y 1 0x04 0x04 | egrep "(04|UU)" | awk '{print $2}') # SJ201 Led Ring
if [ is_04 == "04" ] || [ is_04 == "UU" ] ; then
0x04="found"
fi
# Remove old configurations
rm /var/lib/alsa/asound.state
rm /etc/ovos_asound.state
rm /etc/pulse/system.pa
rm /etc/pulse/daemon.conf
if [ 0x1a == "found" ] && [ 0x35 != "found" ] ; then
echo "Installing and configuring ReSpeaker 2-mic"
modprobe snd-soc-wm8960
OVERLAY=seeed-2mic-voicecard
ASOUND_STATE=/etc/voicecard/wm8960_asound.state
fi
if [ 0x3b == "found" ] && [ 0x35 != "found" ] ; then
echo "Installing and configuring ReSpeaker 4-mic"
modprobe snd-soc-seeed-voicecard
modprobe snd-soc-ac108
OVERLAY=seeed-4mic-voicecard
ASOUND_STATE=/etc/voicecard/ac108_asound.state
PULSE_SYSTEM=/etc/pulse/seeed-voicecard-4mic-default.pa
PULSE_DAEMON=/etc/pulse/seeed-voicecard-4mic-daemon.conf
fi
if [ 0x3b == "found" ] && [ 0x35 == "found" ] ; then
echo "Installing and configuring 6mic"
modprobe snd-soc-seeed-voicecard
modprobe snd-soc-ac108
OVERLAY=seeed-8mic-voicecard
ASOUND_STATE=/etc/voicecard/ac108_6mic.state
PULSE_SYSTEM=/etc/pulse/seeed-voicecard-8mic-default.pa
PULSE_DAEMON=/etc/pulse/seeed-voicecard-8mic-daemon.conf
fi
if [ 0x4b == "found" ] ; then
echo "Installing and configuring Adafruit"
/usr/sbin/i2cset -y 1 0x4b 30 # Set maximum volume to 30
fi
if [ 0x2c == "found" ] && [ 0x2f == "found" ] && [ 0x04 == "found" ]; then
echo "Installing and configuring SJ201"
# Initializing XMOS xvf3510
/usr/sbin/xvf3510-start
# Initializing Texas Instruments 5860 DAC
/usr/bin/tas5806-init
# Initializing and resetting LED ring
/usr/bin/sj201-reset-led
PULSE_SYSTEM=/etc/pulse/mycroft-sj201-default.pa
PULSE_DAEMON=/etc/pulse/mycroft-sj201-daemon.conf
fi
# Load overlay
if [ "$OVERLAY" ]; then
echo Loading $OVERLAY ...
# Make sure the driver loads correctly
dtoverlay -d $OVERLAYS $overlay || true
fi
# Install soundstate
echo "create $overlay asound status file"
ln -s $asound_state /etc/ovos_asound.state
# 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
# Restore sound levels
alsactl -E HOME=/run/alsa -f /etc/ovos_asound.state restore

View File

@ -15,7 +15,7 @@ index 8730ec959b..d10a8b1db9 100644
@@ -1,3 +1,3 @@
# Locally computed
-sha256 ae4e317681995e0f7becd7900ae667cba394e3a0b7ca93a267f3303df7284697 rpi-firmware-d016a6eb01c8c7326a89cb42809fed2a21525de5.tar.gz
+sha256 a942cc52cabf17661675d0877f39b1159fca2c83d57299d2dde06ad6e39ab0ab rpi-firmware-8717598c7eb443c39c28a4b3a66b4d369ae0a83f.tar.gz
+sha256 3dd57730399b0bc12d99a0bcaca9fcbd54514486bf554597221316e3552d0e6e rpi-firmware-d9c382e0f3a546e9da153673dce5dd4ba1200994.tar.gz
sha256 c7283ff51f863d93a275c66e3b4cb08021a5dd4d8c1e7acc47d872fbe52d3d6b boot/LICENCE.broadcom
diff --git a/package/rpi-firmware/rpi-firmware.mk b/package/rpi-firmware/rpi-firmware.mk
index 8b2b2c7154..6099e1f170 100644
@ -26,7 +26,7 @@ index 8b2b2c7154..6099e1f170 100644
################################################################################
-RPI_FIRMWARE_VERSION = d016a6eb01c8c7326a89cb42809fed2a21525de5
+RPI_FIRMWARE_VERSION = 8717598c7eb443c39c28a4b3a66b4d369ae0a83f
+RPI_FIRMWARE_VERSION = d9c382e0f3a546e9da153673dce5dd4ba1200994
RPI_FIRMWARE_SITE = $(call github,raspberrypi,firmware,$(RPI_FIRMWARE_VERSION))
RPI_FIRMWARE_LICENSE = BSD-3-Clause
RPI_FIRMWARE_LICENSE_FILES = boot/LICENCE.broadcom