ASoC: wm9712: Remove driver specific version
[deliverable/linux.git] / sound / soc / soc-pcm.c
index cdc860a5ff37ca0fe070bdc9f6f4532e1cd6a7c3..93be95b7864c7be2ea9936c8c67020f582a02613 100644 (file)
@@ -62,6 +62,41 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,
        return 0;
 }
 
+/*
+ * 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_apply_msb(struct snd_pcm_substream *substream,
+                             struct snd_soc_dai *dai)
+{
+       int ret, i, bits;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               bits = dai->driver->playback.sig_bits;
+       else
+               bits = dai->driver->capture.sig_bits;
+
+       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(dai->dev,
+                                "Failed to set MSB %d/%d: %d\n",
+                                bits, sample_sizes[i], ret);
+       }
+}
+
 /*
  * Called by ALSA when a PCM substream is opened, the runtime->hw record is
  * then initialized and any private data can be allocated. This also calls
@@ -187,6 +222,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
                goto config_err;
        }
 
+       soc_pcm_apply_msb(substream, codec_dai);
+       soc_pcm_apply_msb(substream, cpu_dai);
+
        /* Symmetry only applies if we've already got an active stream. */
        if (cpu_dai->active) {
                ret = soc_pcm_apply_symmetry(substream, cpu_dai);
This page took 0.035699 seconds and 5 git commands to generate.