ASoC: omap-pcm: Allow only formats with 1, 2, and 4 byte physical size
authorJyri Sarha <jsarha@ti.com>
Tue, 3 Mar 2015 11:28:53 +0000 (13:28 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 4 Mar 2015 17:28:51 +0000 (17:28 +0000)
sDMA support only transfer elements with 1, 2, and 4 byte physical
size. Initialize the pcm driver accordingly.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/omap/omap-pcm.c

index f4b05bc23e4bfb4d27adf8dea4702539c2696609..e49ee2383a884145fb60881c019efa8840a3cfae 100644 (file)
@@ -39,7 +39,7 @@
 #define pcm_omap1510() 0
 #endif
 
-static const struct snd_pcm_hardware omap_pcm_hardware = {
+static struct snd_pcm_hardware omap_pcm_hardware = {
        .info                   = SNDRV_PCM_INFO_MMAP |
                                  SNDRV_PCM_INFO_MMAP_VALID |
                                  SNDRV_PCM_INFO_INTERLEAVED |
@@ -53,6 +53,24 @@ static const struct snd_pcm_hardware omap_pcm_hardware = {
        .buffer_bytes_max       = 128 * 1024,
 };
 
+/* sDMA supports only 1, 2, and 4 byte transfer elements. */
+static void omap_pcm_limit_supported_formats(void)
+{
+       int i;
+
+       for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) {
+               switch (snd_pcm_format_physical_width(i)) {
+               case 8:
+               case 16:
+               case 32:
+                       omap_pcm_hardware.formats |= (1LL << i);
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
 /* this may get called several times by oss emulation */
 static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
                              struct snd_pcm_hw_params *params)
@@ -235,6 +253,7 @@ static struct snd_soc_platform_driver omap_soc_platform = {
 
 int omap_pcm_platform_register(struct device *dev)
 {
+       omap_pcm_limit_supported_formats();
        return devm_snd_soc_register_platform(dev, &omap_soc_platform);
 }
 EXPORT_SYMBOL_GPL(omap_pcm_platform_register);