Skip to content

Topology: Apply high-pass for HDA capture streams, Volume: Force gain ramp - #2109

Merged
lgirdwood merged 5 commits into
thesofproject:masterfrom
singalsu:hda_capture_add_hp
Jan 16, 2020
Merged

lgirdwood merged 5 commits into
thesofproject:masterfrom
singalsu:hda_capture_add_hp

Conversation

@singalsu

@singalsu singalsu commented Nov 19, 2019 •

Copy link
Copy Markdown
Collaborator

This pull request consists of five commits. The purpose is to mitigate the DC pulse noise in the beginning of audio capture from headset.

  1. Topology: Apply high-pass for HDA capture streams
  2. Volume: Fix for gain ramp step macro value
  3. Volume: Always launch ramp in beginning of copy() operations
  4. Volume: Simplify ramp calculation and provide constant rate on/off
  5. Volume: Simplify volume synchronization to host

The core of the fix is in commits 1 and 3. Commit 4 makes the initial ramp consistent. Commit 2 fixes a mistake that luckily haven't triggered any issues. Commit 5 is additional cleanup of code that was requested in review or this PR.

@plbossart

Copy link
Copy Markdown
Member

@bardliao can you try this with a change to the rt715 capture pipeline to solve thesofproject/linux#1480

it should be just a change in the pipeline name

@bardliao

Copy link
Copy Markdown
Collaborator

@bardliao can you try this with a change to the rt715 capture pipeline to solve thesofproject/linux#1480

it should be just a change in the pipeline name

Not lucky. This PR doesn't solve thesofproject/linux#1480

@aiChaoSONG

aiChaoSONG commented Nov 20, 2019 •

Copy link
Copy Markdown
Collaborator

Screenshot from 2019-11-20 10-18-46

The DC pulse becomes shorter, about 0.04s(previously 0.35s)

@singalsu

Copy link
Copy Markdown
Collaborator Author

@aiChaoSONG Can you please check if there's volume ramp happening at all in the capture? There's also the suspending volume jump issue that makes the driver suspect of not doing un-mute in beginning.

Normally the volume ramp should conceal the beginning and once the ramp has completed the IIR has settled mostly. Also I can still increase a bit the cut-off frequency to settle the DC level a bit faster than 0.04s.

@singalsu

Copy link
Copy Markdown
Collaborator Author

Not lucky. This PR doesn't solve thesofproject/linux#1480

@bardliao Do you have a captured sample or wav editor screenshot of the result?

@aiChaoSONG

Copy link
Copy Markdown
Collaborator

@singalsu I think you are talking about #1463 Output very loud at the beginning ..., as a matter of fact, this issue exist on almost every device we have.

the volume ramp only exists at the begin of the recording, because the dsp never goes into suspended after I pause(SPACE)/stop(CTRL+Z) the recording pipeline and wait for a long time. now I suspect #2102 and #1463 are the same issue.

@singalsu

Copy link
Copy Markdown
Collaborator Author

@aiChaoSONG Thanks for info! The bugs were assigned to me so I will try to fix these. Sounds indeed they are the same issues.

@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 I would upstream most of this PR even if it does not fix this particular issue. This DC blocking filter is useful even if there are no users on the Intel platforms atm.

Comment thread tools/topology/m4/eq_iir_coef_highpass_50hz_0db_48khz.m4 Outdated
@bardliao

bardliao commented Nov 21, 2019 •

Copy link
Copy Markdown
Collaborator

Not lucky. This PR doesn't solve thesofproject/linux#1480

@bardliao Do you have a captured sample or wav editor screenshot of the result?

@singalsu dmic.zip is the captured sample and highpass.diff.txt is the change I did.

Thanks @bardliao ! It's as expected and the next version of this PR should fix this.

@singalsu singalsu changed the title [RFC] Topology: Apply 50 Hz high-pass for HDA capture streams [RFC] Topology: Apply 50 Hz high-pass for HDA capture streams, Volume: Force gain ramp Nov 21, 2019
@singalsu

Copy link
Copy Markdown
Collaborator Author

@bardliao @aiChaoSONG Can please re-check with this PR version the capture waveform. There's now a FW change into FW component as well.

@singalsu
singalsu requested a review from lgirdwood November 21, 2019 14:37
Comment thread src/audio/volume/volume.c Outdated
Comment thread src/audio/volume/volume.c Outdated
Comment thread src/audio/volume/volume.c Outdated
@bardliao

Copy link
Copy Markdown
Collaborator

@bardliao @aiChaoSONG Can please re-check with this PR version the capture waveform. There's now a FW change into FW component as well.

@singalsu It works. Please check the captured file dmic.zip

@aiChaoSONG

Copy link
Copy Markdown
Collaborator

The volume of the capture pipeline will influence the waveform at the begin of recording. I tried vol=30 and vol =50, please find the waveform in the file below
waveform.zip

@singalsu

Copy link
Copy Markdown
Collaborator Author

The volume of the capture pipeline will influence the waveform at the begin of recording. I tried vol=30 and vol =50, please find the waveform in the file below
waveform.zip

Thanks, yep it seems to do. The request volume should not impact the start ramp time. Looks like the ramp time calculation fails somehow. I'll look into it and fix it. What is strange is that it looks like the high-pass IIR fails. The DC settling time of 3 seconds looks like it's not working.

@singalsu

Copy link
Copy Markdown
Collaborator Author

@bardliao @aiChaoSONG Can please re-check with this PR version the capture waveform. There's now a FW change into FW component as well.

@singalsu It works. Please check the captured file dmic.zip

This does not look as I intended. There's no unmute ramp happening in the beginning, strange. But I'll anyway do a new version, need to fix and clean up the ramp calculation.

@singalsu

Copy link
Copy Markdown
Collaborator Author

I fixed bugs / rewrote the ramp step calculation since I no more understood why the code was like that. Also not sure if it was the case but when testing this PR please ensure both topology and firmware commits from this PR are included.

@singalsu

singalsu commented Jan 9, 2020

Copy link
Copy Markdown
Collaborator Author

@zrombel @lgirdwood @lbetlej One idea to address the KPB fail could be to alter the gain ramp length for the volume instance instance for KPB, e.g. change ramp length from 250 ms to 10 ms. Would be OK for testing such approach?

@zrombel

zrombel commented Jan 9, 2020

Copy link
Copy Markdown

@singalsu I've investigated fails in that particular test (KD + DMIC) and it seems that there is a bug in KD on APL platform. It's rather sporadic but as we can see it affects CI results. I've removed that test from CI scope and I'm about to report the bug on github, so it shouldn't be a problem any more.

@singalsu

singalsu commented Jan 9, 2020

Copy link
Copy Markdown
Collaborator Author

@zrombel Thanks, it's excellent news for this PR and hope the issue gets a fix soon too!

@lgirdwood

Copy link
Copy Markdown
Member

@singalsu cant we just change the ramp time for KPB only in topology ?

@singalsu

singalsu commented Jan 9, 2020

Copy link
Copy Markdown
Collaborator Author

@lgirdwood Yep, that was exactly my thought. If there's still problem in some specific usage I can make ramp time 0 ms for them via topology to get the previous behavior. DMIC does in HW an unmute ramp when started so the volume ramp is not a must. But also it doesn't hurt.

@lgirdwood

Copy link
Copy Markdown
Member

@singalsu ack, lets keep KPB ramp at 0 then.

@singalsu

singalsu commented Jan 9, 2020

Copy link
Copy Markdown
Collaborator Author

@singalsu ack, lets keep KPB ramp at 0 then.

OK, I'll add the topology change to this PR then too.

@singalsu

Copy link
Copy Markdown
Collaborator Author

@singalsu ack, lets keep KPB ramp at 0 then.

OK, I'll add the topology change to this PR then too.

@lgirdwood There's no need to update this PR. I just checked that all topologies those use pipe-kfbm-capture.m4 macro (sof-cml-rt5682-kwd.m4, sof-apl-keyword-detect.m4, sof-glk-da7219-kwd.m4) have no more volume component in the pipeline. The KPB fails must be a totally separate issue since the components impacted by this PR are not included.

@lgirdwood

Copy link
Copy Markdown
Member

SOFCI TEST

@lgirdwood

Copy link
Copy Markdown
Member

@singalsu ok, @mrajwa any idea why we are seeing KPB UT failures now ?

This patch replaces in topology sof-hda-generic.m4 the use of macro
pipe-volume-capture.m4 usage with a new macro pipe-highpass-capture.m4.
The used 40 Hz cut-off is sufficient to suppress the DC pulse in the
beginning of capture from headset with minimal impact to other
applications such as recording music.

The capture volume ramp length is changed from 250 ms to 400 ms. The
longer ramp is feasible because the microphone path seems to open
at 500 ms from capture. It helps to attenuate the remaining noises
in the beginning of capture.

The patch also adds additional high-pass responses macros for
topology with different 20-50 Hz cut-off frequencies into
SOF/tools/topology/m4.

The changes for Matlab/Octave script example_iir_eq.m that
generated the filter coefficients are included here as well.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch fixes the calculation of macro VOL_RAMP_STEP_CONST
that is used in linear step size calculation. The previous version
calculated incorrectly the value as inverse. However with used ramp
update rate of 1000 us there were no issues seen because the value
and inverse were both 1.0. The bug would have triggered with with
a faster or slower ramp update rate.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch ensures that a ramp will happen in beginning of
streaming even if the driver control sequence would not launch
it by successive volume requests for mute and actual volume.

Also a check is added into volume ramp update to prevent a volume
command in component idle state to schedule repeatedly ramp
updates. In that case the volume can be set immediately to ramp
end value.

Also the ramp is updated for active channels only. There's no need to
update for the maximum channels count.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The earlier version of ramp step calculation was more complex than
necessary and there was no way to ensure the max. topology defined
ramp time happens in beginning of streaming so the step equation
was rewritten. The step value is rounded for better match with
topology defined ramp length.

Normally the ramp is constant rate type where the topology define
time happens for vol min-max transition. A smaller transition is
completed in less time.

The constant rate mode is not used for the first copy() triggered
ramp to ensure the ramp from vol min to used volume takes the
entire topology defined time. This mode is also as earlier used
for legacy kernels where the vol min/max information is not passed.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch removes a trivial function vol_update() and alters
vol_sync_host() to update all channels the same time into the
host data structure instead of per channel updates. There is no
other change to component operation.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu

Copy link
Copy Markdown
Collaborator Author

New version, no other changes than the conflict fix with PR #2272.

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

CI seems to missed this update lets rerun

@lgirdwood

Copy link
Copy Markdown
Member

SOFCI TEST

@singalsu

Copy link
Copy Markdown
Collaborator Author

@zrombel @lgirdwood I wonder why TestPtpSimpleLoopback48000Hz32b32b8ch fails on ICL. Could the forced volume unmute ramp or IIR high-pass cause it? There's no same test for other HDA codec based platform. Though there's a pass for similar case for APL but maybe the tested pipelines are not similar?

@lgirdwood

Copy link
Copy Markdown
Member

@singalsu sorry, I've no visibility on this, @zrombel will have to guide us here.

@jajanusz

Copy link
Copy Markdown
Contributor
11:41:07,449 INFO  - ### Verify captured stream 0 ###
11:41:07,449 INFO  -
11:41:07,449 INFO  - Opening source file:
11:41:07,449 INFO  - C:\Testing\Generated\\SineGenerator_48kHz_32bit_in_32bit_8ch_3s_freq_[300, 400, 500, 600, 800, 1200, 1600, 2000]_amp_1.wav
11:41:07,449 INFO  - Opening sink file:
11:41:07,449 INFO  - c:\history\SOF\LABELED\PR_REGRESSION_pull-2109-merge_9075_2138\02_00_TestPtpSimpleLoopback48000Hz32b32b8ch\TestPtpSimpleLoopback48000Hz32b32b8ch.test_2020_01_15_11_47_01_tplg0_iter0.wav
11:41:07,449 INFO  - BBB value is smaller than acceptable value (0) on channel 0: 0.00

For me it looks like it recorded silence, maybe @zrombel can tell more

@singalsu

Copy link
Copy Markdown
Collaborator Author

@jajanusz Thanks. @zrombel It would be good to know if the file is entirely zeros and how the (slim?) driver has configured the volume instance gains how does the test topology look like.

@singalsu

Copy link
Copy Markdown
Collaborator Author

@lgirdwood The CI fail is still mystery to me if it's real or not. I wonder if I should split the volume changes into another PR to proceed with the high-pass part that cannot impact the loop-back test. We need the high-pass filters set also to address a similar issue with a SDW codec and I can't proceed while they are not merged.

@zrombel

zrombel commented Jan 16, 2020

Copy link
Copy Markdown

@singalsu @lgirdwood I've checked this PR test history and it looks like there were some random errors. We have enhanced some of test to prevent this issues, but some was just hardware failures which sadly we cannot avoid. Sorry for that. We will continue to work to increase CI stability.

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.