blob: 4707f2b862c3762502d622d1d799944ee0e401fc [file] [log] [blame]
Rajeev Kumar241b4462012-06-21 15:54:52 +05301/*
2 * ALSA PCM interface for ST SPEAr Processors
3 *
4 * sound/soc/spear/spear_pcm.c
5 *
6 * Copyright (C) 2012 ST Microelectronics
7 * Rajeev Kumar<rajeev-dlh.kumar@st.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#include <linux/module.h>
15#include <linux/dmaengine.h>
Rajeev Kumar241b4462012-06-21 15:54:52 +053016#include <linux/platform_device.h>
Rajeev Kumar241b4462012-06-21 15:54:52 +053017#include <sound/dmaengine_pcm.h>
18#include <sound/pcm.h>
Rajeev Kumar241b4462012-06-21 15:54:52 +053019#include <sound/soc.h>
20#include <sound/spear_dma.h>
21
Lars-Peter Clausen52c102e2013-04-20 19:29:07 +020022static const struct snd_pcm_hardware spear_pcm_hardware = {
Rajeev Kumar241b4462012-06-21 15:54:52 +053023 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
24 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
25 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
26 .buffer_bytes_max = 16 * 1024, /* max buffer size */
27 .period_bytes_min = 2 * 1024, /* 1 msec data minimum period size */
28 .period_bytes_max = 2 * 1024, /* maximum period size */
29 .periods_min = 1, /* min # periods */
30 .periods_max = 8, /* max # of periods */
31 .fifo_size = 0, /* fifo size in bytes */
32};
33
Lars-Peter Clausen52c102e2013-04-20 19:29:07 +020034static struct dma_chan *spear_pcm_request_chan(struct snd_soc_pcm_runtime *rtd,
35 struct snd_pcm_substream *substream)
Rajeev Kumar241b4462012-06-21 15:54:52 +053036{
Lars-Peter Clausen52c102e2013-04-20 19:29:07 +020037 struct spear_dma_data *dma_data;
Rajeev Kumar241b4462012-06-21 15:54:52 +053038
Lars-Peter Clausen52c102e2013-04-20 19:29:07 +020039 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
40
41 return snd_dmaengine_pcm_request_channel(dma_data->filter, dma_data);
Rajeev Kumar241b4462012-06-21 15:54:52 +053042}
43
Lars-Peter Clausen52c102e2013-04-20 19:29:07 +020044static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = {
45 .pcm_hardware = &spear_pcm_hardware,
46 .compat_request_channel = spear_pcm_request_chan,
47 .prealloc_buffer_size = 16 * 1024,
Rajeev Kumar241b4462012-06-21 15:54:52 +053048};
49
Bill Pemberton468c1172012-12-07 09:26:32 -050050static int spear_soc_platform_probe(struct platform_device *pdev)
Rajeev Kumar241b4462012-06-21 15:54:52 +053051{
Lars-Peter Clausen52c102e2013-04-20 19:29:07 +020052 return snd_dmaengine_pcm_register(&pdev->dev,
53 &spear_dmaengine_pcm_config,
54 SND_DMAENGINE_PCM_FLAG_NO_DT |
55 SND_DMAENGINE_PCM_FLAG_COMPAT);
Rajeev Kumar241b4462012-06-21 15:54:52 +053056}
57
Bill Pemberton468c1172012-12-07 09:26:32 -050058static int spear_soc_platform_remove(struct platform_device *pdev)
Rajeev Kumar241b4462012-06-21 15:54:52 +053059{
Lars-Peter Clausen52c102e2013-04-20 19:29:07 +020060 snd_dmaengine_pcm_unregister(&pdev->dev);
Rajeev Kumar241b4462012-06-21 15:54:52 +053061 return 0;
62}
63
64static struct platform_driver spear_pcm_driver = {
65 .driver = {
66 .name = "spear-pcm-audio",
67 .owner = THIS_MODULE,
68 },
69
70 .probe = spear_soc_platform_probe,
Bill Pemberton468c1172012-12-07 09:26:32 -050071 .remove = spear_soc_platform_remove,
Rajeev Kumar241b4462012-06-21 15:54:52 +053072};
73
74module_platform_driver(spear_pcm_driver);
75
76MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>");
77MODULE_DESCRIPTION("SPEAr PCM DMA module");
78MODULE_LICENSE("GPL");
79MODULE_ALIAS("platform:spear-pcm-audio");