xref: /linux/sound/soc/cirrus/ep93xx-pcm.c (revision cb54b53adae70701bdd77d848cea4b9b39b61cf9)
1 /*
2  * linux/sound/arm/ep93xx-pcm.c - EP93xx ALSA PCM interface
3  *
4  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
5  * Copyright (C) 2006 Applied Data Systems
6  *
7  * Rewritten for the SoC audio subsystem (Based on PXA2xx code):
8  *   Copyright (c) 2008 Ryan Mallon
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14 
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/dmaengine.h>
19 
20 #include <sound/pcm.h>
21 #include <sound/soc.h>
22 #include <sound/dmaengine_pcm.h>
23 
24 #include <linux/platform_data/dma-ep93xx.h>
25 
26 static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
27 	.info			= (SNDRV_PCM_INFO_MMAP		|
28 				   SNDRV_PCM_INFO_MMAP_VALID	|
29 				   SNDRV_PCM_INFO_INTERLEAVED	|
30 				   SNDRV_PCM_INFO_BLOCK_TRANSFER),
31 
32 	.rates			= SNDRV_PCM_RATE_8000_192000,
33 	.rate_min		= SNDRV_PCM_RATE_8000,
34 	.rate_max		= SNDRV_PCM_RATE_192000,
35 
36 	.formats		= (SNDRV_PCM_FMTBIT_S16_LE |
37 				   SNDRV_PCM_FMTBIT_S24_LE |
38 				   SNDRV_PCM_FMTBIT_S32_LE),
39 
40 	.buffer_bytes_max	= 131072,
41 	.period_bytes_min	= 32,
42 	.period_bytes_max	= 32768,
43 	.periods_min		= 1,
44 	.periods_max		= 32,
45 	.fifo_size		= 32,
46 };
47 
48 static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
49 {
50 	struct ep93xx_dma_data *data = filter_param;
51 
52 	if (data->direction == ep93xx_dma_chan_direction(chan)) {
53 		chan->private = data;
54 		return true;
55 	}
56 
57 	return false;
58 }
59 
60 static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
61 	.pcm_hardware = &ep93xx_pcm_hardware,
62 	.compat_filter_fn = ep93xx_pcm_dma_filter,
63 	.prealloc_buffer_size = 131072,
64 };
65 
66 static int ep93xx_soc_platform_probe(struct platform_device *pdev)
67 {
68 	return snd_dmaengine_pcm_register(&pdev->dev,
69 		&ep93xx_dmaengine_pcm_config,
70 		SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
71 		SND_DMAENGINE_PCM_FLAG_NO_DT |
72 		SND_DMAENGINE_PCM_FLAG_COMPAT);
73 }
74 
75 static int ep93xx_soc_platform_remove(struct platform_device *pdev)
76 {
77 	snd_dmaengine_pcm_unregister(&pdev->dev);
78 	return 0;
79 }
80 
81 static struct platform_driver ep93xx_pcm_driver = {
82 	.driver = {
83 			.name = "ep93xx-pcm-audio",
84 			.owner = THIS_MODULE,
85 	},
86 
87 	.probe = ep93xx_soc_platform_probe,
88 	.remove = ep93xx_soc_platform_remove,
89 };
90 
91 module_platform_driver(ep93xx_pcm_driver);
92 
93 MODULE_AUTHOR("Ryan Mallon");
94 MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
95 MODULE_LICENSE("GPL");
96 MODULE_ALIAS("platform:ep93xx-pcm-audio");
97