Commit ccff7bd468d5e0595176656a051ef67c01f01968

Authored by Hui Wang
Committed by Mark Brown
1 parent b023666e6c

ASoC: amd: renoir: restore two more registers during resume

Recently we found an issue about the suspend and resume. If dmic is
recording the sound, and we run suspend and resume, after the resume,
the dmic can't work well anymore. we need to close the app and reopen
the app, then the dmic could record the sound again.

For example, we run "arecord -D hw:CARD=acp,DEV=0 -f S32_LE -c 2
-r 48000 test.wav", then suspend and resume, after the system resume
back, we speak to the dmic. then stop the arecord, use aplay to play
the test.wav, we could hear the sound recorded after resume is weird,
it is not what we speak to the dmic.

I found two registers are set in the dai_hw_params(), if the two
registers are set during the resume, this issue could be fixed.
Move the code of the dai_hw_params() into the pdm_dai_trigger(), then
these two registers will be set during resume since pdm_dai_trigger()
will be called during resume. And delete the empty function
dai_hw_params().

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Reviewed-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200730123138.5659-1-hui.wang@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>

Showing 1 changed file with 9 additions and 20 deletions Side-by-side Diff

sound/soc/amd/renoir/acp3x-pdm-dma.c
... ... @@ -314,40 +314,30 @@
314 314 return 0;
315 315 }
316 316  
317   -static int acp_pdm_dai_hw_params(struct snd_pcm_substream *substream,
318   - struct snd_pcm_hw_params *params,
319   - struct snd_soc_dai *dai)
  317 +static int acp_pdm_dai_trigger(struct snd_pcm_substream *substream,
  318 + int cmd, struct snd_soc_dai *dai)
320 319 {
321 320 struct pdm_stream_instance *rtd;
  321 + int ret;
  322 + bool pdm_status;
322 323 unsigned int ch_mask;
323 324  
324 325 rtd = substream->runtime->private_data;
325   - switch (params_channels(params)) {
  326 + ret = 0;
  327 + switch (substream->runtime->channels) {
326 328 case TWO_CH:
327 329 ch_mask = 0x00;
328 330 break;
329 331 default:
330 332 return -EINVAL;
331 333 }
332   - rn_writel(ch_mask, rtd->acp_base + ACP_WOV_PDM_NO_OF_CHANNELS);
333   - rn_writel(PDM_DECIMATION_FACTOR, rtd->acp_base +
334   - ACP_WOV_PDM_DECIMATION_FACTOR);
335   - return 0;
336   -}
337   -
338   -static int acp_pdm_dai_trigger(struct snd_pcm_substream *substream,
339   - int cmd, struct snd_soc_dai *dai)
340   -{
341   - struct pdm_stream_instance *rtd;
342   - int ret;
343   - bool pdm_status;
344   -
345   - rtd = substream->runtime->private_data;
346   - ret = 0;
347 334 switch (cmd) {
348 335 case SNDRV_PCM_TRIGGER_START:
349 336 case SNDRV_PCM_TRIGGER_RESUME:
350 337 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  338 + rn_writel(ch_mask, rtd->acp_base + ACP_WOV_PDM_NO_OF_CHANNELS);
  339 + rn_writel(PDM_DECIMATION_FACTOR, rtd->acp_base +
  340 + ACP_WOV_PDM_DECIMATION_FACTOR);
351 341 rtd->bytescount = acp_pdm_get_byte_count(rtd,
352 342 substream->stream);
353 343 pdm_status = check_pdm_dma_status(rtd->acp_base);
... ... @@ -369,7 +359,6 @@
369 359 }
370 360  
371 361 static struct snd_soc_dai_ops acp_pdm_dai_ops = {
372   - .hw_params = acp_pdm_dai_hw_params,
373 362 .trigger = acp_pdm_dai_trigger,
374 363 };
375 364