Skip to content

RTNR: Decouple switch-enable control from params blob - #5618

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
MingJenTai:main_RTNR_fix_control_switch
May 3, 2022
Merged

lgirdwood merged 1 commit into
thesofproject:mainfrom
MingJenTai:main_RTNR_fix_control_switch

Conversation

@MingJenTai

Copy link
Copy Markdown
Contributor

This PR is based on #5616

It decouples the switch-typed control for enabling/disabling from the control bytes.

Previously, control blobs should be sent from userspace to to toggle RTNR on/off.
With this PR, RTNR can be toggled by setting the UCM switch value.

cset "name='RTNR10.0 rtnr_enable_10' off"
cset "name='RTNR10.0 rtnr_enable_10' on"

or from command line

amixer -c0 cset name='RTNR10.0 rtnr_enable_10' 1
amixer -c0 cget name='RTNR10.0 rtnr_enable_10' 0

Signed-off-by: Pin-chih Lin johnylin@google.com
Signed-off-by: Ming Jen Tai mingjen_tai@realtek.com

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

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.

Just as I mentioned in https://github.com/thesofproject/sof/pull/5616/files#r838305750
I am worried about that rtnr_copy_func may be out of sync. What would happen if rtnr_copy_func is changed while it is under processing?
Will need the comment from the expert.

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.

How about using single copy_func, but check the process_enable flag inside copy_func?

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.

Yes that would be better than the current code. rtnr_set_value() only do setting cd->process_enable value.
In rtnr_copy(), check cd->process_enable to determine the path. I think it could minimize the risk of asynchronous issue.

A quick question, when this is implemented, it means we can switch path in units of copy() (data sample chunk in one scheduled task). Would rtnr effect be degraded since it will obtain intermittent data samples, e.g. enabled during 1st to 100th task and then bypassed, re-enabled from 200th task. Fow now I could think of some factors which may drop the effect and even generate wrong output data.

  1. is there sample latency in rtnr? That is, the processed data has a certain delay than the source data.
  2. due to the discontinuity of data sample chunks, the waveform could be distorted if some algorithm uses a processing window larger than one chunk.

That's also the reason we tend to change path/config during the component restart (reset and prepare). In so doing the component actually regard each segment as an individual stream.

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.

Hi Johny,

There will be latency, but in overall it should be acceptable unless the user is toggling on&off rapidly.

@MingJenTai
MingJenTai force-pushed the main_RTNR_fix_control_switch branch from e1707f9 to 13bfa37 Compare April 1, 2022 00:32
Comment thread src/audio/rtnr/rtnr.c Outdated

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.

as much as this is appreciated as this reduces the call stack, I don't think this i needed. We just need the control interface modified.

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.

@cujomalainey Do you mean that we should use the original bypass path provided by RTNR, instead of introducing a new one?

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.

yea i don't see any issue with using that. the concern was the TLV interface only.

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.

Force-pushed a new commit. Please check it, thanks.

@MingJenTai
MingJenTai force-pushed the main_RTNR_fix_control_switch branch 3 times, most recently from 29039ef to f1e2bc4 Compare April 6, 2022 05:47
@sys-pt1s

Copy link
Copy Markdown

Can one of the admins verify this patch?

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

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.

why not just use !val for everything here so we can remove the if?

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.

@cujomalainey Fixed this. Thank you!

@MingJenTai
MingJenTai force-pushed the main_RTNR_fix_control_switch branch from f1e2bc4 to 32be360 Compare April 18, 2022 01:13
@lgirdwood

Copy link
Copy Markdown
Member

SOFCI TEST

@lgirdwood

Copy link
Copy Markdown
Member

Unblock the CI.

This PR is based on thesofproject#5616

It decouples the switch-typed control for enabling/disabling from the
control bytes.

Previously, control blobs should be sent from userspace to to toggle
RTNR on/off.
With this PR, RTNR can be toggled by setting the UCM switch value.

cset "name='RTNR10.0 rtnr_enable_10' off"
cset "name='RTNR10.0 rtnr_enable_10' on"

or from command line

amixer -c0 cset name='RTNR10.0 rtnr_enable_10' 1
amixer -c0 cget name='RTNR10.0 rtnr_enable_10' 0

Signed-off-by: Pin-chih Lin <johnylin@google.com>
Signed-off-by: Ming Jen Tai <mingjen_tai@realtek.com>

merge copy_func
@MingJenTai
MingJenTai force-pushed the main_RTNR_fix_control_switch branch from 32be360 to 947867d Compare April 29, 2022 06:39
@MingJenTai

Copy link
Copy Markdown
Contributor Author

Unblock the CI.

@lgirdwood Can this PR be merged now? Thanks!

@lgirdwood
lgirdwood merged commit 2e6bfbe into thesofproject:main May 3, 2022
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