diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2017-09-25 21:00:53 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-09-27 13:11:12 -0400 |
commit | f523acebbb74f3cf5840d801f2e4856c688bf14a (patch) | |
tree | 903b1daa75d4f8939f636febf577d669f3d53420 /sound/soc/soc-pcm.c | |
parent | 3b1b3a7ba5536b4247024a5f00950d0932edf691 (diff) |
ASoC: add Component level pcm_new/pcm_free v2
In current ALSA SoC, Platform only has pcm_new/pcm_free feature,
but it should be supported on Component level. This patch adds it.
The v1 was added commit 99b04f4c4051f7 ("ASoC: add Component level
pcm_new/pcm_free") but it called all "card" connected component's
pcm_new/free, it was wrong.
This patch calls "rtd" connected component.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-pcm.c')
-rw-r--r-- | sound/soc/soc-pcm.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 09fed7014ed8..e5eb0cff790b 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
@@ -2633,12 +2633,18 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream) | |||
2633 | static void soc_pcm_private_free(struct snd_pcm *pcm) | 2633 | static void soc_pcm_private_free(struct snd_pcm *pcm) |
2634 | { | 2634 | { |
2635 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; | 2635 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; |
2636 | struct snd_soc_platform *platform = rtd->platform; | 2636 | struct snd_soc_rtdcom_list *rtdcom; |
2637 | struct snd_soc_component *component; | ||
2638 | |||
2639 | for_each_rtdcom(rtd, rtdcom) { | ||
2640 | /* need to sync the delayed work before releasing resources */ | ||
2641 | |||
2642 | flush_delayed_work(&rtd->delayed_work); | ||
2643 | component = rtdcom->component; | ||
2637 | 2644 | ||
2638 | /* need to sync the delayed work before releasing resources */ | 2645 | if (component->pcm_free) |
2639 | flush_delayed_work(&rtd->delayed_work); | 2646 | component->pcm_free(component, pcm); |
2640 | if (platform->driver->pcm_free) | 2647 | } |
2641 | platform->driver->pcm_free(pcm); | ||
2642 | } | 2648 | } |
2643 | 2649 | ||
2644 | /* create a new pcm */ | 2650 | /* create a new pcm */ |
@@ -2647,6 +2653,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
2647 | struct snd_soc_platform *platform = rtd->platform; | 2653 | struct snd_soc_platform *platform = rtd->platform; |
2648 | struct snd_soc_dai *codec_dai; | 2654 | struct snd_soc_dai *codec_dai; |
2649 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 2655 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
2656 | struct snd_soc_component *component; | ||
2657 | struct snd_soc_rtdcom_list *rtdcom; | ||
2650 | struct snd_pcm *pcm; | 2658 | struct snd_pcm *pcm; |
2651 | char new_name[64]; | 2659 | char new_name[64]; |
2652 | int ret = 0, playback = 0, capture = 0; | 2660 | int ret = 0, playback = 0, capture = 0; |
@@ -2756,10 +2764,15 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
2756 | if (capture) | 2764 | if (capture) |
2757 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); | 2765 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); |
2758 | 2766 | ||
2759 | if (platform->driver->pcm_new) { | 2767 | for_each_rtdcom(rtd, rtdcom) { |
2760 | ret = platform->driver->pcm_new(rtd); | 2768 | component = rtdcom->component; |
2769 | |||
2770 | if (!component->pcm_new) | ||
2771 | continue; | ||
2772 | |||
2773 | ret = component->pcm_new(component, rtd); | ||
2761 | if (ret < 0) { | 2774 | if (ret < 0) { |
2762 | dev_err(platform->dev, | 2775 | dev_err(component->dev, |
2763 | "ASoC: pcm constructor failed: %d\n", | 2776 | "ASoC: pcm constructor failed: %d\n", |
2764 | ret); | 2777 | ret); |
2765 | return ret; | 2778 | return ret; |