summaryrefslogtreecommitdiff
path: root/sound/soc/soc-pcm.c
diff options
context:
space:
mode:
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>2022-04-06 22:00:55 +0300
committerMark Brown <broonie@kernel.org>2022-04-19 18:33:51 +0300
commit9995c1d096c8ab1b5f1edc4141257719f6a53524 (patch)
tree6b1f3f5af4716b2b8a3642e580bfc907a460ee55 /sound/soc/soc-pcm.c
parente65f2fce08fc708e65b544131999bdd933d09164 (diff)
downloadlinux-9995c1d096c8ab1b5f1edc4141257719f6a53524.tar.xz
ASoC: soc-pcm: improve BE transition for PAUSE_RELEASE
Commit 3aa1e96a2b95 ("ASoC: soc-pcm: fix BE handling of PAUSE_RELEASE") did not modify the existing logic and kept the same logic for the following transition play FE1 -> BE state is START pause FE1 -> BE state is PAUSED play FE2 -> BE state is START stop FE2 -> BE state is STOP <<< !! release FE1 -> BE state is START stop FE1 -> BE state is STOP At the time it was identified by reviewers that a better solution might consist in play FE1 -> BE state is START pause FE1 -> BE state is PAUSED play FE2 -> BE state is START stop FE2 -> BE state is PAUSE <<< !! release FE1 -> BE state is START stop FE1 -> BE state is STOP This patch suggest a transition to PAUSE when all the 'active' streams are paused. This would allow for a more consistent resource management for platforms where PAUSE and STOP are handled differently. To track the special case of an FE going from PAUSE_PUSH to STOP, we add a state variable for each FE context. This 'fe_pause' boolean is set on PAUSE_PUSH and cleared on either PAUSE_RELEASE and STOP triggers. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220406190056.233481-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-pcm.c')
-rw-r--r--sound/soc/soc-pcm.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 11c9853e9e80..e8700dd1839f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2090,6 +2090,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
int cmd)
{
struct snd_soc_pcm_runtime *be;
+ bool pause_stop_transition;
struct snd_soc_dpcm *dpcm;
unsigned long flags;
int ret = 0;
@@ -2148,10 +2149,12 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
if (!be->dpcm[stream].be_start &&
(be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) &&
- (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
(be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED))
goto next;
+ fe->dpcm[stream].fe_pause = false;
+ be->dpcm[stream].be_pause--;
+
be->dpcm[stream].be_start++;
if (be->dpcm[stream].be_start != 1)
goto next;
@@ -2175,14 +2178,33 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
if (be->dpcm[stream].be_start != 0)
goto next;
- ret = soc_pcm_trigger(be_substream, cmd);
+ pause_stop_transition = false;
+ if (fe->dpcm[stream].fe_pause) {
+ pause_stop_transition = true;
+ fe->dpcm[stream].fe_pause = false;
+ be->dpcm[stream].be_pause--;
+ }
+
+ if (be->dpcm[stream].be_pause != 0)
+ ret = soc_pcm_trigger(be_substream, SNDRV_PCM_TRIGGER_PAUSE_PUSH);
+ else
+ ret = soc_pcm_trigger(be_substream, SNDRV_PCM_TRIGGER_STOP);
+
if (ret) {
if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START)
be->dpcm[stream].be_start++;
+ if (pause_stop_transition) {
+ fe->dpcm[stream].fe_pause = true;
+ be->dpcm[stream].be_pause++;
+ }
goto next;
}
- be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
+ if (be->dpcm[stream].be_pause != 0)
+ be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
+ else
+ be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
+
break;
case SNDRV_PCM_TRIGGER_SUSPEND:
if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
@@ -2204,6 +2226,9 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
goto next;
+ fe->dpcm[stream].fe_pause = true;
+ be->dpcm[stream].be_pause++;
+
be->dpcm[stream].be_start--;
if (be->dpcm[stream].be_start != 0)
goto next;