diff options
author | lassulus <git@lassul.us> | 2023-06-19 03:25:39 +0200 |
---|---|---|
committer | lassulus <git@lassul.us> | 2023-06-19 03:25:39 +0200 |
commit | 139799c53cdaf55c362109e01be9dd96cc8700ed (patch) | |
tree | b1ce719ec8f62458bce2d9fe2191b8d004630f2a /makefu/2configs/audio | |
parent | cb8fbb09127392a17d698d91f78ede7ae46accb8 (diff) | |
parent | a766e88e7c8d87aa6bdbde796d3a454f7b5e546e (diff) |
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/2configs/audio')
-rw-r--r-- | makefu/2configs/audio/jack-on-pulse.nix | 52 | ||||
-rw-r--r-- | makefu/2configs/audio/respeaker.nix | 122 |
2 files changed, 122 insertions, 52 deletions
diff --git a/makefu/2configs/audio/jack-on-pulse.nix b/makefu/2configs/audio/jack-on-pulse.nix deleted file mode 100644 index e18b2192a..000000000 --- a/makefu/2configs/audio/jack-on-pulse.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ config, pkgs, ... }: -let - pulse = pkgs.pulseaudioFull; - user = config.makefu.gui.user; - wait_time = 30; -in -{ - sound.enable = true; - hardware.pulseaudio = { - enable = true; - package = pulse; - }; - - environment.systemPackages = with pkgs; [ - jack2Full - jack_capture - ]; - # from http://anderspapitto.com/posts/2015-11-26-overtone-on-nixos-with-jack-and-pulseaudio.html - - systemd.user.services = { - jackdbus = { - description = "Runs jack, and points pulseaudio at it"; - serviceConfig = { - Type = "oneshot"; - ExecStart = pkgs.writeScript "start_jack.sh" '' - #! ${pkgs.bash}/bin/bash - . ${config.system.build.setEnvironment} - - # TODO: correctly wait for pulseaudio, cannot use pulseaudio.service - sleep ${toString wait_time} # wait for the gui to load - - ${pkgs.jack2Full}/bin/jack_control start - sleep 3 # give some time for sources/sinks to be created - - ${pulse}/bin/pacmd set-default-sink jack_out - ${pulse}/bin/pacmd set-default-source jack_in - ''; - ExecStop = pkgs.writeScript "stop_jack.sh" '' - #! ${pkgs.bash}/bin/bash - . ${config.system.build.setEnvironment} - - ${pkgs.jack2Full}/bin/jack_control stop - ''; - RemainAfterExit = true; - Restart = "always"; - RestartSec = "5"; - }; - after = [ "display-manager.service" "sound.target" ]; - wantedBy = [ "default.target" ]; - }; - }; -} diff --git a/makefu/2configs/audio/respeaker.nix b/makefu/2configs/audio/respeaker.nix new file mode 100644 index 000000000..0aaef5dac --- /dev/null +++ b/makefu/2configs/audio/respeaker.nix @@ -0,0 +1,122 @@ +{ config, lib, pkgs, ... }: +let + seeed-voicecard = (pkgs.callPackage ../../5pkgs/seeed-voicecard { kernel = config.boot.kernelPackages.kernel; }); +in +{ + hardware.raspberry-pi."4".i2c1.enable = true; + hardware.raspberry-pi."4".audio.enable = true; + hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = true; + hardware.deviceTree.filter = lib.mkForce "bcm2711-rpi-4-b.dtb"; + + security.rtkit.enable = true; + + environment.systemPackages = with pkgs; [ + alsaUtils + i2c-tools + ponymix + ]; + + sound.enable = true; + hardware.pulseaudio.enable = lib.mkForce false; + services.pipewire = { + enable = true; + systemWide = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + services.pipewire.config.pipewire-pulse = { + "pulse.properties"."server.address" = [ "unix:native" "tcp:4713" ]; + }; + + sound.extraConfig = '' + pcm.!default { + type asym + playback.pcm "playback" + capture.pcm "ac108" + } + + pcm.ac108 { + type plug + slave.pcm "hw:seeed4micvoicec" + } + '' ; + + + boot.extraModulePackages = [ + seeed-voicecard + ]; + boot.initrd.kernelModules = [ + "snd-soc-seeed-voicecard" + "snd-soc-ac108" + "i2c-dev" + #"i2c-bcm2708" + #"snd-soc-wm8960" + ]; + + boot.loader.raspberryPi.firmwareConfig = [ + "dtparam=i2c_arm=on" + "dtparam=i2s=on" + "dtparam=spi=on" + "dtparam=i2c1=on" + # dtoverlay=seeeed-8mic-voicecard not required because we use hardware.deviceTree + ]; + hardware.deviceTree = { + enable = true; + overlays = [ + { name = "respeaker-4mic"; dtsFile = "${seeed-voicecard}/lib/dts/seeed-4mic-voicecard-overlay.dts";} + { name = "spi"; dtsText = '' + /dts-v1/; + /plugin/; + + / { + compatible = "raspberrypi"; + fragment@0 { + target = <&spi>; + __overlay__ { + cs-gpios = <&gpio 8 1>, <&gpio 7 1>; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&spi0_pins &spi0_cs_pins>; + #address-cells = <1>; + #size-cells = <0>; + spidev@0 { + reg = <0>; // CE0 + spi-max-frequency = <500000>; + compatible = "spidev"; + }; + + spidev@1 { + reg = <1>; // CE1 + spi-max-frequency = <500000>; + compatible = "spidev"; + }; + }; + }; + fragment@1 { + target = <&alt0>; + __overlay__ { + // Drop GPIO 7, SPI 8-11 + brcm,pins = <4 5>; + }; + }; + + fragment@2 { + target = <&gpio>; + __overlay__ { + spi0_pins: spi0_pins { + brcm,pins = <9 10 11>; + brcm,function = <4>; // alt0 + }; + spi0_cs_pins: spi0_cs_pins { + brcm,pins = <8 7>; + brcm,function = <1>; // out + }; + }; + }; + }; + '';} + ]; + }; +} |