Compare commits

...

37 commits

Author SHA1 Message Date
Hin-Tak Leung
dd94d86a09 Additional debug code to where the *_trigger()'s finish.
Conflicts:
	ac108.c
       modified:   seeed-voicecard.c
2021-04-27 15:54:08 +01:00
Hin-Tak Leung
267152505b better fix for older compiler than gcc 5
Reference: kernel's include/linux/compiler_attributes.h
2020-12-04 23:20:42 +00:00
Hin-Tak Leung
28b9319379 older compiler than gcc 5 does not have __has_attribute 2020-12-04 22:05:28 +00:00
Hin-Tak Leung
71321134f6 update OVERLAYS location for LibreELEC 2020-12-03 10:02:40 +00:00
Hin-Tak Leung
796adb3f08 update CONFIG location for LibreELEC 2020-12-03 09:50:43 +00:00
Hin-Tak Leung
c236752f91 stop systemd service before diabling in uninstall, taken from upstream c1c2e5ca 2020-12-02 15:57:10 +00:00
turmary
85160dac38 Remove: useless dd message in get_kernel_version() 2020-12-02 15:57:10 +00:00
Hin-Tak Leung
d9fdfac988 Adding missing shebang
This script has no bash-ism, so /bin/sh (dash on Debian/Ubuntu) is fine.
2020-12-02 15:57:10 +00:00
Hin-Tak Leung
5c311c4031 updating for Ubuntu location of dkms-generated kernel modules
Conflicts:
	uninstall.sh
2020-12-02 15:57:10 +00:00
Hin-Tak Leung
0248378f7f updating non-standard PATH for Ubuntu in uninstall.sh 2020-12-02 15:57:10 +00:00
Hin-Tak Leung
fc77a4c00a update check_kernel_headers() for Ubuntu header packages 2020-12-02 15:57:10 +00:00
Hin-Tak Leung
7e4917be89 Add reference to Ubuntu kernel package names
Signed-off-by: Hin-Tak Leung <htl10@users.sourceforge.net>
2020-12-02 15:57:10 +00:00
Hin-Tak Leung
f512fe32bd make the config un-install directory configurable, for Ubuntu 2020-12-02 15:57:10 +00:00
Hin-Tak Leung
99b29b06c1 make the overlay un-install directory configurable, for Ubuntu 2020-12-02 15:57:10 +00:00
Hin-Tak Leung
37cd69fc1a Allow kernel images to be elsewhere - Ubuntu kernel is not at Raspbian location 2020-12-02 15:57:10 +00:00
Hin-Tak Leung
408f71d2f4 adding new ubuntu-prerequisite.sh script
notes and typo
2020-12-02 15:57:10 +00:00
Hin-Tak Leung
cddfe7b15e /opt/vc/bin is not on standard $PATH on Ubuntu 2020-12-02 15:57:10 +00:00
Hin-Tak Leung
f4cb786a5b adding advice to run ./ubuntu-prerequisite.sh in install.sh 2020-12-02 15:46:31 +00:00
Hin-Tak Leung
115186c53c Ubuntu kernels is not at /boot/kernel.img. Revisit for Raspbian
check running kernel agree with installed kernel, and ask the user to reboot before continue

Ubuntu kernels are not installed at /boot/kernel.img
2020-12-02 15:45:24 +00:00
Hin-Tak Leung
4e29eb8f51 make the config file configurable, for Ubuntu 2020-12-02 15:45:13 +00:00
Hin-Tak Leung
de0e478df4 make the overlay install directory configurable, for Ubuntu 2020-12-02 15:45:04 +00:00
Hin-Tak Leung
f716cece88 spelling 2020-12-02 15:44:45 +00:00
Hin-Tak Leung
7958dd2076 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
2020-12-02 15:40:46 +00:00
Hin-Tak Leung
64a207940f Use logic from raspi-config to determine if bcm2835 routing option exists or not - 3 merged commits
Number 1:
mask amixer failures - some user have different numbered / multiple audio devices

Number 2:

remove "-c 1" and also protect with test for older kernel / alsa

The "-c 1" was simply wrong. The default (-c 0) sound device of
older kernel / alsa has a numid=3 selector for auto vs headphone vs hdmi .
Newer kernel simply has multiple devices. Also, headphone is -c 0 .

$ amixer contents
numid=2,iface=MIXER,name='Headphone Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=1,iface=MIXER,name='Headphone Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0
  : values=-2000
  | dBscale-min=-102.39dB,step=0.01dB,mute=1

TODO: For now, broadly dividing by kernel v4.x vs v5.x is good enough, but
it would be nice to find out when / which kernel /alsa this is relevant.

closes https://github.com/respeaker/seeed-voicecard/issues/240

Number 3:

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 <simon@raspberrypi.org>  Mon, 20 Jan 2020 11:38:37 +0000
2020-12-02 15:38:06 +00:00
Hin-Tak Leung
35bc08973c likely v5 kernels behave like late 4.x, regarding dynamic dtoverlay; untested, and possibly revisit. 2020-12-02 15:38:06 +00:00
Claus-Justus Heine
bafb3c85aa Support ubuntu-server with /boot/firmware/overlays 2020-12-02 15:32:43 +00:00
Hin-Tak Leung
556ed21066 rebuilt dtbo on current Raspbian 2020-12-02 15:30:48 +00:00
Hin-Tak Leung
f4cc5722d0 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.
2020-12-02 15:30:31 +00:00
Hin-Tak Leung
49f1135da8 Use pr_warn() for recoverable errors, not pr_info() 2020-12-02 15:21:14 +00:00
Hin-Tak Leung
6244e5d618 Use pr_info() for just routine information, not pr_warn() 2020-12-02 15:20:53 +00:00
Hin-Tak Leung
5ce09f2095 Use pr_info() for regular information 2020-12-02 15:20:33 +00:00
Hin-Tak Leung
140a220946 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
2020-12-02 15:16:13 +00:00
Hin-Tak Leung
31bea0c3be compatibility - fallthrough' pseudo keyword was introduced in v5.4
commit 294f69e662d1570703e9b56e95be37a9fd3afba5
Author: Joe Perches <joe@perches.com>
Date:   Sat Oct 5 09:46:42 2019 -0700

    compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use
2020-12-02 15:09:06 +00:00
Hin-Tak Leung
b80f7bc89b 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 <label>;
 *   return [expression];
 *
 *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
 */
-if __has_attribute(__fallthrough__)
- define fallthrough                    __attribute__((__fallthrough__))
-else
- define fallthrough                    do {} while (0)  /* fallthrough */
-endif
2020-12-02 15:09:06 +00:00
Hin-Tak Leung
6f03b0df86 suppress another "this statement may fall through" warning
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*/
      |  ^~~~
2020-12-02 15:09:06 +00:00
Hin-Tak Leung
26cfab95cf suppress "this statement may fall through" warning
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:
      |  ^~~~~~~
2020-12-02 15:09:06 +00:00
Hin-Tak Leung
8497972d65 Don't force kernel downgrade
Revert "Fix: try to use a specific version kernel & headers"

This reverts commit ae32476755.

Conflicts:
	install.sh
2020-04-27 00:16:44 +01:00
15 changed files with 167 additions and 78 deletions

17
ac101.c
View file

@ -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;
}
@ -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 */
@ -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<<AIF1_MSTR_MOD);
break;
#else
pr_warn("AC108 as Master\n");
pr_info("AC108 as Master\n");
#endif
case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & frm slave, ap is master*/
pr_warn("AC101 as Slave\n");
pr_info("AC101 as Slave\n");
reg_val |= (0x1<<AIF1_MSTR_MOD);
break;
default:
@ -1286,6 +1286,9 @@ int ac101_trigger(struct snd_pcm_substream *substream, int cmd,
default:
ret = -EINVAL;
}
AC101_DBG("stream=%s cmd=%d;finished %d\n",
snd_pcm_stream_str(substream),
cmd, ret);
return ret;
}

11
ac108.c
View file

@ -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");
}
fallthrough;
case SND_SOC_DAIFMT_CBS_CFS: /*AC108 Slave*/
dev_dbg(dai->dev, "AC108 set to work as Slave\n");
/**
@ -1087,6 +1088,10 @@ static int ac108_trigger(struct snd_pcm_substream *substream, int cmd,
__ret:
spin_unlock_irqrestore(&ac10x->lock, flags);
dev_dbg(dai->dev, "%s() stream=%s cmd=%d; finished %d\n",
__FUNCTION__,
snd_pcm_stream_str(substream),
cmd, ret);
return ret;
}
@ -1435,8 +1440,8 @@ static int ac108_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i
if (of_property_read_u32(np, "tdm-chips-count", &val)) val = 1;
ac10x->tdm_chips_cnt = val;
pr_err(" ac10x i2c_id number: %d\n", index);
pr_err(" ac10x data protocol: %d\n", ac10x->data_protocol);
pr_info(" ac10x i2c_id number: %d\n", index);
pr_info(" ac10x data protocol: %d\n", ac10x->data_protocol);
ac10x->i2c[index] = i2c;
ac10x->i2cmap[index] = devm_regmap_init_i2c(i2c, &ac108_regmap);
@ -1458,7 +1463,7 @@ static int ac108_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i
ac10x_fill_regcache(&i2c->dev, ac10x->i2cmap[index]);
ac10x->codec_cnt++;
pr_err(" ac10x codec count : %d\n", ac10x->codec_cnt);
pr_info(" ac10x codec count : %d\n", ac10x->codec_cnt);
ret = sysfs_create_group(&i2c->dev.kobj, &ac108_debug_attr_group);
if (ret) {

View file

@ -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'

View file

@ -1,3 +1,4 @@
#!/bin/sh
#dtoverlay -r seeed-2mic-voicecard
DTC_FLAGS="-b 0 -Wno-unit_address_vs_reg -I dts -O dtb"

View file

@ -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
@ -33,14 +31,22 @@ fi
# - check for /boot/overlays
# - dtparam and dtoverlay is available
errorFound=0
if [ ! -d /boot/overlays ] ; then
echo "/boot/overlays not found or not a directory" 1>&2
# Try Raspbian, Ubuntu, then LibreELEC location for OVERLAYS:
OVERLAYS=/boot/overlays
[ -d /boot/firmware/overlays ] && OVERLAYS=/boot/firmware/overlays
[ -d /flash/overlays ] && OVERLAYS=/flash/overlays
if [ ! -d $OVERLAYS ] ; then
echo "$OVERLAYS not found or not a directory" 1>&2
errorFound=1
fi
# should we also check for alsactl and amixer used in seeed-voicecard?
PATH=$PATH:/opt/vc/bin
for cmd in dtparam dtoverlay ; do
if ! which $cmd &>/dev/null ; then
echo "$cmd not found" 1>&2
echo "You may need to run ./ubuntu-prerequisite.sh"
errorFound=1
fi
done
@ -63,8 +69,9 @@ 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; }')
_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
@ -76,10 +83,14 @@ 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"
echo " Not found *** coressponding *** kernel headers with apt-get."
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."
@ -92,43 +103,15 @@ 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
# 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
@ -143,7 +126,8 @@ 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="${base_ver}+ ${base_ver}-v7+ ${base_ver}-v7l+"
kernels=$(uname -r)
function install_module {
local _i
@ -177,9 +161,9 @@ install_module "./" "seeed-voicecard"
# install dtbos
cp seeed-2mic-voicecard.dtbo /boot/overlays
cp seeed-4mic-voicecard.dtbo /boot/overlays
cp seeed-8mic-voicecard.dtbo /boot/overlays
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
@ -194,14 +178,20 @@ grep -q "^snd-soc-ac108$" /etc/modules || \
grep -q "^snd-soc-wm8960$" /etc/modules || \
echo "snd-soc-wm8960" >> /etc/modules
#set dtoverlays
sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' /boot/config.txt || true
grep -q "^dtoverlay=i2s-mmap$" /boot/config.txt || \
echo "dtoverlay=i2s-mmap" >> /boot/config.txt
#set dtoverlays - Raspbian:
CONFIG=/boot/config.txt
# Ubuntu:
[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt
# LibreELEC:
[ -f /flash/distroconfig.txt ] && CONFIG=/flash/distroconfig.txt
sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' $CONFIG || true
grep -q "^dtoverlay=i2s-mmap$" $CONFIG || \
echo "dtoverlay=i2s-mmap" >> $CONFIG
grep -q "^dtparam=i2s=on$" /boot/config.txt || \
echo "dtparam=i2s=on" >> /boot/config.txt
grep -q "^dtparam=i2s=on$" $CONFIG || \
echo "dtparam=i2s=on" >> $CONFIG
#install config files
mkdir /etc/voicecard || true

View file

@ -13,7 +13,7 @@
};
fragment@1 {
target-path = "/clocks";
target-path = "/";
__overlay__ {
ac108_mclk: codec-mclk {
compatible = "fixed-clock";

Binary file not shown.

View file

@ -13,7 +13,7 @@
};
fragment@1 {
target-path = "/clocks";
target-path = "/";
__overlay__ {
ac10x_mclk: codec-mclk {
compatible = "fixed-clock";

Binary file not shown.

View file

@ -21,13 +21,21 @@
# THE SOFTWARE.
set -x
exec 1>/var/log/$(basename $0).log 2>&1
#exec 1>/var/log/$(basename $0).log 2>&1
export PATH=$PATH:/opt/vc/bin
# Try Raspbian, Ubuntu, then LibreELEC location for OVERLAYS:
OVERLAYS=/boot/overlays
[ -d /boot/firmware/overlays ] && OVERLAYS=/boot/firmware/overlays
[ -d /flash/overlays ] && OVERLAYS=/flash/overlays
#enable i2c interface
dtparam i2c_arm=on
dtparam -d $OVERLAYS i2c_arm=on
modprobe i2c-dev
#enable spi interface
dtparam spi=on
dtparam -d $OVERLAYS spi=on
_VER_RUN=
function get_kernel_version() {
@ -43,7 +51,13 @@ function get_kernel_version() {
return 0
}
# Raspbian:
CONFIG=/boot/config.txt
# Ubuntu:
[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt
# LibreELEC:
[ -f /flash/distroconfig.txt ] && CONFIG=/flash/distroconfig.txt
get_overlay() {
ov=$1
if grep -q -E "^dtoverlay=$ov" $CONFIG; then
@ -115,13 +129,12 @@ if [ "$overlay" ]; then
rm /etc/asound.conf
rm /var/lib/alsa/asound.state
: <<\EOF
kernel_ver=$(get_kernel_version)
kernel_ver=$(uname -r) # get_kernel_version)
# echo kernel_ver=$kernel_ver
# TODO: dynamic dtoverlay Bug of v4.19.x
# no DT node phandle inserted.
if [[ "$kernel_ver" =~ ^4\.19.*$ ]]; then
if [[ "$kernel_ver" =~ ^4\.19.*$ || "$kernel_ver" =~ ^5\.*$ ]]; then
for i in $RPI_HATS; do
if [ "$i" == "$overlay" ]; then
do_overlay $overlay 0
@ -131,9 +144,8 @@ if [ "$overlay" ]; then
fi
done
fi
EOF
#make sure the driver loads correctly
dtoverlay $overlay || true
dtoverlay -d $OVERLAYS $overlay || true
echo "create $overlay asound configure file"
@ -145,5 +157,12 @@ fi
alsactl restore
#Force 3.5mm ('headphone') jack
amixer cset numid=3 1
# 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

View file

@ -240,6 +240,10 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd
ret = -EINVAL;
}
dev_dbg(rtd->card->dev, "%s() stream=%s cmd=%d play:%d, capt:%d;finished %d\n",
__FUNCTION__, snd_pcm_stream_str(substream), cmd,
dai->playback_active, dai->capture_active, ret);
return ret;
}

View file

@ -15,6 +15,18 @@
#define __NO_SND_SOC_CODEC_DRV 0
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
#ifndef __has_attribute
# define __has_attribute(x) __GCC4_has_attribute_##x
# define __GCC4_has_attribute___fallthrough__ 0
#endif
#if __has_attribute(__fallthrough__)
# define fallthrough __attribute__((__fallthrough__))
#else
# define fallthrough do {} while (0) /* fallthrough */
#endif
#endif
#if __NO_SND_SOC_CODEC_DRV
#define codec component
#define snd_soc_codec snd_soc_component

37
ubuntu-prerequisite.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
# Copyright (c) Hin-Tak Leung 2020
#
# Overview:
# This script compiles and install the Broadcom VideoCore tools,
# configure the dynamic loader for the non-standard library location,
# and update the loader cache.
#
# A few steps explicitly requires root privilege, which are
# marked with "sudo". The rest is just checking for duplicate/previous
# action.
#
# This derived from my command history on ubuntu 20.04.1 .YMMV
sudo apt install -y git gcc make alsa-utils cmake
git clone git://github.com/raspberrypi/userland.git
pushd userland/
arch=$(uname -m)
if [[ "$arch" =~ aarch64 ]]; then
./buildme --aarch64
else
./buildme
fi
# ./buildme already includes "sudo make install" at the end
popd
# matches Raspbian's location:
if [ ! -f /etc/ld.so.conf.d/00-vmcs.conf ] ; then
echo "/opt/vc/lib" | sudo tee -a /etc/ld.so.conf.d/00-vmcs.conf
sudo ldconfig -v
else
echo "/etc/ld.so.conf.d/00-vmcs.conf exists - no need to update ld.cache!"
fi

View file

@ -13,7 +13,13 @@ fi
uname_r=$(uname -r)
# Raspbian:
CONFIG=/boot/config.txt
# Ubuntu:
[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt
# LibreELEC:
[ -f /flash/distroconfig.txt ] && CONFIG=/flash/distroconfig.txt
get_overlay() {
ov=$1
if grep -q -E "^dtoverlay=$ov" $CONFIG; then
@ -51,18 +57,26 @@ 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
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
# Try Raspbian, Ubuntu, then LibreELEC location for OVERLAYS:
OVERLAYS=/boot/overlays
[ -d /boot/firmware/overlays ] && OVERLAYS=/boot/firmware/overlays
[ -d /flash/overlays ] && OVERLAYS=/flash/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
echo "disabled seeed-voicecard.service "
systemctl stop seeed-voicecard.service
systemctl disable seeed-voicecard.service
echo "remove seeed-voicecard"
@ -73,9 +87,12 @@ echo "remove dkms"
rm -rf /var/lib/dkms/seeed-voicecard || true
echo "remove kernel modules"
rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-wm8960.ko || true
rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-ac108.ko || true
rm /lib/modules/${uname_r}/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true
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

View file

@ -753,6 +753,7 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
iface |= 0x000c;
break;
}
fallthrough;
default:
dev_err(codec->dev, "unsupported width %d\n",
params_width(params));