Merge remote-tracking branch 'asoc/for-5.9' into asoc-next
[linux-2.6-microblaze.git] / sound / soc / soc-dai.c
index b05e18b..91a2551 100644 (file)
@@ -298,13 +298,15 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
 {
        int ret = -ENOTSUPP;
 
+       /*
+        * ignore if direction was CAPTURE
+        * and it had .no_capture_mute flag
+        */
        if (dai->driver->ops &&
-           dai->driver->ops->mute_stream)
+           dai->driver->ops->mute_stream &&
+           (direction == SNDRV_PCM_STREAM_PLAYBACK ||
+            !dai->driver->ops->no_capture_mute))
                ret = dai->driver->ops->mute_stream(dai, mute, direction);
-       else if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
-                dai->driver->ops &&
-                dai->driver->ops->digital_mute)
-               ret = dai->driver->ops->digital_mute(dai, mute);
 
        return soc_dai_ret(dai, ret);
 }
@@ -314,7 +316,7 @@ int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
                          struct snd_pcm_substream *substream,
                          struct snd_pcm_hw_params *params)
 {
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
        int ret = 0;
 
        /* perform any topology hw_params fixups before DAI  */
@@ -391,6 +393,46 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
        return stream->channels_min;
 }
 
+/*
+ * snd_soc_dai_link_set_capabilities() - set dai_link properties based on its DAIs
+ */
+void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
+{
+       struct snd_soc_dai_link_component *cpu;
+       struct snd_soc_dai_link_component *codec;
+       struct snd_soc_dai *dai;
+       bool supported[SNDRV_PCM_STREAM_LAST + 1];
+       bool supported_cpu;
+       bool supported_codec;
+       int direction;
+       int i;
+
+       for_each_pcm_streams(direction) {
+               supported_cpu = false;
+               supported_codec = false;
+
+               for_each_link_cpus(dai_link, i, cpu) {
+                       dai = snd_soc_find_dai(cpu);
+                       if (dai && snd_soc_dai_stream_valid(dai, direction)) {
+                               supported_cpu = true;
+                               break;
+                       }
+               }
+               for_each_link_codecs(dai_link, i, codec) {
+                       dai = snd_soc_find_dai(codec);
+                       if (dai && snd_soc_dai_stream_valid(dai, direction)) {
+                               supported_codec = true;
+                               break;
+                       }
+               }
+               supported[direction] = supported_cpu && supported_codec;
+       }
+
+       dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
+       dai_link->dpcm_capture  = supported[SNDRV_PCM_STREAM_CAPTURE];
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_link_set_capabilities);
+
 void snd_soc_dai_action(struct snd_soc_dai *dai,
                        int stream, int action)
 {
@@ -476,7 +518,7 @@ int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
 
 int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
 {
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
        struct snd_soc_dai *dai;
        int i, ret;
 
@@ -495,7 +537,7 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
 int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
                            int cmd)
 {
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
        struct snd_soc_dai *dai;
        int i, ret;
 
@@ -514,7 +556,7 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
 int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
                                    int cmd)
 {
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
        struct snd_soc_dai *dai;
        int i, ret;