|
| 1 | +{ |
| 2 | + pkgs, |
| 3 | + lib, |
| 4 | + ... |
| 5 | +}: |
| 6 | + |
| 7 | +{ |
| 8 | + imports = [ |
| 9 | + ../default.nix |
| 10 | + ./tas2783-kernel-patches.nix |
| 11 | + ]; |
| 12 | + |
| 13 | + hardware = { |
| 14 | + alsa.enablePersistence = lib.mkDefault true; |
| 15 | + firmware = lib.optional (lib.versionOlder pkgs.linux-firmware.version "20260519") ( |
| 16 | + pkgs.callPackage ./tas2783-firmware.nix { } |
| 17 | + ); |
| 18 | + }; |
| 19 | + |
| 20 | + environment.etc = { |
| 21 | + "alsa/ucm2/codecs/tas2783/init.conf".source = ./ucm2/codecs/tas2783/init.conf; |
| 22 | + "alsa/ucm2/sof-soundwire/acp-dmic.conf".source = ./ucm2/sof-soundwire/acp-dmic.conf; |
| 23 | + "alsa/ucm2/sof-soundwire/tas2783.conf".source = ./ucm2/sof-soundwire/tas2783.conf; |
| 24 | + "alsa/ucm2/sof-soundwire/sof-soundwire.conf".source = ./ucm2/sof-soundwire/sof-soundwire.conf; |
| 25 | + }; |
| 26 | + |
| 27 | + # WirePlumber config for TAS2783 smart amp speakers. |
| 28 | + # UCM doesn’t expose a Speakers port for this card, so force pro-audio and |
| 29 | + # prevent the speaker sink from suspending (prevents desync on idle). |
| 30 | + # Firmware extraction recipe and original config: |
| 31 | + # https://gist.github.com/cryptob1/f62aaf8517df2e540f447347f42c7a03 |
| 32 | + services.pipewire.wireplumber.extraConfig."51-strix-halo-audio" = { |
| 33 | + "monitor.alsa.rules" = [ |
| 34 | + { |
| 35 | + matches = [ |
| 36 | + { "device.name" = "alsa_card.pci-0000_c4_00.5-platform-amd_sdw"; } |
| 37 | + ]; |
| 38 | + actions."update-props" = { |
| 39 | + "device.profile" = "pro-audio"; |
| 40 | + }; |
| 41 | + } |
| 42 | + { |
| 43 | + matches = [ |
| 44 | + { "node.name" = "alsa_output.pci-0000_c4_00.5-platform-amd_sdw.pro-output-2"; } |
| 45 | + ]; |
| 46 | + actions."update-props" = { |
| 47 | + "session.suspend-timeout-seconds" = 0; |
| 48 | + "node.description" = "Internal Speakers (TAS2783)"; |
| 49 | + "priority.session" = 2300; |
| 50 | + }; |
| 51 | + } |
| 52 | + ]; |
| 53 | + }; |
| 54 | + |
| 55 | + # Unmute the TAS2783 once detected. |
| 56 | + services.udev.extraRules = |
| 57 | + let |
| 58 | + amixer = "${lib.getBin pkgs.alsa-utils}/bin/amixer"; |
| 59 | + in |
| 60 | + /* udev */ '' |
| 61 | + ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="sofsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Amp Playback Switch' 1" |
| 62 | +
|
| 63 | + ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Amp' on" |
| 64 | + ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-2 Amp' on" |
| 65 | + ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Speaker' on" |
| 66 | + ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-2 Speaker' on" |
| 67 | + ''; |
| 68 | +} |
0 commit comments