From e553d4f851fe35ef2706e5b9d0ea85e26a5d4ce3 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 23 Apr 2021 22:55:59 +0100 Subject: [PATCH] Operational change to correct for 5.5+ change in trigger order; REVISIT! Need to revisit, and do in a different way. https://github.com/respeaker/seeed-voicecard/issues/290 6mics / linear 4 mics: fails to record against v5.10 kernel https://github.com/raspberrypi/linux/issues/4279 [regression] alsa system call blocks on record between 5.4.83 and 5.5.19 In v5.5, commit 4378f1fbe924054a09ff0d4e39e1a581b9245252 Author: Peter Ujfalusi Date: Fri Sep 27 10:16:46 2019 +0300 ASoC: soc-pcm: Use different sequence for start/stop trigger On stream stop currently we stop the DMA first followed by the CPU DAI. This can cause underflow (playback) or overflow (capture) on the DAI side as the DMA is no longer feeding data while the DAI is still active. It can be observed easily if the DAI side does not have FIFO (or it is disabled) to survive the time while the DMA is stopped, but still can happen on relatively slow CPUs when relatively high sampling rate is used: the FIFO is drained between the time the DMA is stopped and the DAI is stopped. It can only fixed by using different sequence within trigger for 'stop' and 'start': case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: Trigger order: dai_link, DMA, CPU DAI then the codec case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: Trigger order: codec, CPU DAI, DMA then dai_link Signed-off-by: Peter Ujfalusi Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20190927071646.22319-1-peter.ujfalusi@ti.com Signed-off-by: Mark Brown --- Makefile | 2 +- ac108.c | 2 +- seeed-voicecard.c | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b9de7f4..1aa0949 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ ifneq ($(KERNELRELEASE),) snd-soc-wm8960-objs := wm8960.o snd-soc-ac108-objs := ac108.o ac101.o -snd-soc-seeed-voicecard-objs := seeed-voicecard.o +snd-soc-seeed-voicecard-objs := seeed-voicecard.o ac101.o obj-m += snd-soc-wm8960.o diff --git a/ac108.c b/ac108.c index 4075eee..075b6cd 100644 --- a/ac108.c +++ b/ac108.c @@ -1058,7 +1058,7 @@ static int ac108_trigger(struct snd_pcm_substream *substream, int cmd, snd_pcm_stream_str(substream), cmd); - if (ac10x->i2c101 && _MASTER_MULTI_CODEC == _MASTER_AC101) { + if (!cmd && ac10x->i2c101 && _MASTER_MULTI_CODEC == _MASTER_AC101) { ac101_trigger(substream, cmd, dai); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { goto __ret; diff --git a/seeed-voicecard.c b/seeed-voicecard.c index 9f5f7e7..25bca71 100644 --- a/seeed-voicecard.c +++ b/seeed-voicecard.c @@ -198,6 +198,7 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); + struct ac10x_priv *ac10x = snd_soc_dai_get_drvdata(dai); struct seeed_card_data *priv = snd_soc_card_get_drvdata(rtd->card); #if CONFIG_AC10X_TRIG_LOCK unsigned long flags; @@ -217,6 +218,9 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd /* I know it will degrades performance, but I have no choice */ spin_lock_irqsave(&priv->lock, flags); #endif + if (cmd && ac10x->i2c101 && _MASTER_MULTI_CODEC == _MASTER_AC101) { + ac101_trigger(substream, cmd, dai); + } if (_set_clock[SNDRV_PCM_STREAM_CAPTURE]) _set_clock[SNDRV_PCM_STREAM_CAPTURE](1); if (_set_clock[SNDRV_PCM_STREAM_PLAYBACK]) _set_clock[SNDRV_PCM_STREAM_PLAYBACK](1); #if CONFIG_AC10X_TRIG_LOCK