1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) 2018 Rockchip Electronics Co. Ltd.
4  */
5 
6 #include <linux/device.h>
7 #include <linux/init.h>
8 #include <linux/module.h>
9 
10 #include <sound/core.h>
11 #include <sound/pcm.h>
12 #include <sound/soc.h>
13 #include <sound/dmaengine_pcm.h>
14 
15 #include "rockchip_pcm.h"
16 
17 static const struct snd_pcm_hardware snd_rockchip_hardware = {
18 	.info			= SNDRV_PCM_INFO_MMAP |
19 				  SNDRV_PCM_INFO_MMAP_VALID |
20 				  SNDRV_PCM_INFO_PAUSE |
21 				  SNDRV_PCM_INFO_RESUME |
22 				  SNDRV_PCM_INFO_INTERLEAVED,
23 	.period_bytes_min	= 32,
24 	.period_bytes_max	= 8192,
25 	.periods_min		= 1,
26 	.periods_max		= 52,
27 	.buffer_bytes_max	= 64 * 1024,
28 	.fifo_size		= 32,
29 };
30 
31 static const struct snd_dmaengine_pcm_config rk_dmaengine_pcm_config = {
32 	.pcm_hardware = &snd_rockchip_hardware,
33 	.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
34 	.prealloc_buffer_size = 32 * 1024,
35 };
36 
rockchip_pcm_platform_register(struct device * dev)37 int rockchip_pcm_platform_register(struct device *dev)
38 {
39 	return devm_snd_dmaengine_pcm_register(dev, &rk_dmaengine_pcm_config,
40 		SND_DMAENGINE_PCM_FLAG_COMPAT);
41 }
42 EXPORT_SYMBOL_GPL(rockchip_pcm_platform_register);
43 
44 MODULE_LICENSE("GPL v2");
45