How to feed the playback signal into a capture stream through AHUB (echo-cancellation reference) on Jetson Linux R39.2.1?

Summary

We need a copy of the speaker playback signal inside a microphone capture stream (echo-cancellation reference)
on Orin NX. On Jetson Linux R35 we routed the playback through the XBAR into the capture path and it worked.

On R39.2.1 with the default DPCM links, the same routing breaks playback: opening or closing the capture stream
disables I2S4 while playback is running (silence, no error), and opening the capture first makes the playback open
fail with failed to stop AMX, err = -110.

With nvidia,ahub-c2c-links (codec2codec links) the R35 routing works again, but per-module rates and channels can
only be set with the PCM override controls (“Sample Rate/Channels/Bits”), which the R39 documentation says will be
deprecated. codec2codec mode itself is not described in the R39 documentation.

We would like to know whether codec2codec mode is a configuration we can rely on for this use case.

Environment

  • Jetson Orin NX 16GB, Jetson Orin NX Engineering Reference Developer Kit Super (p3768-0000+p3767-0000-super)
    and our own carrier board
  • Jetson Linux R39.2.1 (kernel 6.8.12-tegra), stock tegra-audio-graph-card
  • Comparison: Jetson Linux R35.4.1 on the same developer kit (Orin NX)

Routing

playback : ADMAIF2 (48 kHz) -> MVC2 -> I2S4 (speaker amplifier, DSP-A, Tegra is clock master)
capture  : I2S2 (microphones, 16 kHz, 4 ch, DSP-A) -> AMX2 RX1
           MVC2 -> SFC2 (48 kHz -> 16 kHz) -> AMX2 RX2   ("SFC2 Mux" = MVC2, the reference)
           AMX2 (6 ch: 4 mic + 2 reference) -> ADMAIF3 (16 kHz, 6 ch)

The script nvidia_repro.sh (attached) sets this route with amixer and runs the tests below.
It changes only the APE card mixer state; please save it with alsactl store -f <file> 1 beforehand.

DPCM links (default): playback stops

sudo ./nvidia_repro.sh setup-fanout
sudo ./nvidia_repro.sh trial none|close|keep|first

trial plays a 10 s tone on ADMAIF2, opens/closes ADMAIF3 capture, and samples I2S4 RX_ENABLE
(regmap offset 0x00) every 0.25 s.

trial R35.4.1 R39.2.1 (DPCM)
none playback 10 s playback 10 s
close (capture opened at +2 s for 1 s) playback 10 s, I2S4 stays enabled aplay returns 0 at +2.17 s, I2S4 RX_ENABLE 1 → 0 at +2.32 s
keep (capture opened at +2 s and kept) playback 10 s aplay returns 0 at +2.17 s, I2S4 RX_ENABLE 1 → 0 at +2.33 s
first (capture opened before playback) both complete opening ADMAIF2 fails: audio open error: Connection timed out (log below)

The R39.2.1 column was taken with nvidia_repro.sh on the developer kit (no overlay, DPCM links).
The R35.4.1 column was taken on the developer kit with the same mux routing and the same trial procedure,
but without the I2S frame/master mode settings and AMX byte map (an earlier version of the script).
On our product (same R39.2.1, same routing) the playback PCM stays open when the capture process closes:
I2S4 RX_ENABLE goes 1 → 0 and the I2S4/SFC2 regmaps become unreadable (runtime-suspended) while the ADMAIF2 DMA
keeps running and aplay does not report an error, so the speaker stays silent until the playback PCM is reopened.
Kernel log for the first trial (same on the developer kit and on our product):

tegra210-amx 2903100.amx: failed to stop AMX, err = -110
tegra210-amx 2903100.amx: ASoC: error at snd_soc_dai_startup on AMX-TX-CIF: -110
fe.admaif@290f000.ADMAIF2: ASoC: error at dpcm_fe_dai_startup on fe.admaif@290f000.ADMAIF2: -110

codec2codec links: works with PCM override controls

We added nvidia,ahub-c2c-links; to the sound node with overlays/c2c.dts on the developer kit.
install_overlay.sh (attached) builds it with dtc and installs it as /boot/ape-c2c.dtbo; jetson-io then writes
the extlinux entry (the overlay has jetson-header-name so that jetson-io lists it):

sudo ./install_overlay.sh overlays/c2c.dts
sudo /opt/nvidia/jetson-io/config-by-hardware.py -n 1="APE AHUB codec2codec links (experiment)"
sudo reboot

After reboot, /proc/device-tree/sound/nvidia,ahub-c2c-links exists. To go back to DPCM links, restore
/boot/extlinux/extlinux.conf.jetson-io-backup. The overlay’s compatible lists the Orin NX developer kit;
adjust it for other boards.

With the overlay applied, the same routing behaves like R35:
none/close/keep/first all keep I2S4 enabled and play the full 10 s.

All internal links then take the hw_params of the last opened ADMAIF (tegra_audio_graph_hw_params), so we set the
per-module values with the PCM override controls:

sudo ./nvidia_repro.sh setup-fanout
sudo ./nvidia_repro.sh set-overrides
sudo ./nvidia_repro.sh reference play_first   # and cap_first

The reference is correct (440 Hz in ch4/ch5, 16 kHz) in both open orders. In this mode the override values
persist after the stream closes and are restored by alsactl restore after reboot.
We also ran a playback (1 ch, 48 kHz), a microphone capture on ADMAIF4 (I2S2, 16 kHz, 4 ch) and repeated
open/close of ADMAIF3 together, in three start orders, without problems.

Questions

  1. With DPCM links, is sharing AHUB modules (MVC/SFC/AMX) between a playback FE and a capture FE supported,
    and is the I2S4 shutdown above expected behaviour?
  2. Is nvidia,ahub-c2c-links with per-module values set by the PCM override controls a supported configuration on
    R39 that will stay available (“PCM override controls will be deprecated in future releases”)?
    If not, what is the recommended way on R39 to get the speaker reference into a microphone capture stream?

Attachments

r39-ape-c2c.zip (4.2 KB)

  • nvidia_repro.sh: reproduction script
  • install_overlay.sh, overlays/c2c.dts: overlay for the codec2codec links

Hi,

Enabling c2c is not recommended. The PCM overrides can be handled by adding the required properties to the port endpoints, as described in the Developer Guide.

I am looking into the issue and will update you soon.

@Sheetal.G Thank you for looking into this.

We tried the Developer Guide approach first, staying on the default DPCM links and adding convert-rate / convert-channels to the AHUB port endpoints. Two issues remain.

  1. The endpoint properties are not applied to the BE hw_params

Overlay (labels from the stock DT; attached as overlays/dpcm-convert.dts):

endpoint convert-rate convert-channels
i2s4_cif, i2s4_dap, mvc2_cif_in, mvc2_cif_out, sfc2_cif_in 48000 2
sfc2_cif_out 16000 2
amx2_in1 / amx2_in2 / amx2_out 16000 4 / 2 / 6
i2s2_cif, i2s2_dap 16000 4

After reboot, find /proc/device-tree/ -name ‘convert-*’ lists all 22 properties. However, while ADMAIF2 plays 48 kHz 2 ch and ADMAIF3 captures 16 kHz 6 ch, /sys/kernel/debug/asoc/<card>/fe.admaif@290f000.ADMAIF3/state shows:

  • be.amx@2903100.AMX-RX-CIF1
    Hardware Params: Format = S16_LE, Channels = 6, Rate = 16000 ← expected 4 ch
  • be.sfc@2902200.SFC-RX-CIF
    Hardware Params: Format = S16_LE, Channels = 6, Rate = 16000 ← expected 48000 Hz, 2 ch

SFC2 RX_FREQ / TX_FREQ are both 2 (no conversion), and the reference arrives at the wrong rate (a 440 Hz tone appears as 146.6 Hz).

  1. Even with fixed parameters, DPCM links stop the playback

With the R35 routing (MVC2 → SFC2 → AMX2 → ADMAIF3 as the reference), opening or closing ADMAIF3 disables I2S4 while ADMAIF2 is playing (table in the first post). Endpoint properties do not change this, because the shutdown comes from MVC2/SFC2/AMX2 being shared by the playback and capture FEs.

As a workaround we take the reference from the I2S4 internal loopback instead (I2S4 Loopback = on, SFC2 Mux = I2S4). With this, I2S4 stays enabled in the same none/close/keep eed the fixed parameters from issue 1.

Questions

  1. Are the endpoints in our overlay the right place for convert-rate / convert-channels on R39.2.1, or is something else needed for the properties to reach the AHUB BE links?
  2. With DPCM links, is sharing MVC/SFC/AMX between a playback FE and a capture FE supported? If not, is the I2S4 loopback (DPCM + I2S4 Loopback + endpoint properties) the recommended way to get the speaker reference into a capture stream?

Reproduction (r39-ape-dpcm-convert.zip: nvidia_repro.sh, install_overlay.sh, overlays/dpcm-convert.dts):

r39-ape-dpcm-convert.zip (4.5 KB)

sudo ./install_overlay.sh overlays/dpcm-convert.dts
sudo /opt/nvidia/jetson-io/config-by-hardware.py -n 1=“APE DPCM convert for I2S4 loopback reference (experiment)”
sudo reboot
sudo ./nvidia_repro.sh setup-loopback
sudo ./nvidia_repro.sh state

Could you please fetch the dt log and mixer controls from target and share? For commands refer fetch log steps

Thank you. Attached are the logs from the developer kit (R39.2.1), collected as described in “Get More Help on NVIDIA Developer Forum”:
r39-ape-logs.zip (334.0 KB).

  • dpcmconv/: DPCM links with convert-rate / convert-channels on the AHUB port endpoints (overlays/dpcm-convert.dts), reference from the I2S4 loopback. The properties are in dt.log, but dpcm_state_ADMAIF3.txt shows the AMX2 and SFC2 BEs still at 6 ch / 16 kHz.
  • primary/: stock device tree (DPCM links, no overlay) with the R35 routing (MVC2 → SFC2 → AMX2 → ADMAIF3). Opening the capture stops the playback: the ADMAIF2 FE is already closed in dpcm_state_ADMAIF2.txt and the I2S4 register dump reads XXXXXXXX for the volatile registers because I2S4 is runtime-suspended (its regmap is cache-only).

settings.txt (amixer -c APE contents), the DPCM state and the I2S4 register dump were taken while both streams were running. README.txt describes each file.

Root caused the issue, will share the fix soon.

Please try with the patches attached. If still facing issue please let me know.

audio-dpcm-fixes.tar (39.5 KB)

Thank you for the patches.
We applied both on the Orin NX developer kit (R39.2.1): 0001 to the AMX/ADX/MVC/SFC modules and 0002 to snd-soc-tegra-controls.
We used the default DPCM links, overlays/dpcm-convert.dts, and all PCM override controls set to 0.
We tested both reference routes (MVC2 → SFC2 → AMX2, and the I2S4 loopback).

Issue Before With the patches
Opening/closing ADMAIF3 capture during playback I2S4 disabled, playback silent I2S4 stays enabled; playback runs the full 10 s (trial close/keep)
Opening ADMAIF3 capture before playback failed to stop AMX, err = -110, playback open fails Both streams complete (trial first)
convert-* on the AHUB endpoints BEs at FE params (AMX2/SFC2 at 6 ch / 16 kHz), reference at 146.6 Hz BEs at the DT values (AMX-RX-CIF1 4 ch, AMX-RX-CIF2 2 ch, SFC-RX-CIF 2 ch / 48 kHz); reference at 440 Hz in both open orders
Repeated open/close — 20 capture open/close cycles during playback, and 10 playbacks during one capture: no errors, reference present every time

Could you tell us:

  1. Which Jetson Linux release will include these two patches, and when is it planned? Will they be in an R39.2.x update, or only in the next minor release?
  2. The 0001 commit message says hardware regression for ADX/SFC is still pending. Will that be completed before the release?
  3. With 0002, is the combination we tested (DPCM links, convert-* on the endpoints, mixer-controls enabled with all PCM override controls at 0) the configuration you recommend for R39 going forward?

We will try to merge in upcoming release. Will update you.

Its fixed, commit message missed to be updated.

Yes, mixer -controls soon will be deprecated.