Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unprivileged access to kernel-only notification state can fault, IPC3 builds fail, and RX bypass and TX envelope defects can stall capture or distort output.
7 open issues
Both ultrasound components default to enabled without IPC4 or module-adapter dependencies, so… · New No source buffer has been acquired on this bypass path.source_release_data()returns-ENODATA… · New The addition can overflow before the clamp runs for an accepted full-scale Q1.31 amplitude. With… · New On default PTL/WCL Linux builds, RX runs in an unprivileged LL thread, but this plain exported… · New This flag is ordinary kernel BSS, but RX prepare/reset and pulsed TX access it through plain… · New If RX is bypassed afterPRESENCE_DETECTED, local and shared presence remain true while the… · New When the envelope reaches zero inSOF_US_TX_MODE_REPLACE, this branch restores source audio… · New
What changed in this PR
Adds DSP-autonomous ultrasonic gesture and presence sensing to SOF IPC4, alongside hostless stream support in companion Linux PR #6074.
Changes:
- Adds ultrasonic TX/RX modules with Doppler detection, duty cycling, and presence-driven continuous transmission.
- Introduces event/configuration interfaces, IPC4 notifications, and firmware packaging.
- Adds an RT722/4-channel DMIC hostless topology and validator support for virtual audio interfaces.
| File | Description |
|---|---|
uuid-registry.txt |
Registers TX and RX module UUIDs. |
tools/topology/validator/tplgparse/kernel_engine.py |
Recognizes hostless virtual widgets. |
tools/topology/validator/checks/ipc4.py |
Exempts hostless widgets from module-format checks. |
tools/topology/topology2/platform/intel/sdw-ultrasound.conf |
Connects ultrasonic pipelines to speaker and DMIC backends. |
tools/topology/topology2/include/pipelines/cavs/ultrasound-tx-playback.conf |
Defines the hostless TX pipeline. |
tools/topology/topology2/include/pipelines/cavs/ultrasound-rx-capture.conf |
Defines the hostless RX pipeline. |
tools/topology/topology2/include/components/ultrasound_tx.conf |
Defines the TX widget and controls. |
tools/topology/topology2/include/components/ultrasound_rx.conf |
Defines the RX widget and controls. |
tools/topology/topology2/include/components/hostless-aif.conf |
Defines virtual hostless audio-interface widgets. |
tools/topology/topology2/development/tplg-targets.cmake |
Registers the PTL/WCL ultrasound topology target. |
tools/topology/topology2/cavs-sdw.conf |
Adds optional ultrasound topology integration. |
tools/rimage/config/wcl.toml.h |
Includes ultrasound modules in WCL manifests. |
tools/rimage/config/ptl.toml.h |
Includes ultrasound modules in PTL manifests. |
src/kernel/ipc/notification_pool.c |
Enlarges notification payload capacity. |
src/kernel/ipc/ipc4/notification.c |
Adds module notifications and shared presence state. |
src/include/user/ultrasound.h |
Defines event payloads, configuration, and controls. |
src/include/ipc4/notification.h |
Declares notification and presence APIs. |
src/include/ipc4/header.h |
Defines the ultrasound event-ID prefix. |
src/audio/ultrasound/ultrasound_tx.toml |
Defines TX module manifest metadata. |
src/audio/ultrasound/ultrasound_tx.h |
Defines TX defaults and runtime state. |
src/audio/ultrasound/ultrasound_tx.c |
Implements carrier generation, ramps, and duty cycling. |
src/audio/ultrasound/ultrasound_rx.toml |
Defines RX module manifest metadata. |
src/audio/ultrasound/ultrasound_rx.h |
Defines detector defaults and runtime state. |
src/audio/ultrasound/ultrasound_rx.c |
Implements Doppler analysis and gesture/presence events. |
src/audio/ultrasound/ultrasound_dsp.h |
Provides fixed-point signal-processing primitives. |
src/audio/ultrasound/llext_tx/llext.toml.h |
Defines the loadable TX manifest. |
src/audio/ultrasound/llext_tx/CMakeLists.txt |
Builds TX as a loadable extension. |
src/audio/ultrasound/llext_rx/llext.toml.h |
Defines the loadable RX manifest. |
src/audio/ultrasound/llext_rx/CMakeLists.txt |
Builds RX as a loadable extension. |
src/audio/ultrasound/Kconfig |
Adds TX and RX component options. |
src/audio/ultrasound/CMakeLists.txt |
Selects built-in or loadable module builds. |
src/audio/Kconfig |
Includes ultrasound configuration options. |
src/audio/CMakeLists.txt |
Integrates ultrasound into audio builds. |
app/ultrasound.conf |
Enables both modules as loadable extensions. |
Review effort: Balanced
| DAI DMA operation and issues with low-latency scheduling. | ||
|
|
||
| rsource "bt_codec/Kconfig" | ||
| rsource "ultrasound/Kconfig" |
There was a problem hiding this comment.
Fixed in 5dd7937: gated COMP_ULTRASOUND_TX and COMP_ULTRASOUND_RX on depends on COMP_MODULE_ADAPTER && IPC_MAJOR_4 and removed the default y / default m if LIBRARY_DEFAULT_MODULAR lines so the components are opt-in via app/ultrasound.conf. Also fixed the 64-bit host/testbench size_t buffer size types and added missing sys_comp_module_ultrasound_{tx,rx}_interface_init() prototypes.
| if (sink) | ||
| source_to_sink_copy(source, sink, true, frames * cd->frame_bytes); | ||
| else | ||
| source_release_data(source, frames * cd->frame_bytes); |
There was a problem hiding this comment.
Fixed in 5dd7937: replaced source_release_data() with return source_drop_data(source, frames * cd->frame_bytes) on the terminal-sink bypass path (and propagated source_to_sink_copy() return when sink != NULL). Live-verified on Ladybird WCL 4-ch DMIC toggling Ultrasound RX Bypass on/off with zero overruns or stalls.
| cd->env_q31 += cd->ramp_step_q31; | ||
| if (cd->env_q31 > desired) | ||
| cd->env_q31 = desired; |
There was a problem hiding this comment.
Fixed in 5dd7937: ultrasound_tx_step_env() now computes ramp addition and subtraction in int64_t before clamping against desired and narrowing to int32_t, avoiding signed overflow at INT32_MAX.
| struct ipc_msg *msg; | ||
| size_t total_size = sizeof(*mod_data) + data_size; | ||
|
|
||
| msg = ipc_notification_pool_get(total_size); |
There was a problem hiding this comment.
Fixed in f8e5ee3: converted send_module_notif_msg() into a Zephyr __syscall (z_impl_send_module_notif_msg + EXPORT_SYMBOL + z_vrfy_send_module_notif_msg validating pointer/size consistency, max payload bounds, and K_SYSCALL_MEMORY_READ()), matching send_resource_notif(). Also sized CONFIG_SOF_ZEPHYR_HEAP_SIZE=0x80000 in app/ultrasound.conf so LLEXT authentication succeeds under CONFIG_SOF_USERSPACE_LL=y. Live-verified on Ladybird WCL (CONFIG_SOF_USERSPACE_LL=y): all 7/7 gesture/presence notifications delivered cleanly from the unprivileged LL thread with zero faults.
| } | ||
| EXPORT_SYMBOL(send_module_notif_msg); | ||
|
|
||
| static atomic_t g_ultrasound_presence; |
There was a problem hiding this comment.
Fixed in f8e5ee3: exposed ultrasound_set_presence() and ultrasound_get_presence() as Zephyr __syscalls (z_impl_* + EXPORT_SYMBOL + z_vrfy_*). Live-verified on Ladybird WCL (CONFIG_SOF_USERSPACE_LL=y) across RX prepare/reset/detection and TX Low Power Mode duty-cycle polling in unprivileged LL threads with zero faults.
| return 0; | ||
| } | ||
|
|
||
| cd->cfg.enable = ctl->chanv[0].value ? 0 : 1; |
There was a problem hiding this comment.
Fixed in 5dd7937: added ultrasound_rx_handle_bypass() (invoked on bypass switch and SOF_US_RX_PARAM_CONFIG) to clear local and shared presence (ultrasound_set_presence(false)), immediately emit SOF_US_EVT_PRESENCE_LOST, and reset detector/channel state with warmup_until_ms = cd->bb_ms + US_RX_WARMUP_MS while preserving monotonic total_frames/bb_ms timestamps. Live-verified on Ladybird: toggling RX bypass mid-presence immediately emitted PRESENCE_LOST and resumed monotonic timestamps upon re-enable.
| *y = sat_s32((int64_t)(*x) + tone31); | ||
| } | ||
| } else { | ||
| *y = *x; |
There was a problem hiding this comment.
Fixed in 5dd7937: in both ultrasound_tx_process_s16() and ultrasound_tx_process_s32(), when env == 0 on carrier channels (ch < SOF_ULTRASOUND_MAX_CHANNELS) in SOF_US_TX_MODE_REPLACE, output 0 instead of copying source *x.
…ce state Add send_module_notif_msg() for sending IPC4 module notifications (SOF_IPC4_NOTIFY_MODULE_NOTIFICATION) from loadable LLEXT processing modules, define SOF_IPC4_NOTIFY_MODULE_EVENTID_GESTURE_MAGIC_VAL (0x6E57 << 16), and increase NOTIFICATION_POOL_MAX_PAYLOAD_SIZE from 40 to 80 bytes to accommodate struct sof_ipc4_notify_module_data payloads. Also expose atomic ultrasound_set_presence() / ultrasound_get_presence() helpers from base firmware so separate ultrasound_rx and ultrasound_tx LLEXT modules can coordinate duty-cycle auto-boost without cross-LLEXT symbol dependencies. Expose send_module_notif_msg(), ultrasound_set_presence(), and ultrasound_get_presence() as validated Zephyr __syscalls (with payload bounds and K_SYSCALL_MEMORY_READ checks in z_vrfy_send_module_notif_msg, plus EXPORT_SYMBOL(z_impl_*) for kernel-mode LLEXT callers) so unprivileged userspace LL threads (CONFIG_SOF_USERSPACE_LL=y) can invoke them safely. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add two standalone relocatable LLEXT processing modules for DSP-autonomous ultrasonic Doppler gesture and presence sensing: - ultrasound_tx (0-in/1-out standalone or 1-in/1-out additive/replace): synthesizes a phase-continuous 20 kHz carrier (-18 dBFS default) with optional low-power duty-cycled bursting (96 ms ON / 154 ms OFF, 250 ms period, 10 ms linear fade-in/out ramps) that automatically boosts to 100% continuous TX while ultrasound_get_presence() is active. - ultrasound_rx (1-in/0-out terminal sink or 1-in/1-out passthrough): performs 24-bit Q23 quadrature down-conversion, 2nd-order CIC decimation to 1 kHz complex baseband, DC carrier blocking, 64-pt Hann FFT with parabolic sub-bin interpolation, per-sideband local in-band noise floor estimation (canceling CIC droop and PDM DMIC high-frequency rolloff tilt), 3-hop Doppler frequency continuity filtering, and emits PRESENCE_DETECTED, PUSH, PULL, TAP, SWIPE_RIGHT, SWIPE_LEFT, and PRESENCE_LOST via IPC4 module notifications. Gate both Kconfig options on COMP_MODULE_ADAPTER && IPC_MAJOR_4 (opt-in via app/ultrasound.conf, which also sizes CONFIG_SOF_ZEPHYR_HEAP_SIZE for signed LLEXT authentication alongside LL userspace), and provide rimage manifest entries for PTL/WCL builds. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…opology Add virtual hostless-aif widget (zero private token data), ultrasound_tx and ultrasound_rx widget/pipeline definitions, and the sdw-ultrasound.conf integration wired into cavs-sdw.conf (ADD_ULTRASOUND) and sof-ptl-rt722-4ch-ultrasound: - Pipeline 160 (PCM 40: "Ultrasound TX", D0i3-compatible): ultrasound_tx.160.1 -> mixin.160.1 -> mixout.21.1 (RT722 Speaker BE), coexisting cleanly with normal media playback on PCM 2. - Pipeline 161 (PCM 41: "Ultrasound RX", D0i3-compatible): module-copier.101.2 (Intel 4-ch PDM DMIC BE) -> ultrasound_rx.161.1, coexisting cleanly with normal DMIC capture on PCM 10. Teach tools/topology/validator to recognize hostless virtual aif_in / aif_out widgets (priv.size == 0) matching kernel sof_widget_ready(). Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
0ab988f to
6219c7b
Compare


Summary
Implements DSP-autonomous ultrasonic Doppler gesture and presence sensing on IPC4 platforms (tested on Wildcat Lake / ACE 3.0 with Realtek RT722 SoundWire speaker + 4-ch Intel PDM DMIC), supporting both Approach A (hostless TX/RX with zero host audio DMA) and Approach B (click-free duty-cycled TX bursting with in-DSP presence auto-boost and D0i3/S0ix low-power operation).
Commits
ipc4: notification: add generic module notification helper and presence statesend_module_notif_msg()for LLEXT modules to emitSOF_IPC4_NOTIFY_MODULE_NOTIFICATIONmessages (SOF_IPC4_NOTIFY_MODULE_EVENTID_GESTURE_MAGIC_VAL = 0x6E570000).NOTIFICATION_POOL_MAX_PAYLOAD_SIZEfrom 40 to 80 bytes.ultrasound_set_presence()/ultrasound_get_presence()from base firmware for lockless RX→TX duty-cycle auto-boost coordination across separate LLEXTs.audio: ultrasound: add hostless ultrasonic TX/RX Doppler gesture modulesultrasound_tx(standalone 0-in/1-out source or 1-in/1-out additive): phase-continuous 20 kHz carrier (-18 dBFS default) with click-free Approach B low-power duty cycling (96 ms ON / 154 ms OFF, 250 ms period, 10 ms linear fade-in/out ramps) and automatic switch to 100% continuous TX while presence is active.ultrasound_rx(1-in/0-out terminal sink or 1-in/1-out passthrough): 24-bit Q23 complex mixer, 2nd-order CIC decimation to 1 kHz baseband, DC carrier blocker, 64-pt Hann FFT with parabolic sub-bin interpolation, per-sideband local in-band noise floor estimation (canceling CIC droop and PDM DMIC rolloff tilt), 3-hop Doppler continuity filtering, and IPC4 event emission (PRESENCE_DETECTED,PUSH,PULL,TAP,SWIPE_RIGHT,SWIPE_LEFT,PRESENCE_LOST).app/ultrasound.confoverlay and PTL/WCL rimage manifest entries.topology2: intel: add hostless RT722 + 4-ch DMIC ultrasonic sensing topologyhostless-aifwidget (priv.size == 0),ultrasound_tx/ultrasound_rxwidgets & pipelines,sdw-ultrasound.conf, andsof-ptl-rt722-4ch-ultrasoundtarget (Pipelines 160/161, PCMs 40/41, D0i3-compatible).tools/topology/validatorto recognize hostless virtualaif_in/aif_outwidgets matching kernelsof_widget_ready().Hardware Verification (WCL RVP2 / Realtek RT722 + 4-ch Intel PDM DMIC)
probe_points_availableverified zerohost-copierin DSP; AudioDSP PCI IRQ delta was 7 IRQs over 4 s (mtrace flushes only).0false positives (nf=[607, 491]).alh-copier.Playback-SmartAmp.0): 20,000.0 Hz at -7.31 dBFS (audible band < -124 dBFS); coexisted cleanly with mid-streamaplay -D hw:0,2playback andarecord -D hw:0,10capture with zero dropout.ultrasound_tx.160.1): Verified exact 250.0 ms pulsed TX (10 ms smooth ramps, audible edge ≤ -75 dBFS) → automatic 100% continuous TX onPRESENCE_DETECTED→ return to 250.0 ms pulsed TX onPRESENCE_LOST, with 7/7 gesture/presence events detected with sub-Hz Doppler precision.D0I3entry (~5 s idle) andrtcwake -m freeze -s 4(s2idle) retention inD0I3without pipeline teardown or FW reload.app/ultrasound.conf, plustopology2_dev_sof-ptl-rt722-4ch-ultrasound(0 validator errors).Companion Linux Kernel PR