Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions install/hardware/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ run_logged "$OMARCHY_INSTALL/hardware/asus/fix-z13-touchpad.sh"
run_logged "$OMARCHY_INSTALL/hardware/framework/qmk-hid.sh"

run_logged "$OMARCHY_INSTALL/hardware/apple/fix-spi-keyboard.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-cs4208-audio.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-suspend-nvme.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-t2.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-brcmfmac-supplicant.sh"
Expand Down
14 changes: 14 additions & 0 deletions install/hardware/apple/fix-cs4208-audio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Enable speakers on 12-inch MacBooks (MacBook9,1 / 2016 and MacBook10,1 / 2017).
# Mainline snd_hda_codec_cs420x detects the CS4208 but never runs the macOS
# init that powers the speaker amplifier, so PipeWire plays to a silent analog
# path. The out-of-tree module replays that init.
# MacBook8,1 (2015) is not supported by this driver.
# https://github.com/leifliddy/macbook12-audio-driver
# https://github.com/basecamp/omarchy/issues/2101

product_name="${OMARCHY_MACBOOK12_AUDIO_MODEL:-$(cat /sys/class/dmi/id/product_name 2>/dev/null)}"
if [[ $product_name == "MacBook9,1" || $product_name == "MacBook10,1" ]]; then
echo "Detected 12-inch MacBook with CS4208 audio"

omarchy-pkg-add macbook12-audio-driver-dkms
fi
Comment on lines +1 to +14
1 change: 1 addition & 0 deletions install/omarchy-other.packages
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ linux-headers
linux-ptl
linux-ptl-headers
macbook12-spi-driver-dkms
macbook12-audio-driver-dkms
nvidia-580xx-dkms
nvidia-dkms
nvidia-open-dkms
Expand Down
2 changes: 1 addition & 1 deletion manual/44-mac-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ It is necessary to disable Apple's Secure Boot in order to boot the bootable USB
3. Select the orange EFI Boot device
4. Proceed with the [install as normal](02-getting-started.md)

The installer detects Mac hardware and applies the needed fixes automatically: Broadcom Wi-Fi drivers and firmware, the SPI keyboard driver on the MacBook models that need it, and an NVMe suspend fix for those same models.
The installer detects Mac hardware and applies the needed fixes automatically: Broadcom Wi-Fi drivers and firmware, the SPI keyboard driver on the MacBook models that need it, an NVMe suspend fix for those same models, and the CS4208 speaker driver on the 12-inch MacBook (2016 and 2017).

### Known Limitations

Expand Down
23 changes: 23 additions & 0 deletions migrations/1790562029.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
echo "Install the CS4208 speaker driver on 12-inch MacBooks"

# Fresh installs get this from install/hardware/apple/fix-cs4208-audio.sh.
# Existing MacBook9,1 / MacBook10,1 installs still have silent speakers:
# mainline detects the codec and PipeWire plays, but the speaker amp is never
# enabled. Skip machines that already have the packaged module or the same
# DKMS driver installed by hand.

product_name="${OMARCHY_MACBOOK12_AUDIO_MODEL:-$(cat /sys/class/dmi/id/product_name 2>/dev/null)}"
if [[ $product_name != "MacBook9,1" && $product_name != "MacBook10,1" ]]; then
exit 0
fi

if omarchy-pkg-present macbook12-audio-driver-dkms; then
exit 0
fi

if dkms status 2>/dev/null | grep -q '^macbook12-audio-driver/'; then
exit 0
fi

omarchy-pkg-add macbook12-audio-driver-dkms
omarchy-state set reboot-required
Comment on lines +1 to +23
118 changes: 118 additions & 0 deletions test/shell.d/cs4208-audio-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

leaf="$ROOT/install/hardware/apple/fix-cs4208-audio.sh"
all="$ROOT/install/hardware/all.sh"
other_packages="$ROOT/install/omarchy-other.packages"
migration="$ROOT/migrations/1790562029.sh"

grep -q 'apple/fix-cs4208-audio.sh' "$all" ||
fail "the CS4208 audio fix runs during hardware setup"
grep -qx 'macbook12-audio-driver-dkms' "$other_packages" ||
fail "the ISO caches the CS4208 speaker driver"
grep -Fq 'MacBook9,1' "$leaf" && grep -Fq 'MacBook10,1' "$leaf" ||
fail "the CS4208 leaf matches the 12-inch MacBooks"
pass "the CS4208 audio fix is wired into setup"

test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT

stub_bin="$test_tmp/bin"
calls="$test_tmp/calls.log"
mkdir -p "$stub_bin"

cat >"$stub_bin/omarchy-pkg-add" <<'SH'
#!/bin/bash

printf 'omarchy-pkg-add' >>"$TEST_LOG"
printf '\t%s' "$@" >>"$TEST_LOG"
printf '\n' >>"$TEST_LOG"
SH

cat >"$stub_bin/omarchy-pkg-present" <<'SH'
#!/bin/bash

(( ${CS4208_PKG_PRESENT:-0} == 1 ))
SH

cat >"$stub_bin/omarchy-state" <<'SH'
#!/bin/bash

printf 'omarchy-state' >>"$TEST_LOG"
printf '\t%s' "$@" >>"$TEST_LOG"
printf '\n' >>"$TEST_LOG"
SH

cat >"$stub_bin/dkms" <<'SH'
#!/bin/bash

if (( ${CS4208_DKMS_INSTALLED:-0} == 1 )); then
# The name upstream's dkms.conf registers, which is what dkms status prints.
echo 'macbook12-audio-driver/0.1, 7.1.8-arch1-3, x86_64: installed (Original modules exist)'
exit 0
fi
echo 'macbook12-spi-driver/0+git.315: added'
SH

chmod +x "$stub_bin"/*

run_leaf() {
local model="$1"
: >"$calls"
PATH="$stub_bin:$PATH" TEST_LOG="$calls" \
OMARCHY_MACBOOK12_AUDIO_MODEL="$model" \
bash -eE -o pipefail -c 'source "$1"' bash "$leaf"
}

run_leaf "MacBook10,1" >/dev/null
grep -Fq $'omarchy-pkg-add\tmacbook12-audio-driver-dkms' "$calls" ||
fail "a 2017 12-inch MacBook gets the CS4208 driver" "$(cat "$calls")"
pass "a 2017 12-inch MacBook gets the CS4208 driver"

run_leaf "MacBook9,1" >/dev/null
grep -Fq $'omarchy-pkg-add\tmacbook12-audio-driver-dkms' "$calls" ||
fail "a 2016 12-inch MacBook gets the CS4208 driver" "$(cat "$calls")"
pass "a 2016 12-inch MacBook gets the CS4208 driver"

run_leaf "MacBook8,1" >/dev/null
[[ ! -s $calls ]] || fail "the 2015 12-inch MacBook is left alone" "$(cat "$calls")"
pass "the 2015 12-inch MacBook is left alone"

run_leaf "MacBookPro14,1" >/dev/null
[[ ! -s $calls ]] || fail "a MacBook Pro is left alone" "$(cat "$calls")"
pass "a MacBook Pro is left alone"

run_leaf "XPS 13 9310" >/dev/null
[[ ! -s $calls ]] || fail "non-Apple hardware is left alone" "$(cat "$calls")"
pass "non-Apple hardware is left alone"

run_migration() {
: >"$calls"
PATH="$stub_bin:$PATH" TEST_LOG="$calls" \
OMARCHY_MACBOOK12_AUDIO_MODEL="$1" \
CS4208_PKG_PRESENT="${2:-0}" \
CS4208_DKMS_INSTALLED="${3:-0}" \
bash -euo pipefail "$migration" >/dev/null
}

run_migration "MacBook10,1" 0 0
grep -Fq $'omarchy-pkg-add\tmacbook12-audio-driver-dkms' "$calls" ||
fail "the migration installs the CS4208 driver" "$(cat "$calls")"
grep -Fq $'omarchy-state\tset\treboot-required' "$calls" ||
fail "the migration asks for the reboot that loads the module" "$(cat "$calls")"
pass "the migration installs the CS4208 driver"

run_migration "MacBook10,1" 1 0
[[ ! -s $calls ]] || fail "the migration skips a machine that already has the package" "$(cat "$calls")"
pass "the migration skips a machine that already has the package"

run_migration "MacBook10,1" 0 1
[[ ! -s $calls ]] || fail "the migration skips a hand-installed DKMS driver" "$(cat "$calls")"
pass "the migration skips a hand-installed DKMS driver"

run_migration "MacBookPro14,1" 0 0
[[ ! -s $calls ]] || fail "the migration skips unrelated hardware" "$(cat "$calls")"
pass "the migration skips unrelated hardware"