From 47776bd4aa19cd047cf51bae5535fece52fa44be Mon Sep 17 00:00:00 2001
From: j1nx
Date: Tue, 12 Dec 2023 09:07:53 +0000
Subject: [PATCH] [RPI] More work on getting the wm8960 2-mic card to work
properly
---
.../etc/modprobe.d/bcm2835-alsa.conf | 3 ++
.../rootfs-overlay/usr/libexec/ovos-i2csound | 49 +++++++++---------
.../package/respeaker/respeaker.mk | 2 +
.../respeaker/wm8960-button-overlay.dtbo | Bin 0 -> 1185 bytes
.../respeaker/wm8960-button-overlay.dts | 39 ++++++++++++++
5 files changed, 69 insertions(+), 24 deletions(-)
create mode 100644 buildroot-external/board/ovos/raspberrypi/rootfs-overlay/etc/modprobe.d/bcm2835-alsa.conf
create mode 100644 buildroot-external/package/respeaker/wm8960-button-overlay.dtbo
create mode 100644 buildroot-external/package/respeaker/wm8960-button-overlay.dts
diff --git a/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/etc/modprobe.d/bcm2835-alsa.conf b/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/etc/modprobe.d/bcm2835-alsa.conf
new file mode 100644
index 00000000..d53bfc21
--- /dev/null
+++ b/buildroot-external/board/ovos/raspberrypi/rootfs-overlay/etc/modprobe.d/bcm2835-alsa.conf
@@ -0,0 +1,3 @@
+options snd_soc_simple_card index=0
+options snd_bcm2835 index=1
+options snd slots=snd-soc-simple-card,snd-bcm2835
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 6c4b4f2f..7660e244 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
@@ -16,10 +16,10 @@
##########################################################################
# Scanning the I2C bus for know addresses
-is_1a=$(i2cdetect -y 1 0x1a 0x1a | grep -E "(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 based
if [ "${is_1a}" == "1a" ] || [ "${is_1a}" == "UU" ] ; then
- RESPEAKER2=found
- echo "ReSpeaker 2-mic $RESPEAKER2"
+ WM8960=found
+ echo "WM8960 based 2-mic $WM8960"
fi
is_35=$(i2cdetect -y 1 0x35 0x35 | grep -E "(35|UU)" | awk '{print $2}') # ReSpeaker 4-mic squared
@@ -59,30 +59,31 @@ if [ "${is_04}" == "04" ] || [ "${is_04}" == "UU" ] ; then
fi
# Configure found devices
-if [ "$RESPEAKER2" == "found" ] && [ "$RESPEAKER4" != "found" ] ; then
+if [ "$WM8960" == "found" ] && [ "$RESPEAKER4" != "found" ] ; then
echo "Installing and configuring WM8960 based 2-mic HAT"
dtoverlay wm8960-soundcard
echo "Configuring board"
- amixer cset numid=1 34,34
- amixer cset numid=26 3
- amixer cset numid=27 4
- amixer cset numid=30 5
- amixer cset numid=32 5
- amixer cset numid=33 5
- amixer cset numid=34 25
- amixer cset numid=35 on
- amixer cset numid=9 3
- amixer cset numid=8 3
- amixer cset numid=49 on
- amixer cset numid=51 on
- amixer cset numid=37 0
- amixer cset numid=38 0
- amixer cset numid=39 5
- amixer cset numid=48 on
- amixer cset numid=50 on
- amixer cset numid=54 on
- amixer cset numid=16 5
- amixer cset numid=15 4
+ amixer -c "wm8960soundcard" cset numid=1 34,34
+ amixer -c "wm8960soundcard" cset numid=26 3
+ amixer -c "wm8960soundcard" cset numid=27 4
+ amixer -c "wm8960soundcard" cset numid=30 5
+ amixer -c "wm8960soundcard" cset numid=32 5
+ amixer -c "wm8960soundcard" cset numid=33 5
+ amixer -c "wm8960soundcard" cset numid=34 25
+ amixer -c "wm8960soundcard" cset numid=35 on
+ amixer -c "wm8960soundcard" cset numid=9 3
+ amixer -c "wm8960soundcard" cset numid=8 3
+ amixer -c "wm8960soundcard" cset numid=49 on
+ amixer -c "wm8960soundcard" cset numid=51 on
+ amixer -c "wm8960soundcard" cset numid=37 0
+ amixer -c "wm8960soundcard" cset numid=38 0
+ amixer -c "wm8960soundcard" cset numid=39 5
+ amixer -c "wm8960soundcard" cset numid=48 on
+ amixer -c "wm8960soundcard" cset numid=50 on
+ amixer -c "wm8960soundcard" cset numid=54 on
+ amixer -c "wm8960soundcard" cset numid=16 5
+ amixer -c "wm8960soundcard" cset numid=15 4
+ alsactl store
fi
if [ "${RESPEAKER6}" == "found" ] && [ "${RESPEAKER4}" != "found" ] ; then
diff --git a/buildroot-external/package/respeaker/respeaker.mk b/buildroot-external/package/respeaker/respeaker.mk
index c82166e3..fb52a8ce 100644
--- a/buildroot-external/package/respeaker/respeaker.mk
+++ b/buildroot-external/package/respeaker/respeaker.mk
@@ -20,6 +20,8 @@ define RESPEAKER_INSTALL_TARGET_CMDS
mkdir -p $(BINARIES_DIR)/rpi-firmware/overlays
$(INSTALL) -D -m 0644 $(@D)/seeed-4mic-voicecard.dtbo $(BINARIES_DIR)/rpi-firmware/overlays/
$(INSTALL) -D -m 0644 $(@D)/seeed-8mic-voicecard.dtbo $(BINARIES_DIR)/rpi-firmware/overlays/
+ $(INSTALL) -D -m 0644 $(BR2_EXTERNAL_OPENVOICEOS_PATH)/package/respeaker/wm8960-button-overlay.dtbo \
+ $(BINARIES_DIR)/rpi-firmware/overlays/
mkdir -p $(TARGET_DIR)/usr/share/pulseaudio/alsa-mixer/profile-sets/
$(INSTALL) -D -m 0644 $(@D)/pulseaudio/pulse_config_4mic/seeed-voicecard.conf \
diff --git a/buildroot-external/package/respeaker/wm8960-button-overlay.dtbo b/buildroot-external/package/respeaker/wm8960-button-overlay.dtbo
new file mode 100644
index 0000000000000000000000000000000000000000..9da9a74f600c45b33e516015d67fba796a068624
GIT binary patch
literal 1185
zcma)5y-wUf5FYa*5eO2brbtB)x|4nUgyWQgGEK@rxvYJAhjnYO_Oq
zU$4@Z@q9;em`6z`jFN-?;c=s!1pT&hYNNbS&c}&J%~@b|%CUmH@fQhCk1=&Ea>+}^
z$icfw`ls&$HW4Mu;*?BK$Gky#qowcAPo(<)zEh|A5$c3}sl^SRp7o~KRpbx8R*|(V
z#uOIDCbSSSB+7OO6z)h?Lwts#FLiV-iQA#08A9A&~&*Su5{UXlY+?K4LCprz9t
z2*2lwpY;D?E
z36<1tKIB6?@ZE0)>$hg;FPPsh#ym7Jz2{=)`%4@1^F=ZKOm`~WqxiPSD%kdJpD^FA
zCSNcxJRb`)2%s_k2Ut^NKttCU=cuYDRm3Hmsfsh1w#f}{(Z0{$on}J&LNq@U(qBa?
z$+(F_DZpLBy*+$0+DW4#jZBRDYF}$sND0{$PlwZhF2-L021F*8-IOOnPqhHF;ik|q
z6rsXIq8q11|O?NPIW#~)ogn#6<
B{EYwr
literal 0
HcmV?d00001
diff --git a/buildroot-external/package/respeaker/wm8960-button-overlay.dts b/buildroot-external/package/respeaker/wm8960-button-overlay.dts
new file mode 100644
index 00000000..a8ee97d2
--- /dev/null
+++ b/buildroot-external/package/respeaker/wm8960-button-overlay.dts
@@ -0,0 +1,39 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
+
+ fragment@0 {
+ target = <&gpio>;
+ __overlay__ {
+ wm8960_key_pin: wm8960_key_pin {
+ brcm,pins = <11>;
+ brcm,function = <0>; /* input mode */
+ brcm,pull = <0>; /* pull up/down disabled */
+ };
+ };
+ };
+
+ fragment@1 {
+ target-path = "/soc";
+ __overlay__ {
+ wm8960_button: wm8960_button {
+ compatible = "gpio-keys";
+ // #address-cells = <1>;
+ // #size-cells = <0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&wm8960_key_pin>;
+ status = "okay";
+ debounce-interval = <50>;
+
+ button_wake_up: button@11 {
+ gpios = <&gpio 11 1>;
+ linux,code = <143>; // KEY_WAKEUP
+ label = "Wake Up";
+ gpio-key,wakeup;
+ };
+ };
+ };
+ };
+};