P20 eq fir convert the eq_fir module to only use the sink/source api - #11221
piotrhoppeintel wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
eq_fir_process() returns -ENOSPC for fatal buffer-capacity mismatches, which can be silently treated as non-fatal by module_process_sink_src(), masking real errors and risking stalled processing.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Converts the eq_fir audio module (and its cmocka coverage) from legacy audio_stream buffer handling to the sink/source API, aligning it with the pipeline 2.0 direction.
Changes:
- Switch
eq_firprocessing entrypoint tomodule_interface.process()and implement processing usingsof_source/sof_sinkacquire/commit APIs. - Update FIR inner-loop implementations (generic + HiFi variants) to operate on
cir_buf_source/cir_buf_sinkviews. - Extend cmocka tests to prepare/process via sink/source APIs and add negative/config/alignment-related test cases.
| File | Description |
|---|---|
| test/cmocka/src/audio/eq_fir/eq_fir_process.c | Updates unit tests to use sink/source prepare + processing, and adds new validation/alignment tests. |
| src/audio/eq_fir/eq_fir.h | Updates FIR function signatures to take circular buffer views and explicit channel count. |
| src/audio/eq_fir/eq_fir.c | Reworks module processing + prepare to use sink/source APIs and passthrough via source_to_sink_copy(). |
| src/audio/eq_fir/eq_fir_hifi3.c | Adapts HiFi3 optimized FIR processing to circular buffer view API. |
| src/audio/eq_fir/eq_fir_hifi2ep.c | Adapts HiFi2EP optimized FIR processing to circular buffer view API. |
| src/audio/eq_fir/eq_fir_generic.c | Adapts generic FIR processing to circular buffer view API. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (buffer_size < source_bytes) { | ||
| source_release_data(source, 0); | ||
| return -ENOSPC; | ||
| } |
lgirdwood
left a comment
There was a problem hiding this comment.
@piotrhoppeintel can you resolve the GH comments too. Thanks !
| fir_get_lrshifts(f, &lshift, &rshift); | ||
| fir_hifiep_setup_circular(f); | ||
| y0 = snk + ch; | ||
| fir_32x16(f, src[ch], y0, lshift, rshift); |
There was a problem hiding this comment.
looks like the indentation is wrong here unless its the GH diff rendering ?
527602c to
f9ad41f
Compare
| int max_samples; | ||
| int chunk_samples; | ||
| int sample_index; | ||
| int channel; |
There was a problem hiding this comment.
@singalsu Can you quickly check just the generic naming approach?
586bfc9 to
2969fb7
Compare
|
@piotrhoppeintel just 1 CI open. |
|
|
||
| return 0; | ||
| if (!cd->eq_fir_func) | ||
| return -EINVAL; |
There was a problem hiding this comment.
this is actually impossible, right? cd->eq_fir_func == NULL is only possible if cd->fir_delay_size == 0 and then you'd take one of returns in lines 425 or 427. If you really want you could just use an assertion here.
| return ret; | ||
| } | ||
|
|
||
| return sink_commit_buffer(sink, sink_bytes); |
There was a problem hiding this comment.
would you be converting them all to use your new release_source_and_commit_sink()?
| int nmax, n, i, j; | ||
| int nch = audio_stream_get_channels(source); | ||
| int remaining_samples = frames * nch; | ||
| int remaining_samples = frames * channels; |
There was a problem hiding this comment.
...consistent across modules types would be nice...
| fir_32x16_2x(f, *x0, *x1, y0, y1, lshift, rshift); | ||
| x0 += 2 * nch; | ||
| y0 += 2 * nch; | ||
| } |
There was a problem hiding this comment.
would it be possible to just add here the handling of the "left-over" odd frame and remove the whole block in lines 53-65 above and line 52? Maybe just
if (chunk_frames & 1)
fir_32x16(f, src[ch], y0, lshift, rshift);
would be enough then. Same in other cases too.
| abi->size = sizeof(*config); | ||
| config->size = abi->size; | ||
| ret = eq_fir_send_blob(mod, abi, sizeof(blob_copy)); | ||
| assert_int_equal(ret, -EINVAL); |
There was a problem hiding this comment.
a short comment explaining which specific invalid case each block is testing would be nice...
There was a problem hiding this comment.
Done. The comments have been added.
kv2019i
left a comment
There was a problem hiding this comment.
@lgirdwood Please note the local variable naming change. I want @singalsu to ack.
Add -1 just to make sure @singalsu has a change to check
|
@piotrhoppeintel There's a build error with |
| @@ -11,6 +11,7 @@ | |||
| #include <sof/audio/data_blob.h> | |||
There was a problem hiding this comment.
The new FIR worked in my device tests, but I could not run tests with xtensa build of sof-testbench4. There is a build fail. It also appears as a warning in normal FW build. Please fix it to preserve test-ability.
There was a problem hiding this comment.
I fixed the issue, and it should build correctly now.
339565b to
9c53965
Compare
Add release_source_and_commit_sink() to release processed source data and commit produced data to the sink. Always commit the sink, while preserving the source release error when both operations fail. Signed-off-by: Piotr Hoppe <piotr.hoppe@intel.com>
Replace legacy input/output buffer processing with the source/sink API. Handle circular-buffer wrapping in FIR kernels and use direct source-to-sink copy for pass-through operation. Validate matching source and sink formats and add tests for invalid configurations and odd frame counts. Signed-off-by: Piotr Hoppe <piotr.hoppe@intel.com>
Replace abbreviated local variable names with descriptive names across the generic, HiFi2EP, and HiFi3 EQ FIR implementations. Clarify channel, sample, pointer, filter, and stride handling without changing processing behavior. Signed-off-by: Piotr Hoppe <piotr.hoppe@intel.com>
9c53965 to
a3c02b2
Compare


Rework the eq_fir module to only use the sink/source api to
prepare the SOF for the full transition to pipeline 2.0.