aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-04-29 08:51:22 -0400
committerMark Brown <broonie@linaro.org>2014-04-29 12:40:51 -0400
commitc471fdd1b6f41a8e4efc8ca684e47005e7ebbb61 (patch)
treeed1349fb8d47fa0236a01fe7776dd3a182f2edab /sound/soc/soc-dapm.c
parent3477501274b79a904a4195b675bb74caa57d2e14 (diff)
ASoC: dapm: Factor out duplicated code in soc_dapm_stream_event()
In soc_dapm_stream_event() we have the same code twice, once for the codec_dai and once for the cpu_dai. This patch factors the duplicated code out into a separate function. This will make it easier to modify the implementation (since there is only one place that needs to be updated) and also easier to add support for more than two DAIs per DAI link. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c51
1 files changed, 16 insertions, 35 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f4ba7b40a6ab..9e7209c06358 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3510,32 +3510,25 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
3510 } 3510 }
3511} 3511}
3512 3512
3513static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, 3513static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream,
3514 int event) 3514 int event)
3515{ 3515{
3516 struct snd_soc_dapm_widget *w;
3516 3517
3517 struct snd_soc_dapm_widget *w_cpu, *w_codec; 3518 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
3518 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 3519 w = dai->playback_widget;
3519 struct snd_soc_dai *codec_dai = rtd->codec_dai; 3520 else
3520 3521 w = dai->capture_widget;
3521 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
3522 w_cpu = cpu_dai->playback_widget;
3523 w_codec = codec_dai->playback_widget;
3524 } else {
3525 w_cpu = cpu_dai->capture_widget;
3526 w_codec = codec_dai->capture_widget;
3527 }
3528
3529 if (w_cpu) {
3530 3522
3531 dapm_mark_dirty(w_cpu, "stream event"); 3523 if (w) {
3524 dapm_mark_dirty(w, "stream event");
3532 3525
3533 switch (event) { 3526 switch (event) {
3534 case SND_SOC_DAPM_STREAM_START: 3527 case SND_SOC_DAPM_STREAM_START:
3535 w_cpu->active = 1; 3528 w->active = 1;
3536 break; 3529 break;
3537 case SND_SOC_DAPM_STREAM_STOP: 3530 case SND_SOC_DAPM_STREAM_STOP:
3538 w_cpu->active = 0; 3531 w->active = 0;
3539 break; 3532 break;
3540 case SND_SOC_DAPM_STREAM_SUSPEND: 3533 case SND_SOC_DAPM_STREAM_SUSPEND:
3541 case SND_SOC_DAPM_STREAM_RESUME: 3534 case SND_SOC_DAPM_STREAM_RESUME:
@@ -3544,25 +3537,13 @@ static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
3544 break; 3537 break;
3545 } 3538 }
3546 } 3539 }
3540}
3547 3541
3548 if (w_codec) { 3542static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
3549 3543 int event)
3550 dapm_mark_dirty(w_codec, "stream event"); 3544{
3551 3545 soc_dapm_dai_stream_event(rtd->cpu_dai, stream, event);
3552 switch (event) { 3546 soc_dapm_dai_stream_event(rtd->codec_dai, stream, event);
3553 case SND_SOC_DAPM_STREAM_START:
3554 w_codec->active = 1;
3555 break;
3556 case SND_SOC_DAPM_STREAM_STOP:
3557 w_codec->active = 0;
3558 break;
3559 case SND_SOC_DAPM_STREAM_SUSPEND:
3560 case SND_SOC_DAPM_STREAM_RESUME:
3561 case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
3562 case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
3563 break;
3564 }
3565 }
3566 3547
3567 dapm_power_widgets(rtd->card, event); 3548 dapm_power_widgets(rtd->card, event);
3568} 3549}