Skip to content

Commit 55eb107

Browse files
committed
fix(2michat-v2): align with #42 — add wpctl unity + user@1000 dep
Match the post-#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 55eb107

3 files changed

Lines changed: 19 additions & 15 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: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
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.
4+
# TLV320AIC3104 codec defaults on the V2.0 HAT are extremely quiet: HP DAC
5+
# attenuates by -23.5 dB and HP / Line analog amps ship at ~89% and muted
6+
# on some units. Without tuning these codec-internal gain stages, end users
7+
# report "silent card" even with HA / LVA output at maximum.
8+
#
9+
# We deliberately do NOT set PCM here — PipeWire drives that control as
10+
# hardware volume passthrough, and the wpctl call below would overwrite
11+
# any value we set anyway. User-facing volume is the HA media_player /
12+
# wpctl sink level.
813
#
914
# Runs on every boot via configure_audio.service — PipeWire / WirePlumber
1015
# manages ALSA mixer state per session and can reset controls to 0% between
1116
# 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`.
1617

1718
wait_for_card_and_control() {
1819
local card="$1"
@@ -73,10 +74,6 @@ CARD="seeed2micvoicec"
7374

7475
FAIL=0
7576

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-
8077
# DAC output gains (ship at -23.5 dB by default — main source of quietness).
8178
set_control_if_exists "$CARD" "HP DAC" 100% || FAIL=1
8279
set_control_if_exists "$CARD" "Line DAC" 100% || FAIL=1
@@ -90,4 +87,10 @@ if [ "$FAIL" -ne 0 ]; then
9087
exit 1
9188
fi
9289

90+
# Match the project pattern (see 02-stage-audiodriver-2michat-v1 and #42):
91+
# keep the PipeWire default sink at unity so HA / LVA volume reaches the
92+
# ALSA stages we just tuned. wpctl needs the user PipeWire socket, which
93+
# is why this unit has After=user@1000.service and XDG_RUNTIME_DIR set.
94+
wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0
95+
9396
alsactl store

docs/hardware_2mic_v2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Unlike v1 — which needs an out-of-tree DKMS kernel module — v2 uses the main
3333
2. `dtparam=i2c_arm=on` in `/boot/firmware/config.txt`.
3434
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.
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)