Skip to content

uaol: add UAOL feedback support - #11265

Open
serhiy-katsyuba-intel wants to merge 5 commits into
thesofproject:mainfrom
serhiy-katsyuba-intel:uaol_feedback_0210_2
Open

serhiy-katsyuba-intel wants to merge 5 commits into
thesofproject:mainfrom
serhiy-katsyuba-intel:uaol_feedback_0210_2

Conversation

@serhiy-katsyuba-intel

@serhiy-katsyuba-intel serhiy-katsyuba-intel commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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

*** 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>

Copilot AI left a comment

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.

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 High severity · 2 Medium severity · 2 Low severity

Open (8)
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 thread src/audio/dai-zephyr.c
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 thread src/audio/dai-zephyr.c
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 thread src/audio/dai-zephyr.c
Comment thread src/audio/intel_uaol.c
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);
Comment thread src/audio/dai-zephyr.c
Comment thread src/audio/dsrc.c Outdated
Comment thread src/include/sof/audio/dsrc.h
Comment thread west.yml
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>
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