1 /* 2 * ALSA PCM interface for ST SPEAr Processors 3 * 4 * sound/soc/spear/spear_pcm.c 5 * 6 * Copyright (C) 2012 ST Microelectronics 7 * Rajeev Kumar<rajeev-dlh.kumar@st.com> 8 * 9 * This file is licensed under the terms of the GNU General Public 10 * License version 2. This program is licensed "as is" without any 11 * warranty of any kind, whether express or implied. 12 */ 13 14 #include <linux/module.h> 15 #include <linux/dmaengine.h> 16 #include <linux/platform_device.h> 17 #include <sound/dmaengine_pcm.h> 18 #include <sound/pcm.h> 19 #include <sound/soc.h> 20 #include <sound/spear_dma.h> 21 #include "spear_pcm.h" 22 23 static const struct snd_pcm_hardware spear_pcm_hardware = { 24 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | 25 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | 26 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), 27 .buffer_bytes_max = 16 * 1024, /* max buffer size */ 28 .period_bytes_min = 2 * 1024, /* 1 msec data minimum period size */ 29 .period_bytes_max = 2 * 1024, /* maximum period size */ 30 .periods_min = 1, /* min # periods */ 31 .periods_max = 8, /* max # of periods */ 32 .fifo_size = 0, /* fifo size in bytes */ 33 }; 34 35 static struct dma_chan *spear_pcm_request_chan(struct snd_soc_pcm_runtime *rtd, 36 struct snd_pcm_substream *substream) 37 { 38 struct spear_dma_data *dma_data; 39 40 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 41 42 return snd_dmaengine_pcm_request_channel(dma_data->filter, dma_data); 43 } 44 45 static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = { 46 .pcm_hardware = &spear_pcm_hardware, 47 .compat_request_channel = spear_pcm_request_chan, 48 .prealloc_buffer_size = 16 * 1024, 49 }; 50 51 int devm_spear_pcm_platform_register(struct device *dev) 52 { 53 return devm_snd_dmaengine_pcm_register(dev, 54 &spear_dmaengine_pcm_config, 55 SND_DMAENGINE_PCM_FLAG_NO_DT | 56 SND_DMAENGINE_PCM_FLAG_COMPAT); 57 } 58 EXPORT_SYMBOL_GPL(devm_spear_pcm_platform_register); 59 60 MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>"); 61 MODULE_DESCRIPTION("SPEAr PCM DMA module"); 62 MODULE_LICENSE("GPL"); 63