-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: change trigger sequence to fix pop noise when stopping playback on sdw platforms #1897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASoC: SOF: change trigger sequence to fix pop noise when stopping playback on sdw platforms #1897
Conversation
|
Error is much improved with PR#1897. But still has very light pop via scenario "pause aplay first then Ctl+c to release aplay". Can observe this pop sound when increase speaker volume to Max via PGA3.0 3 |
sound/soc/sof/pcm.c
Outdated
| fe->dai_link->trigger[SNDRV_PCM_STREAM_PLAYBACK] = | ||
| SND_SOC_DPCM_TRIGGER_PRE; | ||
| fe->dai_link->trigger[SNDRV_PCM_STREAM_CAPTURE] = | ||
| SND_SOC_DPCM_TRIGGER_PRE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RanderWang a question: this PR aims at reducing the "pop" noise for playback. Do we need to change capture too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be called multi times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed with QA, they didn't find noise in wav data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be called multi times?
just like hw_params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RanderWang just wondering why not do this in sof_link_load()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I guess we dont know if this is connected to an ALH BE during link_load.
|
Good fine @RanderWang ! Because we have been switching the orders before, I'd want to have an explicit ack from @ranj063 that this is ok. We obviously need to do something due ot the many bugs, but let's still make sure we are fixing at the right place. Also FYI @tlauda I would expect the BE to run out of data (xrun) in case FE is stopped first, but not to play out garbage, but the tests do point to different behaviour. Please comment. |
|
I am also not comfortable with this change. We had a very long discussion on this in the context of HDaudio, and now we would revert the trigger order only for ALH - but what about SSP/DMIC which also use the GPDMA. |
Last week I just reverted the commit to use PRE sequence for all and @YvonneYang2 tested the patch. She found IPC timeout and DSP panic caused by HDMI, which uses link DMA. So it seems FW require POST sequence for link dma. @tlauda can you help to explain this ? |
The pop noise should be caused by this case: the value of last data sample should be much bigger than zero and suddenly followed by zero-value data, so a sound like "bang" |
@plbossart unfortunately from the results it looks like that might indeed be the case. But I have a suggestion. Instead of setting the trigger order to POST during topology loading, I think we should we should leave it as default during topology loading and only set the trigger order to POST in the BE hw_params() ioctl for HDA link. |
|
@ranj063 @tlauda rather than discussing where the order change is handled, can we please have clarity on why the HDaudio link DMA requires a specific order and SoundWire another? That is the big question to me, and I am not willing to merge anything until we understand what the directions are. It seems like a firmware dependency that's not properly handled or documented |
@plbossart I am just as much in the dark about this as you are. I was under the impression that when we made the change the last time around it was going to be blanket fix for all types of BEs. I'll have to punt this to the FW team @tlauda , please could you chime in? |
|
@plbossart @ranj063 @RanderWang I'm not very familiar with the differences between FE and BE triggers, so maybe I will just describe why the order has been changed in the first place. When you are sending TRIGGER_START/RELEASE IPC to the FW, the DSP starts the pipeline immediately. Pipelines are scheduled on timer, so ticks are happening asynchronously to the IPCs. Since you first triggered the pipeline and HDA Link was started after that, sometimes there was a race happening, where we expected to copy the data, but the data wasn't yet there. It often caused xruns. The same thing is for the STOP sequence, but for the stop it gets even worse, since the wrong sequence between FW and host can hang everything. |
@tlauda the xruns we saw was for the capture case where starting the BE before the FE makes sense because you dont want to be in a situation where there's nothing to copy. Shouldnt the order be the reverse then for playback? But that would make it even more crazy to have 2 different trigger orders for playback and capture. Does it make sense? |
|
@tlauda oh yeah. dont know why I have it as capture in my mind. So in the case of HDA link DMA< even for playback the trigger order makes sense. So now to @plbossart 's question. Why should it change for SDW? |
@RanderWang Have you tried what I proposed? Emptying ALH/SDW FIFO (in kernel) and zeroing DMA buffer (in FW)? Maybe it will help for the pop without changing any order. |
@tlauda We have tested this solution "Emptying ALH/SDW FIFO (in kernel) and zeroing DMA buffer (in FW)"(#1887 & thesofproject/sof#2573), but still have pop noise when stop playback. And you can image when someone is climbing a ladder and the ladder is suddenly removed, what will happen. |
|
@RanderWang So the pop is also when stopping playback? How is that possible if the FW pipeline is stopped first? |
@tlauda please check above bugs, not only start & stop, but also pulse & resume. If FW is stopped first, then the there is no data sent to sdw bus, and there is a abrupt change in data stream, just produce a big bang. |
|
@ClarexZhou Now I change the trigger sequence of playback for both SDW & I2S, can you help to validate playback on I2S platforms ? thanks! |
Do all sanity test and check all noise scenarios on GLK Chrome with onboard codec DA7219 in I2S mode, found no regression. |
Thanks! |
BugLink: https://bugs.launchpad.net/bugs/1872916 Now the trigger sequence is set to SND_SOC_DPCM_TRIGGER_POST for SOF. This means FE will be stopped before BE, so BE will consume invalid data and this generates huge pop noise. Now set trigger sequence to SND_SOC_DPCM_TRIGGER_PRE to let FE to be stopped after BE to avoid this issue. Fully tested on Comet Lake for a few cycles. Signed-off-by: randerwang <rander.wang@linux.intel.com> (backported from thesofproject#1897) Signed-off-by: Hui Wang <hui.wang@canonical.com>
a3c3fa6 to
d0c07dc
Compare
|
@plbossart update my PR to unify the trigger sequence with I2S & sdw. |
plbossart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add more comments or reword them. Thanks @RanderWang
sound/soc/sof/topology.c
Outdated
| * HDA and sdw. Frontend is started before the backend | ||
| * when start playback and Frontend is stopped after the | ||
| * backend when stop playback. The tigger order is reverse | ||
| * for Capture compared to playback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested edit:
set default trigger order for all links. Exceptions to the rule will be handled in sof_pcm_dai_link_fixup()
For playback, the sequence is the following:
start FE, start BE, stop BE, stop FE
For Capture the sequence is inverted
start BE, start FE, stop FE, stop BE
@ranj063 can you please review this since you modified the sequence for HDaudio. Thanks!
…ing playback on sdw platforms Now the trigger sequence is set to SND_SOC_DPCM_TRIGGER_POST for SOF. This means FE will be stopped before BE, so BE will consume invalid data and this generates huge pop noise. This sequence is introduced for HDA DAI which requires SND_SOC_DPCM_TRIGGER_POST for some reasons. Now set default trigger sequence to SND_SOC_DPCM_TRIGGER_PRE for playback with all DAI and fix sequence only for HDA DAI. Fully tested on Comet Lake for a few cycles. Signed-off-by: randerwang <rander.wang@linux.intel.com>
d0c07dc to
360d48c
Compare
|
QA also tested HDMI playback. Thanks! |
ClarexZhou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on GLK I2S and CML-U&H SDW. Works OK and no regression.
lyakh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for my info: this means, with HDA DAIs we will still have pop noises and they are impossible to fix?
@lyakh It also depends on audio IP connected to codecs. Now we don't get pop noise issue with HDA link. |
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RanderWang can you check if this has any impact on capture.
capture is not modified by this PR. |
@RanderWang got it, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart @RanderWang I made an interesting discovery today while trying to debug another issue with power management. Basically, what I noticed was the idle_bias_on setting for the component driver has some connection with the xruns that we saw with pause/release in capture. So, to confirm this, I set the trigger order for the DAI's in the SOF driver to the default TRIGGER_PRE and set the "idle_bias_on" in the hdac codec component driver to true.
So my suggestion is try experimenting with the idle_bias_on setting in the rt1308/rt711 codec component drivers and see if this problem can be fixed.
ranj063
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idle_bias_off might have PM regressions. so this change is good.
|
@kv2019i sorry, I assumed you were reviewer for you commented it, now add you to review this PR. Thanks! |
|
@RanderWang wrote:
It seems this patch has sufficient review approvals already. So the remaining blockers are @plbossart request-changes. Another are the CML SDW failures in CI, why are these happening: |
SoundWire pause/resume is currently not supported, so this test should be skipped for now. |
we need another PR to fix it thesofproject/sof#2673 |
|
Let's merge and see what QA reports. |

Now the trigger sequence is set to SND_SOC_DPCM_TRIGGER_POST for
SOF. This means FE will be stopped before BE, so BE will consume
invalid data and this generates huge pop noise. Now set trigger
sequence to SND_SOC_DPCM_TRIGGER_PRE to let FE to be stopped after
BE to avoid this issue.
Thanks @YvonneYang2 Fully tested on Comet Lake for a few cycles. She didn't find any issue on Comet Lake U. On Comet Lake H, she found a clock stop issue when doing S3 stress test, but she can't reproduce it again. I think is not connect to this PR directly.
Fixes #1867 #1869 #1865 #1866