summaryrefslogtreecommitdiff
path: root/sound/soc/soc-pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-pcm.c')
-rw-r--r--sound/soc/soc-pcm.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 0717f39d2eec..b2440f2f9bf5 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1534,7 +1534,7 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
goto unwind;
}
-
+ be->dpcm[stream].be_start = 0;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN;
count++;
}
@@ -2001,6 +2001,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
int ret = 0;
unsigned long flags;
enum snd_soc_dpcm_state state;
+ bool do_trigger;
for_each_dpcm_be(fe, stream, dpcm) {
struct snd_pcm_substream *be_substream;
@@ -2015,6 +2016,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
dev_dbg(be->dev, "ASoC: trigger BE %s cmd %d\n",
be->dai_link->name, cmd);
+ do_trigger = false;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
@@ -2025,13 +2027,20 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
continue;
}
state = be->dpcm[stream].state;
+ if (be->dpcm[stream].be_start == 0)
+ do_trigger = true;
+ be->dpcm[stream].be_start++;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
+ if (!do_trigger)
+ continue;
+
ret = soc_pcm_trigger(be_substream, cmd);
if (ret) {
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
be->dpcm[stream].state = state;
+ be->dpcm[stream].be_start--;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
goto end;
}
@@ -2045,13 +2054,20 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
}
state = be->dpcm[stream].state;
+ if (be->dpcm[stream].be_start == 0)
+ do_trigger = true;
+ be->dpcm[stream].be_start++;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
+ if (!do_trigger)
+ continue;
+
ret = soc_pcm_trigger(be_substream, cmd);
if (ret) {
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
be->dpcm[stream].state = state;
+ be->dpcm[stream].be_start--;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
goto end;
}
@@ -2065,13 +2081,20 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
}
state = be->dpcm[stream].state;
+ if (be->dpcm[stream].be_start == 0)
+ do_trigger = true;
+ be->dpcm[stream].be_start++;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
+ if (!do_trigger)
+ continue;
+
ret = soc_pcm_trigger(be_substream, cmd);
if (ret) {
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
be->dpcm[stream].state = state;
+ be->dpcm[stream].be_start--;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
goto end;
}
@@ -2084,9 +2107,15 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
continue;
}
+ if ((be->dpcm[stream].state == SND_SOC_DPCM_STATE_START &&
+ be->dpcm[stream].be_start == 1) ||
+ (be->dpcm[stream].state == SND_SOC_DPCM_STATE_PAUSED &&
+ be->dpcm[stream].be_start == 0))
+ do_trigger = true;
+ be->dpcm[stream].be_start--;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
- if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream))
+ if (!do_trigger)
continue;
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
@@ -2098,6 +2127,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
if (ret) {
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
be->dpcm[stream].state = state;
+ be->dpcm[stream].be_start++;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
goto end;
}
@@ -2109,9 +2139,12 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
continue;
}
+ if (be->dpcm[stream].be_start == 1)
+ do_trigger = true;
+ be->dpcm[stream].be_start--;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
- if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream))
+ if (!do_trigger)
continue;
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
@@ -2123,6 +2156,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
if (ret) {
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
be->dpcm[stream].state = state;
+ be->dpcm[stream].be_start++;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
goto end;
}
@@ -2134,9 +2168,12 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
continue;
}
+ if (be->dpcm[stream].be_start == 1)
+ do_trigger = true;
+ be->dpcm[stream].be_start--;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
- if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream))
+ if (!do_trigger)
continue;
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
@@ -2148,6 +2185,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
if (ret) {
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
be->dpcm[stream].state = state;
+ be->dpcm[stream].be_start++;
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
goto end;
}