From f5154ef4598a2d2d5a98624661459184eb03a694 Mon Sep 17 00:00:00 2001 From: j1nx Date: Sat, 4 Nov 2023 12:57:26 +0000 Subject: [PATCH] [RPI][WIP] Work on migrating the i2csound system towards pipewire --- .../pipewire.conf.d/20-xvf3510-input.conf | 19 ++++++ .../rootfs-overlay/usr/libexec/ovos-i2csound | 62 +++---------------- buildroot-external/configs/rpi3_64_defconfig | 3 + buildroot-external/configs/rpi4_64_defconfig | 3 + 4 files changed, 32 insertions(+), 55 deletions(-) create mode 100644 buildroot-external/board/ovos/raspberrypi/rootfs-overlay/etc/pipewire/pipewire.conf.d/20-xvf3510-input.conf diff --git a/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/etc/pipewire/pipewire.conf.d/20-xvf3510-input.conf b/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/etc/pipewire/pipewire.conf.d/20-xvf3510-input.conf new file mode 100644 index 00000000..f77930ac --- /dev/null +++ b/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/etc/pipewire/pipewire.conf.d/20-xvf3510-input.conf @@ -0,0 +1,19 @@ +context.modules = [ + { name = libpipewire-module-loopback + args = { + node.description = "VocalFusion ASR recording" + capture.props = { + node.name = capture.VF_ASR_L" + audio.position = [ FL ] + stream.dont-remix = true + target.object = "alsa_input.platform-asoc-simple-card.0.xvf3510-2mic" + node.passive = true + } + playback.props = { + node.name = "VF_ASR_L" + media.class = "Audio/Source" + audio.position = [ MONO ] + } + } + } +] diff --git a/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/usr/libexec/ovos-i2csound b/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/usr/libexec/ovos-i2csound index 9142b1b0..ad69c9a3 100755 --- a/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/usr/libexec/ovos-i2csound +++ b/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/usr/libexec/ovos-i2csound @@ -15,86 +15,57 @@ # limitations under the License. ########################################################################## -# Set default configurations -ASOUND_STATE=/var/lib/alsa/default-asound.state -PULSE_SYSTEM=/etc/pulse/pulseaudio-system.pa -PULSE_DAEMON=/etc/pulse/pulseaudio-daemon.conf - # Scanning the I2C bus for know addresses -is_1a=$(i2cdetect -y 1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}') # ReSpeaker 2-mic / WM8960 +is_1a=$(i2cdetect -y 1 0x1a 0x1a | grep -E "(1a|UU)" | awk '{print $2}') # ReSpeaker 2-mic / WM8960 if [ "${is_1a}" == "1a" ] || [ "${is_1a}" == "UU" ] ; then RESPEAKER2=found echo "ReSpeaker 2-mic $RESPEAKER2" fi -is_35=$(i2cdetect -y 1 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}') # ReSpeaker 4-mic squared +is_35=$(i2cdetect -y 1 0x35 0x35 | grep -E "(35|UU)" | awk '{print $2}') # ReSpeaker 4-mic squared if [ "${is_35}" == "35" ] || [ "${is_35}" == "UU" ] ; then RESPEAKER4=found echo "ReSpeaker 4-mic $RESPEAKER4" fi -is_3b=$(i2cdetect -y 1 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}') # ReSpeaker 4-mic lineair / 6-mic +is_3b=$(i2cdetect -y 1 0x3b 0x3b | grep -E "(3b|UU)" | awk '{print $2}') # ReSpeaker 4-mic lineair / 6-mic if [ "${is_3b}" == "3b" ] || [ "${is_3b}" == "UU" ] ; then RESPEAKER6=found echo "ReSpeaker 6-mic $RESPEAKER6" fi -is_4b=$(i2cdetect -y 1 0x4b 0x4b | egrep "(4b|UU)" | awk '{print $2}') # Adafruit +is_4b=$(i2cdetect -y 1 0x4b 0x4b | grep -E "(4b|UU)" | awk '{print $2}') # Adafruit if [ "${is_4b}" == "4b" ] || [ "${is_4b}" == "UU" ] ; then ADAFRUIT=found echo "Adafruit $ADAFRUIT" fi -is_2f=$(i2cdetect -y 1 0x2f 0x2f | egrep "(2f|UU)" | awk '{print $2}') # TAS5806 +is_2f=$(i2cdetect -y 1 0x2f 0x2f | grep -E "(2f|UU)" | awk '{print $2}') # TAS5806 if [ "${is_2f}" == "2f" ] || [ "${is_2f}" == "UU" ] ; then TAS5806=found echo "Texas Instruments 5806 $TAS5806" fi -is_04=$(i2cdetect -y -a 1 0x04 0x04 | egrep "(04|UU)" | awk '{print $2}') # SJ201 Led Ring +is_04=$(i2cdetect -y -a 1 0x04 0x04 | grep -E "(04|UU)" | awk '{print $2}') # SJ201 Led Ring if [ "${is_04}" == "04" ] || [ "${is_04}" == "UU" ] ; then SJ201LED=found echo "Mark2-Devkit SJ201 Leds $SJ201LED" fi - -# Remove old configurations -if [ -f /etc/pulse/system.pa ] ; then - rm /etc/pulse/system.pa -fi -if [ -f /etc/pulse/default.pa ] ; then - rm /etc/pulse/default.pa -fi -if [ -f /etc/pulse/daemon.conf ] ; then - rm /etc/pulse/daemon.conf -fi -if [ -f /var/lib/alsa/asound.state ] ; then - rm /var/lib/alsa/asound.state -fi -if [ -f /etc/ovos_asound.state ] ; then - rm /etc/ovos_asound.state -fi - +# Configure found devices if [ "$RESPEAKER2" == "found" ] && [ "$RESPEAKER4" != "found" ] ; then echo "Installing and configuring ReSpeaker 2-mic" dtoverlay seeed-2mic-voicecard - ASOUND_STATE=/etc/voicecard/wm8960_asound.state fi if [ "${RESPEAKER6}" == "found" ] && [ "${RESPEAKER4}" != "found" ] ; then echo "Installing and configuring ReSpeaker 4-mic" dtoverlay 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 [ "{$RESPEAKER6}" == "found" ] && [ "${RESPEAKER4}" == "found" ] ; then echo "Installing and configuring ReSpeaker 6mic" dtoverlay 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 [ "$ADAFRUIT" ] ; then @@ -115,23 +86,4 @@ if [ "$TAS5806" ] ; then fi # Reset FAN to low speed /usr/sbin/i2cset -a -y 1 0x04 101 30 i - - PULSE_SYSTEM=/etc/pulse/mycroft-sj201-default.pa - PULSE_DAEMON=/etc/pulse/mycroft-sj201-daemon.conf fi - -# Install soundstate -echo "create asound status file" -ln -s $ASOUND_STATE /etc/ovos_asound.state -ln -s $ASOUND_STATE /var/lib/alsa/asound.state - -# Install pulseaudio files -echo "create pulse system file" -ln -s $PULSE_SYSTEM /etc/pulse/system.pa -echo "create pulse default file" -ln -s $PULSE_SYSTEM /etc/pulse/default.pa -echo "create 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 diff --git a/buildroot-external/configs/rpi3_64_defconfig b/buildroot-external/configs/rpi3_64_defconfig index b9794737..572e1492 100644 --- a/buildroot-external/configs/rpi3_64_defconfig +++ b/buildroot-external/configs/rpi3_64_defconfig @@ -140,6 +140,8 @@ BR2_PACKAGE_PYTHON3=y BR2_PACKAGE_PYTHON3_PYEXPAT=y BR2_PACKAGE_PYTHON_GOBJECT=y BR2_PACKAGE_PYTHON_PODMAN_COMPOSE=y +BR2_PACKAGE_PYTHON_RPI_GPIO=y +BR2_PACKAGE_PYTHON_SPIDEV=y BR2_PACKAGE_LILV=y BR2_PACKAGE_OPUS=y BR2_PACKAGE_PORTAUDIO=y @@ -307,3 +309,4 @@ BR2_PACKAGE_RESPEAKER=y BR2_PACKAGE_RPI_EEPROM=y BR2_PACKAGE_USERLAND_TOOLS=y BR2_PACKAGE_VOCALFUSION=y +BR2_PACKAGE_PYTHON_SMBUS2=y diff --git a/buildroot-external/configs/rpi4_64_defconfig b/buildroot-external/configs/rpi4_64_defconfig index c6e66e78..1c77ea84 100644 --- a/buildroot-external/configs/rpi4_64_defconfig +++ b/buildroot-external/configs/rpi4_64_defconfig @@ -139,6 +139,8 @@ BR2_PACKAGE_PYTHON3=y BR2_PACKAGE_PYTHON3_PYEXPAT=y BR2_PACKAGE_PYTHON_GOBJECT=y BR2_PACKAGE_PYTHON_PODMAN_COMPOSE=y +BR2_PACKAGE_PYTHON_RPI_GPIO=y +BR2_PACKAGE_PYTHON_SPIDEV=y BR2_PACKAGE_LILV=y BR2_PACKAGE_OPUS=y BR2_PACKAGE_PORTAUDIO=y @@ -306,3 +308,4 @@ BR2_PACKAGE_RESPEAKER=y BR2_PACKAGE_RPI_EEPROM=y BR2_PACKAGE_USERLAND_TOOLS=y BR2_PACKAGE_VOCALFUSION=y +BR2_PACKAGE_PYTHON_SMBUS2=y