# The Google AIY Voice Kit v1's HAT on a Raspberry Pi 3B: its speaker and mics, on one I2S bus: # a MAX98357A amp (out, GPIO 21) and two ICS-43432 mics (in, GPIO 20). Mainline Linux has no # googlevoicehat driver, but the codecs and simple-audio-card do the same; SD_MODE on GPIO 16, as in # Google's overlay. simple-audio-card takes one codec per link, so the card gets two links on the # same I2S: device 0 plays, device 1 records. The direction flags go on the codec nodes: simple-card # reads them from the link, cpu, then codec, and the last one read wins. { ... }: { hardware.deviceTree.overlays = [{ name = "voicehat"; dtsText = '' /dts-v1/; /plugin/; / { compatible = "brcm,bcm2837"; fragment@0 { target = <&gpio>; __overlay__ { voicehat_i2s_pins: voicehat_i2s_pins { brcm,pins = <18 19 20 21>; brcm,function = <4>; }; /* ALT0 */ }; }; fragment@1 { target = <&i2s>; /* mainline's i2s node lacks #sound-dai-cells; without it simple-audio-card fails with -EINVAL */ __overlay__ { pinctrl-names = "default"; pinctrl-0 = <&voicehat_i2s_pins>; #sound-dai-cells = <0>; status = "okay"; }; }; fragment@2 { target-path = "/"; __overlay__ { voicehat_amp: voicehat-amp { compatible = "maxim,max98357a"; #sound-dai-cells = <0>; sdmode-gpios = <&gpio 16 0>; }; voicehat_mic: voicehat-mic { compatible = "invensense,ics43432"; #sound-dai-cells = <0>; }; voicehat-sound { compatible = "simple-audio-card"; simple-audio-card,name = "voicehat"; #address-cells = <1>; #size-cells = <0>; simple-audio-card,dai-link@0 { reg = <0>; format = "i2s"; cpu { sound-dai = <&i2s>; }; codec { sound-dai = <&voicehat_amp>; playback-only; }; }; simple-audio-card,dai-link@1 { reg = <1>; format = "i2s"; cpu { sound-dai = <&i2s>; }; codec { sound-dai = <&voicehat_mic>; capture-only; }; }; }; }; }; }; ''; }]; # The amp has no volume control of its own, so a softvol named speaker goes in front of it; everything # plays through it. make volume VOL=30% sets the level, and the brain can nudge it (body/mixer.py); # persistence keeps it across reboots. hardware.alsa = { enable = true; enablePersistence = true; # The card numbers its links in reverse of the overlay's order: device 0 is the mics, 1 the amp. # The amp and mics share one I2S bus, so they run together only in one format: the mics'. # Whichever opens first sets it; so the amp always asks for 32-bit stereo at 16 kHz. config = '' pcm.voicehat_out { type plug slave { pcm "hw:CARD=voicehat,DEV=1"; format S32_LE; rate 16000; channels 2; } } ''; controls.speaker = { device = "voicehat_out"; card = "voicehat"; }; }; }