ASoC: dapm: Add platform stream event support

Currently stream events are only perfomed on codec stream widgets only.
There is now a need to be able to perform stream events on platform
widgets too.

e.g. we have the ABE platform driver with several DAI links
to dummy codecs. We need to be able to perform stream events on any
of the dummy codec DAI links.

This patch also removes the snd_soc_dai * parameter since it's already
contained within the rtd * parameter.

Finally makle stream event return void since no one checks it anyway.

Signed-off-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Liam Girdwood 2012-03-07 16:32:59 +00:00 committed by Mark Brown
parent be09ad90e1
commit d9b0951b96
4 changed files with 61 additions and 43 deletions

View file

@ -369,8 +369,8 @@ int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_route *route, int num); const struct snd_soc_dapm_route *route, int num);
/* dapm events */ /* dapm events */
int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
struct snd_soc_dai *dai, int event); int event);
void snd_soc_dapm_shutdown(struct snd_soc_card *card); void snd_soc_dapm_shutdown(struct snd_soc_card *card);
/* external DAPM widget events */ /* external DAPM widget events */

View file

@ -573,19 +573,16 @@ int snd_soc_suspend(struct device *dev)
} }
for (i = 0; i < card->num_rtd; i++) { for (i = 0; i < card->num_rtd; i++) {
struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
if (card->rtd[i].dai_link->ignore_suspend) if (card->rtd[i].dai_link->ignore_suspend)
continue; continue;
snd_soc_dapm_stream_event(&card->rtd[i], snd_soc_dapm_stream_event(&card->rtd[i],
SNDRV_PCM_STREAM_PLAYBACK, SNDRV_PCM_STREAM_PLAYBACK,
codec_dai,
SND_SOC_DAPM_STREAM_SUSPEND); SND_SOC_DAPM_STREAM_SUSPEND);
snd_soc_dapm_stream_event(&card->rtd[i], snd_soc_dapm_stream_event(&card->rtd[i],
SNDRV_PCM_STREAM_CAPTURE, SNDRV_PCM_STREAM_CAPTURE,
codec_dai,
SND_SOC_DAPM_STREAM_SUSPEND); SND_SOC_DAPM_STREAM_SUSPEND);
} }
@ -689,17 +686,16 @@ static void soc_resume_deferred(struct work_struct *work)
} }
for (i = 0; i < card->num_rtd; i++) { for (i = 0; i < card->num_rtd; i++) {
struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
if (card->rtd[i].dai_link->ignore_suspend) if (card->rtd[i].dai_link->ignore_suspend)
continue; continue;
snd_soc_dapm_stream_event(&card->rtd[i], snd_soc_dapm_stream_event(&card->rtd[i],
SNDRV_PCM_STREAM_PLAYBACK, codec_dai, SNDRV_PCM_STREAM_PLAYBACK,
SND_SOC_DAPM_STREAM_RESUME); SND_SOC_DAPM_STREAM_RESUME);
snd_soc_dapm_stream_event(&card->rtd[i], snd_soc_dapm_stream_event(&card->rtd[i],
SNDRV_PCM_STREAM_CAPTURE, codec_dai, SNDRV_PCM_STREAM_CAPTURE,
SND_SOC_DAPM_STREAM_RESUME); SND_SOC_DAPM_STREAM_RESUME);
} }

View file

@ -2987,37 +2987,61 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
return 0; return 0;
} }
static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm, static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
int stream, struct snd_soc_dai *dai, int event)
int event)
{ {
struct snd_soc_dapm_widget *w;
if (stream == SNDRV_PCM_STREAM_PLAYBACK) struct snd_soc_dapm_widget *w_cpu, *w_codec;
w = dai->playback_widget; struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
else struct snd_soc_dai *codec_dai = rtd->codec_dai;
w = dai->capture_widget;
if (!w) if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
return; w_cpu = cpu_dai->playback_widget;
w_codec = codec_dai->playback_widget;
dapm_mark_dirty(w, "stream event"); } else {
w_cpu = cpu_dai->capture_widget;
switch (event) { w_codec = codec_dai->capture_widget;
case SND_SOC_DAPM_STREAM_START:
w->active = 1;
break;
case SND_SOC_DAPM_STREAM_STOP:
w->active = 0;
break;
case SND_SOC_DAPM_STREAM_SUSPEND:
case SND_SOC_DAPM_STREAM_RESUME:
case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
break;
} }
dapm_power_widgets(dapm, event); if (w_cpu) {
dapm_mark_dirty(w_cpu, "stream event");
switch (event) {
case SND_SOC_DAPM_STREAM_START:
w_cpu->active = 1;
break;
case SND_SOC_DAPM_STREAM_STOP:
w_cpu->active = 0;
break;
case SND_SOC_DAPM_STREAM_SUSPEND:
case SND_SOC_DAPM_STREAM_RESUME:
case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
break;
}
}
if (w_codec) {
dapm_mark_dirty(w_codec, "stream event");
switch (event) {
case SND_SOC_DAPM_STREAM_START:
w_codec->active = 1;
break;
case SND_SOC_DAPM_STREAM_STOP:
w_codec->active = 0;
break;
case SND_SOC_DAPM_STREAM_SUSPEND:
case SND_SOC_DAPM_STREAM_RESUME:
case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
break;
}
}
dapm_power_widgets(&rtd->card->dapm, event);
} }
/** /**
@ -3031,15 +3055,14 @@ static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm,
* *
* Returns 0 for success else error. * Returns 0 for success else error.
*/ */
int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
struct snd_soc_dai *dai, int event) int event)
{ {
struct snd_soc_card *card = rtd->card; struct snd_soc_card *card = rtd->card;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM); mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
soc_dapm_stream_event(&card->dapm, stream, dai, event); soc_dapm_stream_event(rtd, stream, event);
mutex_unlock(&card->dapm_mutex); mutex_unlock(&card->dapm_mutex);
return 0;
} }
/** /**

View file

@ -308,7 +308,7 @@ static void close_delayed_work(struct work_struct *work)
if (codec_dai->pop_wait == 1) { if (codec_dai->pop_wait == 1) {
codec_dai->pop_wait = 0; codec_dai->pop_wait = 0;
snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK, snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
codec_dai, SND_SOC_DAPM_STREAM_STOP); SND_SOC_DAPM_STREAM_STOP);
} }
mutex_unlock(&rtd->pcm_mutex); mutex_unlock(&rtd->pcm_mutex);
@ -373,7 +373,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
/* powered down playback stream now */ /* powered down playback stream now */
snd_soc_dapm_stream_event(rtd, snd_soc_dapm_stream_event(rtd,
SNDRV_PCM_STREAM_PLAYBACK, SNDRV_PCM_STREAM_PLAYBACK,
codec_dai,
SND_SOC_DAPM_STREAM_STOP); SND_SOC_DAPM_STREAM_STOP);
} else { } else {
/* start delayed pop wq here for playback streams */ /* start delayed pop wq here for playback streams */
@ -384,7 +383,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
} else { } else {
/* capture streams can be powered down now */ /* capture streams can be powered down now */
snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE, snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
codec_dai, SND_SOC_DAPM_STREAM_STOP); SND_SOC_DAPM_STREAM_STOP);
} }
mutex_unlock(&rtd->pcm_mutex); mutex_unlock(&rtd->pcm_mutex);
@ -453,8 +452,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
cancel_delayed_work(&rtd->delayed_work); cancel_delayed_work(&rtd->delayed_work);
} }
snd_soc_dapm_stream_event(rtd, substream->stream, codec_dai, snd_soc_dapm_stream_event(rtd, substream->stream,
SND_SOC_DAPM_STREAM_START); SND_SOC_DAPM_STREAM_START);
snd_soc_dai_digital_mute(codec_dai, 0); snd_soc_dai_digital_mute(codec_dai, 0);