Skip to content

P20 drc#11001

Open
piotrhoppeintel wants to merge 3 commits into
thesofproject:mainfrom
piotrhoppeintel:p20-drc
Open

P20 drc#11001
piotrhoppeintel wants to merge 3 commits into
thesofproject:mainfrom
piotrhoppeintel:p20-drc

Conversation

@piotrhoppeintel

Copy link
Copy Markdown

Convert the DRC module from the legacy audio_stream processing API
to the modern sof_source/sof_sink API.

Add a process-level cmocka test for the DRC module.

The new drc_process test follows the eq_iir_process harness (legacy
process_audio_stream API): it builds a small libaudio, creates the DRC
component through the full lifecycle (comp_new -> set_configuration ->
prepare -> streaming) and pushes a chirp signal in S16/S24/S32.
Convert the DRC module from the legacy audio_stream processing API
to the modern sof_source/sof_sink API.
Copilot AI review requested due to automatic review settings July 15, 2026 07:30

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.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Converts the DRC module processing path from the legacy audio_stream buffer API to the sof_source/sof_sink API, and adds a dedicated cmocka process-level test to validate the new data flow.

Changes:

  • Update DRC processing entrypoint to use sof_source/sof_sink and circular-buffer views (cir_buf_source/cir_buf_sink).
  • Refactor DRC kernels (generic + HiFi4) to operate on circular-buffer pointers rather than audio_stream helpers.
  • Add a new cmocka drc_process unit test and embed coefficient blobs for enabled / passthrough modes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/cmocka/src/audio/drc/drc_process.c New cmocka test that instantiates the module adapter and directly exercises cd->drc_func() with circular-buffer views.
test/cmocka/src/audio/drc/cmocka_drc_coef.h Adds generated DRC configuration blobs used by the new process test.
test/cmocka/src/audio/drc/CMakeLists.txt Adds the drc_process test target and a small static audio_for_drc library to satisfy module dependencies.
src/audio/drc/drc_hifi4.c Updates passthrough + delay/processing routines to use cir_buf_* sources/sinks and wrapping.
src/audio/drc/drc_generic.c Same as above for the generic implementation; adds memcpy_s include usage.
src/audio/drc/drc.h Updates public DRC function signature to cir_buf_source/cir_buf_sink and stores channel count in drc_comp_data.
src/audio/drc/drc.c Switches module interface to .process and implements source/sink acquire/commit flow.

Comment on lines +64 to +66
ipc = calloc(1, ipc_size + SOF_UUID_SIZE);
memcpy_s(ipc + 1, SOF_UUID_SIZE, &uuid, SOF_UUID_SIZE);
ipc->comp.hdr.size = ipc_size + SOF_UUID_SIZE;
Comment on lines +95 to +97
ret = ops->set_configuration(mod, 0, MODULE_CFG_FRAGMENT_SINGLE,
blob->size, (const uint8_t *)cdata,
blob->size, NULL, 0);
# make small version of libaudio so we don't have to care
# about unused missing references

add_compile_options(-DUNIT_TEST)
Comment on lines +485 to +494
while (bytes) {
n = MIN((const uint8_t *)source->buf_end - src,
(uint8_t *)sink->buf_end - dst);
n = MIN(n, bytes);
memcpy_s(dst, n, src, n);
src = cir_buf_wrap((void *)(src + n), (void *)source->buf_start,
(void *)source->buf_end);
dst = cir_buf_wrap(dst + n, sink->buf_start, sink->buf_end);
bytes -= n;
}
Comment thread src/audio/drc/drc_hifi4.c
Comment on lines +539 to +548
while (bytes) {
n = MIN((const uint8_t *)source->buf_end - src,
(uint8_t *)sink->buf_end - dst);
n = MIN(n, bytes);
memcpy_s(dst, n, src, n);
src = cir_buf_wrap((void *)(src + n), (void *)source->buf_start,
(void *)source->buf_end);
dst = cir_buf_wrap(dst + n, sink->buf_start, sink->buf_end);
bytes -= n;
}
Comment thread src/audio/drc/drc.c
Comment on lines +325 to +337
/* acquire source and sink circular buffers for the whole period */
ret = source_get_data(source, source_bytes, &source_buf.ptr,
&source_buf.buf_start, &bytes);
if (ret < 0)
return ret;
source_buf.buf_end = (const char *)source_buf.buf_start + bytes;

ret = sink_get_buffer(sink, sink_bytes, &sink_buf.ptr, &sink_buf.buf_start, &bytes);
if (ret < 0) {
source_release_data(source, 0);
return ret;
}
sink_buf.buf_end = (char *)sink_buf.buf_start + bytes;
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