2012-06-21 18:24:52 +08:00
|
|
|
/*
|
|
|
|
* ALSA PCM interface for ST SPEAr Processors
|
|
|
|
*
|
|
|
|
* sound/soc/spear/spear_pcm.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 ST Microelectronics
|
|
|
|
* Rajeev Kumar<rajeev-dlh.kumar@st.com>
|
|
|
|
*
|
|
|
|
* This file is licensed under the terms of the GNU General Public
|
|
|
|
* License version 2. This program is licensed "as is" without any
|
|
|
|
* warranty of any kind, whether express or implied.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/dmaengine.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <sound/dmaengine_pcm.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/soc.h>
|
|
|
|
#include <sound/spear_dma.h>
|
|
|
|
|
2013-04-21 01:29:07 +08:00
|
|
|
static const struct snd_pcm_hardware spear_pcm_hardware = {
|
2012-06-21 18:24:52 +08:00
|
|
|
.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
|
|
|
SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
|
|
|
|
SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
|
|
|
|
.buffer_bytes_max = 16 * 1024, /* max buffer size */
|
|
|
|
.period_bytes_min = 2 * 1024, /* 1 msec data minimum period size */
|
|
|
|
.period_bytes_max = 2 * 1024, /* maximum period size */
|
|
|
|
.periods_min = 1, /* min # periods */
|
|
|
|
.periods_max = 8, /* max # of periods */
|
|
|
|
.fifo_size = 0, /* fifo size in bytes */
|
|
|
|
};
|
|
|
|
|
2013-04-21 01:29:07 +08:00
|
|
|
static struct dma_chan *spear_pcm_request_chan(struct snd_soc_pcm_runtime *rtd,
|
|
|
|
struct snd_pcm_substream *substream)
|
2012-06-21 18:24:52 +08:00
|
|
|
{
|
2013-04-21 01:29:07 +08:00
|
|
|
struct spear_dma_data *dma_data;
|
2012-06-21 18:24:52 +08:00
|
|
|
|
2013-04-21 01:29:07 +08:00
|
|
|
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
|
2012-06-21 18:24:52 +08:00
|
|
|
|
2013-04-21 01:29:07 +08:00
|
|
|
return snd_dmaengine_pcm_request_channel(dma_data->filter, dma_data);
|
2012-06-21 18:24:52 +08:00
|
|
|
}
|
|
|
|
|
2013-04-21 01:29:07 +08:00
|
|
|
static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = {
|
|
|
|
.pcm_hardware = &spear_pcm_hardware,
|
|
|
|
.compat_request_channel = spear_pcm_request_chan,
|
|
|
|
.prealloc_buffer_size = 16 * 1024,
|
2012-06-21 18:24:52 +08:00
|
|
|
};
|
|
|
|
|
2012-12-07 22:26:32 +08:00
|
|
|
static int spear_soc_platform_probe(struct platform_device *pdev)
|
2012-06-21 18:24:52 +08:00
|
|
|
{
|
2013-11-28 15:50:36 +08:00
|
|
|
return devm_snd_dmaengine_pcm_register(&pdev->dev,
|
2013-04-21 01:29:07 +08:00
|
|
|
&spear_dmaengine_pcm_config,
|
|
|
|
SND_DMAENGINE_PCM_FLAG_NO_DT |
|
|
|
|
SND_DMAENGINE_PCM_FLAG_COMPAT);
|
2012-06-21 18:24:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver spear_pcm_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "spear-pcm-audio",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
|
|
|
|
.probe = spear_soc_platform_probe,
|
|
|
|
};
|
|
|
|
|
|
|
|
module_platform_driver(spear_pcm_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>");
|
|
|
|
MODULE_DESCRIPTION("SPEAr PCM DMA module");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS("platform:spear-pcm-audio");
|