xref: /openbmc/linux/sound/soc/ti/edma-pcm.c (revision 4f727ece)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * edma-pcm.c - eDMA PCM driver using dmaengine for AM3xxx, AM4xxx
4  *
5  * Copyright (C) 2014 Texas Instruments, Inc.
6  *
7  * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
8  *
9  * Based on: sound/soc/tegra/tegra_pcm.c
10  */
11 
12 #include <linux/module.h>
13 #include <sound/core.h>
14 #include <sound/pcm.h>
15 #include <sound/pcm_params.h>
16 #include <sound/soc.h>
17 #include <sound/dmaengine_pcm.h>
18 
19 #include "edma-pcm.h"
20 
21 static const struct snd_pcm_hardware edma_pcm_hardware = {
22 	.info			= SNDRV_PCM_INFO_MMAP |
23 				  SNDRV_PCM_INFO_MMAP_VALID |
24 				  SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME |
25 				  SNDRV_PCM_INFO_NO_PERIOD_WAKEUP |
26 				  SNDRV_PCM_INFO_INTERLEAVED,
27 	.buffer_bytes_max	= 128 * 1024,
28 	.period_bytes_min	= 32,
29 	.period_bytes_max	= 64 * 1024,
30 	.periods_min		= 2,
31 	.periods_max		= 19, /* Limit by edma dmaengine driver */
32 };
33 
34 static const struct snd_dmaengine_pcm_config edma_dmaengine_pcm_config = {
35 	.pcm_hardware = &edma_pcm_hardware,
36 	.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
37 	.prealloc_buffer_size = 128 * 1024,
38 };
39 
40 int edma_pcm_platform_register(struct device *dev)
41 {
42 	return devm_snd_dmaengine_pcm_register(dev, &edma_dmaengine_pcm_config, 0);
43 }
44 EXPORT_SYMBOL_GPL(edma_pcm_platform_register);
45 
46 MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
47 MODULE_DESCRIPTION("eDMA PCM ASoC platform driver");
48 MODULE_LICENSE("GPL");
49