Skip to content

sound: bring up the mici audio card on the mainline kernel - #128

Draft
greatgitsby wants to merge 4 commits into
commaai:masterfrom
greatgitsby:mainline-sound
Draft

sound: bring up the mici audio card on the mainline kernel#128
greatgitsby wants to merge 4 commits into
commaai:masterfrom
greatgitsby:mainline-sound

Conversation

@greatgitsby

@greatgitsby greatgitsby commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Kernel

  • vamos.config: enable the QDSP6 audio stack (APR, PD mapper, Q6V5 PAS, SoundWire, SND_SOC_QDSP6/SDM845/SPDIF).
  • sdm845-comma-mici.dts: describe the sound card — adsp_pas enabled with firmware-name = qcom/sdm845/adsp.mbn; q6afedai/q6asmdai declare Secondary MI2S RX/TX and the MultiMedia1 (RX) / MultiMedia2 (TX) frontends; the qcom,sdm845-sndcard links MM1/MM2 to spdif-dit/dir dummy codecs over sec_mi2s.
  • Patches 0013–0015:
    • guard NULL dai ops in snd_soc_dai_set/get_stream (the spdif dummy codecs register without an ops struct);
    • constrain q6asm audio-buffer IOVAs to the ADSP shared-mem aperture the downstream AVS 2.8 firmware validates against;
    • track DSP stream open state across prepare failures so a failed prepare doesn't leak the stream for the rest of the boot.

Firmware

  • Ship the factory ADSP PAS firmware (adsp.mdt + adsp.b00..b13, tracked in LFS); the Dockerfile symlinks adsp.mbn -> adsp.mdt so the q6v5-pas loader finds the MDT header and loads the segments alongside it.

Userspace

  • sound_init.sh: start the ADSP remoteproc explicitly. With no initramfs, q6v5-pas auto-boots the ADSP at probe (~0.5s) before the rootfs firmware is mounted, so that load fails and the remoteproc stays offline — sound_init (root, after /lib/firmware is up) starts it, then routes MultiMedia1→SEC_MI2S_RX (playback hw:0,0) + MultiMedia2→SEC_MI2S_TX (capture hw:0,1). Bails cleanly on boards with no adsp/card (e.g. tizi).
  • asound.conf: card-id-gated asym default so PortAudio opens playback on hw:0,0 and capture on hw:0,1.
  • Drop the downstream adsp/cdsp remoteproc services, adsp-start.sh, and amplifier.py; init.qcom.sh no longer pokes the downstream subsys restart knobs.

Verified on device (comma four, kernel 6.18.0-vamos)

  • Clean auto-boot: the runit sound service brings the commamici card up, adsp remoteproc running from the baked-in adsp.mbn (no runtime firmware farm), pcm0p/pcm1c present, /dev/snd at root:audio 0660.
  • aplay -D hw:0,0 and arecord -D hw:0,1 both run clean with no q6asm/ADSP errors.
  • Also verified the same mainline kernel drives sound under AGNOS userspace (1:1 kernel goal).

Wire up the comma four (mici) audio card end to end on vamOS: kernel config,
device tree, ADSP firmware, driver fixes, and the runit userspace init.

Kernel:
- vamos.config: enable the QDSP6 audio stack (APR, PD mapper, Q6V5 PAS,
  SoundWire, SND_SOC_QDSP6/SDM845/SPDIF).
- sdm845-comma-mici.dts: describe the sound card. adsp_pas is enabled with
  firmware-name qcom/sdm845/adsp.mbn; q6afedai/q6asmdai declare Secondary MI2S
  RX/TX and the MultiMedia1 (RX) / MultiMedia2 (TX) frontends; the qcom
  sdm845-sndcard links MM1/MM2 to spdif-dit/dir dummy codecs over sec_mi2s.
- patches 0013-0015: guard NULL dai ops in snd_soc_dai_set/get_stream (the
  spdif dummy codecs register without an ops struct); constrain q6asm audio
  buffer IOVAs to the ADSP shared-mem aperture the downstream AVS 2.8 firmware
  validates against; track DSP stream open state across prepare failures so a
  failed prepare doesn't leak the stream for the rest of the boot.

Firmware:
- ship the factory ADSP PAS firmware (adsp.mdt + adsp.b00..b13) pulled from the
  device, tracked in LFS; Dockerfile symlinks adsp.mbn -> adsp.mdt so the
  q6v5-pas loader finds the MDT header and loads the segments alongside it.

Userspace:
- sound_init.sh: the ADSP auto-boots via q6v5-pas, so just wait for the
  commamici ASoC card, fix /dev/snd perms (no udev rule fires), and route
  MultiMedia1->SEC_MI2S_RX (playback hw:0,0) + MultiMedia2->SEC_MI2S_TX
  (capture hw:0,1). Bail cleanly if no card appears (e.g. tizi).
- asound.conf: card-id-gated asym default so PortAudio opens playback on
  hw:0,0 and capture on hw:0,1.
- drop the downstream adsp/cdsp remoteproc services, adsp-start.sh, and
  amplifier.py; init.qcom.sh no longer pokes the downstream subsys restart
  knobs.
The q6v5-pas driver auto-boots the ADSP at probe (~0.5s), but with no
initramfs the rootfs firmware isn't available yet, so the load fails with
-ENOENT and the remoteproc stays offline permanently -- the sound card never
registers (msm-snd-sdm845 deferred-probes forever on "error getting cpu dai
name"). Start the adsp explicitly from sound_init, which runs as root after
/lib/firmware is mounted, so the baked-in adsp.mbn loads and the q6 audio
services come up. Verified on device: card commamici registers, pcm0p/pcm1c
present, aplay hw:0,0 and arecord hw:0,1 both run clean with no q6asm errors.
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

vamOS System Profile

Changes vs master

Metric Change
Used space 3437.2MB → 3448.5MB (+11.2MB)
Sparse image 3392.0MB → 3402.0MB (+9.9MB)
Package count 524 → 524
Directory size changes (>1MB)
Directory Change

Metric Value
Used space 3448.5MB / 5959.5MB
Files 56150
Directories 4759
Symlinks 3588
Packages 524

Top 10 Directories

Directory Size

Category Breakdown

Category Size %
xbps packages 2502.8MB 72.5%
Python venv 591.7MB 17.1%
Firmware 21.1MB .6%
Other 332.7MB 9.6%

Top 10 Packages by Size

Package Size
mit-krb5-libs-1.21.3_1 270.4MB
gawk-5.3.2_1 210.3MB
llvm-21_3 148.6MB
libldns-1.9.2_1 124.3MB
pd-mapper-1.0_1 73.9MB
libclang21-21.1.7_1 70.2MB
glib-2.88.0_1 67.4MB
gcc-14.2.1+20250405_4 66.6MB
libcap-progs-2.78_1 56MB
cmake-4.2.2_2 53.2MB

Top 30 Files by Size

File Size
/usr/lib/llvm/21/lib/libLLVM.so.21.1 124.3MB
/usr/lib/llvm/21/lib/libMLIR.so.21.1 89.7MB
/usr/lib/llvm/21/bin/mlir-transform-opt 82.9MB
/usr/lib/llvm/21/lib/libclang-cpp.so.21.1 56MB
/usr/bin/uv 54MB
/usr/lib/llvm/21/bin/mlir-translate 53.2MB
/usr/lib/llvm/21/bin/llvm-exegesis 52MB
/usr/lib/llvm/21/bin/llvm-bolt-binary-analysis 50.6MB
/usr/lib/gcc/aarch64-linux-gnu/14.2/gnat1 40.1MB
/usr/bin/gdb 39.1MB
/usr/lib/libgallium-26.1.3.so 37.7MB
/usr/lib/gcc/aarch64-linux-gnu/14.2/cc1plus 37.3MB
/usr/lib/libllvm-qcom.so 35.2MB
/usr/lib/gcc/aarch64-linux-gnu/14.2/cc1 35.2MB
/usr/lib/libRusticlOpenCL.so.1.0.0 34.3MB
/usr/lib/gcc/aarch64-linux-gnu/14.2/lto1 33.9MB
/usr/bin/lto-dump 33.9MB
/usr/local/venv/bin/ruff 31.8MB
/usr/share/icu/78.3/icudt78l.dat 31.5MB
/usr/lib/llvm/21/lib/libclang.so.21.1.7 30.2MB
/usr/lib/llvm/21/bin/c-index-test 28.6MB
/usr/local/venv/lib/python3.12/site-packages/gcc_arm_none_eabi/toolchain/libexec/gcc/arm-none-eabi/13.2.1/cc1 28.2MB
/usr/lib/libz3.so 27.9MB
/usr/bin/run 26.7MB
/usr/local/venv/lib/python3.12/site-packages/numpy.libs/libscipy_openblas64_-71e1b124.so 23.6MB
/usr/comma/updater 23.5MB
/usr/comma/setup 23.5MB
/usr/comma/reset 23.5MB
/usr/local/uv/python/cpython-3.12.13-linux-aarch64-gnu/bin/python3.12 22.2MB
/usr/local/uv/python/cpython-3.12.13-linux-aarch64-gnu/lib/libpython3.12.so.1.0 22.1MB

Comment thread kernel/dts/sdm845-comma-mici.dts Outdated
Comment on lines +153 to +158
sec_mi2s_active: sec-mi2s-active-state {
pins = "gpio80", "gpio81", "gpio82", "gpio83";
function = "sec_mi2s";
drive-strength = <8>;
bias-disable;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part should be sent to the mainling list into sdm845.dtsi (b4 is your friend).

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.

2 participants