aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-16 18:03:27 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-17 11:10:01 -0500
commit7bd3a6f34cdd4b1776ca34d0b6fab216e9323759 (patch)
treed76722c3f70e4a6ef2cce5ff619a1b8755ddd6a9 /sound
parent5ba06fc969d068dee9a59f1fa3dbe58e235fa913 (diff)
ASoC: dapm: Supply the DAI and substream when calling stream events
In order to allow us to do something smarter than iterate through widgets doing strcmp() to work out what to power up for stream events change the interface used to generate them to be based on the combination of a DAI and a stream direction rather than just a simple string identifying the stream. At some point we'll probably want a set of channels too. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-core.c30
-rw-r--r--sound/soc/soc-dapm.c25
-rw-r--r--sound/soc/soc-pcm.c25
3 files changed, 41 insertions, 39 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6bad7cd4131..7645b8a545c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -573,18 +573,20 @@ int snd_soc_suspend(struct device *dev)
573 } 573 }
574 574
575 for (i = 0; i < card->num_rtd; i++) { 575 for (i = 0; i < card->num_rtd; i++) {
576 struct snd_soc_dai_driver *driver = card->rtd[i].codec_dai->driver; 576 struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
577 577
578 if (card->rtd[i].dai_link->ignore_suspend) 578 if (card->rtd[i].dai_link->ignore_suspend)
579 continue; 579 continue;
580 580
581 if (driver->playback.stream_name != NULL) 581 snd_soc_dapm_stream_event(&card->rtd[i],
582 snd_soc_dapm_stream_event(&card->rtd[i], driver->playback.stream_name, 582 SNDRV_PCM_STREAM_PLAYBACK,
583 SND_SOC_DAPM_STREAM_SUSPEND); 583 codec_dai,
584 SND_SOC_DAPM_STREAM_SUSPEND);
584 585
585 if (driver->capture.stream_name != NULL) 586 snd_soc_dapm_stream_event(&card->rtd[i],
586 snd_soc_dapm_stream_event(&card->rtd[i], driver->capture.stream_name, 587 SNDRV_PCM_STREAM_CAPTURE,
587 SND_SOC_DAPM_STREAM_SUSPEND); 588 codec_dai,
589 SND_SOC_DAPM_STREAM_SUSPEND);
588 } 590 }
589 591
590 /* suspend all CODECs */ 592 /* suspend all CODECs */
@@ -687,18 +689,18 @@ static void soc_resume_deferred(struct work_struct *work)
687 } 689 }
688 690
689 for (i = 0; i < card->num_rtd; i++) { 691 for (i = 0; i < card->num_rtd; i++) {
690 struct snd_soc_dai_driver *driver = card->rtd[i].codec_dai->driver; 692 struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
691 693
692 if (card->rtd[i].dai_link->ignore_suspend) 694 if (card->rtd[i].dai_link->ignore_suspend)
693 continue; 695 continue;
694 696
695 if (driver->playback.stream_name != NULL) 697 snd_soc_dapm_stream_event(&card->rtd[i],
696 snd_soc_dapm_stream_event(&card->rtd[i], driver->playback.stream_name, 698 SNDRV_PCM_STREAM_PLAYBACK, codec_dai,
697 SND_SOC_DAPM_STREAM_RESUME); 699 SND_SOC_DAPM_STREAM_RESUME);
698 700
699 if (driver->capture.stream_name != NULL) 701 snd_soc_dapm_stream_event(&card->rtd[i],
700 snd_soc_dapm_stream_event(&card->rtd[i], driver->capture.stream_name, 702 SNDRV_PCM_STREAM_CAPTURE, codec_dai,
701 SND_SOC_DAPM_STREAM_RESUME); 703 SND_SOC_DAPM_STREAM_RESUME);
702 } 704 }
703 705
704 /* unmute any active DACs */ 706 /* unmute any active DACs */
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 295fa91d9d0..97915eb711c 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2823,17 +2823,27 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
2823EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls); 2823EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
2824 2824
2825static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm, 2825static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm,
2826 const char *stream, int event) 2826 int stream, struct snd_soc_dai *dai,
2827 int event)
2827{ 2828{
2828 struct snd_soc_dapm_widget *w; 2829 struct snd_soc_dapm_widget *w;
2830 const char *stream_name;
2831
2832 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
2833 stream_name = dai->driver->playback.stream_name;
2834 else
2835 stream_name = dai->driver->capture.stream_name;
2836
2837 if (!stream_name)
2838 return;
2829 2839
2830 list_for_each_entry(w, &dapm->card->widgets, list) 2840 list_for_each_entry(w, &dapm->card->widgets, list)
2831 { 2841 {
2832 if (!w->sname || w->dapm != dapm) 2842 if (!w->sname || w->dapm != dapm)
2833 continue; 2843 continue;
2834 dev_vdbg(w->dapm->dev, "widget %s\n %s stream %s event %d\n", 2844 dev_vdbg(w->dapm->dev, "widget %s\n %s stream %s event %d\n",
2835 w->name, w->sname, stream, event); 2845 w->name, w->sname, stream_name, event);
2836 if (strstr(w->sname, stream)) { 2846 if (strstr(w->sname, stream_name)) {
2837 dapm_mark_dirty(w, "stream event"); 2847 dapm_mark_dirty(w, "stream event");
2838 switch(event) { 2848 switch(event) {
2839 case SND_SOC_DAPM_STREAM_START: 2849 case SND_SOC_DAPM_STREAM_START:
@@ -2865,16 +2875,13 @@ static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm,
2865 * 2875 *
2866 * Returns 0 for success else error. 2876 * Returns 0 for success else error.
2867 */ 2877 */
2868int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, 2878int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
2869 const char *stream, int event) 2879 struct snd_soc_dai *dai, int event)
2870{ 2880{
2871 struct snd_soc_codec *codec = rtd->codec; 2881 struct snd_soc_codec *codec = rtd->codec;
2872 2882
2873 if (stream == NULL)
2874 return 0;
2875
2876 mutex_lock(&codec->mutex); 2883 mutex_lock(&codec->mutex);
2877 soc_dapm_stream_event(&codec->dapm, stream, event); 2884 soc_dapm_stream_event(&codec->dapm, stream, dai, event);
2878 mutex_unlock(&codec->mutex); 2885 mutex_unlock(&codec->mutex);
2879 return 0; 2886 return 0;
2880} 2887}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 15816eccad3..0ad8dcacd2f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -307,9 +307,8 @@ static void close_delayed_work(struct work_struct *work)
307 /* are we waiting on this codec DAI stream */ 307 /* are we waiting on this codec DAI stream */
308 if (codec_dai->pop_wait == 1) { 308 if (codec_dai->pop_wait == 1) {
309 codec_dai->pop_wait = 0; 309 codec_dai->pop_wait = 0;
310 snd_soc_dapm_stream_event(rtd, 310 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
311 codec_dai->driver->playback.stream_name, 311 codec_dai, SND_SOC_DAPM_STREAM_STOP);
312 SND_SOC_DAPM_STREAM_STOP);
313 } 312 }
314 313
315 mutex_unlock(&rtd->pcm_mutex); 314 mutex_unlock(&rtd->pcm_mutex);
@@ -373,8 +372,9 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
373 rtd->dai_link->ignore_pmdown_time) { 372 rtd->dai_link->ignore_pmdown_time) {
374 /* powered down playback stream now */ 373 /* powered down playback stream now */
375 snd_soc_dapm_stream_event(rtd, 374 snd_soc_dapm_stream_event(rtd,
376 codec_dai->driver->playback.stream_name, 375 SNDRV_PCM_STREAM_PLAYBACK,
377 SND_SOC_DAPM_STREAM_STOP); 376 codec_dai,
377 SND_SOC_DAPM_STREAM_STOP);
378 } else { 378 } else {
379 /* start delayed pop wq here for playback streams */ 379 /* start delayed pop wq here for playback streams */
380 codec_dai->pop_wait = 1; 380 codec_dai->pop_wait = 1;
@@ -383,9 +383,8 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
383 } 383 }
384 } else { 384 } else {
385 /* capture streams can be powered down now */ 385 /* capture streams can be powered down now */
386 snd_soc_dapm_stream_event(rtd, 386 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
387 codec_dai->driver->capture.stream_name, 387 codec_dai, SND_SOC_DAPM_STREAM_STOP);
388 SND_SOC_DAPM_STREAM_STOP);
389 } 388 }
390 389
391 mutex_unlock(&rtd->pcm_mutex); 390 mutex_unlock(&rtd->pcm_mutex);
@@ -454,14 +453,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
454 cancel_delayed_work(&rtd->delayed_work); 453 cancel_delayed_work(&rtd->delayed_work);
455 } 454 }
456 455
457 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 456 snd_soc_dapm_stream_event(rtd, substream->stream, codec_dai,
458 snd_soc_dapm_stream_event(rtd, 457 SND_SOC_DAPM_STREAM_START);
459 codec_dai->driver->playback.stream_name,
460 SND_SOC_DAPM_STREAM_START);
461 else
462 snd_soc_dapm_stream_event(rtd,
463 codec_dai->driver->capture.stream_name,
464 SND_SOC_DAPM_STREAM_START);
465 458
466 snd_soc_dai_digital_mute(codec_dai, 0); 459 snd_soc_dai_digital_mute(codec_dai, 0);
467 460