Skip to content

P20 eq fir convert the eq_fir module to only use the sink/source api - #11221

Open
piotrhoppeintel wants to merge 2 commits into
thesofproject:mainfrom
piotrhoppeintel:p20-eq-fir
Open

piotrhoppeintel wants to merge 2 commits into
thesofproject:mainfrom
piotrhoppeintel:p20-eq-fir

Conversation

@piotrhoppeintel

@piotrhoppeintel piotrhoppeintel commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

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

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

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

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_fir processing entrypoint to module_interface.process() and implement processing using sof_source/sof_sink acquire/commit APIs.
  • Update FIR inner-loop implementations (generic + HiFi variants) to operate on cir_buf_source/cir_buf_sink views.
  • 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.

Comment thread src/audio/eq_fir/eq_fir.c
Comment on lines +437 to +440
if (buffer_size < source_bytes) {
source_release_data(source, 0);
return -ENOSPC;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/audio/eq_fir/eq_fir.c

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piotrhoppeintel can you resolve the GH comments too. Thanks !

Comment thread src/audio/eq_fir/eq_fir_hifi2ep.c Outdated
fir_get_lrshifts(f, &lshift, &rshift);
fir_hifiep_setup_circular(f);
y0 = snk + ch;
fir_32x16(f, src[ch], y0, lshift, rshift);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the indentation is wrong here unless its the GH diff rendering ?

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First commit looks good, I'd like @singalsu to sign of the variable naming change in second commit.

int max_samples;
int chunk_samples;
int sample_index;
int channel;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu Can you quickly check just the generic naming approach?

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>
@lgirdwood

Copy link
Copy Markdown
Member

@piotrhoppeintel just 1 CI open.

Comment thread src/audio/eq_fir/eq_fir.c

return 0;
if (!cd->eq_fir_func)
return -EINVAL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/audio/eq_fir/eq_fir.c
return ret;
}

return sink_commit_buffer(sink, sink_bytes);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...consistent across modules types would be nice...

fir_32x16_2x(f, *x0, *x1, y0, y1, lshift, rshift);
x0 += 2 * nch;
y0 += 2 * nch;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a short comment explaining which specific invalid case each block is testing would be nice...

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

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.

5 participants