Skip to content

fix(audiodriver): remove alsa setup use pipewire volume only#42

Merged
florian-asche merged 1 commit into
mainfrom
fix/configure_audio_2
Apr 19, 2026
Merged

fix(audiodriver): remove alsa setup use pipewire volume only#42
florian-asche merged 1 commit into
mainfrom
fix/configure_audio_2

Conversation

@florian-asche

Copy link
Copy Markdown
Owner

Remove legacy sound card detection and ALSA mixer configuration from all audio driver stage scripts. Standardize volume setup to only use PipeWire default sink setting across all driver variants.

Remove legacy sound card detection and ALSA mixer configuration
from all audio driver stage scripts. Standardize volume setup to
only use PipeWire default sink setting across all driver variants.
@florian-asche florian-asche merged commit fe215a7 into main Apr 19, 2026
0 of 5 checks passed
genericJE added a commit to genericJE/PiCompose that referenced this pull request Apr 19, 2026
…@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.

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%, so wpctl unity on its own still yields a stuck-quiet card.
genericJE added a commit to genericJE/PiCompose that referenced this pull request Apr 19, 2026
…@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.
genericJE added a commit to genericJE/PiCompose that referenced this pull request Apr 19, 2026
…@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.
genericJE added a commit to genericJE/PiCompose that referenced this pull request Apr 19, 2026
…@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.
@florian-asche florian-asche deleted the fix/configure_audio_2 branch April 20, 2026 00:06
florian-asche added a commit that referenced this pull request May 19, 2026
…AT (#41)

* feat(audiodriver): add 02-stage-audiodriver-2michat-v2 for V2.0 HAT

The ReSpeaker 2-Mics Pi HAT V2.0 replaces the WM8960 codec (V1, I2C 0x1a)
with a TLV320AIC3104 codec (I2C 0x18). The mainline kernel already ships
the `snd-soc-tlv320aic3x` driver, so no DKMS module is needed — but a
device-tree overlay and a separate set of mixer defaults are required.
Without these two bits the card either never appears or appears silent.

The new stage mirrors the v1 layout:

- prerun.sh — copy_previous guard, same as v1
- 01-driver/
  - 01-packages — build deps only (no dkms, no kernel headers needed)
  - 03-run-chroot.sh — clone seeed-linux-dtoverlays, compile
    respeaker-2mic-v2_0-overlay.dtbo with dtc, install into /boot/overlays,
    enable I2C + dtoverlay=respeaker-2mic-v2_0 in /boot/config.txt
- 02-set-audio-volume/
  - 01-run.sh — install script + oneshot unit (same pattern as v1)
  - files/configure_audio.sh — TLV320-aware defaults: PCM 85%
    (digital pre-DAC, 100% clips on typical JST speakers), HP DAC and
    Line DAC to 100% (defaults sit at -23.5 dB), HP and Line output amps
    unmuted at 100%, then alsactl store + wpctl sink to 1.0
  - files/configure_audio.service — After=sound.target alsa-restore.service,
    no dependency on a seeed-voicecard.service (none needed for v2)

The v2 stage is additive; the existing v1 stage is untouched. A build
can pick v1 or v2 by including the matching directory in stage selection.

* fix(2michat-v2): wire CI, guard mixer service, drop dead code

Follow-up to the initial 02-stage-audiodriver-2michat-v2 commit:

- build-all.yml: add build-2michat-v2 and build-2michat-v2-lva jobs and
  include them in generate-rpi-imager-json.needs. Without this the new
  stage exists but no image is ever produced.
- configure_audio.service: add ConditionPathExists=!/var/lib/configure_audio/success
  + ExecStartPost touch marker so mixer tuning runs once on first boot
  and subsequent manual amixer + alsactl store customisations survive
  reboots. Without the guard every boot reset the mixer to the stage's
  canned defaults.
- configure_audio.sh: drop the wpctl block. The service runs as root
  under systemd; wpctl requires the PipeWire user session (uid 1000)
  and the existing `|| true` made it a silent no-op.
- 01-driver/01-packages: drop i2c-tools (no runtime hardware detection
  on v2 — the overlay is fixed) and libasound2-plugins (v2 does not
  install a custom asound.conf that references resample plugins).
- docs/hardware_2mic_v2.md + README.md: add a v2 hardware page and
  two README rows (base + LVA) mirroring the v1 entries.

* fix(2michat-v2): run mixer tune every boot, propagate amixer failures

Address review feedback on #41: drop the first-boot guard so the mixer
tuning runs on every boot. PipeWire / WirePlumber manage ALSA state per
session and can reset controls to 0% between reboots, which would leave
users stuck silent if the service only ran once.

Also make configure_audio.sh surface amixer set failures (previously
swallowed by unconditional return 0), so that a broken tuning exits
non-zero and the systemd Restart=on-failure path actually retries
instead of falsely claiming success and persisting the broken state
via alsactl store.

Verified with a shim-based test harness (5 cases: happy path, single
amixer set failure, missing control, multiple failures, card timeout).

* 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.

* fix(2michat-v2): boost capture PGA for wake-word detection

TLV320AIC3104 ships with the input PGA at 27% (16 dB), which is too
quiet for reliable microWakeWord triggering on a Pi Zero 2 W at typical
speaking distance. Verified on satellite-bedroom: at 27% 'Hey Jarvis'
never fires; at 80% (47.5 dB) it does. The output-side tune handled
audibility; this handles detectability.

---------

Co-authored-by: Florian Asche <github@florian-asche.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant