From e750de0ecc84ee81035bbb27ad820848aafd7dda Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 24 Aug 2020 12:03:46 +0100 Subject: [PATCH 01/39] Allow kernel images to be elsewhere - Ubuntu kernel is not at Raspbian location --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 3268e69..2665d29 100755 --- a/install.sh +++ b/install.sh @@ -66,6 +66,7 @@ function get_kernel_version() { _VER_RUN="" [ -z "$_VER_RUN" ] && { ZIMAGE=/boot/kernel.img + [ -f /boot/firmware/vmlinuz ] && ZIMAGE=/boot/firmware/vmlinuz 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; }') } From cd899a83d54343045bfc25d791fb592d57dfe1a5 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 27 Aug 2020 13:15:03 +0100 Subject: [PATCH 02/39] make the overlay un-install directory configurable, for Ubuntu --- uninstall.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index c9491d6..2d28681 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -55,9 +55,12 @@ echo "remove dtbos" for i in $RPI_HATS; do dtoverlay -r $i done -rm /boot/overlays/seeed-2mic-voicecard.dtbo || true -rm /boot/overlays/seeed-4mic-voicecard.dtbo || true -rm /boot/overlays/seeed-8mic-voicecard.dtbo || true +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 echo "remove alsa configs" rm -rf /etc/voicecard/ || true From e82e6fde67d9f7b77b3898912a656cb1329fdb8e Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 27 Aug 2020 13:17:20 +0100 Subject: [PATCH 03/39] make the config un-install directory configurable, for Ubuntu --- uninstall.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index 2d28681..6b9f8d1 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -14,6 +14,8 @@ fi uname_r=$(uname -r) CONFIG=/boot/config.txt +[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt + get_overlay() { ov=$1 if grep -q -E "^dtoverlay=$ov" $CONFIG; then From 1f7323417b60c032f626535a8a94dee255bffcb7 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 4 Sep 2020 20:22:17 +0100 Subject: [PATCH 04/39] temporary work-around for not being able to read sysclk from dts for ac10x The "sysclk = 24000000" value is supposed to come from the "clock-frequency" field of ac108_mclk / ac10x_mclk, but somehow it isn't on 5.4 (vs 4.19). This is a temporary work-around. For some strange unknown reasons, this affects only the square 4-mic device, but not the linear 4-mic nor the 6-mics device. The other two devices have two ac108's, and seem to work fine without it. In v4.19: seeed_voice_card_probe [snd_soc_seeed_voicecard] -> devm_snd_soc_register_card [snd_soc_core] -> snd_soc_register_card [snd_soc_core] -> seeed_voice_card_dai_init [snd_soc_seeed_voicecard] -> asoc_simple_card_init_dai [snd_soc_simple_card_utils] -> snd_soc_dai_set_sysclk [snd_soc_core] -> ac108_set_sysclk [snd_soc_ac108] In 5.4: seeed_voice_card_probe [snd_soc_seeed_voicecard] -> devm_snd_soc_register_card [snd_soc_core] -> snd_soc_register_card [snd_soc_core] -> snd_soc_instantiate_card [snd_soc_core] -> seeed_voice_card_dai_init [snd_soc_seeed_voicecard] -> asoc_simple_init_dai.part.0 [snd_soc_seeed_voicecard] -> snd_soc_dai_set_sysclk [snd_soc_core] -> ac108_set_sysclk [snd_soc_ac108] Which results in the "ac108_set_sysclk :24000000" kernel message. Note the extra snd_soc_instantiate_card(), and the copied/renamed asoc_simple_init_dai() - it became static and not-available to other drivers in v5.x. See https://github.com/respeaker/seeed-voicecard/issues/246 --- seeed-voicecard.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/seeed-voicecard.c b/seeed-voicecard.c index 1ed9a0e..aceb7b9 100644 --- a/seeed-voicecard.c +++ b/seeed-voicecard.c @@ -457,6 +457,8 @@ static int seeed_voice_card_dai_link_of(struct device_node *node, #else ret = asoc_simple_parse_clk_codec(dev, codec, dai_link, codec_dai); #endif + if (!strncmp(dai_link->codecs->dai_name, "ac10", 4)) + codec_dai->sysclk = 24000000; if (ret < 0) goto dai_link_of_err; From f47375e54dd07d758c71d861467820b3f8333061 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 4 Sep 2020 06:37:57 +0100 Subject: [PATCH 05/39] Add reference to Ubuntu kernel package names Signed-off-by: Hin-Tak Leung --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index 2665d29..c9fca53 100755 --- a/install.sh +++ b/install.sh @@ -100,7 +100,10 @@ function check_kernel_headers() { which apt &>/dev/null if [[ $? -eq 0 ]]; then apt update -y + # Raspbian kernel packages apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel + # Ubuntu kernel packages + apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi apt-get -y install dkms git i2c-tools libasound2-plugins # rpi-update checker check_kernel_headers From 8c25d818905a3509adb8df3a8fff9dfe18a95407 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 4 Sep 2020 06:26:13 +0000 Subject: [PATCH 06/39] update check_kernel_headers() for Ubuntu header packages --- install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install.sh b/install.sh index c9fca53..1d8370b 100755 --- a/install.sh +++ b/install.sh @@ -80,6 +80,10 @@ function check_kernel_headers() { [ "X$VER_RUN" == "X$VER_HDR" ] && { return 0 } + VER_HDR=$(dpkg -L linux-headers-$VER_RUN | egrep -m1 "/lib/modules/[[:print:]]+/build" | awk -F'/' '{ print $4; }') + [ "X$VER_RUN" == "X$VER_HDR" ] && { + return 0 + } # echo RUN=$VER_RUN HDR=$VER_HDR echo " !!! Your kernel version is $VER_RUN" From 5ca9ab45dfe7ff65718990f36ee2e8fae58bdac2 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Wed, 9 Sep 2020 03:25:19 +0100 Subject: [PATCH 07/39] Use logic from raspi-config to determine if bcm2835 routing option exists or not The snd_bcm2835.enable_compat_alsa option: enable_compat_alsa:Enables ALSA compatibility virtual audio device (bool) is off these days, since the beginning of 2020 apparently. Reference: raspi-config (20200120) buster; urgency=medium * Add audio switching for discrete internal ALSA devices -- Simon Long Mon, 20 Jan 2020 11:38:37 +0000 --- seeed-voicecard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seeed-voicecard b/seeed-voicecard index f8c3986..79a3551 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -150,6 +150,6 @@ fi alsactl restore #Force 3.5mm ('headphone') jack -if [[ "$kernel_ver" =~ ^4\.*$ ]]; then +if aplay -l | grep -q "bcm2835 ALSA"; then amixer cset numid=3 1 || true fi From cca7bbfe2af11acef42d9ce1e2a73de10dc69533 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 10 Sep 2020 23:18:08 +0100 Subject: [PATCH 08/39] comment about Raspberry Pi 4 having two HDMI ports The if-endif block below around the amixer call fixes https://github.com/respeaker/seeed-voicecard/issues/239 https://github.com/respeaker/seeed-voicecard/issues/240 https://github.com/respeaker/seeed-voicecard/issues/243 --- seeed-voicecard | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/seeed-voicecard b/seeed-voicecard index 79a3551..9a135a1 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -150,6 +150,12 @@ fi alsactl restore #Force 3.5mm ('headphone') jack +# The Raspberry Pi 4, released on 24th Jun 2019, has two HDMI ports, +# and can drive two displays with audios for two users simultaneously, +# in a "multiseat" configuration. The earlier single virtual ALSA +# option for re-directing audio playback between headphone jack and HDMI +# via a 'Routing' mixer setting was turned off eventually to allow +# simultaneous usage of all 3 playback devices. if aplay -l | grep -q "bcm2835 ALSA"; then amixer cset numid=3 1 || true fi From de23c612101018ad7f53361f2fdc55fefee50228 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 13 Sep 2020 18:18:30 +0100 Subject: [PATCH 09/39] Use pr_info() for just routine information, not pr_warn() --- ac101.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ac101.c b/ac101.c index a4bcd62..762c8d3 100644 --- a/ac101.c +++ b/ac101.c @@ -1152,14 +1152,14 @@ int ac101_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) switch(fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master, ap is slave*/ #if _MASTER_MULTI_CODEC == _MASTER_AC101 - pr_warn("AC101 as Master\n"); + pr_info("AC101 as Master\n"); reg_val |= (0x0< Date: Sun, 13 Sep 2020 18:24:25 +0100 Subject: [PATCH 10/39] Use pr_warn() for recoverable errors, not pr_info() --- ac101.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ac101.c b/ac101.c index 762c8d3..92b2583 100644 --- a/ac101.c +++ b/ac101.c @@ -376,7 +376,7 @@ static int ac101_switch_probe(struct ac10x_priv *ac10x) { ac10x->irq = gpiod_to_irq(ac10x->gpiod_irq); if (IS_ERR_VALUE(ac10x->irq)) { - pr_info("[ac101] map gpio to irq failed, errno = %ld\n", ac10x->irq); + pr_warn("[ac101] map gpio to irq failed, errno = %ld\n", ac10x->irq); ac10x->irq = 0; goto _err_irq; } @@ -384,7 +384,7 @@ static int ac101_switch_probe(struct ac10x_priv *ac10x) { /* request irq, set irq type to falling edge trigger */ ret = devm_request_irq(ac10x->codec->dev, ac10x->irq, audio_hmic_irq, IRQF_TRIGGER_FALLING, "SWTICH_EINT", ac10x); if (IS_ERR_VALUE(ret)) { - pr_info("[ac101] request virq %ld failed, errno = %ld\n", ac10x->irq, ret); + pr_warn("[ac101] request virq %ld failed, errno = %ld\n", ac10x->irq, ret); goto _err_irq; } From 9722cb01e480c0b5b5e94bc6d9f8862c5733f32e Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 14:26:40 +0100 Subject: [PATCH 11/39] Revert "temporary work-around for not being able to read sysclk from dts for ac10x" This reverts commit 138d22226ed2b36a94d74873f8f1ac3193ee944f. --- seeed-voicecard.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/seeed-voicecard.c b/seeed-voicecard.c index aceb7b9..1ed9a0e 100644 --- a/seeed-voicecard.c +++ b/seeed-voicecard.c @@ -457,8 +457,6 @@ static int seeed_voice_card_dai_link_of(struct device_node *node, #else ret = asoc_simple_parse_clk_codec(dev, codec, dai_link, codec_dai); #endif - if (!strncmp(dai_link->codecs->dai_name, "ac10", 4)) - codec_dai->sysclk = 24000000; if (ret < 0) goto dai_link_of_err; From c4c112dcafbc83ce19730bf53429a3b39bd38ca3 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 11:25:59 +0100 Subject: [PATCH 12/39] relocating fixed-clock entry, based on upstream advice See upstream - https://github.com/raspberrypi/documentation/issues/1671 https://github.com/raspberrypi/documentation/pull/1673 Quoted here: * Only Device Tree nodes at the top level of the tree and children of a bus node will be probed. For nodes added at run-time there is the further limitation that the bus must register for notifications of the addition and removal of children. However, there are exceptions that break this rule and cause confusion: the kernel explicitly scans the entire tree for some device types - clocks and interrupt controller being the two main ones - in order to (for clocks) initialise them early and/or (for interrupt controllers) in a particular order. This search mechanism only happens during booting and so doesn't work for nodes added by an overlay at run-time. It is therefore recommended for overlays to place fixed-clock nodes in the root of the tree unless it is guaranteed that the overlay will not be used at run-time. --- seeed-4mic-voicecard-overlay.dts | 2 +- seeed-8mic-voicecard-overlay.dts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/seeed-4mic-voicecard-overlay.dts b/seeed-4mic-voicecard-overlay.dts index de7213b..db0b988 100644 --- a/seeed-4mic-voicecard-overlay.dts +++ b/seeed-4mic-voicecard-overlay.dts @@ -13,7 +13,7 @@ }; fragment@1 { - target-path = "/clocks"; + target-path = "/"; __overlay__ { ac108_mclk: codec-mclk { compatible = "fixed-clock"; diff --git a/seeed-8mic-voicecard-overlay.dts b/seeed-8mic-voicecard-overlay.dts index 6d60469..56a1433 100644 --- a/seeed-8mic-voicecard-overlay.dts +++ b/seeed-8mic-voicecard-overlay.dts @@ -13,7 +13,7 @@ }; fragment@1 { - target-path = "/clocks"; + target-path = "/"; __overlay__ { ac10x_mclk: codec-mclk { compatible = "fixed-clock"; From cf98b67079420bbe87eca4bf37a6fa937ce3295f Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 11:27:45 +0100 Subject: [PATCH 13/39] rebuilt dtbo on current Raspbian --- seeed-4mic-voicecard.dtbo | Bin 2349 -> 2259 bytes seeed-8mic-voicecard.dtbo | Bin 3463 -> 3385 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/seeed-4mic-voicecard.dtbo b/seeed-4mic-voicecard.dtbo index 764dc804b98a83cb68fff3a92157b5c2e20671f1..09ee56626c466a2f3d1bca1e8482608c2c88a8d9 100644 GIT binary patch delta 421 zcmZ20bXid20`I@K3=ABX85kHW7#P^@0BH>%76f7eAO-@)??CY-6E&7|Fadd5`V0&c zZ|6)7XLJ#a2FU_3GZ3=?an|HDjQ)&elm9Tv3swR7AOMpKo@~REF4~b&To9j#kP!tk z7fjy4WNx?($U-*jIvW2gkPos0Y96EFWCdpN$?nW5hCcs+07)hc$OgF-rZOGKR)F$> zUSh18Jcn7Dv48RoX64DRnKe{>fO5#{mq69RT@K_kPX55A&MF0Dte#xLV$Ha9@&*=t z#siZd0Lc@R1z43CuT3ss)tVf~D#&;b$ns}=G5G*%G~=7eGHl9>A16Do#S4Ob2m&y3 guTS2Ex0`I@K3=EvQ3=9kw3=HfBKw1Nc1%X%qh=G9dF9QSHkBJ(~c{qSPE&b%2 z{N(K7iPv*DnSp#3AdZ}D!{{xT2vQ5gFwug^GZ_6DYbL*7lviy4ih}@5E*QvWLgGh) z_>&zNB`2FQd5QL=6c@yUi~|CY4pAUpHhBt@dEg!(3)zmlX#C$mKFCE-dl=PG`3xX? zk>r6c=V8|N4f+oRNV;NxY$Vq)<^uT&PXhWHvB@81Dc@ zbSCq#@-sdGva}}eW9FRf&nmskzfXR{8ZQV6ClG*!1H;|PF>Kmk ecOZ!}u9`f94P^5Pwsf|f%)HVHoz42}OBey)FHxre diff --git a/seeed-8mic-voicecard.dtbo b/seeed-8mic-voicecard.dtbo index 4ef515b52dc5e8ef508e41cea63bb9f1f0fe3d55..2dcaa93d42b0a3535fbe2aaea8354e8690d6ac9e 100644 GIT binary patch delta 920 zcmah{&r4KM6u#&En0ar;2?t|Dr^V=yjftpD!c;~GxyT{{4T+>2-n>+pbZW+(QqUrV zAna`X11z^eRJ3RrZCVT@E~1UlqK)8k+F0M2dDlh|JaFzk-*>)q-#ho7=gCi$|a1lK4%BqsN>f3RNgALN&c z6@&+W@CLC|NE=es0)P7#hFv-k)BG1sneDXAIr9uJnmKzLxnUkLlU+aRy8qw(4XjTL zdNQxn^_N6{`dB^c9iA~d__Z}oHQuwj&(R4X;X!kB@i10LHQ&dZcIJs+D3|W%A&2Se zVi0S*d>AWfPK>Y#5t7wQ{YMW*Q)X$RO2 z)Zj@jPM#w;9mB8{%GxzBA>NNBxI5fM244*iP>d^BJ9z_Z59i&Kl_ zPo-kZN~vo~MULZ6!#(&BI4m%!l)Jr>UXMCJeYr|=veIbt$MCV0A9uq+|3&FpeEc+Su|5*)I+sOPyqn7FjH*Sp{S4cJsA zD$TDb@h6`@aA>}4QL8EONT^2N`Az7|ef1Xwqey83BTu8%iAUwx<_yw%4@gedEQ>Kk zF8Vn=WR)E&V|;Sf%H~ zM z2vvxaZpM?{h-pm={J>3kqFhX8clenr+TOc0yIF6|KFM+_QsDW>+xS$yRhgM?UTBpc OPqdXr{To-K7X1eSFNL@O From cbd6da78fc2cea3b8bd3844dd6fbe94cac28ae37 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 11:10:31 +0000 Subject: [PATCH 14/39] updating non-standard PATH for Ubuntu in uninstall.sh --- uninstall.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/uninstall.sh b/uninstall.sh index 6b9f8d1..c88caf9 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -53,6 +53,7 @@ do_overlay() { RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard" +PATH=$PATH:/opt/vc/bin echo "remove dtbos" for i in $RPI_HATS; do dtoverlay -r $i From 90144a2f2e644e7b9ef6ce2af600a62e7ca8c839 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 11:13:40 +0000 Subject: [PATCH 15/39] updating for Ubuntu location of dkms-generated kernel modules --- uninstall.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index c88caf9..a00f7a1 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -82,6 +82,9 @@ echo "remove kernel modules" rm /lib/modules/*/kernel/sound/soc/codecs/snd-soc-wm8960.ko || true rm /lib/modules/*/kernel/sound/soc/codecs/snd-soc-ac108.ko || true rm /lib/modules/*/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true +rm /lib/modules/*/updates/dkms/snd-soc-wm8960.ko || true +rm /lib/modules/*/updates/dkms/snd-soc-ac108.ko || true +rm /lib/modules/*/updates/dkms/snd-soc-seeed-voicecard.ko || true echo "remove $CONFIG configuration" for i in $RPI_HATS; do From 9285159a7ddb50ba733630042abf46de29214a53 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sat, 12 Sep 2020 00:39:19 +0000 Subject: [PATCH 16/39] Apparently, snd_soc_dai_set_bclk_ratio should be used where snd_soc_dai_set_tdm_slot is. See, for example, commit b78b30e32a19f1ac79c26e0a3e9f7bc7385a02a2 Author: j-schambacher Date: Tue May 19 13:56:17 2020 +0200 Switch to snd_soc_dai_set_bclk_ratio Replaces obsolete function snd_soc_dai_set_tdm_slot --- seeed-voicecard.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/seeed-voicecard.c b/seeed-voicecard.c index 1ed9a0e..43535aa 100644 --- a/seeed-voicecard.c +++ b/seeed-voicecard.c @@ -322,10 +322,8 @@ static int asoc_simple_init_dai(struct snd_soc_dai *dai, } if (simple_dai->slots) { - ret = snd_soc_dai_set_tdm_slot(dai, - simple_dai->tx_slot_mask, - simple_dai->rx_slot_mask, - simple_dai->slots, + ret = snd_soc_dai_set_bclk_ratio(dai, + simple_dai->slots * simple_dai->slot_width); if (ret && ret != -ENOTSUPP) { dev_err(dai->dev, "simple-card: set_tdm_slot error\n"); From 6875869cb253bdfd0caeb8bb6cb1e33f16aa0068 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 13 Sep 2020 15:33:56 +0000 Subject: [PATCH 17/39] emit warning for calling ac108_set_sysclk() with unexpected arguments Don't know why Seeed Studio staff did not put it in. Conflicts: ac108.c --- ac108.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ac108.c b/ac108.c index 29e0a94..12ab27b 100644 --- a/ac108.c +++ b/ac108.c @@ -810,6 +810,9 @@ static int ac108_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int fr struct ac10x_priv *ac10x = snd_soc_dai_get_drvdata(dai); + if (freq != 24000000 || clk_id != SYSCLK_SRC_PLL) + dev_warn(dai->dev, "ac108_set_sysclk freq = %d clk = %d\n", freq, clk_id); + freq = 24000000; clk_id = SYSCLK_SRC_PLL; From 19cfed5bd772ff89b26acc1abdd748b6738a0b6c Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 18 Sep 2020 01:06:57 +0100 Subject: [PATCH 18/39] Adding missing shebang This script has no bash-ism, so /bin/sh (dash on Debian/Ubuntu) is fine. --- builddtbo.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/builddtbo.sh b/builddtbo.sh index e98800f..d6e8009 100755 --- a/builddtbo.sh +++ b/builddtbo.sh @@ -1,3 +1,4 @@ +#!/bin/sh #dtoverlay -r seeed-2mic-voicecard DTC_FLAGS="-b 0 -Wno-unit_address_vs_reg -I dts -O dtb" From 1372794704ff6c94ffdd690d9d750dde7adc535d Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 04:25:35 +0100 Subject: [PATCH 19/39] Revert "Don't force kernel downgrade" This reverts commit 30276c80bc1e66cdece5ce6d88928e1fa5265e2c. --- install.sh | 41 +++++++++++++++++++++++++++++++++++++---- seeed-voicecard | 4 +++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 1d8370b..872b428 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,7 @@ #!/bin/bash +FORCE_KERNEL="1.20190925+1-1" + if [[ $EUID -ne 0 ]]; then echo "This script must be run as root (use sudo)" 1>&2 exit 1 @@ -100,15 +102,46 @@ function check_kernel_headers() { apt-get -y --reinstall install raspberrypi-kernel } +function download_install_debpkg() { + local prefix name r + prefix=$1 + name=$2 + + for (( i = 0; i < 3; i++ )); do + wget $prefix$name -O /tmp/$name && break + done + dpkg -i /tmp/$name; r=$? + rm -f /tmp/$name + return $r +} + +function install_kernel() { + local _url _prefix + + # Instead of retriving the lastest kernel & headers + [ "X$FORCE_KERNEL" == "X" ] && { + # Raspbian kernel packages + apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel + # Ubuntu kernel packages + apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi + } || { + # We would like to a fixed version + KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_armhf.deb + HDR_NAME=raspberrypi-kernel-headers_${FORCE_KERNEL}_armhf.deb + _url=$(apt-get download --print-uris raspberrypi-kernel | sed -nre "s/'([^']+)'.*$/\1/g;p") + _prefix=$(echo $_url | sed -nre 's/^(.*)raspberrypi-kernel_.*$/\1/g;p') + + download_install_debpkg "$_prefix" "$KERN_NAME" + download_install_debpkg "$_prefix" "$HDR_NAME" + } +} + # update and install required packages which apt &>/dev/null if [[ $? -eq 0 ]]; then apt update -y - # Raspbian kernel packages - apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel - # Ubuntu kernel packages - apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi apt-get -y install dkms git i2c-tools libasound2-plugins + install_kernel # rpi-update checker check_kernel_headers fi diff --git a/seeed-voicecard b/seeed-voicecard index 9a135a1..2e11ef0 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -122,7 +122,8 @@ if [ "$overlay" ]; then rm /etc/asound.conf rm /var/lib/alsa/asound.state - kernel_ver=$(uname -r) # get_kernel_version) +: <<\EOF + kernel_ver=$(get_kernel_version) # echo kernel_ver=$kernel_ver # TODO: dynamic dtoverlay Bug of v4.19.x @@ -137,6 +138,7 @@ if [ "$overlay" ]; then fi done fi +EOF #make sure the driver loads correctly dtoverlay -d $OVERLAYS $overlay || true From b83519eb828fd59b1e40947aa1dfe0d8872719b8 Mon Sep 17 00:00:00 2001 From: Psycho Date: Sun, 9 Aug 2020 17:57:20 +0200 Subject: [PATCH 20/39] English correction --- install.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 872b428..ba309ca 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -# Check for enough space on /boot volume +# Check if enough space on /boot volume boot_line=$(df -h | grep /boot | head -n 1) if [ "x${boot_line}" = "x" ]; then echo "Warning: /boot volume not found .." @@ -89,10 +89,10 @@ function check_kernel_headers() { # echo RUN=$VER_RUN HDR=$VER_HDR echo " !!! Your kernel version is $VER_RUN" - echo " Not found *** corresponding *** kernel headers with apt-get." - echo " This may occur if you have ran 'rpi-update'." - echo " Choose *** y *** will revert the kernel to version $VER_HDR then continue." - echo " Choose *** N *** will exit without this driver support, by default." + echo " Couldn't find *** corresponding *** kernel headers with apt-get." + echo " This may happen if you ran 'rpi-update'." + echo " Choose *** y *** to revert the kernel to version $VER_HDR and continue." + echo " Choose *** N *** to exit without this driver support, by default." read -p "Would you like to proceed? (y/N)" -n 1 -r -s echo if ! [[ $REPLY =~ ^[Yy]$ ]]; then @@ -118,7 +118,7 @@ function download_install_debpkg() { function install_kernel() { local _url _prefix - # Instead of retriving the lastest kernel & headers + # Instead of retrieving the lastest kernel & headers [ "X$FORCE_KERNEL" == "X" ] && { # Raspbian kernel packages apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel @@ -195,8 +195,8 @@ cp seeed-2mic-voicecard.dtbo $OVERLAYS cp seeed-4mic-voicecard.dtbo $OVERLAYS cp seeed-8mic-voicecard.dtbo $OVERLAYS -#install alsa plugins -# no need this plugin now +# install alsa plugins +# we don't need this plugin now # install -D ac108_plugin/libasound_module_pcm_ac108.so /usr/lib/arm-linux-gnueabihf/alsa-lib/ rm -f /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so @@ -246,6 +246,6 @@ systemctl enable seeed-voicecard.service systemctl start seeed-voicecard echo "------------------------------------------------------" -echo "Please reboot your raspberry pi to apply all settings" +echo "Please reboot your device to apply all settings" echo "Enjoy!" echo "------------------------------------------------------" From 901b451bd53734419f0ae2641f7f21d6401b3cbf Mon Sep 17 00:00:00 2001 From: KillingJacky Date: Mon, 27 Apr 2020 07:58:47 +0100 Subject: [PATCH 21/39] add an cmd line option for choosing compile with compatible kernel; clean up more when uninstalling --- install.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ba309ca..71685a1 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -FORCE_KERNEL="1.20190925+1-1" +FORCE_KERNEL="1.20200819-1" if [[ $EUID -ne 0 ]]; then echo "This script must be run as root (use sudo)" 1>&2 @@ -115,6 +115,14 @@ function download_install_debpkg() { return $r } +option_pattern="compat-kernel" +if [[ $1 =~ ${option_pattern} ]]; then + echo "will compile with a compatible kernel..." +else + FORCE_KERNEL="" + echo "will compile with the latest kernel..." +fi + function install_kernel() { local _url _prefix @@ -181,6 +189,10 @@ function install_module { for _i in $kernels; do dkms build -k $_i -m $mod -v $ver && { dkms install --force -k $_i -m $mod -v $ver + } || { + echo "Can't compile with this kernel, aborting" + echo "Please try to compile with the option --compat-kernel" + exit 1 } done From 957b1298d5b7018af485fa3c57c78cc151b78aab Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 08:09:25 +0100 Subject: [PATCH 22/39] Add: more convenience error message about /boot free space --- install.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 71685a1..32110cf 100755 --- a/install.sh +++ b/install.sh @@ -8,21 +8,20 @@ if [[ $EUID -ne 0 ]]; then fi # Check if enough space on /boot volume -boot_line=$(df -h | grep /boot | head -n 1) +boot_line=$(df -BM | grep /boot | head -n 1) +MIN_BOOT_SPC=25 # MegaBytes if [ "x${boot_line}" = "x" ]; then echo "Warning: /boot volume not found .." else boot_space=$(echo $boot_line | awk '{print $4;}') free_space=$(echo "${boot_space%?}") unit="${boot_space: -1}" - if [[ "$unit" = "K" ]]; then + if [[ "$unit" != "M" ]]; then + echo "Warning: /boot volume not found .." + elif [ "$free_space" -lt "$MIN_BOOT_SPC" ]; then echo "Error: Not enough space left ($boot_space) on /boot" + echo " at least $MIN_BOOT_SPC MB required" exit 1 - elif [[ "$unit" = "M" ]]; then - if [ "$free_space" -lt "25" ]; then - echo "Error: Not enough space left ($boot_space) on /boot" - exit 1 - fi fi fi From 4cec9e73df8a7291f28dddd5e9e5819bf858317b Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:12:35 +0100 Subject: [PATCH 23/39] Fix: probing architecture when installing specific package --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 32110cf..3d5e311 100755 --- a/install.sh +++ b/install.sh @@ -55,6 +55,7 @@ fi ver="0.3" uname_r=$(uname -r) +arch_r=$(dpkg --print-architecture) # we create a dir with this version to ensure that 'dkms remove' won't delete # the sources during kernel updates @@ -133,8 +134,8 @@ function install_kernel() { apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi } || { # We would like to a fixed version - KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_armhf.deb - HDR_NAME=raspberrypi-kernel-headers_${FORCE_KERNEL}_armhf.deb + KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_${arch_r}.deb + HDR_NAME=raspberrypi-kernel-headers_${FORCE_KERNEL}_${arch_r}.deb _url=$(apt-get download --print-uris raspberrypi-kernel | sed -nre "s/'([^']+)'.*$/\1/g;p") _prefix=$(echo $_url | sed -nre 's/^(.*)raspberrypi-kernel_.*$/\1/g;p') From 74620fbdbf8ac7819e964ac8b71c26feda22180b Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:13:55 +0100 Subject: [PATCH 24/39] Remove: useless dd message in get_kernel_version() --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 3d5e311..a49f114 100755 --- a/install.sh +++ b/install.sh @@ -70,7 +70,7 @@ function get_kernel_version() { ZIMAGE=/boot/kernel.img [ -f /boot/firmware/vmlinuz ] && ZIMAGE=/boot/firmware/vmlinuz 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; }') + _VER_RUN=$(dd if=$ZIMAGE obs=64K ibs=4 skip=$(( IMG_OFFSET / 4)) 2>/dev/null | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }') } echo "$_VER_RUN" return 0 From 6af23967a50abb13647fd72c5a8ae861b1a5ae30 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:14:54 +0100 Subject: [PATCH 25/39] Add: prevent install package again in download_install_debpkg() --- install.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a49f114..04747a0 100755 --- a/install.sh +++ b/install.sh @@ -103,9 +103,19 @@ function check_kernel_headers() { } function download_install_debpkg() { - local prefix name r + local prefix name r pkg status _name prefix=$1 name=$2 + pkg=${name%%_*} + + status=$(dpkg -l $pkg | tail -1) + _name=$( echo "$status" | awk '{ printf "%s_%s_%s", $2, $3, $4; }') + status=$(echo "$status" | awk '{ printf "%s", $1; }') + + if [ "X$status" == "Xii" -a "X${name%.deb}" == "X$_name" ]; then + echo "debian package $name already installed." + return 0 + fi for (( i = 0; i < 3; i++ )); do wget $prefix$name -O /tmp/$name && break From 30216a9c7cd8287372a48a02032d19ccfd2d7b29 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:15:41 +0100 Subject: [PATCH 26/39] Add: probing kernel postfix automatically for dkms --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 04747a0..69e011d 100755 --- a/install.sh +++ b/install.sh @@ -174,8 +174,9 @@ fi # it's just been updated) base_ver=$(get_kernel_version) base_ver=${base_ver%%[-+]*} -#kernels="${base_ver}+ ${base_ver}-v7+ ${base_ver}-v7l+" -kernels=$(uname -r) +# kernels="${base_ver}+ ${base_ver}-v7+ ${base_ver}-v7l+" +# select exact kernel postfix +kernels=${base_ver}$(echo $uname_r | sed -re 's/^[0-9.]+(.*)/\1/g') function install_module { local _i From 0abc6ed072c731768b2abdb0082a00c5f6c74dc7 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 11:00:37 +0100 Subject: [PATCH 27/39] Add: checking current directory when installing --- install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.sh b/install.sh index 69e011d..ad0ca61 100755 --- a/install.sh +++ b/install.sh @@ -48,6 +48,13 @@ for cmd in dtparam dtoverlay ; do errorFound=1 fi done + +if [ ! -x seeed-voicecard -o ! -f seeed-voicecard.service ]; then + echo "Please run this script in the project directory" + echo "which has files such as install.sh and seeed-voicecard.service" + errorFound=1 +fi + if [ $errorFound = 1 ] ; then echo "Errors found, exiting." 1>&2 exit 1 From b5def1af8ed71783f5dd067afb8d3c9d260a9899 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 11:01:51 +0100 Subject: [PATCH 28/39] Add: script option --keep-kernel to not change current kernel --- install.sh | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index ad0ca61..3be9d4d 100755 --- a/install.sh +++ b/install.sh @@ -132,13 +132,48 @@ function download_install_debpkg() { return $r } -option_pattern="compat-kernel" -if [[ $1 =~ ${option_pattern} ]]; then +function usage() { + cat <<-__EOF__ + usage: sudo ./install [ --compat-kernel | --keep-kernel ] [ -h | --help ] + default action is update kernel & headers to latest version. + --compat-kernel uses an older kernel but ensures that the driver can work. + --keep-kernel don't change/update the system kernel, maybe install + coressponding kernel headers. + --help show this help message +__EOF__ + exit 1 +} + +compat_kernel= +keep_kernel= +# parse commandline options +while [ ! -z "$1" ] ; do + case $1 in + -h|--help) + usage + ;; + --compat-kernel) + compat_kernel=Y + ;; + --keep-kernel) + keep_kernel=Y + ;; + esac + shift +done + +if [ "X$keep_kernel" != "X" ]; then + FORCE_KERNEL=$(dpkg -s raspberrypi-kernel | awk '/^Version:/{printf "%s\n",$2;}') + echo "Keep current system kernel not to change" +elif [ "X$compat_kernel" != "X" ]; then echo "will compile with a compatible kernel..." else FORCE_KERNEL="" echo "will compile with the latest kernel..." fi +[ "X$FORCE_KERNEL" != "X" ] && { + echo -e "The kernel & headers use package version: $FORCE_KERNEL\r\n\r\n" +} function install_kernel() { local _url _prefix From 2baddde5ba0418cba4aaa6a4704715d4b410c9e7 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 11:03:03 +0100 Subject: [PATCH 29/39] Fix: install ubuntu kernel only if debian kernel install failed --- install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 3be9d4d..e806c40 100755 --- a/install.sh +++ b/install.sh @@ -181,9 +181,10 @@ function install_kernel() { # Instead of retrieving the lastest kernel & headers [ "X$FORCE_KERNEL" == "X" ] && { # Raspbian kernel packages - apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel - # Ubuntu kernel packages - apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi + apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel || { + # Ubuntu kernel packages + apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi + } } || { # We would like to a fixed version KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_${arch_r}.deb From 9bb3afb358529e354af851cf17d6a5d20b8b1375 Mon Sep 17 00:00:00 2001 From: Andre Marschalek <39925052+cyberh0me@users.noreply.github.com> Date: Sat, 22 Aug 2020 15:17:14 +0200 Subject: [PATCH 30/39] Update seeed-voicecard to avoid systemd error messages because of failed service start systemctl restart seeed-voicecard.service Job for seeed-voicecard.service failed because the control process exited with error code. See "systemctl status seeed-voicecard.service" and "journalctl -xe" for details. --- seeed-voicecard | 1 + 1 file changed, 1 insertion(+) diff --git a/seeed-voicecard b/seeed-voicecard index f1367a9..ea8aba9 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -147,3 +147,4 @@ alsactl restore #Force 3.5mm ('headphone') jack amixer cset numid=3 1 +exit 0 From 84247b003709f64e90533729d94b695f9a1978c1 Mon Sep 17 00:00:00 2001 From: Andre Marschalek <39925052+cyberh0me@users.noreply.github.com> Date: Sat, 22 Aug 2020 15:17:14 +0200 Subject: [PATCH 31/39] Update seeed-voicecard to avoid systemd error messages because of failed service start systemctl restart seeed-voicecard.service Job for seeed-voicecard.service failed because the control process exited with error code. See "systemctl status seeed-voicecard.service" and "journalctl -xe" for details. --- seeed-voicecard | 2 ++ 1 file changed, 2 insertions(+) diff --git a/seeed-voicecard b/seeed-voicecard index 2e11ef0..b94ec20 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -161,3 +161,5 @@ alsactl restore if aplay -l | grep -q "bcm2835 ALSA"; then amixer cset numid=3 1 || true fi + +exit 0 From 6a30a3efc69157a61fbbd42fd6743f3deb5bc120 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:13:55 +0100 Subject: [PATCH 32/39] Remove: useless dd message in get_kernel_version() --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 1d8370b..8c84be9 100755 --- a/install.sh +++ b/install.sh @@ -68,7 +68,7 @@ function get_kernel_version() { ZIMAGE=/boot/kernel.img [ -f /boot/firmware/vmlinuz ] && ZIMAGE=/boot/firmware/vmlinuz 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; }') + _VER_RUN=$(dd if=$ZIMAGE obs=64K ibs=4 skip=$(( IMG_OFFSET / 4)) 2>/dev/null | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }') } echo "$_VER_RUN" return 0 From f1a46d63cc8f887053b9c7c5908089ee95c8065d Mon Sep 17 00:00:00 2001 From: turmary Date: Mon, 28 Sep 2020 08:44:56 +0100 Subject: [PATCH 33/39] Add: service message direct to standard output and also /var/log/seeed-voicecard.log --- seeed-voicecard | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/seeed-voicecard b/seeed-voicecard index b94ec20..c82f973 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -21,7 +21,9 @@ # THE SOFTWARE. set -x -#exec 1>/var/log/$(basename $0).log 2>&1 +LOGF=/var/log/$(basename $0).log +exec 1> >(tee $LOGF) +exec 2>&1 export PATH=$PATH:/opt/vc/bin OVERLAYS=/boot/overlays From c1c2e5ca5687c092b61017b210cf91bbc0edb44f Mon Sep 17 00:00:00 2001 From: turmary Date: Mon, 28 Sep 2020 08:45:45 +0100 Subject: [PATCH 34/39] Add: clear title for each install/uninstall steps --- install.sh | 25 +++++++++++++++++-------- uninstall.sh | 41 +++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/install.sh b/install.sh index e806c40..2fac40a 100755 --- a/install.sh +++ b/install.sh @@ -164,12 +164,12 @@ done if [ "X$keep_kernel" != "X" ]; then FORCE_KERNEL=$(dpkg -s raspberrypi-kernel | awk '/^Version:/{printf "%s\n",$2;}') - echo "Keep current system kernel not to change" + echo -e "\n### Keep current system kernel not to change" elif [ "X$compat_kernel" != "X" ]; then - echo "will compile with a compatible kernel..." + echo -e "\n### will compile with a compatible kernel..." else FORCE_KERNEL="" - echo "will compile with the latest kernel..." + echo -e "\n### will compile with the latest kernel..." fi [ "X$FORCE_KERNEL" != "X" ] && { echo -e "The kernel & headers use package version: $FORCE_KERNEL\r\n\r\n" @@ -202,6 +202,7 @@ which apt &>/dev/null if [[ $? -eq 0 ]]; then apt update -y apt-get -y install dkms git i2c-tools libasound2-plugins + echo -e "\n### Install required kernel package" install_kernel # rpi-update checker check_kernel_headers @@ -253,13 +254,15 @@ function install_module { mkdir -p /var/lib/dkms/$mod/$ver/$marker } +echo -e "\n### Install sound card driver" install_module "./" "seeed-voicecard" # install dtbos -cp seeed-2mic-voicecard.dtbo $OVERLAYS -cp seeed-4mic-voicecard.dtbo $OVERLAYS -cp seeed-8mic-voicecard.dtbo $OVERLAYS +echo -e "\n### Install device tree overlays" +cp -v seeed-2mic-voicecard.dtbo $OVERLAYS +cp -v seeed-4mic-voicecard.dtbo $OVERLAYS +cp -v seeed-8mic-voicecard.dtbo $OVERLAYS # install alsa plugins # we don't need this plugin now @@ -267,6 +270,7 @@ cp seeed-8mic-voicecard.dtbo $OVERLAYS rm -f /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so #set kernel modules +echo -e "\n### Install startup modules in /etc/modules" grep -q "^snd-soc-seeed-voicecard$" /etc/modules || \ echo "snd-soc-seeed-voicecard" >> /etc/modules grep -q "^snd-soc-ac108$" /etc/modules || \ @@ -277,6 +281,7 @@ grep -q "^snd-soc-wm8960$" /etc/modules || \ #set dtoverlays CONFIG=/boot/config.txt [ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt +echo -e "\n### Found boot configuration file $CONFIG" sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' $CONFIG || true grep -q "^dtoverlay=i2s-mmap$" $CONFIG || \ @@ -287,11 +292,13 @@ grep -q "^dtparam=i2s=on$" $CONFIG || \ echo "dtparam=i2s=on" >> $CONFIG #install config files +echo -e "\n### Install alsa and widget configuration" mkdir /etc/voicecard || true -cp *.conf /etc/voicecard -cp *.state /etc/voicecard +cp -v *.conf /etc/voicecard +cp -v *.state /etc/voicecard #create git repo +echo -e "\n### Manage alsa configuration by git" git_email=$(git config --global --get user.email) git_name=$(git config --global --get user.name) if [ "x${git_email}" == "x" ] || [ "x${git_name}" == "x" ] ; then @@ -306,6 +313,8 @@ git --git-dir=/etc/voicecard/.git --work-tree=/etc/voicecard/ add --all echo "git commit -m \"origin configures\"" git --git-dir=/etc/voicecard/.git --work-tree=/etc/voicecard/ commit -m "origin configures" +echo -e "\n### Start service seeed-voicecard" +echo -e " see /var/log/seeed-voicecard for more service information" cp seeed-voicecard /usr/bin/ cp seeed-voicecard.service /lib/systemd/system/ systemctl enable seeed-voicecard.service diff --git a/uninstall.sh b/uninstall.sh index a00f7a1..b1292fc 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -54,39 +54,40 @@ do_overlay() { RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard" PATH=$PATH:/opt/vc/bin -echo "remove dtbos" +echo -e "\n### Remove dtbos" for i in $RPI_HATS; do dtoverlay -r $i done 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 +rm -v ${OVERLAYS}/seeed-2mic-voicecard.dtbo || true +rm -v ${OVERLAYS}/seeed-4mic-voicecard.dtbo || true +rm -v ${OVERLAYS}/seeed-8mic-voicecard.dtbo || true -echo "remove alsa configs" -rm -rf /etc/voicecard/ || true +echo -e "\n### Remove alsa configs" +rm -rfv /etc/voicecard/ || true -echo "disabled seeed-voicecard.service " +echo -e "\n### Disable seeed-voicecard.service " +systemctl stop seeed-voicecard.service systemctl disable seeed-voicecard.service -echo "remove seeed-voicecard" -rm /usr/bin/seeed-voicecard || true -rm /lib/systemd/system/seeed-voicecard.service || true +echo -e "\n### Remove seeed-voicecard" +rm -v /usr/bin/seeed-voicecard || true +rm -v /lib/systemd/system/seeed-voicecard.service || true -echo "remove dkms" -rm -rf /var/lib/dkms/seeed-voicecard || true +echo -e "\n### Remove dkms" +rm -rfv /var/lib/dkms/seeed-voicecard || true -echo "remove kernel modules" -rm /lib/modules/*/kernel/sound/soc/codecs/snd-soc-wm8960.ko || true -rm /lib/modules/*/kernel/sound/soc/codecs/snd-soc-ac108.ko || true -rm /lib/modules/*/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true -rm /lib/modules/*/updates/dkms/snd-soc-wm8960.ko || true -rm /lib/modules/*/updates/dkms/snd-soc-ac108.ko || true -rm /lib/modules/*/updates/dkms/snd-soc-seeed-voicecard.ko || true +echo -e "\n### Remove kernel modules" +rm -v /lib/modules/*/kernel/sound/soc/codecs/snd-soc-wm8960.ko || true +rm -v /lib/modules/*/kernel/sound/soc/codecs/snd-soc-ac108.ko || true +rm -v /lib/modules/*/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true +rm -v /lib/modules/*/updates/dkms/snd-soc-wm8960.ko || true +rm -v /lib/modules/*/updates/dkms/snd-soc-ac108.ko || true +rm -v /lib/modules/*/updates/dkms/snd-soc-seeed-voicecard.ko || true -echo "remove $CONFIG configuration" +echo -e "\n### Remove $CONFIG configuration" for i in $RPI_HATS; do echo Uninstall $i ... do_overlay $i 1 From a891e0260ecf83eeeda47583fea568d363485322 Mon Sep 17 00:00:00 2001 From: turmary Date: Mon, 28 Sep 2020 18:03:18 +0800 Subject: [PATCH 35/39] Remove: debug only or wrong widget --- ac101.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ac101.c b/ac101.c index 92b2583..2499bc1 100644 --- a/ac101.c +++ b/ac101.c @@ -772,16 +772,18 @@ static int snd_ac101_put_volsw(struct snd_kcontrol *kcontrol, static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -11925, 75, 0); +/* static const DECLARE_TLV_DB_SCALE(dac_mix_vol_tlv, -600, 600, 0); static const DECLARE_TLV_DB_SCALE(dig_vol_tlv, -7308, 116, 0); +*/ static const DECLARE_TLV_DB_SCALE(speaker_vol_tlv, -4800, 150, 0); static const DECLARE_TLV_DB_SCALE(headphone_vol_tlv, -6300, 100, 0); static struct snd_kcontrol_new ac101_controls[] = { /*DAC*/ SOC_DOUBLE_TLV("DAC volume", DAC_VOL_CTRL, DAC_VOL_L, DAC_VOL_R, 0xff, 0, dac_vol_tlv), - SOC_DOUBLE_TLV("DAC mixer gain", DAC_MXR_GAIN, DACL_MXR_GAIN, DACR_MXR_GAIN, 0xf, 0, dac_mix_vol_tlv), - SOC_SINGLE_TLV("digital volume", DAC_DBG_CTRL, DVC, 0x3f, 1, dig_vol_tlv), + /* SOC_DOUBLE_TLV("DAC Mix Gain", DAC_MXR_GAIN, DACL_MXR_GAIN, DACR_MXR_GAIN, 0xf, 0, dac_mix_vol_tlv), */ + /* SOC_SINGLE_TLV("DAC Debug Volume", DAC_DBG_CTRL, DVC, 0x3f, 1, dig_vol_tlv), */ SOC_SINGLE_TLV("speaker volume", SPKOUT_CTRL, SPK_VOL, 0x1f, 0, speaker_vol_tlv), SOC_SINGLE_TLV("headphone volume", HPOUT_CTRL, HP_VOL, 0x3f, 0, headphone_vol_tlv), }; From e1110617b2dcb06c0191234b5b643187db2d58e4 Mon Sep 17 00:00:00 2001 From: turmary Date: Mon, 28 Sep 2020 18:04:40 +0800 Subject: [PATCH 36/39] Move: volume name widget to ALSA tradition --- ac101.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ac101.c b/ac101.c index 2499bc1..eaa8831 100644 --- a/ac101.c +++ b/ac101.c @@ -781,11 +781,11 @@ static const DECLARE_TLV_DB_SCALE(headphone_vol_tlv, -6300, 100, 0); static struct snd_kcontrol_new ac101_controls[] = { /*DAC*/ - SOC_DOUBLE_TLV("DAC volume", DAC_VOL_CTRL, DAC_VOL_L, DAC_VOL_R, 0xff, 0, dac_vol_tlv), + SOC_DOUBLE_TLV("DAC Playback Volume", DAC_VOL_CTRL, DAC_VOL_L, DAC_VOL_R, 0xff, 0, dac_vol_tlv), /* SOC_DOUBLE_TLV("DAC Mix Gain", DAC_MXR_GAIN, DACL_MXR_GAIN, DACR_MXR_GAIN, 0xf, 0, dac_mix_vol_tlv), */ /* SOC_SINGLE_TLV("DAC Debug Volume", DAC_DBG_CTRL, DVC, 0x3f, 1, dig_vol_tlv), */ - SOC_SINGLE_TLV("speaker volume", SPKOUT_CTRL, SPK_VOL, 0x1f, 0, speaker_vol_tlv), - SOC_SINGLE_TLV("headphone volume", HPOUT_CTRL, HP_VOL, 0x3f, 0, headphone_vol_tlv), + SOC_SINGLE_TLV("Speaker Playback Volume", SPKOUT_CTRL, SPK_VOL, 0x1f, 0, speaker_vol_tlv), + SOC_SINGLE_TLV("Headphone Playback Volume", HPOUT_CTRL, HP_VOL, 0x3f, 0, headphone_vol_tlv), }; /* PLL divisors */ From 30ceb546fa1e6d9f3814599f2d0208253e223d85 Mon Sep 17 00:00:00 2001 From: turmary Date: Mon, 28 Sep 2020 18:14:32 +0800 Subject: [PATCH 37/39] Move: volume name in state configuration --- ac108_6mic.state | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/ac108_6mic.state b/ac108_6mic.state index bdbe64a..0920cdb 100644 --- a/ac108_6mic.state +++ b/ac108_6mic.state @@ -292,7 +292,7 @@ state.seeed8micvoicec { } control.17 { iface MIXER - name 'DAC volume' + name 'DAC Playback Volume' value.0 0 value.1 0 comment { @@ -308,37 +308,7 @@ state.seeed8micvoicec { } control.18 { iface MIXER - name 'DAC mixer gain' - value.0 0 - value.1 0 - comment { - access 'read write' - type INTEGER - count 2 - range '0 - 15' - dbmin -600 - dbmax 8400 - dbvalue.0 -600 - dbvalue.1 -600 - } - } - control.19 { - iface MIXER - name 'digital volume' - value 51 - comment { - access 'read write' - type INTEGER - count 1 - range '0 - 63' - dbmin -7308 - dbmax 0 - dbvalue.0 -1392 - } - } - control.20 { - iface MIXER - name 'speaker volume' + name 'Speaker Playback Volume' value 25 comment { access 'read write' @@ -350,9 +320,9 @@ state.seeed8micvoicec { dbvalue.0 -1050 } } - control.21 { + control.19 { iface MIXER - name 'headphone volume' + name 'Headphone Playback Volume' value 52 comment { access 'read write' From 921ac8fba57bf95e039acafa2f827cdedccfbd27 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 28 Sep 2020 16:38:30 +0100 Subject: [PATCH 38/39] Following Standard ALSA Control Names convention See kernel documentation, e.g. v5.5:Documentation/sound/designs/control-names.rst Fixes https://github.com/respeaker/seeed-voicecard/issues/247 --- ac101.c | 4 ++-- ac108_6mic.state | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ac101.c b/ac101.c index 92b2583..343f030 100644 --- a/ac101.c +++ b/ac101.c @@ -782,8 +782,8 @@ static struct snd_kcontrol_new ac101_controls[] = { SOC_DOUBLE_TLV("DAC volume", DAC_VOL_CTRL, DAC_VOL_L, DAC_VOL_R, 0xff, 0, dac_vol_tlv), SOC_DOUBLE_TLV("DAC mixer gain", DAC_MXR_GAIN, DACL_MXR_GAIN, DACR_MXR_GAIN, 0xf, 0, dac_mix_vol_tlv), SOC_SINGLE_TLV("digital volume", DAC_DBG_CTRL, DVC, 0x3f, 1, dig_vol_tlv), - SOC_SINGLE_TLV("speaker volume", SPKOUT_CTRL, SPK_VOL, 0x1f, 0, speaker_vol_tlv), - SOC_SINGLE_TLV("headphone volume", HPOUT_CTRL, HP_VOL, 0x3f, 0, headphone_vol_tlv), + SOC_SINGLE_TLV("Speaker Playback Volume", SPKOUT_CTRL, SPK_VOL, 0x1f, 0, speaker_vol_tlv), + SOC_SINGLE_TLV("Headphone Playback Volume", HPOUT_CTRL, HP_VOL, 0x3f, 0, headphone_vol_tlv), }; /* PLL divisors */ diff --git a/ac108_6mic.state b/ac108_6mic.state index bdbe64a..61e691a 100644 --- a/ac108_6mic.state +++ b/ac108_6mic.state @@ -338,7 +338,7 @@ state.seeed8micvoicec { } control.20 { iface MIXER - name 'speaker volume' + name 'Speaker Playback Volume' value 25 comment { access 'read write' @@ -352,7 +352,7 @@ state.seeed8micvoicec { } control.21 { iface MIXER - name 'headphone volume' + name 'Headphone Playback Volume' value 52 comment { access 'read write' From e0f9a554fc23045704f69b65b475ebc4786cd69f Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 28 Sep 2020 17:02:11 +0100 Subject: [PATCH 39/39] stop systemd service before diabling in uninstall, taken from upstream c1c2e5ca --- uninstall.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/uninstall.sh b/uninstall.sh index a00f7a1..adbebfc 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -69,6 +69,7 @@ echo "remove alsa configs" rm -rf /etc/voicecard/ || true echo "disabled seeed-voicecard.service " +systemctl stop seeed-voicecard.service systemctl disable seeed-voicecard.service echo "remove seeed-voicecard"