Skip to content

Recover MacBook CS8409 audio without rebooting - #12968

Draft
pcifaldi wants to merge 1 commit into
omacom:quattrofrom
pcifaldi:fix/macbook-cs8409-audio-recovery
Draft

pcifaldi wants to merge 1 commit into
omacom:quattrofrom
pcifaldi:fix/macbook-cs8409-audio-recovery

Conversation

@pcifaldi

Copy link
Copy Markdown

Summary

  • detect the MacBookPro13,1 CS8409 failure where the analog PCM disappears and PipeWire falls back to Dummy Output
  • reset the Intel HDA controller and reload the DKMS codec module before restarting userspace audio services
  • skip the PipeWire restart when hardware recovery succeeds, preserving connected clients such as the Omarchy shell
  • retain the existing PipeWire and stuck-USB recovery paths as fallbacks

Scope and dependency

This path is deliberately restricted to MacBookPro13,1 systems using the out-of-tree CS8409 DKMS module, and only runs when its analog playback PCM is absent. Other Macs and normal audio restarts are unchanged.

The no-reboot reset depends on davidjo/snd_hda_macbookpro#215, which restores the subsystem identity and HDA pin configuration lost during a live controller reset. This PR is a draft until that prerequisite is accepted.

Hardware validation

Tested on a MacBookPro13,1 / A1708 running Omarchy, PipeWire 1.6.8, kernel 7.1.9-arch1-2, and the patched CS8409 DKMS module.

Before recovery:

  • ALSA exposed only HDMI playback PCMs
  • the CS8409 analog playback/capture PCM was absent
  • PipeWire exposed Dummy Output

After the same controller unbind, codec reload, and controller rebind sequence used here:

  • CS8409/CS42L83 Analog playback and capture returned
  • PipeWire exposed built-in analog audio
  • speaker output worked without rebooting
  • PipeWire did not need to be stopped

Tests

  • bash -n bin/omarchy-restart-audio
  • git diff --check
  • ./test/cli
  • relevant shell/audio tests passed during ./test/all; the aggregate could not complete because the separate omarchy-pkgs checkout required by config-test was unavailable

@stefanoverna

Copy link
Copy Markdown
Contributor

Same recovery on a MacBookPro14,1 (A1708 2017, 0x106b3300), Omarchy 4.0.4, kernel 7.2.5, but without the driver dependency: the two things the codec loses across S3 (subsystem id and pin default configs, both firmware-programmed only at boot) can be saved and put back from userspace, so the unpatched DKMS module probes exactly like at boot. Works as a systemd-sleep hook, so audio comes back on every resume, not only on demand.

What it does, in case any of it is useful here:

  • pre: save subsystem_id and init_pin_configs from /sys/class/sound/hwC0D0/ (the kernel's cache is still right) to /var/lib. Refuses to save reset-looking values.
  • post (in a transient unit, since post hooks run with user.slice frozen): write them back through hwdep verbs (SET_SUBSYSTEM_ID, SET_CONFIG_DEFAULT_BYTES), then unbind the controller.
  • The unbind blocks until every /dev/snd descriptor of the card is closed and WirePlumber keeps controlC0 open, so WirePlumber is restarted for each logged-in user while the unbind is pending (PipeWire and client streams stay up).
  • modprobe -r snd_hda_codec_cs8409 before the rebind: with the module already loaded the re-probe fails with -22 and the codec falls back to the generic driver; loaded on demand it works.
  • After the rebind, wait for pcm0p and restart WirePlumber once more: the codec's probe takes several seconds after the card appears, and if WirePlumber enumerates the card in between it sees the HDMI PCMs only and keeps the HDMI profile until it looks again.

Scripts: https://gist.github.com/stefanoverna/2dc9f547d3abc5c5ba47bcc24a82263b. Happy to test this PR's path on the 14,1 as well.

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