0001
0002
0003
0004
0005
0006
0007 #include <linux/device.h>
0008 #include <linux/module.h>
0009 #include <sound/core.h>
0010 #include <sound/pcm.h>
0011 #include <sound/pcm_params.h>
0012 #include <sound/soc.h>
0013 #include <sound/dmaengine_pcm.h>
0014
0015 #include "sdma-pcm.h"
0016
0017 static const struct snd_pcm_hardware sdma_pcm_hardware = {
0018 .info = SNDRV_PCM_INFO_MMAP |
0019 SNDRV_PCM_INFO_MMAP_VALID |
0020 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME |
0021 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP |
0022 SNDRV_PCM_INFO_INTERLEAVED,
0023 .period_bytes_min = 32,
0024 .period_bytes_max = 64 * 1024,
0025 .buffer_bytes_max = 128 * 1024,
0026 .periods_min = 2,
0027 .periods_max = 255,
0028 };
0029
0030 static const struct snd_dmaengine_pcm_config sdma_dmaengine_pcm_config = {
0031 .pcm_hardware = &sdma_pcm_hardware,
0032 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
0033 .prealloc_buffer_size = 128 * 1024,
0034 };
0035
0036 int sdma_pcm_platform_register(struct device *dev,
0037 char *txdmachan, char *rxdmachan)
0038 {
0039 struct snd_dmaengine_pcm_config *config;
0040 unsigned int flags = 0;
0041
0042
0043 if (!txdmachan && !rxdmachan)
0044 return devm_snd_dmaengine_pcm_register(dev,
0045 &sdma_dmaengine_pcm_config, 0);
0046
0047 config = devm_kzalloc(dev, sizeof(*config), GFP_KERNEL);
0048 if (!config)
0049 return -ENOMEM;
0050
0051 *config = sdma_dmaengine_pcm_config;
0052
0053 if (!txdmachan || !rxdmachan) {
0054
0055 flags |= SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX;
0056 if (!txdmachan) {
0057 txdmachan = rxdmachan;
0058 rxdmachan = NULL;
0059 }
0060 }
0061
0062 config->chan_names[0] = txdmachan;
0063 config->chan_names[1] = rxdmachan;
0064
0065 return devm_snd_dmaengine_pcm_register(dev, config, flags);
0066 }
0067 EXPORT_SYMBOL_GPL(sdma_pcm_platform_register);
0068
0069 MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
0070 MODULE_DESCRIPTION("sDMA PCM ASoC platform driver");
0071 MODULE_LICENSE("GPL v2");