blob: 0aaef5dac47b911f0666caf700c468a617d8f51c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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
};
};
};
};
'';}
];
};
}
|