uaol: add UAOL feedback support - #11265
Open
serhiy-katsyuba-intel wants to merge 5 commits into
Open
serhiy-katsyuba-intel wants to merge 5 commits into
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>
serhiy-katsyuba-intel
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
October 2, 2026 18:24
Contributor
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.
Comment on lines
+1288
to
+1292
| 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, |
Comment on lines
+1290
to
+1295
| /* 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); |
Comment on lines
+206
to
+221
| 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>
serhiy-katsyuba-intel
force-pushed
the
uaol_feedback_0210_2
branch
from
October 2, 2026 20:58
b186022 to
e74ee91
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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