tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs
MIT License
743 stars 73 forks source link

Macbook Air M1 Speakers and headphone jack stopped working #155

Closed karlskewes closed 4 months ago

karlskewes commented 5 months ago

First thank you and the other contributors to this repo. It is a joy to use Apple's nice hardware with NixOS, no more Thinkpads.

Timeline

  1. installed nixos-apple-silicon on Macbook M1
  2. headphone jack worked
  3. migrated to nix flakes - karl-mba.nix
  4. headphone jack still worked
  5. enabled bluetooth, bluetooth headphones worked
  6. speaker support landed
  7. enabled speakers, speakers worked
  8. some time passed
  9. speakers and headphone no longer work (they work in MacOS if I reboot)

I'm not sure what has changed. I have been through maybe 3 or 4 nixos-apple-silicon releases, using a USB stick to update firmware. Multiple reboots don't seem to change anything.

Diagnostics

alsamixer:

dmesg:

I don't know if the below output is normal or not. Note, there are no headphone plug/unplug events generated when I plug/unplug headphones into 3.5mm jack.

$ dmesg | grep cs42l83
[    1.333922] cs42l83 1-0048: supply VA not found, using dummy regulator
[    1.339842] cs42l83 1-0048: supply VP not found, using dummy regulator
[    1.345527] cs42l83 1-0048: supply VCP not found, using dummy regulator
[    1.348417] cs42l83 1-0048: supply VD_FILT not found, using dummy regulator
[    1.348933] cs42l83 1-0048: supply VL not found, using dummy regulator
[    1.358827] cs42l83 1-0048: Cirrus Logic CS42L83, Revision: B0

wpctl:

$ wpctl status
PipeWire 'pipewire-0' [1.0.0, karl@karl-mba, cookie:3237069984]
 └─ Clients:
        33. WirePlumber                         [1.0.0, karl@karl-mba, pid:1908]
        34. WirePlumber [export]                [1.0.0, karl@karl-mba, pid:1908]
        48. WirePlumber                         [1.0.0, karl@karl-mba, pid:1908]
        68. wpctl                               [1.0.0, karl@karl-mba, pid:3620]

Audio
 ├─ Devices:
 │      42. Built-in Audio                      [alsa]
 │  
 ├─ Sinks:
 │      46. Built-in Audio Headphones           [vol: 0.40]
 │  *   58. MacBook Air J313 Speakers           [vol: 0.70]
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │      47. Built-in Audio Headset Microphone   [vol: 1.00]
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:
        59. effect_output.j313-convolver                                
             64. output_FL       > Speakers:playback_FL [paused]
             65. output_FR       > Speakers:playback_FR [paused]

Video
 ├─ Devices:
 │      41. FaceTime HD Camera                  [v4l2]
 │  
 ├─ Sinks:
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │  *   43. FaceTime HD Camera (V4L2)          
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:

Settings
 └─ Default Configured Node Names:

Asahi diagnose and /etc files

$ ./asahi-diagnose 
Collecting system diagnostic information...

Saved diagnostic information to /home/karl/asahi-diagnose-20240201-104027.txt

Pipewire macaudio profile is "none".
Headphones and speakers will not work. Select the "Default" or "HiFi" profile.

!! IMPORTANT !!
Your audio configuration is in an invalid state. It is likely that you tried to
enable speakers early, despite numerous and very explicit warnings not to do so.
Potential reason(s) you are seeing this message: 
    - You have files in /etc/ from a prerelease version of asahi-audio.
Please go to https://github.com/AsahiLinux/docs/wiki/Undoing-early-speaker-support-hacks for fixes.
Do NOT file audio-related bugs until you have tried ALL fixes suggested at the page above.
Your bugs will be ignored and you will not be assisted.

Then checking https://github.com/AsahiLinux/docs/wiki/Undoing-early-speaker-support-hacks#the-pro-audio-profile-iswas-enabled-for-the-internal-speakers--headphones

$ ls /etc/wireplumber/**/*asahi* | xargs ls -l
lrwxrwxrwx 1 root root 47 Feb  1 10:32 /etc/wireplumber/main.lua.d/85-asahi.lua -> /etc/static/wireplumber/main.lua.d/85-asahi.lua
lrwxrwxrwx 1 root root 56 Feb  1 10:32 /etc/wireplumber/policy.lua.d/85-asahi-policy.lua -> /etc/static/wireplumber/policy.lua.d/85-asahi-policy.lua
lrwxrwxrwx 1 root root 48 Feb  1 10:32 /etc/wireplumber/scripts/policy-asahi.lua -> /etc/static/wireplumber/scripts/policy-asahi.lua
lrwxrwxrwx 1 root root 56 Feb  1 10:32 /etc/wireplumber/wireplumber.conf.d/99-asahi.conf -> /etc/static/wireplumber/wireplumber.conf.d/99-asahi.conf

$ ls -l /etc/static/wireplumber/main.lua.d/85-asahi.lua
lrwxrwxrwx 5 root root 101 Jan  1  1970 /etc/static/wireplumber/main.lua.d/85-asahi.lua -> /nix/store/a7qrsahs358z7ngrvkng3afn5sm7ni07-asahi-audio-1.6/share/wireplumber/main.lua.d/85-asahi.lua

I think it might be related to: https://github.com/tpwrules/nixos-apple-silicon/blob/6e324ab06cb27a19409ebc1dc2664bf1e585490a/apple-silicon-support/packages/asahi-audio/default.nix#L39-L51

Should these files still exist? I have done relevant nix switch, clean, reboots, etc

karlskewes commented 5 months ago

asahi-diagnose.sh has a bug apparently, possible fix: https://github.com/AsahiLinux/asahi-scripts/pull/40

Doesn't explain my lack of sound though. I've done a flake update to latest inputs including this repo, nixos-unstable.

diegobfernandez commented 4 months ago

@karlskewes did you try using older generations? If you find one that is working you can than diff the next generation to find what broke it. This tool can be of use for diffing the generations. Hope it helps.

karlskewes commented 4 months ago

Thanks very much Diego. Good idea. Unfortunately it seems I've cleaned older generations. I can't see too much in the flake configuration that might affect it however I do wonder about the firmware files. At one point I didn't see anything for dmesg | grep cs42l83 which might be similar to this issue. Currently I do see grep results per above.

I will try a kind of git bisect back a bit and see.

Thanks for the nvd suggestion. I've been using nix-diff but will experiment with nvd too.

karlskewes commented 4 months ago

Interestingly, when I boot up I can see this which looks good, speakers are present:

$ wpctl status
PipeWire 'pipewire-0' [1.0.0, karl@karl-mba, cookie:3728832050]
 └─ Clients:
        33. WirePlumber                         [1.0.0, karl@karl-mba, pid:1887]
        34. WirePlumber [export]                [1.0.0, karl@karl-mba, pid:1887]
        48. WirePlumber                         [1.0.0, karl@karl-mba, pid:1887]
        68. wpctl                               [1.0.1, karl@karl-mba, pid:2606]

Audio
 ├─ Devices:
 │      42. Built-in Audio                      [alsa]
 │  
 ├─ Sinks:
 │      46. Built-in Audio Headphones           [vol: 1.00]
 │  *   58. MacBook Air J313 Speakers           [vol: 0.70]
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │      47. Built-in Audio Headset Microphone   [vol: 1.00]
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:
        59. effect_output.j313-convolver                                
             64. output_FL       > Speakers:playback_FL [paused]
             65. output_FR       > Speakers:playback_FR [paused]

Video
 ├─ Devices:
 │      41. FaceTime HD Camera                  [v4l2]
 │  
 ├─ Sinks:
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │  *   43. FaceTime HD Camera (V4L2)          
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:

Settings
 └─ Default Configured Node Names:
         0. Audio/Sink    audio_effect.j313-convolver

As soon as I start an application that plays audio, e.g: VLC, Firefox/Youtube the Sinks change to Dummy Output and MacBook Air J313 Speakers disappears:

$ wpctl status
PipeWire 'pipewire-0' [1.0.0, karl@karl-mba, cookie:3728832050]
 └─ Clients:
        33. WirePlumber                         [1.0.0, karl@karl-mba, pid:1887]
        34. WirePlumber [export]                [1.0.0, karl@karl-mba, pid:1887]
        62. wpctl                               [1.0.1, karl@karl-mba, pid:6359]
        68. WirePlumber                         [1.0.0, karl@karl-mba, pid:6302]
        69. WirePlumber [export]                [1.0.0, karl@karl-mba, pid:6302]
        71. pipewire                            [1.0.1, karl@karl-mba, pid:6303]
        72. VLC media player (LibVLC 3.0.20)    [1.0.1, karl@karl-mba, pid:6300]

Audio
 ├─ Devices:
 │  
 ├─ Sinks:
 │  *   54. Dummy Output                        [vol: 1.00]
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:
        46. VLC media player (LibVLC 3.0.20)                            
             60. output_FR       > Dummy Output:playback_FR [active]
             61. output_FL       > Dummy Output:playback_FL [active]

Video
 ├─ Devices:
 │      41. FaceTime HD Camera                  [v4l2]
 │      78. FaceTime HD Camera                  [v4l2]
 │  
 ├─ Sinks:
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │  *   43. FaceTime HD Camera (V4L2)          
 │      47. FaceTime HD Camera (V4L2)          
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:

Settings
 └─ Default Configured Node Names:
         0. Audio/Sink    audio_effect.j313-convolver

What could be causing this I wonder. I have experimented with helvum and other patch tools earlier on but I can't see any config anywhere in $HOME.

karlskewes commented 4 months ago

Speakers working!

What I did which is possible just the reinstall step per: https://github.com/AsahiLinux/docs/wiki/Undoing-early-speaker-support-hacks#the-pro-audio-profile-iswas-enabled-for-the-internal-speakers--headphones:

  1. delete ~/.local/state/wireplumber/* (again)
  2. set sound.enable = false;
  3. set hardware.asahi.setupAsahiSound = false;
  4. deleted ~/.config/systemd/wireplumber/* and pipewire files (these were all symlinked to nix store though so probably no effect.
  5. delete ~/.config/dconf/user because it had audio profiles and other possible things, though dconf dump / didn't show anything relevant, only bluez headphones.
  6. reboot

I was contemplating doing a fresh reinstall so got a little keen with deleting files but this seems to have done it. Thanks all.