Skip to content

EQ IIR: Add support for response reconfigure during streaming - #2065

Merged
lgirdwood merged 2 commits into
thesofproject:masterfrom
singalsu:eq_runtime_update
Nov 11, 2019
Merged

lgirdwood merged 2 commits into
thesofproject:masterfrom
singalsu:eq_runtime_update

Conversation

@singalsu

@singalsu singalsu commented Nov 6, 2019

Copy link
Copy Markdown
Collaborator

This patch adds capability to equalizer to switch response during
audio playback or capture. The glitches are minimized by check and
apply of the filter configuration before each copy() operation.

The existing only halfway implemented SOF_CTRL_CMD_ENUM for quick
stored presets switching during streaming is removed for now since
there is no driver support.

The internal code cleanup includes extracting two functions from
eq_iir_setup() for check and initialize of coefficients and
initialize of filter delay lines.

To minimize number of duplicated functions in generic and HiFi3 version
a new module iir_generic.c is created for the filter core. After the
change iir.c contains only the common code for both implementations.

Finally, some trace messages are cleaned up to easier to understand
text.

Signed-off-by: Seppo Ingalsuo [email protected]

@singalsu

singalsu commented Nov 6, 2019

Copy link
Copy Markdown
Collaborator Author

I get checkpatch warnings from trace functions usage. What's the recommended practice. Should all traces be trace_x_with_ids() type instead of trace_x()? Also should the trace print multiple line split strings be in single line now?

@paulstelian97

Copy link
Copy Markdown
Collaborator

@singalsu Indeed with the recent Checkpatch changes it is recommended to not split long strings. However some splits are legitimate.

Please do not split individual phrases which one may grep for, like "request for non-defined filter" or "Illegal number of biquads". You may split and safely ignore the warning if you split at some ":", "." or format specifier though.

The one with "%s..." should be completely ignored, the current trace system doesn't support %s at all.

Do focus on the alignment with open parenthesis too.

@singalsu

singalsu commented Nov 7, 2019

Copy link
Copy Markdown
Collaborator Author

@paulstelian97 Thanks for help! I'll re-format this PR.

@jajanusz

jajanusz commented Nov 7, 2019

Copy link
Copy Markdown
Contributor

@paulstelian97 @singalsu Which splits are legitmiate?

@paulstelian97

paulstelian97 commented Nov 7, 2019 •

Copy link
Copy Markdown
Collaborator

@jajanusz I'd argue all of the ones present now are good enough because I doubt someone will try to grep for the whole message in order to debug. But if you argue otherwise and there should be no splitting at all then fair enough. Also... I thought your recent Checkpatch updates helped remove those "line too long" warnings with traces?

@singalsu Is there anything that can be done about the line too long in eq_iir.c:883? Or would that break an alignment for no real gain?

@singalsu

singalsu commented Nov 7, 2019

Copy link
Copy Markdown
Collaborator Author

@singalsu Is there anything that can be done about the line too long in eq_iir.c:883? Or would that break an alignment for no real gain?

a new pointer "cn" could store "cd->config_new" and the arguments could be "cn" and "cn->size". I've sometimes done such to get all green check marks. Now that we get warning for every trace I don't now if aiming for all green is feasible.

I tried to split size into third argument line but then checkpatch warns about xx->yy->zz pointers usage. It's strange that keeping it in single line doesn't give such warning.

What would you prefer?

@singalsu

singalsu commented Nov 7, 2019

Copy link
Copy Markdown
Collaborator Author

Also I don't like myself the longer than earlier trace macro name that triggered these many issues with long or split strings lines. Why could not the trace_eq() be converted to do the same as trace_eq_with_ids(). Why was the old no-ids trace preserved?

@jajanusz

jajanusz commented Nov 7, 2019

Copy link
Copy Markdown
Contributor

@singalsu @paulstelian97 I think it doesn't matter what we think in that regard. One of the project goals is to be compatible with kernel coding style and it clearly states: However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them.

https://www.kernel.org/doc/html/latest/process/coding-style.html#breaking-long-lines-and-strings

@paulstelian97

Copy link
Copy Markdown
Collaborator

@singalsu @paulstelian97 I think it doesn't matter what we think in that regard. One of the project goals is to be compatible with kernel coding style and it clearly states: However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them.

https://www.kernel.org/doc/html/latest/process/coding-style.html#breaking-long-lines-and-strings

So we should only be allowed to split at format specifiers (because you can't grep for the value anyway). So only at %d or something. Got it.

@singalsu

singalsu commented Nov 7, 2019

Copy link
Copy Markdown
Collaborator Author

The push that I just did addresses the trace strings split and long lines recommendation. I shortened the local trace macro names to keep sufficient verbosity. Hope it's OK now.

Comment thread src/audio/eq_iir/eq_iir.c Outdated

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.

Why do we rename these? (also, if there's a good reason please split this rename into a separate commit)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The obvious reason is avoiding long lines. Yes, I'll place them to separate commit.

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.

I honestly believe that this actually makes code less clear, so NAK on this one. Long lines are fine in certain circumstances (greppability). I'd rather sacrifice alignment than readability or allow lines of 81-82 characters on a case-by-case basis.

@paulstelian97 paulstelian97 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.

I don't know that much about the added functionality, however I don't like that you rename the trace macros to something that is essentially harder to understand at a glance just so you can fit within the 80-character limit.

Do split pass-by refactoring into a separate commit.

Comment thread src/audio/eq_iir/eq_iir.c Outdated

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.

"er"? Too vague, is this ONLY to prevent lines too long? Then not OK in my view.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Would tr_error() be better? Also when tracing an error could we omit string "error:" from them since we already have trace class for errors? All of these tricks help a lot to keep the lines <= 80 chars.

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.

I'd say leave it as "trace_eq_error". You can omit the "error: " prefix if you wish. And then format strings are not subject to the <=80 chars restriction anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

OK, I'll revert and the long lines will be back. I hope the checkpatch.pl script can be in future updated to contain these rules relaxations. It would be nice to see again the column of all green check marks from CI.

@paulstelian97 paulstelian97 Nov 11, 2019 •

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.

Yeah, @jajanusz attempted to update certain things already (please rebase to latest master, I'm not sure you are using that update) so some "line too long" warnings shouldn't exist.

Some long lines are fine. Not all but some are. And really when the only issue is Checkpatch just have a second opinion, a discussion and then let it work.

Comment thread src/audio/eq_iir/eq_iir.c Outdated

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.

Same with "ei", I believe you should just leave it as-is.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think "_with_ids" is an ugly bloat. It should be the default trace type and use the original trace macro name. Another macro could be defined for functions without access to "dev" handle.

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.

I do agree that it should be the default but i'd take this into a different, more involved discussion rather than a "pass-by refactor". So you should instead make a separate PR where you would do such proposed changes to the traces so we can discuss them rather than blocking this PR with such issues.

Comment thread src/audio/eq_iir/eq_iir.c Outdated

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.

Because this one with the original trace_eq_error shouldn't make Checkpatch complain, and if it does you may safely ignore it.

Comment thread src/audio/eq_iir/eq_iir.c Outdated

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.

Rewords of traces should be in a separate commit from the actual new functionality.

@paulstelian97 paulstelian97 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.

I won't block this one even though the fact that there are still changes in the trace messages bothers me. At least there isn't anything that becomes significantly less clear now.

While a cleanup of the changed messages from there would be best I can leave it as such.

@singalsu

Copy link
Copy Markdown
Collaborator Author

I won't block this one even though the fact that there are still changes in the trace messages bothers me. At least there isn't anything that becomes significantly less clear now.

While a cleanup of the changed messages from there would be best I can leave it as such.

I left into first commit trace prints changes those were due to function name change. The setup() function was split to init_coef() and init_delay() functions to be able to do those separately. The trace texts in init_coef() function those held the old function name were included to first commit.

Thanks for reviewing this @paulstelian97 ! Others please review too.

This patch adds capability to equalizer to switch response during
audio playback or capture. The glitches are minimized by check
and apply of the filter configuration before each copy()
operation.

The existing only halfway implemented SOF_CTRL_CMD_ENUM for quick
stored presets switching during streaming is removed for now
since there is no driver support.

The internal code cleanup includes extract of two functions from
eq_iir_setup() for check and initialize of coefficients and
initialize of filter delay lines. It helps to better understand
the setup flow.

The extrapolation of channels to response assign map is changed
to use previous channel response instead of first if the stream
contains more channels than the response definition. The
procedure was changed to avoid a code static analysis issue. The
behavior is not specified so this simpler way was chosen.

To minimize number of duplicated functions in generic and HiFi3
version a new module iir_generic.c is created for the filter
core. After the change iir.c contains only the common code for
both implementations.

Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch contains maintenance for module traces. Some redundant
traces are removed and some new traces with useful information are
added, especially if they are related to an error with configuration
request. The long trace strings are shortened to and split to
several lines at numbers print when possible.

Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu

Copy link
Copy Markdown
Collaborator Author

File iir_generic.c was missing from first commit after a git reset. Hope it's now OK in this just pushed version.

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

@singalsu btw, what is the cost of coefficient recalc ?

@lgirdwood

Copy link
Copy Markdown
Member

CI issues not relevant to this PR.

@lgirdwood
lgirdwood merged commit b27b21a into thesofproject:master Nov 11, 2019
@juimonen

Copy link
Copy Markdown

@lgirdwood I think this PR is not recalculating coefficients, they are already calculated in user space way before... so I guess this is just switching them and clearing delay lines. @singalsu correct if I'm wrong.

@singalsu

Copy link
Copy Markdown
Collaborator Author

@lgirdwood I think this PR is not recalculating coefficients, they are already calculated in user space way before... so I guess this is just switching them and clearing delay lines. @singalsu correct if I'm wrong.

Yep, all calculation is done in Octave EQ tool SOF/tools/tune/eq. However if need for realtime parameteric EQ the computation is not complicated, especially on some host side audio server for realtime updates. On FW it would be possible too but maybe with some simplifications into scaling and poles & zeros into biquads assign code.

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