Merge tag 'sound-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[sfrench/cifs-2.6.git] / sound / soc / soc-generic-dmaengine-pcm.c
index 6fd1906af3873aa90b351649c2d0b8afe7152e9d..6cef3977507ae15c11ff074c5e33c0b275cef9c8 100644 (file)
@@ -163,31 +163,42 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea
        }
 
        /*
-        * Prepare formats mask for valid/allowed sample types. If the dma does
-        * not have support for the given physical word size, it needs to be
-        * masked out so user space can not use the format which produces
-        * corrupted audio.
-        * In case the dma driver does not implement the slave_caps the default
-        * assumption is that it supports 1, 2 and 4 bytes widths.
+        * If SND_DMAENGINE_PCM_DAI_FLAG_PACK is set keep
+        * hw.formats set to 0, meaning no restrictions are in place.
+        * In this case it's the responsibility of the DAI driver to
+        * provide the supported format information.
         */
-       for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) {
-               int bits = snd_pcm_format_physical_width(i);
-
-               /* Enable only samples with DMA supported physical widths */
-               switch (bits) {
-               case 8:
-               case 16:
-               case 24:
-               case 32:
-               case 64:
-                       if (addr_widths & (1 << (bits / 8)))
-                               hw.formats |= (1LL << i);
-                       break;
-               default:
-                       /* Unsupported types */
-                       break;
+       if (!(dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK))
+               /*
+                * Prepare formats mask for valid/allowed sample types. If the
+                * dma does not have support for the given physical word size,
+                * it needs to be masked out so user space can not use the
+                * format which produces corrupted audio.
+                * In case the dma driver does not implement the slave_caps the
+                * default assumption is that it supports 1, 2 and 4 bytes
+                * widths.
+                */
+               for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) {
+                       int bits = snd_pcm_format_physical_width(i);
+
+                       /*
+                        * Enable only samples with DMA supported physical
+                        * widths
+                        */
+                       switch (bits) {
+                       case 8:
+                       case 16:
+                       case 24:
+                       case 32:
+                       case 64:
+                               if (addr_widths & (1 << (bits / 8)))
+                                       hw.formats |= (1LL << i);
+                               break;
+                       default:
+                               /* Unsupported types */
+                               break;
+                       }
                }
-       }
 
        return snd_soc_set_runtime_hwparams(substream, &hw);
 }