Merge tag 'asoc-v6.8' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[linux-2.6-block.git] / sound / soc / soc-pcm.c
index 6c0d949c60c7b1d60402ec1e391aac72e14c07d8..77ee103b7cd1a901f495a357f331d77e7c9adddd 100644 (file)
@@ -292,6 +292,7 @@ static void dpcm_set_be_update_state(struct snd_soc_pcm_runtime *be,
 void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
                            int stream, int action)
 {
+       struct snd_soc_component *component;
        struct snd_soc_dai *dai;
        int i;
 
@@ -299,6 +300,13 @@ void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
 
        for_each_rtd_dais(rtd, i, dai)
                snd_soc_dai_action(dai, stream, action);
+
+       /* Increments/Decrements the active count for components without DAIs */
+       for_each_rtd_components(rtd, i, component) {
+               if (component->num_dai)
+                       continue;
+               component->active += action;
+       }
 }
 EXPORT_SYMBOL_GPL(snd_soc_runtime_action);
 
@@ -1055,6 +1063,7 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
        }
 
        for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
+               struct snd_soc_dai_link_ch_map *ch_maps;
                unsigned int ch_mask = 0;
                int j;
 
@@ -1068,22 +1077,20 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
                /* copy params for each cpu */
                tmp_params = *params;
 
-               if (!rtd->dai_link->codec_ch_maps)
-                       goto hw_params;
                /*
                 * construct cpu channel mask by combining ch_mask of each
                 * codec which maps to the cpu.
+                * see
+                *      soc.h :: [dai_link->ch_maps Image sample]
                 */
-               for_each_rtd_codec_dais(rtd, j, codec_dai) {
-                       if (rtd->dai_link->codec_ch_maps[j].connected_cpu_id == i)
-                               ch_mask |= rtd->dai_link->codec_ch_maps[j].ch_mask;
-               }
+               for_each_rtd_ch_maps(rtd, j, ch_maps)
+                       if (ch_maps->cpu == i)
+                               ch_mask |= ch_maps->ch_mask;
 
                /* fixup cpu channel number */
                if (ch_mask)
                        soc_pcm_codec_params_fixup(&tmp_params, ch_mask);
 
-hw_params:
                ret = snd_soc_dai_hw_params(cpu_dai, substream, &tmp_params);
                if (ret < 0)
                        goto out;
@@ -2833,35 +2840,20 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
                        }
                }
        } else {
+               struct snd_soc_dai_link_ch_map *ch_maps;
                struct snd_soc_dai *codec_dai;
 
                /* Adapt stream for codec2codec links */
                int cpu_capture  = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE);
                int cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK);
 
-               for_each_rtd_codec_dais(rtd, i, codec_dai) {
-                       if (dai_link->num_cpus == 1) {
-                               cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
-                       } else if (dai_link->num_cpus == dai_link->num_codecs) {
-                               cpu_dai = snd_soc_rtd_to_cpu(rtd, i);
-                       } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) {
-                               int cpu_id;
-
-                               if (!rtd->dai_link->codec_ch_maps) {
-                                       dev_err(rtd->card->dev, "%s: no codec channel mapping table provided\n",
-                                               __func__);
-                                       return -EINVAL;
-                               }
-
-                               cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id;
-                               cpu_dai = snd_soc_rtd_to_cpu(rtd, cpu_id);
-                       } else {
-                               dev_err(rtd->card->dev,
-                                       "%s codec number %d < cpu number %d is not supported\n",
-                                       __func__, rtd->dai_link->num_codecs,
-                                       rtd->dai_link->num_cpus);
-                               return -EINVAL;
-                       }
+               /*
+                * see
+                *      soc.h :: [dai_link->ch_maps Image sample]
+                */
+               for_each_rtd_ch_maps(rtd, i, ch_maps) {
+                       cpu_dai   = snd_soc_rtd_to_cpu(rtd,   ch_maps->cpu);
+                       codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec);
 
                        if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
                            snd_soc_dai_stream_valid(cpu_dai,   cpu_playback))