Skip to content

Commit 9121dd6

Browse files
committed
fix(2michat-v2): align with florian-asche#42 — add wpctl unity + user@1000 dep
Match the post-florian-asche#42 pattern already used by 02-stage-audiodriver-2michat-v1: call `wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0` after the amixer tune so the PipeWire default sink lands at unity, and add `After=/Wants=user@1000.service` + `Environment=XDG_RUNTIME_DIR=/run/user/1000` to the unit so wpctl can reach the user PipeWire socket. Drop the `PCM 85%` amixer set: PipeWire drives PCM as hardware volume passthrough, so wpctl unity immediately overwrites whatever we set PCM to. Verified on satellite-bedroom: `amixer set PCM 50%` then `wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0` leaves PCM at 100%. Keeping the line made the intent misleading ("85% for headroom") while having zero effect on the final state. The rest of the amixer tuning stays — unlike WM8960 on v1 or the DSP-driven lite board, the TLV320AIC3104 on the V2.0 HAT ships with `HP DAC` at -23.5 dB and `HP` at ~89%. Those stages are downstream of the PipeWire-managed PCM, so wpctl unity on its own still yields a stuck-quiet card.
1 parent a119130 commit 9121dd6

4 files changed

Lines changed: 18 additions & 32 deletions

File tree

02-stage-audiodriver-2michat-v2/02-set-audio-volume/files/configure_audio.service

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[Unit]
22
Description=PiCompose - Configure Audio volume setting (ReSpeaker 2-Mic HAT V2.0)
3-
After=sound.target alsa-restore.service
4-
Wants=sound.target alsa-restore.service
3+
After=user@1000.service sound.target alsa-restore.service
4+
Wants=user@1000.service sound.target alsa-restore.service
55

66
[Service]
77
Type=oneshot
8+
Environment=XDG_RUNTIME_DIR=/run/user/1000
89
ExecStart=/usr/bin/configure_audio.sh
910
RemainAfterExit=yes
1011
Restart=on-failure

02-stage-audiodriver-2michat-v2/02-set-audio-volume/files/configure_audio.sh

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
#!/bin/bash
22
set -u
33

4-
# TLV320AIC3104 mixer defaults on the V2.0 HAT are extremely quiet: the
5-
# HP DAC attenuates by -23.5 dB and the HP analog amp sits at ~89%. Without
6-
# tuning these three separate gain stages, end users report "silent card"
7-
# even with HA / LVA output at maximum.
8-
#
9-
# Runs on every boot via configure_audio.service — PipeWire / WirePlumber
10-
# manages ALSA mixer state per session and can reset controls to 0% between
11-
# reboots, so a first-boot-only guard would let users end up stuck silent.
12-
#
13-
# Values below are the safe defaults calibrated against JST-connected
14-
# speakers (peaks clip at 100% PCM). Tune further in-field with `amixer`
15-
# and persist via `alsactl store`.
4+
# TLV320AIC3104 on V2.0 ships quiet: HP DAC at -23.5 dB, HP/Line amps at
5+
# ~89% and muted on some units. PCM is driven by wpctl as hardware-volume
6+
# passthrough, so only the downstream stages need tuning. Runs every boot
7+
# because WirePlumber can reset ALSA state between sessions.
168

179
wait_for_card_and_control() {
1810
local card="$1"
@@ -40,10 +32,8 @@ wait_for_card_and_control() {
4032
return 1
4133
}
4234

43-
# Returns 0 on success OR when the control is absent (expected on hardware
44-
# variants without that stage). Returns 1 only when `amixer set` actually
45-
# failed for a control that exists — so a broken tuning surfaces as a
46-
# non-zero exit from the script and triggers the systemd retry.
35+
# Returns 0 on set-success or missing control; 1 on set-failure.
36+
# Non-zero exit triggers the systemd retry.
4737
set_control_if_exists() {
4838
local card="$1"
4939
local control="$2"
@@ -62,26 +52,17 @@ set_control_if_exists() {
6252
return 0
6353
}
6454

65-
# The kernel alias is the same for V1 and V2: `seeed2micvoicec`. The V2 HAT
66-
# is distinguished by the presence of `PCM`/`HP DAC`/`Line DAC` controls
67-
# (from tlv320aic3x) rather than V1's `Headphone`/`Speaker` (wm8960).
55+
# Same kernel alias as V1 (`seeed2micvoicec`); the PCM control distinguishes
56+
# V2's tlv320aic3x from V1's wm8960.
6857
if ! wait_for_card_and_control seeed2micvoicec PCM; then
6958
echo "No TLV320AIC3104-based card became ready; is the V2.0 overlay loaded?"
7059
exit 1
7160
fi
7261
CARD="seeed2micvoicec"
7362

7463
FAIL=0
75-
76-
# Digital pre-DAC attenuator. 100% clips on typical speakers; 85% keeps
77-
# headroom while still being clearly audible.
78-
set_control_if_exists "$CARD" "PCM" 85% || FAIL=1
79-
80-
# DAC output gains (ship at -23.5 dB by default — main source of quietness).
8164
set_control_if_exists "$CARD" "HP DAC" 100% || FAIL=1
8265
set_control_if_exists "$CARD" "Line DAC" 100% || FAIL=1
83-
84-
# Analog output amps (ship slightly below max and muted on some units).
8566
set_control_if_exists "$CARD" "HP" 100% unmute || FAIL=1
8667
set_control_if_exists "$CARD" "Line" 100% unmute || FAIL=1
8768

@@ -90,4 +71,8 @@ if [ "$FAIL" -ne 0 ]; then
9071
exit 1
9172
fi
9273

74+
# Keep PipeWire sink at unity so HA/LVA volume reaches the ALSA stages
75+
# above. Matches the 2michat-v1 pattern from #42.
76+
wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0
77+
9378
alsactl store

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Here is a Overview for the specific images of each hardware:
5252
| **[Sattelite1](docs/hardware_sattelite1.md)**<br>**+Linux-Voice-Assistant**<br>**+Snapcast** | <img src="docs/sattelite1-hat.jpg" alt="ReSpeaker Lite Board" style="width: 200px; height: auto;"> | • Satellite1 Hat Image<br>• Linux-Voice-Assistant (OpenHomeFoundation)<br>• Snapcast MultiRoom Audio Client<br>• Pre-configured for Home Assistant<br><br><span style="color: red;">Image is currently work in progress!</span> |
5353
| **[ReSpeaker 2-Mic HAT v1](docs/hardware_2mic_v1.md)** | <img src="docs/respeaker_2michats.webp" alt="ReSpeaker 2-Mics Pi HAT" style="width: 200px; height: auto;"> | • Base Image<br>• Seeed Voicecard Driver |
5454
| **[ReSpeaker 2-Mic HAT v1](docs/hardware_2mic_v1.md)**<br>**+Linux-Voice-Assistant**<br>**+Snapcast** | <img src="docs/respeaker_2michats.webp" alt="ReSpeaker 2-Mics Pi HAT" style="width: 200px; height: auto;"> | • 2-Mic HAT Image<br>• Linux-Voice-Assistant (OpenHomeFoundation)<br>• 2-Mic HAT GPIO LED Control<br>• Snapcast MultiRoom Audio Client<br>• Pre-configured for Home Assistant |
55-
| **[ReSpeaker 2-Mic HAT v2.0](docs/hardware_2mic_v2.md)** | <img src="docs/respeaker_2michats.webp" alt="ReSpeaker 2-Mics Pi HAT" style="width: 200px; height: auto;"> | • Base Image<br>• TLV320AIC3104 device-tree overlay<br>• First-boot mixer tuning for the V2.0 codec |
55+
| **[ReSpeaker 2-Mic HAT v2.0](docs/hardware_2mic_v2.md)** | <img src="docs/respeaker_2michats.webp" alt="ReSpeaker 2-Mics Pi HAT" style="width: 200px; height: auto;"> | • Base Image<br>• TLV320AIC3104 device-tree overlay<br>• Per-boot codec mixer tuning for the V2.0 |
5656
| **[ReSpeaker 2-Mic HAT v2.0](docs/hardware_2mic_v2.md)**<br>**+Linux-Voice-Assistant**<br>**+Snapcast** | <img src="docs/respeaker_2michats.webp" alt="ReSpeaker 2-Mics Pi HAT" style="width: 200px; height: auto;"> | • 2-Mic HAT v2.0 Image<br>• Linux-Voice-Assistant (OpenHomeFoundation)<br>• Snapcast MultiRoom Audio Client<br>• Pre-configured for Home Assistant |
5757
| **[ReSpeaker Lite](docs/hardware_respeaker_lite.md)** | <img src="docs/respeaker_lite.jpg" alt="ReSpeaker Lite Board" style="width: 200px; height: auto;"> | • Base Image<br>• Audio keep-alive service<br>• Workaround for connectivity issues in combination with the Pi Zero 2W.<br><br><span style="color: red;">There is a USB connectivity issue with the Pi Zero 2W. I cannot recommend this board if you want to use it with that. Use Pi3 or higher.</span> |
5858
| **[ReSpeaker Lite](docs/hardware_respeaker_lite.md)**<br>**+Linux-Voice-Assistant**<br>**+Snapcast** | <img src="docs/respeaker_lite.jpg" alt="ReSpeaker Lite Board" style="width: 200px; height: auto;"> | • ReSpeaker Lite Image<br>• Linux-Voice-Assistant (OpenHomeFoundation)<br>• Snapcast MultiRoom Audio Client<br>• Pre-configured for Home Assistant<br>• Workaround for connectivity issues in combination with the Pi Zero 2W.<br><br><span style="color: red;">There is a USB connectivity issue with the Pi Zero 2W. If you want to use it with that, you need to use Pi3 or higher.</span> |

docs/hardware_2mic_v2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ Unlike v1 — which needs an out-of-tree DKMS kernel module — v2 uses the main
3131

3232
1. The device-tree overlay `respeaker-2mic-v2_0.dtbo` (built from [Seeed-Studio/seeed-linux-dtoverlays](https://github.com/Seeed-Studio/seeed-linux-dtoverlays)), enabled via `dtoverlay=respeaker-2mic-v2_0` in `/boot/firmware/config.txt`.
3333
2. `dtparam=i2c_arm=on` in `/boot/firmware/config.txt`.
34-
3. Mixer tuning on first boot — the TLV320 ships with three separate attenuators all well below 100 % (`HP DAC` at -23.5 dB in particular), producing a card that appears to work but is inaudible at typical application volumes.
34+
3. Per-boot mixer tuning — the TLV320 ships with several attenuators well below 100 % (`HP DAC` at -23.5 dB in particular), producing a card that appears to work but is inaudible at typical application volumes.
3535

36-
The PiCompose `02-stage-audiodriver-2michat-v2` stage performs all three steps automatically. The mixer tuning is applied by `configure_audio.service` on every boot: PipeWire / WirePlumber manage ALSA state per session and can reset the mixer between reboots, so a first-boot-only guard would let users end up stuck at 0%. Customization via `amixer` is still possible at runtime — it just won't survive a reboot.
36+
The PiCompose `02-stage-audiodriver-2michat-v2` stage performs all three steps automatically. The mixer tuning is applied by `configure_audio.service` on every boot, the same pattern other audiodriver stages follow after #42: amixer on the codec-specific controls, then `wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0` to keep the PipeWire sink at unity. PipeWire / WirePlumber manage ALSA state per session and can reset the mixer between reboots, so a first-boot-only guard would let users end up stuck at 0%. Customization via `amixer` is still possible at runtime — it just won't survive a reboot.
3737

3838
## Additional information
3939

0 commit comments

Comments
 (0)