bump
This commit is contained in:
parent
912e427243
commit
fd2df1ece5
|
|
@ -32,6 +32,23 @@ mkdir -p "$OVERLAYS"
|
||||||
|
|
||||||
RESTORE_HELPER="/usr/local/sbin/barepi-audio-restore"
|
RESTORE_HELPER="/usr/local/sbin/barepi-audio-restore"
|
||||||
RESTORE_SERVICE="/etc/systemd/system/barepi-audio-restore.service"
|
RESTORE_SERVICE="/etc/systemd/system/barepi-audio-restore.service"
|
||||||
|
MODULES_LOAD_FILE="/etc/modules-load.d/barepi-audio.conf"
|
||||||
|
NEED_KERNEL_REBOOT=0
|
||||||
|
|
||||||
|
have_audio_modules() {
|
||||||
|
modinfo snd-soc-simple-card >/dev/null 2>&1 \
|
||||||
|
&& modinfo snd-soc-tlv320aic31xx >/dev/null 2>&1 \
|
||||||
|
&& modinfo snd-soc-ics43432 >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
install_pkg_if_available() {
|
||||||
|
local pkg="$1"
|
||||||
|
if apt-cache show "$pkg" >/dev/null 2>&1; then
|
||||||
|
apt-get install -y "$pkg"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
echo "=== barepi audio setup ==="
|
echo "=== barepi audio setup ==="
|
||||||
echo "User: $TARGET_USER Home: $TARGET_HOME"
|
echo "User: $TARGET_USER Home: $TARGET_HOME"
|
||||||
|
|
@ -43,6 +60,48 @@ echo ""
|
||||||
echo "[1/7] Installing packages..."
|
echo "[1/7] Installing packages..."
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y alsa-utils libasound2-plugins swh-plugins i2c-tools device-tree-compiler
|
apt-get install -y alsa-utils libasound2-plugins swh-plugins i2c-tools device-tree-compiler
|
||||||
|
|
||||||
|
if ! have_audio_modules; then
|
||||||
|
KERNEL_MODULES_PKG="linux-modules-$(uname -r)"
|
||||||
|
if install_pkg_if_available "$KERNEL_MODULES_PKG"; then
|
||||||
|
echo " Installed $KERNEL_MODULES_PKG"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! have_audio_modules && [ -r /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
if [ "${ID:-}" = "ubuntu" ] && install_pkg_if_available linux-image-raspi-6.8; then
|
||||||
|
install_pkg_if_available linux-headers-raspi-6.8 || true
|
||||||
|
NEED_KERNEL_REBOOT=1
|
||||||
|
echo " Installed Ubuntu raspi 6.8 kernel fallback for ASoC modules."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! have_audio_modules; then
|
||||||
|
if [ "$NEED_KERNEL_REBOOT" -eq 1 ]; then
|
||||||
|
echo " Current kernel still lacks the required ASoC modules; continuing because a compatible kernel was installed." >&2
|
||||||
|
echo " Reboot into the new kernel after setup completes." >&2
|
||||||
|
else
|
||||||
|
echo "Missing required audio kernel modules: snd-soc-simple-card, snd-soc-tlv320aic31xx, snd-soc-ics43432" >&2
|
||||||
|
echo "Install a raspi kernel package that provides them, then rerun this script." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "i2c-dev"
|
||||||
|
for mod in snd-soc-simple-card snd-soc-tlv320aic31xx snd-soc-ics43432; do
|
||||||
|
if [ "$NEED_KERNEL_REBOOT" -eq 1 ] || modinfo "$mod" >/dev/null 2>&1; then
|
||||||
|
echo "$mod"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
} > "$MODULES_LOAD_FILE"
|
||||||
|
|
||||||
|
modprobe i2c-dev || true
|
||||||
|
modprobe snd-soc-simple-card || true
|
||||||
|
modprobe snd-soc-tlv320aic31xx || true
|
||||||
|
modprobe snd-soc-ics43432 || true
|
||||||
|
|
||||||
echo " Done."
|
echo " Done."
|
||||||
|
|
||||||
# 2. Compile and install device tree overlay
|
# 2. Compile and install device tree overlay
|
||||||
|
|
@ -143,10 +202,10 @@ cat > "$DTS" << 'DTS_EOF'
|
||||||
};
|
};
|
||||||
|
|
||||||
fragment@3 {
|
fragment@3 {
|
||||||
target = <&sound>;
|
target-path = "/";
|
||||||
__overlay__ {
|
__overlay__ {
|
||||||
|
sound {
|
||||||
compatible = "simple-audio-card";
|
compatible = "simple-audio-card";
|
||||||
i2s-controller = <&i2s_clk_producer>;
|
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
#size-cells = <0>;
|
#size-cells = <0>;
|
||||||
simple-audio-card,name = "barepi-audio";
|
simple-audio-card,name = "barepi-audio";
|
||||||
|
|
@ -156,14 +215,14 @@ cat > "$DTS" << 'DTS_EOF'
|
||||||
simple-audio-card,dai-link@0 {
|
simple-audio-card,dai-link@0 {
|
||||||
reg = <0>;
|
reg = <0>;
|
||||||
format = "i2s";
|
format = "i2s";
|
||||||
bitclock-master = <&dailink0_master>;
|
bitclock-master = <&cpu0>;
|
||||||
frame-master = <&dailink0_master>;
|
frame-master = <&cpu0>;
|
||||||
|
|
||||||
dailink0_master: cpu {
|
cpu0: cpu {
|
||||||
sound-dai = <&i2s_clk_producer>;
|
sound-dai = <&i2s_clk_producer>;
|
||||||
};
|
};
|
||||||
|
|
||||||
codec {
|
codec0: codec {
|
||||||
sound-dai = <&dac_codec>;
|
sound-dai = <&dac_codec>;
|
||||||
system-clock-frequency = <1536000>;
|
system-clock-frequency = <1536000>;
|
||||||
};
|
};
|
||||||
|
|
@ -172,19 +231,20 @@ cat > "$DTS" << 'DTS_EOF'
|
||||||
simple-audio-card,dai-link@1 {
|
simple-audio-card,dai-link@1 {
|
||||||
reg = <1>;
|
reg = <1>;
|
||||||
format = "i2s";
|
format = "i2s";
|
||||||
bitclock-master = <&dailink1_master>;
|
bitclock-master = <&cpu1>;
|
||||||
frame-master = <&dailink1_master>;
|
frame-master = <&cpu1>;
|
||||||
|
|
||||||
dailink1_master: cpu {
|
cpu1: cpu {
|
||||||
sound-dai = <&i2s_clk_producer>;
|
sound-dai = <&i2s_clk_producer>;
|
||||||
};
|
};
|
||||||
|
|
||||||
codec {
|
codec1: codec {
|
||||||
sound-dai = <&mic_codec>;
|
sound-dai = <&mic_codec>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
DTS_EOF
|
DTS_EOF
|
||||||
dtc -@ -I dts -O dtb -o "$OVERLAYS/i2s-audio.dtbo" "$DTS"
|
dtc -@ -I dts -O dtb -o "$OVERLAYS/i2s-audio.dtbo" "$DTS"
|
||||||
|
|
@ -686,10 +746,12 @@ fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Done ==="
|
echo "=== Done ==="
|
||||||
if [ "$CHANGED" -eq 1 ]; then
|
if [ "$CHANGED" -eq 1 ]; then
|
||||||
echo "config.txt was modified — reboot to load the overlay/reset config."
|
echo "config.txt was modified."
|
||||||
else
|
|
||||||
echo "config.txt unchanged. Reboot if this is a first-time setup."
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$NEED_KERNEL_REBOOT" -eq 1 ]; then
|
||||||
|
echo "A compatible Ubuntu raspi kernel was installed."
|
||||||
|
fi
|
||||||
|
echo "Reboot to load the updated overlay and audio kernel/module state."
|
||||||
echo "Speaker routing defaults and mic GPIO defaults will be restored automatically after boot."
|
echo "Speaker routing defaults and mic GPIO defaults will be restored automatically after boot."
|
||||||
echo "Manual speaker check/adjust: $TARGET_HOME/volume.sh"
|
echo "Manual speaker check/adjust: $TARGET_HOME/volume.sh"
|
||||||
echo "Manual mic test: $TARGET_HOME/test-mics.sh"
|
echo "Manual mic test: $TARGET_HOME/test-mics.sh"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user