Skip to content

Fix silent speakers on 12-inch MacBook (CS4208) - #12286

Closed
teomurgi wants to merge 3 commits into
omacom:quattrofrom
teomurgi:hardware-macbook12-audio
Closed

teomurgi wants to merge 3 commits into
omacom:quattrofrom
teomurgi:hardware-macbook12-audio

Conversation

@teomurgi

@teomurgi teomurgi commented Sep 17, 2026 •

Copy link
Copy Markdown

Problem

On the 12-inch MacBook (MacBook9,1 / MacBook10,1) the internal speakers are completely silent out of the box. Headphones work; every mixer looks fine; PipeWire shows an active sink — and nothing comes out. manual/44-mac-support.md currently lists "Sound is not functioning" as a known Mac limitation.

Additionally, once speakers do work, audio dies after every suspend/resume and only a reboot brings it back.

Root cause

The Cirrus Logic CS4208 codec's speaker amplifier is never powered by the in-tree driver: the HDA controller reports a generic PCI subsystem ID (8086:7270), so snd_hda_codec_cs420x matches no Apple fixup and probes with speaker_outs=0 (only the headphone jack 0x10 is wired through the analog DAC). Mainline has no working speaker config for this codec.

Four independent things are required for sound to actually come out — and stay out:

  1. The out-of-tree driver — leifliddy/macbook12-audio-driver replays the codec init (reverse-engineered from macOS) that powers the amp.
  2. The EFI startup chime un-muted in NVRAM. The firmware only energises the class-D speaker amp when it plays the boot chime; if the chime is muted the amp is never powered and no software fix can work.
  3. Software volume — the speaker path has no hardware amp volume (the codec's only analog amp is on the headphone path), so without a WirePlumber soft-mixer rule the volume slider does nothing.
  4. Suspend pinned to the freeze path — s2idle kills the speaker amp (see "Suspend" below).

Fix

Detect the two models and install all four pieces:

File What it does
install/hardware/apple/fix-macbook12-audio.sh Gates on MacBook9,1|MacBook10,1; clones + DKMS-builds the driver; installs the WirePlumber soft-mixer rule; clears the chime mute bit; installs a sleep.conf.d drop-in pinning suspend to freeze
install/hardware/all.sh Runs the fix during hardware setup
migrations/<ts>.sh Applies the same fix to existing installs (idempotent; removes the superseded d3cold service if present; sets reboot-required)
test/shell.d/macbook12-audio-test.sh 14 tests, all passing
manual/44-mac-support.md Documents the fix, the expected chime, and software volume

Suspend: what actually works (tested)

The obvious fix — pinning the codec out of D3cold, mirroring fix-suspend-nvme.sh — was implemented first and disproven on real hardware:

  • With d3cold_allowed=0 confirmed active at runtime, suspend/resume still killed the speakers. Post-resume codec state looked fully alive (stream attached, GPIO amp lines up, D0 power) yet no output.
  • A codec reinit attempt (echo 1 > /sys/class/sound/hwC0D0/reconfig) was refused — PipeWire holds the device.

What works: writing freeze to /sys/power/state keeps the amp alive across suspend — audio verified working after resume. These machines have no S3 (the kernel rejects freeze for /sys/power/mem_sleep), so the drop-in sets:

[Sleep]
SuspendState=freeze
MemorySleepMode=

The empty MemorySleepMode= forces systemd (≥254) onto the plain-freeze path instead of probing mem_sleep. Verified end-to-end: systemctl suspend → wake → speakers work.

Notes

  • The chime write must be a single write() on an O_WRONLY fd — piping through tee fails with Invalid argument (tee uses O_TRUNC and the firmware attribute word is rejected). The migration and install script both use that form.
  • Packaging tradeoff: the driver is installed by cloning and building against the running kernel (same template as PR Fix audio on MacBook Pro 2015-2017 (Cirrus Logic CS8409) #11620 for the CS8409). That runtime build downloads the matching kernel source tarball from kernel.org (~140 MB) at DKMS build time. If you'd rather host a macbook12-audio-driver-dkms package in the omarchy repo, the script collapses to a single omarchy-pkg-add — happy to switch.

Tested

Verified end-to-end on a MacBook10,1 running Omarchy 4.0.4 / kernel 7.2.5-3-omarchy: before the fix the sink ran at 91% with speaker_outs=0 and silence; after it the DKMS snd_hda_codec_cs420x loads from updates/dkms/, the chime is audible at boot, the internal speakers produce sound with working software volume, and audio survives suspend with the freeze drop-in. ./test/shell passes (6 unrelated pre-existing environment failures, unchanged with this commit stashed).

Refs #11619 (MacBook audio, CS8409) and #12217 (CS4208 woofers on MacBookPro12,1) — same class of model-gated hardware fix.

MacBook9,1 / MacBook10,1 use a Cirrus Logic CS4208 codec whose speaker
amplifier the in-tree driver never powers (generic PCI SSID 8086:7270, so
no Apple fixup applies and speaker_outs=0). Sound additionally requires the
EFI startup chime un-muted, since the firmware energises the speaker amp
only when playing the chime, and the codec must be kept out of D3cold or
audio dies after suspend.

- install/hardware/apple/fix-macbook12-audio.sh: gate on the two models,
  clone and DKMS-build leifliddy/macbook12-audio-driver, install the
  WirePlumber soft-mixer rule, clear the chime mute bit in NVRAM, and pin
  the audio codec out of D3cold via a systemd service (mirroring
  fix-suspend-nvme.sh).
- install/hardware/all.sh: run the fix during hardware setup.
- migrations/<ts>.sh: apply the same fix to existing installs (idempotent).
- test/shell.d/macbook12-audio-test.sh: detection/DKMS/softvol/chime/suspend.
- manual/44-mac-support.md: document the fix, the expected chime, and
  software volume.
Empirical testing on MacBook10,1 showed pinning the audio controller out of
D3cold does NOT prevent speaker loss after s2idle resume: with
d3cold_allowed=0 confirmed active, the codec still comes back silent
(stream attached, GPIO amp up, D0, yet no output).

Writing "freeze" to /sys/power/state preserves audio across suspend on
this hardware. These machines have no S3 (the kernel rejects "freeze"
for /sys/power/mem_sleep), so the drop-in sets SuspendState=freeze with an
empty MemorySleepMode= to force systemd onto the plain-freeze path.

The migration also removes the earlier d3cold systemd service if present.
@llstrk

llstrk commented Sep 25, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: the fix is gated to MacBook9,1 / MacBook10,1 and does nothing on other hardware. The root cause is consistent with mainline Linux 7.2 (cs420x.c selects the CS4208 Apple fixups only for Apple PCI subsystem IDs), and the WirePlumber rule, efivarfs immutable-flag handling and SuspendState=freeze drop-in are valid for current upstream sources.

Outcome: the main issues are in how and where the out-of-tree driver is built. On a fresh ISO install the new step fails and stops the installation on the two target models, and the "already installed" check can accept a failed or wrong-kernel build, leaving speakers silent with the migration recorded as done. The suspend explanation also does not match kernel semantics. Details and suggested changes follow.

Fresh ISO installs on the target models stop at hardware setup

Hardware setup runs inside the installer's arch-chroot, where uname -r is the live ISO kernel, not the installed one (the existing install/hardware/fix-synaptic-touchpad.sh notes the same constraint). The driver's dkms.sh runs dkms install -m macbook12-audio-driver -v 0.1 --force without -k, so DKMS targets the live ISO kernel, whose headers are not in the target system. The omarchy-iso build notes also describe the install as offline, which the git clone and the kernel.org source download both need.

fix-macbook12-audio.sh      git clone / dkms install fails, exits non-zero
  -> run_logged             bash -eE, returns the failure
  -> omarchy-apply-hardware / omarchy-apply-system   set -euo pipefail, exit
  -> ISO finalization step fails -> installation stops

Impact: before this PR these machines install with silent speakers; with it, a fresh install on MacBook9,1 / MacBook10,1 fails. This follows from the installer and DKMS sources and was reproduced with stubbed commands in a sandbox, not with a real ISO install.

Suggested change: do not build the driver in the installer chroot. Defer it to the installed system (for example first boot or a migration), or build only with explicit -k for the installed kernel when its headers and network are available, and never let this step fail the install. Apply the chime, soft-mixer and sleep changes only once the driver is installed for the kernel that will boot.

The DKMS "already installed" check accepts failed and wrong-kernel builds

Both scripts skip the driver when dkms status | grep -q macbook12-audio matches. DKMS registers the module ("added") before building and does not remove it when the build fails, and the pattern also matches a build for a different kernel.

migration run 1   DKMS adds module, build fails        -> exits non-zero, retried later
dkms status       macbook12-audio-driver/0.1: added
migration run 2   guard matches -> installer skipped
                  soft-mixer, chime, sleep drop-in written, reboot-required set
                  -> exits 0, marked complete; driver never built

(Sandboxed run with a stubbed DKMS failing after "add".)

The same guard hides a kernel upgrade in the same omarchy update: packages are upgraded before migrations run, so the Arch DKMS hook has already run for the new kernel before the driver source exists. The migration then builds for uname -r, the old kernel. After the requested reboot the new kernel has no module, and the guard still matches on later runs.

Impact: speakers can stay silent while the migration is recorded as complete, with no retry.

Suggested change: build for each installed kernel with -k (for example every /usr/lib/modules/*/build), and check per kernel for the installed state, for example dkms status -m macbook12-audio-driver -v 0.1 -k "$kver" matching : installed.

The clone in /usr/src is picked up as a second DKMS module

The Arch dkms package hook scans /usr/src/*-*/dkms.conf and splits the directory name at the last hyphen. The driver's installer copies its source to /usr/src/macbook12-audio-driver-0.1, but the git clone stays at /usr/src/macbook12-audio-driver:

/usr/src/macbook12-audio-driver-0.1/dkms.conf  ->  macbook12-audio-driver/0.1   (intended)
/usr/src/macbook12-audio-driver/dkms.conf      ->  macbook12-audio/driver       (the clone)

DKMS 3.4.3 does not compare PACKAGE_NAME in dkms.conf with the directory name, so the hook treats the clone as its own module.

Impact: on each kernel or header update the hook also tries dkms install macbook12-audio/driver, building from the mutable clone and targeting the same .ko as the intended module. Which build ends up installed was not tested. The phantom registration also satisfies the grep -q macbook12-audio guard above.

Suggested change: clone into a temporary directory outside /usr/src and remove it once the installer has copied its files, or package the driver.

Unpinned third-party code runs as root

The scripts clone the driver's default branch (or git pull an existing clone) and run its installer as root. Every DKMS build for a new kernel also downloads the matching kernel source from kernel.org.

Impact: each install runs whatever the upstream default branch contains at that moment, as root, and each new-kernel build depends on reaching kernel.org.

Suggested change: pin a reviewed commit (and verify it after cloning), or take up the packaging option mentioned in the PR description, which also lets the Arch hook build for every installed kernel.

Suspend explanation: freeze and s2idle are the same kernel state

In Linux 7.2, freeze in /sys/power/state and s2idle in /sys/power/mem_sleep both select PM_SUSPEND_TO_IDLE. /sys/power/mem_sleep only accepts s2idle, shallow and deep, so it rejects the string freeze whether or not S3 exists. With SuspendState=freeze, systemd writes freeze directly and never uses mem_sleep, so MemorySleepMode= is not needed.

Impact: the code comments, the migration and the PR description state a mechanism the kernel does not have. If these models default to deep (S3), the drop-in moves them to suspend-to-idle, which would explain the audio result but may raise battery drain while suspended. That was not tested.

Suggested change: check cat /sys/power/mem_sleep on an unmodified machine, correct the comments and description accordingly, drop MemorySleepMode=, and mention any battery tradeoff in the manual.

EFI chime write (conditional): the scripts write a fixed buffer 07 00 00 00 <byte & 0x7f>. efivarfs takes the first four bytes as the new attribute word and the rest as the complete new payload. Third-party sources (OpenCore, ArchWiki) describe this variable as a 1-byte payload with attributes 0x07, so the write likely matches, but the layout on these firmware versions is not verified. If it differs, trailing bytes are dropped, or the firmware may reject the attribute change, which would fail the install step or block the migration queue. Writing data[:4] + bytes([data[4] & 0x7f]) + data[5:], or refusing when the length is not 5, avoids both. Separately, the common ArchWiki mute recipe stores 0x80; clearing bit 7 leaves 0x00 (volume 0), and whether the firmware then powers the amp was not established.

Optional test improvement: test/shell.d/macbook12-audio-test.sh contains only grep checks. It fails on the base only because the new script is absent, and passes at the head with all of the issues above present. Running the migration with stubbed dkms/git (as xps13-sidecar-amps-test.sh does for its script) and a DKMS build that fails after "add" would have caught the second finding.


Review information

Test scope: source review of head 81860f35 and of the sources it depends on: macbook12-audio-driver at 4cdfcdb (current default branch; the tested commit is not stated in the PR), DKMS 3.4.3 with Arch dkms packaging, kernel-modules-hook, Linux 7.2 / 7.2.5, systemd 259.9 and 261.3, WirePlumber 0.5, PipeWire 1.6.9 and omarchy-iso. Sandboxed runs with stubbed git, DKMS and EFI variables covered install failure propagation, the migration rerun, the chime byte change, the Arch hook's module enumeration, and the PR test at head and base. Not tested: Mac hardware, a real ISO install, a real module build, firmware writes or suspend behavior.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments with targeted follow-up questions, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot omarchybot added bug Something isn't working compatibility Make Omarchy work better on everything! labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 81860f35. The bug is real, but this PR shouldn't be the fix that goes forward. #6921 fixes the same bug in a way the installer can deliver, and the two pieces this PR adds on top of it are the parts worth keeping.

Competing fix. #6921 installs the same leifliddy driver as a packaged macbook12-audio-driver-dkms. That's how macbook12-spi-driver-dkms and every other DKMS driver on quattro is installed, and it caches the package in install/omarchy-other.packages for the offline ISO. It is waiting on that package, omacom/omarchy-pkgs#153. What it lacks, and this PR has, is the EFI startup-chime un-mute and the CS4208 soft-mixer rule. #12008 reports both as necessary on a MacBook9,1. The smallest complete fix is to fold those two into #6921, or into its follow-up sunoxen-lab#1, which already adds a soft-mixer rule.

Confirmed against source, as the community review above also found:

  • install/hardware/apple/fix-macbook12-audio.sh:36 clones from GitHub during hardware setup, and :46 runs upstream's dkms install --force without -k. The ISO runs hardware setup offline under arch-chroot, where uname -r is the live ISO's kernel. So a fresh install on a MacBook9,1/10,1 fails at this step, and omarchy-apply-hardware stops the install. wget (:27) isn't in the offline package set either.
  • The dkms status | grep -q macbook12-audio skip (:30, migrations/1789653967.sh:11) also matches a failed (added) build and a build for another kernel. A failed first run is therefore never retried, and the migration still records itself as done.
  • The EFI write (:88) replaces the attribute word with 07 00 00 00 and the payload with a single byte, instead of clearing only bit 7 of what it read.

Suspend. Writing freeze to /sys/power/state selects suspend-to-idle, which is the same kernel state as s2idle in mem_sleep. The comments at :95 and migrations/1789653967.sh:63 therefore describe a mechanism the kernel doesn't have, and MemorySleepMode= does nothing once SuspendState=freeze is set. If audio really does survive suspend with the drop-in, the likelier explanation is that these models default to deep and the drop-in moves them to s2idle. sunoxen-lab#1 makes that change deliberately and documents the battery cost. Before keeping either, it's worth running cat /sys/power/mem_sleep on an unmodified machine.

Tested: ./test/cli and test/shell.d/macbook12-audio-test.sh pass at this head on a disposable Omarchy worker. Sourcing the install script on non-Apple hardware changes nothing. The new test only greps for strings, so it would still pass with every problem above in place. No worker has this hardware, so we haven't verified the speaker fix itself.

Second opinion: Codex Medium reviewed this head. It also flagged the EFI attribute overwrite and the suspend reasoning. In a separate run, without being told our view, it was asked which of this PR and #6921 should go forward. It recommended #6921's packaged approach with this PR's soft-volume and chime handling added. Its independence isn't guaranteed, since it can read this session's working notes.

Waiting on: the maintainer, to choose between this PR and #6921, and to land omacom/omarchy-pkgs#153 if #6921 goes ahead.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this, @teomurgi. #6921 fixes the same problem in a way the review judged better, so this is closed in favour of it. If it does not cover your case, please say so there.

Closed at the maintainer's request. The review comment above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants