Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 1 | /* |
| 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 Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 16 | #include <linux/platform_device.h> |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 17 | #include <sound/dmaengine_pcm.h> |
| 18 | #include <sound/pcm.h> |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 19 | #include <sound/soc.h> |
| 20 | #include <sound/spear_dma.h> |
| 21 | |
Lars-Peter Clausen | 52c102e | 2013-04-20 19:29:07 +0200 | [diff] [blame] | 22 | static const struct snd_pcm_hardware spear_pcm_hardware = { |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 23 | .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 Clausen | 52c102e | 2013-04-20 19:29:07 +0200 | [diff] [blame] | 34 | static struct dma_chan *spear_pcm_request_chan(struct snd_soc_pcm_runtime *rtd, |
| 35 | struct snd_pcm_substream *substream) |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 36 | { |
Lars-Peter Clausen | 52c102e | 2013-04-20 19:29:07 +0200 | [diff] [blame] | 37 | struct spear_dma_data *dma_data; |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 38 | |
Lars-Peter Clausen | 52c102e | 2013-04-20 19:29:07 +0200 | [diff] [blame] | 39 | 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 Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 42 | } |
| 43 | |
Lars-Peter Clausen | 52c102e | 2013-04-20 19:29:07 +0200 | [diff] [blame] | 44 | static 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 Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 48 | }; |
| 49 | |
Bill Pemberton | 468c117 | 2012-12-07 09:26:32 -0500 | [diff] [blame] | 50 | static int spear_soc_platform_probe(struct platform_device *pdev) |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 51 | { |
Lars-Peter Clausen | 52c102e | 2013-04-20 19:29:07 +0200 | [diff] [blame] | 52 | 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 Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 56 | } |
| 57 | |
Bill Pemberton | 468c117 | 2012-12-07 09:26:32 -0500 | [diff] [blame] | 58 | static int spear_soc_platform_remove(struct platform_device *pdev) |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 59 | { |
Lars-Peter Clausen | 52c102e | 2013-04-20 19:29:07 +0200 | [diff] [blame] | 60 | snd_dmaengine_pcm_unregister(&pdev->dev); |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static 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 Pemberton | 468c117 | 2012-12-07 09:26:32 -0500 | [diff] [blame] | 71 | .remove = spear_soc_platform_remove, |
Rajeev Kumar | 241b446 | 2012-06-21 15:54:52 +0530 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | module_platform_driver(spear_pcm_driver); |
| 75 | |
| 76 | MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>"); |
| 77 | MODULE_DESCRIPTION("SPEAr PCM DMA module"); |
| 78 | MODULE_LICENSE("GPL"); |
| 79 | MODULE_ALIAS("platform:spear-pcm-audio"); |