From 8497972d652808288cf452f740ba2b1315f6bf72 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 16 Mar 2020 18:34:24 +0000 Subject: [PATCH 01/32] Don't force kernel downgrade Revert "Fix: try to use a specific version kernel & headers" This reverts commit ae32476755bf458cdd8883d6975082a244eb9d87. Conflicts: install.sh --- install.sh | 35 +---------------------------------- seeed-voicecard | 2 -- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/install.sh b/install.sh index 8ca241b..1252048 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,5 @@ #!/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 @@ -92,43 +90,12 @@ 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" ] && { - apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel - } || { - # 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 + apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel 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 f1367a9..421f8c5 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -115,7 +115,6 @@ if [ "$overlay" ]; then rm /etc/asound.conf rm /var/lib/alsa/asound.state -: <<\EOF kernel_ver=$(get_kernel_version) # echo kernel_ver=$kernel_ver @@ -131,7 +130,6 @@ if [ "$overlay" ]; then fi done fi -EOF #make sure the driver loads correctly dtoverlay $overlay || true From 26cfab95cff2af83a64e9d89dd15de913cebf233 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 26 Apr 2020 23:27:54 +0100 Subject: [PATCH 02/32] suppress "this statement may fall through" warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The semi-colon is needed, to prevent the comment being parsed as part of the "if {...}" statement. The warning looks like this: seeed-voicecard/wm8960.c: In function ‘wm8960_hw_params’: seeed-voicecard/wm8960.c:752:6: warning: this statement may fall through [-Wimplicit-fallthrough=] 752 | if ((iface & 0x3) != 0) { | ^ seeed-voicecard/wm8960.c:757:2: note: here 757 | default: | ^~~~~~~ --- wm8960.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wm8960.c b/wm8960.c index f26f59b..c2975e1 100644 --- a/wm8960.c +++ b/wm8960.c @@ -752,7 +752,8 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, if ((iface & 0x3) != 0) { iface |= 0x000c; break; - } + }; + /* fall through */ default: dev_err(codec->dev, "unsupported width %d\n", params_width(params)); From 6f03b0df864682dc3804fc12eaab2789d192e574 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 26 Apr 2020 23:39:25 +0100 Subject: [PATCH 03/32] suppress another "this statement may fall through" warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The whole warning is quite long but looks like this: CC [M] seeed-voicecard/ac108.o In file included from ./include/linux/printk.h:331, from ./include/linux/kernel.h:15, from ./include/linux/list.h:9, from ./include/linux/module.h:12, from seeed-voicecard/ac108.c:15: seeed-voicecard/ac108.c: In function ‘ac108_set_fmt’: ./include/linux/dynamic_debug.h:122:52: warning: this statement may fall through [-Wimplicit-fallthrough=] 122 | #define __dynamic_func_call(id, fmt, func, ...) do { \ | ^ ./include/linux/dynamic_debug.h:143:2: note: in expansion of macro ‘__dynamic_func_call’ 143 | __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ ./include/linux/dynamic_debug.h:157:2: note: in expansion of macro ‘_dynamic_func_call’ 157 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \ | ^~~~~~~~~~~~~~~~~~ ./include/linux/device.h:1795:2: note: in expansion of macro ‘dynamic_dev_dbg’ 1795 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~~~~~~~ seeed-voicecard/ac108.c:866:4: note: in expansion of macro ‘dev_dbg’ 866 | dev_dbg(dai->dev, "used as slave when AC101 is master\n"); | ^~~~~~~ seeed-voicecard/ac108.c:868:2: note: here 868 | case SND_SOC_DAIFMT_CBS_CFS: /*AC108 Slave*/ | ^~~~ --- ac108.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ac108.c b/ac108.c index cd20547..d202dc3 100644 --- a/ac108.c +++ b/ac108.c @@ -865,6 +865,7 @@ static int ac108_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { /* TODO: Both cpu_dai and codec_dai(AC108) be set as slave in DTS */ dev_dbg(dai->dev, "used as slave when AC101 is master\n"); } + /* fall through */ case SND_SOC_DAIFMT_CBS_CFS: /*AC108 Slave*/ dev_dbg(dai->dev, "AC108 set to work as Slave\n"); /** From b80f7bc89bfdcab601f0ea5c00f657a01b4119e9 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 27 Apr 2020 01:04:16 +0100 Subject: [PATCH 04/32] use the kernel's way of suppressing fallthrough See include/linux/compiler_attributes.h: /* * Add the pseudo keyword 'fallthrough' so case statement blocks * must end with any of these keywords: * break; * fallthrough; * goto