summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Girdwood <lrg@slimlogic.co.uk>2010-09-24 01:35:50 +0100
committerSebastien Jan <s-jan@ti.com>2010-11-03 15:57:57 +0100
commitb8a7b97b147cee8653a4a0a6021c5d0e57ad5434 (patch)
treec7f5c162a97e630e42a56e3ac0a10ecdee0ea622
parentedb7448260f936c8dede4c0ddfb974360797d62f (diff)
ASoC: core - make BE ref counting per stream
BE ref-counting must be carried out per stream direction to ensure we switch off *only* the correct BE DAIs. Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Margarita Olaya Cabrera <magi.olaya@ti.com>
-rw-r--r--include/sound/soc-dapm.h2
-rw-r--r--include/sound/soc.h4
-rw-r--r--sound/soc/soc-core.c46
-rw-r--r--sound/soc/soc-dapm.c6
4 files changed, 29 insertions, 29 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 9ee8aa577710..e40d5906bf5e 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -338,7 +338,7 @@ const char *snd_soc_dapm_get_aif(struct snd_soc_dapm_context *dapm,
/* dapm events */
int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
- const char *stream, int event);
+ int dir, const char *stream, int event);
void snd_soc_dapm_shutdown(struct snd_soc_card *card);
/* external DAPM widget events */
diff --git a/include/sound/soc.h b/include/sound/soc.h
index a05b879f6b45..f6f39ab60189 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -658,9 +658,9 @@ struct snd_soc_pcm_runtime {
/* BE runtime data */
unsigned int fe_clients;
- unsigned int num_be;
+ unsigned int num_be[2];
unsigned int be_active;
- struct snd_soc_pcm_runtime *be_rtd[SND_SOC_MAX_BE];
+ struct snd_soc_pcm_runtime *be_rtd[SND_SOC_MAX_BE][2];
/* Symmetry data - only valid if symmetry is being enforced */
unsigned int rate;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d1d78debf783..1cd44240ef52 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -451,18 +451,18 @@ int snd_soc_get_backend_dais(struct snd_pcm_substream *substream)
/* add backend if we have space */
if (num > 0) {
- if (rtd->num_be == SND_SOC_MAX_BE)
+ if (rtd->num_be[substream->stream] == SND_SOC_MAX_BE)
dev_dbg(&rtd->dev, "no more backends permitted\n");
else {
dev_dbg(&rtd->dev, "** active path for %s to %s\n", fe_aif, be_aif);
- rtd->be_rtd[rtd->num_be++] = &card->rtd[i];
+ rtd->be_rtd[rtd->num_be[substream->stream]++][substream->stream] = &card->rtd[i];
card->rtd[i].fe_clients++;
}
}
}
}
- return rtd->num_be ? rtd->num_be : -EINVAL;
+ return rtd->num_be[substream->stream] ? rtd->num_be[substream->stream] : -EINVAL;
}
EXPORT_SYMBOL_GPL(snd_soc_get_backend_dais);
@@ -471,11 +471,11 @@ void snd_soc_put_backend_dais(struct snd_pcm_substream *substream)
struct snd_soc_pcm_runtime *rtd = substream->private_data;
int i;
- for (i = 0; i < rtd->num_be; i++) {
- rtd->be_rtd[i]->fe_clients--;
- rtd->be_rtd[i] = NULL;
+ for (i = 0; i < rtd->num_be[substream->stream]; i++) {
+ rtd->be_rtd[i][substream->stream]->fe_clients--;
+ rtd->be_rtd[i][substream->stream] = NULL;
}
- rtd->num_be = 0;
+ rtd->num_be[substream->stream] = 0;
}
EXPORT_SYMBOL_GPL(snd_soc_put_backend_dais);
@@ -703,11 +703,11 @@ static void close_delayed_work(struct work_struct *work)
if (codec_dai->pop_wait == 1) {
codec_dai->pop_wait = 0;
if (rtd->dai_link->dynamic)
- snd_soc_dapm_stream_event(rtd,
+ snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
cpu_dai->driver->playback.stream_name,
SND_SOC_DAPM_STREAM_STOP);
else
- snd_soc_dapm_stream_event(rtd,
+ snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
codec_dai->driver->playback.stream_name,
SND_SOC_DAPM_STREAM_STOP);
}
@@ -773,11 +773,11 @@ int snd_soc_pcm_close(struct snd_pcm_substream *substream)
} else {
/* capture streams can be powered down now */
if (rtd->dai_link->dynamic)
- snd_soc_dapm_stream_event(rtd,
+ snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
cpu_dai->driver->capture.stream_name,
SND_SOC_DAPM_STREAM_STOP);
else
- snd_soc_dapm_stream_event(rtd,
+ snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
codec_dai->driver->capture.stream_name,
SND_SOC_DAPM_STREAM_STOP);
}
@@ -847,20 +847,20 @@ int snd_soc_pcm_prepare(struct snd_pcm_substream *substream)
if (rtd->dai_link->dynamic) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- snd_soc_dapm_stream_event(rtd,
+ snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
cpu_dai->driver->playback.stream_name,
SND_SOC_DAPM_STREAM_START);
else
- snd_soc_dapm_stream_event(rtd,
+ snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
cpu_dai->driver->capture.stream_name,
SND_SOC_DAPM_STREAM_START);
} else {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- snd_soc_dapm_stream_event(rtd,
+ snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
codec_dai->driver->playback.stream_name,
SND_SOC_DAPM_STREAM_START);
else
- snd_soc_dapm_stream_event(rtd,
+ snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
codec_dai->driver->capture.stream_name,
SND_SOC_DAPM_STREAM_START);
}
@@ -1164,12 +1164,12 @@ static int soc_suspend(struct device *dev)
continue;
if (driver->playback.stream_name != NULL)
- snd_soc_dapm_stream_event(&card->rtd[i], driver->playback.stream_name,
- SND_SOC_DAPM_STREAM_SUSPEND);
+ snd_soc_dapm_stream_event(&card->rtd[i], SNDRV_PCM_STREAM_PLAYBACK,
+ driver->playback.stream_name, SND_SOC_DAPM_STREAM_SUSPEND);
if (driver->capture.stream_name != NULL)
- snd_soc_dapm_stream_event(&card->rtd[i], driver->capture.stream_name,
- SND_SOC_DAPM_STREAM_SUSPEND);
+ snd_soc_dapm_stream_event(&card->rtd[i], SNDRV_PCM_STREAM_CAPTURE,
+ driver->capture.stream_name, SND_SOC_DAPM_STREAM_SUSPEND);
}
/* suspend all CODECs */
@@ -1267,12 +1267,12 @@ static void soc_resume_deferred(struct work_struct *work)
continue;
if (driver->playback.stream_name != NULL)
- snd_soc_dapm_stream_event(&card->rtd[i], driver->playback.stream_name,
- SND_SOC_DAPM_STREAM_RESUME);
+ snd_soc_dapm_stream_event(&card->rtd[i], SNDRV_PCM_STREAM_PLAYBACK,
+ driver->playback.stream_name, SND_SOC_DAPM_STREAM_RESUME);
if (driver->capture.stream_name != NULL)
- snd_soc_dapm_stream_event(&card->rtd[i], driver->capture.stream_name,
- SND_SOC_DAPM_STREAM_RESUME);
+ snd_soc_dapm_stream_event(&card->rtd[i], SNDRV_PCM_STREAM_CAPTURE,
+ driver->capture.stream_name, SND_SOC_DAPM_STREAM_RESUME);
}
/* unmute any active DACs */
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 1212555570ee..2f67d482d5b3 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2330,7 +2330,7 @@ static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm,
* Returns 0 for success else error.
*/
int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
- const char *stream, int event)
+ int dir, const char *stream, int event)
{
int i;
@@ -2338,8 +2338,8 @@ int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
return 0;
if (rtd->dai_link->dynamic) {
- for (i = 0; i < rtd->num_be; i++) {
- struct snd_soc_platform *platform = rtd->be_rtd[i]->platform;
+ for (i = 0; i < rtd->num_be[dir]; i++) {
+ struct snd_soc_platform *platform = rtd->be_rtd[i][dir]->platform;
soc_dapm_stream_event(platform->dapm, stream, event);
}