ASoC: pcm: Fix unused variable warning
[firefly-linux-kernel-4.4.55.git] / sound / soc / soc-pcm.c
index 57277dd79e112c2b59bf2ee3925bae6228bc30ac..c076993a20d084587b3fef670aa743553c60d179 100644 (file)
@@ -301,34 +301,18 @@ static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream)
        return symmetry;
 }
 
-/*
- * List of sample sizes that might go over the bus for parameter
- * application.  There ought to be a wildcard sample size for things
- * like the DAC/ADC resolution to use but there isn't right now.
- */
-static int sample_sizes[] = {
-       24, 32,
-};
-
 static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       int ret, i;
+       int ret;
 
        if (!bits)
                return;
 
-       for (i = 0; i < ARRAY_SIZE(sample_sizes); i++) {
-               if (bits >= sample_sizes[i])
-                       continue;
-
-               ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0,
-                                                  sample_sizes[i], bits);
-               if (ret != 0)
-                       dev_warn(rtd->dev,
-                                "ASoC: Failed to set MSB %d/%d: %d\n",
-                                bits, sample_sizes[i], ret);
-       }
+       ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 0, bits);
+       if (ret != 0)
+               dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n",
+                                bits, ret);
 }
 
 static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
@@ -654,6 +638,8 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
                        codec_dai->rate = 0;
        }
 
+       snd_soc_dai_digital_mute(cpu_dai, 1, substream->stream);
+
        if (cpu_dai->driver->ops->shutdown)
                cpu_dai->driver->ops->shutdown(substream, cpu_dai);
 
@@ -772,6 +758,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
        for (i = 0; i < rtd->num_codecs; i++)
                snd_soc_dai_digital_mute(rtd->codec_dais[i], 0,
                                         substream->stream);
+       snd_soc_dai_digital_mute(cpu_dai, 0, substream->stream);
 
 out:
        mutex_unlock(&rtd->pcm_mutex);
@@ -1664,6 +1651,10 @@ int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream)
                if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream))
                                continue;
 
+               /* do not free hw if this BE is used by other FE */
+               if (be->dpcm[stream].users > 1)
+                       continue;
+
                if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) &&
                    (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) &&
                    (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) &&
@@ -2288,7 +2279,13 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)
                        fe->dai_link->name);
 
                /* skip if FE doesn't have playback capability */
-               if (!fe->cpu_dai->driver->playback.channels_min)
+               if (!fe->cpu_dai->driver->playback.channels_min
+                   || !fe->codec_dai->driver->playback.channels_min)
+                       goto capture;
+
+               /* skip if FE isn't currently playing */
+               if (!fe->cpu_dai->playback_active
+                   || !fe->codec_dai->playback_active)
                        goto capture;
 
                paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_PLAYBACK, &list);
@@ -2318,7 +2315,13 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)
                dpcm_path_put(&list);
 capture:
                /* skip if FE doesn't have capture capability */
-               if (!fe->cpu_dai->driver->capture.channels_min)
+               if (!fe->cpu_dai->driver->capture.channels_min
+                   || !fe->codec_dai->driver->capture.channels_min)
+                       continue;
+
+               /* skip if FE isn't currently capturing */
+               if (!fe->cpu_dai->capture_active
+                   || !fe->codec_dai->capture_active)
                        continue;
 
                paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_CAPTURE, &list);