Repository navigation
uaol: add UAOL feedback support - #11265
serhiy-katsyuba-intel wants to merge 5 commits into
Conversation
*** DO NOT MERGE *** This commit will be swapped with proper one once Zephyr PR is merged. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Error propagation, buffer sizing and format handling, DMA rollback, undefined arithmetic, and dependency pinning must be corrected.
Review effort: Balanced
Findings: 4
Open (8)
DSRC lacks validation for unsupported sample formats · New DSRC buffer is too small for fast-mode copies · New Allocation failure incorrectly reports success · New DMA byte count is misused for source-format processing · New Feedback start failure leaves audio DMA running · New Negative reconstructed sample is left-shifted undefinedly · New Public DSRC APIs lack required documentation · New Unpinned feedback branch makes the manifest nonreproducible · New
What changed in this PR
Adds UAOL USB feedback handling and DSRC-based drift compensation to the SOF DAI path.
Changes:
- Adds feedback DMA setup, processing, and UAOL rate adjustment.
- Introduces and tests a lightweight DSRC implementation.
- Updates the Zephyr dependency for required UAOL support.
| File | Description |
|---|---|
west.yml |
Selects a UAOL-enabled Zephyr revision. |
test/ztest/unit/dsrc/testcase.yaml |
Registers DSRC tests. |
test/ztest/unit/dsrc/test_input.txt |
Adds DSRC input data. |
test/ztest/unit/dsrc/test_expected_2.txt |
Adds expected resampling output. |
test/ztest/unit/dsrc/test_dsrc_ztest.c |
Tests DSRC rates and output. |
test/ztest/unit/dsrc/prj.conf |
Configures the test application. |
test/ztest/unit/dsrc/CMakeLists.txt |
Builds the DSRC tests. |
src/ipc/ipc4/dai.c |
Configures and releases feedback DMA. |
src/include/sof/lib/dai-zephyr.h |
Adds UAOL DAI runtime state. |
src/include/sof/audio/intel_uaol.h |
Declares UAOL feedback helpers. |
src/include/sof/audio/dsrc.h |
Defines the DSRC API and state. |
src/audio/intel_uaol.c |
Implements feedback and rate adjustment. |
src/audio/dsrc.c |
Implements drift resampling. |
src/audio/dai-zephyr.c |
Integrates feedback DMA and DSRC processing. |
src/audio/CMakeLists.txt |
Adds DSRC to UAOL builds. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (dd->ipc_config.type == SOF_DAI_INTEL_UAOL && | ||
| dd->ipc_config.direction == SOF_IPC_STREAM_PLAYBACK) { | ||
| /* resampling might generate 1 extra frame; DSRC only works with 32-bit data */ | ||
| size_t dsrc_buf_size = (dev->frames + 1) * dd->ipc_config.gtw_fmt->channels_count * 4; | ||
| dd->uaol.dsrc_buf = buffer_alloc_range(&dd->alloc_ctx, dsrc_buf_size, |
| /* resampling might generate 1 extra frame; DSRC only works with 32-bit data */ | ||
| size_t dsrc_buf_size = (dev->frames + 1) * dd->ipc_config.gtw_fmt->channels_count * 4; | ||
| dd->uaol.dsrc_buf = buffer_alloc_range(&dd->alloc_ctx, dsrc_buf_size, | ||
| dsrc_buf_size, | ||
| SOF_MEM_FLAG_USER, PLATFORM_DCACHE_ALIGN, | ||
| BUFFER_USAGE_NOT_SHARED); |
| if (dd->uaol.feedback_drift > 0) { | ||
| buffer_stream_invalidate(dd->local_buffer, bytes); | ||
|
|
||
| struct cir_buf_ptr in = { dd->local_buffer->stream.addr, | ||
| dd->local_buffer->stream.end_addr, dd->local_buffer->stream.r_ptr }; | ||
| assert(dd->uaol.dsrc_buf); | ||
| struct cir_buf_ptr out = { dd->uaol.dsrc_buf->stream.addr, | ||
| dd->uaol.dsrc_buf->stream.end_addr, dd->uaol.dsrc_buf->stream.w_ptr }; | ||
| size_t frames = bytes / audio_stream_frame_bytes(&dd->local_buffer->stream); | ||
|
|
||
| size_t added_frames = dsrc_process(&dd->uaol.dsrc, &in, &out, frames); | ||
| size_t src_added_bytes = added_frames * | ||
| audio_stream_frame_bytes(&dd->local_buffer->stream); | ||
|
|
||
| comp_update_buffer_consume(dd->local_buffer, bytes); | ||
| audio_stream_produce(&dd->uaol.dsrc_buf->stream, bytes + src_added_bytes); |
This implements a DSRC (Drift-compensating adaptive Sample Rate Converter) for use with the UAOL feedback feature to perform audio resampling and compensate for small dynamic drift. The implementation employs linear interpolation. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
This adds unit tests for DSRC using Zephyr's ztest framework. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
Make dai_get_properties_safe() non-static and declare it in sof/lib/dai-zephyr.h so that DAI-specific code outside dai-zephyr.c (e.g., intel_uaol.c) can use it. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
This extends UAOL functionality to support audio rate adjustment based on the "desired" clock reported by the USB playback device via the USB feedback endpoint. The firmware calculates drift from this feedback and instructs UAOL hardware to increase or decrease the transfer rate accordingly. A DSRC (Drift-compensating adaptive Sample Rate Converter) is used when necessary to perform audio resampling and compensate for small dynamic drift. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
b186022 to
e74ee91
Compare
PR 11265: test resultsRun date: 2026-10-05 15:22 UTC Tested commit: e74ee9139b50cfd7d9b29ec426a881655879be57 |
lgirdwood
left a comment
There was a problem hiding this comment.
Just minor opens, will mark as DNM until Zephyr part is ready.
|
|
||
| static void dai_dma_release_channel(struct dai_data *dd) | ||
| { | ||
| if (dd->chan_index >= 0) { |
There was a problem hiding this comment.
does this need to be atomic, i.e. if we have multiple USB streams ?
| } | ||
|
|
||
| #if CONFIG_UAOL_INTEL_ADSP | ||
| if (dd->uaol.fb_chan_idx >= 0) { |
There was a problem hiding this comment.
it would be good to state via inline comment why we need call certain ops twice for UAOL, i.e. so its understood that its intended.
| * there is no easy access to "params" there to set up the buffer format. | ||
| */ | ||
| #ifdef CONFIG_UAOL_INTEL_ADSP | ||
| /* create DSRC output buffer (if needed) */ |
There was a problem hiding this comment.
btw, do we have the option to plumb in higher performance ASRC instead of DRC ?



This extends UAOL functionality to support audio rate adjustment based on the "desired" clock reported by the USB playback device via the USB feedback endpoint. The firmware calculates drift from this feedback and instructs UAOL hardware to increase or decrease the transfer rate accordingly.
A DSRC (Drift-compensating adaptive Sample Rate Converter) is used when necessary to perform audio resampling and compensate for small dynamic drift.
Depends on Zephyr PR: zephyrproject-rtos/zephyr#121128