xref: /linux/sound/soc/spear/spear_pcm.c (revision 0fc8f6200d2313278fbf4539bbab74677c685531)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * ALSA PCM interface for ST SPEAr Processors
4  *
5  * sound/soc/spear/spear_pcm.c
6  *
7  * Copyright (C) 2012 ST Microelectronics
8  * Rajeev Kumar<rajeevkumar.linux@gmail.com>
9  */
10 
11 #include <linux/module.h>
12 #include <linux/dmaengine.h>
13 #include <linux/platform_device.h>
14 #include <sound/dmaengine_pcm.h>
15 #include <sound/pcm.h>
16 #include <sound/soc.h>
17 #include <sound/spear_dma.h>
18 #include "spear_pcm.h"
19 
20 static const struct snd_pcm_hardware spear_pcm_hardware = {
21 	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
22 		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
23 		 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
24 	.buffer_bytes_max = 16 * 1024, /* max buffer size */
25 	.period_bytes_min = 2 * 1024, /* 1 msec data minimum period size */
26 	.period_bytes_max = 2 * 1024, /* maximum period size */
27 	.periods_min = 1, /* min # periods */
28 	.periods_max = 8, /* max # of periods */
29 	.fifo_size = 0, /* fifo size in bytes */
30 };
31 
32 static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = {
33 	.pcm_hardware = &spear_pcm_hardware,
34 	.prealloc_buffer_size = 16 * 1024,
35 };
36 
37 int devm_spear_pcm_platform_register(struct device *dev,
38 			struct snd_dmaengine_pcm_config *config,
39 			bool (*filter)(struct dma_chan *chan, void *slave))
40 {
41 	*config = spear_dmaengine_pcm_config;
42 	config->compat_filter_fn = filter;
43 
44 	return devm_snd_dmaengine_pcm_register(dev, config,
45 		SND_DMAENGINE_PCM_FLAG_NO_DT |
46 		SND_DMAENGINE_PCM_FLAG_COMPAT);
47 }
48 EXPORT_SYMBOL_GPL(devm_spear_pcm_platform_register);
49 
50 MODULE_AUTHOR("Rajeev Kumar <rajeevkumar.linux@gmail.com>");
51 MODULE_DESCRIPTION("SPEAr PCM DMA module");
52 MODULE_LICENSE("GPL");
53