blob: fdb8b8feb4edc5cd853066461df08508285b4535 [file] [log] [blame]
Ryan Mallondb5bf412010-06-04 17:11:24 +12001/*
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):
Ryan Mallon1c5454e2011-06-15 14:45:36 +10008 * Copyright (c) 2008 Ryan Mallon
Ryan Mallondb5bf412010-06-04 17:11:24 +12009 *
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>
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020017#include <linux/platform_device.h>
Mika Westerberg51e2cc02011-05-29 13:10:04 +030018#include <linux/dmaengine.h>
Ryan Mallondb5bf412010-06-04 17:11:24 +120019
Ryan Mallondb5bf412010-06-04 17:11:24 +120020#include <sound/pcm.h>
Ryan Mallondb5bf412010-06-04 17:11:24 +120021#include <sound/soc.h>
Lars-Peter Clausend7a42e12012-03-05 14:02:15 +010022#include <sound/dmaengine_pcm.h>
Ryan Mallondb5bf412010-06-04 17:11:24 +120023
Arnd Bergmanna3b29242012-08-24 15:12:11 +020024#include <linux/platform_data/dma-ep93xx.h>
Ryan Mallondb5bf412010-06-04 17:11:24 +120025
Ryan Mallondb5bf412010-06-04 17:11:24 +120026static 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
Alexander Sverdlin4cfeb692011-03-07 20:30:12 +030032 .rates = SNDRV_PCM_RATE_8000_192000,
Ryan Mallondb5bf412010-06-04 17:11:24 +120033 .rate_min = SNDRV_PCM_RATE_8000,
Alexander Sverdlin4cfeb692011-03-07 20:30:12 +030034 .rate_max = SNDRV_PCM_RATE_192000,
Ryan Mallondb5bf412010-06-04 17:11:24 +120035
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
Mika Westerberg51e2cc02011-05-29 13:10:04 +030048static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
Ryan Mallondb5bf412010-06-04 17:11:24 +120049{
Mika Westerberg51e2cc02011-05-29 13:10:04 +030050 struct ep93xx_dma_data *data = filter_param;
Ryan Mallondb5bf412010-06-04 17:11:24 +120051
Mika Westerberg51e2cc02011-05-29 13:10:04 +030052 if (data->direction == ep93xx_dma_chan_direction(chan)) {
53 chan->private = data;
54 return true;
Ryan Mallondb5bf412010-06-04 17:11:24 +120055 }
Mika Westerberg51e2cc02011-05-29 13:10:04 +030056
57 return false;
Ryan Mallondb5bf412010-06-04 17:11:24 +120058}
59
Mark Brownd7711dc2013-10-19 14:13:04 +010060static struct dma_chan *ep93xx_compat_request_channel(
61 struct snd_soc_pcm_runtime *rtd,
62 struct snd_pcm_substream *substream)
63{
64 struct snd_dmaengine_dai_dma_data *dma_data;
65
66 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
67
68 return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter,
69 dma_data);
70}
71
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020072static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
73 .pcm_hardware = &ep93xx_pcm_hardware,
74 .compat_filter_fn = ep93xx_pcm_dma_filter,
Mark Brownd7711dc2013-10-19 14:13:04 +010075 .compat_request_channel = ep93xx_compat_request_channel,
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020076 .prealloc_buffer_size = 131072,
Ryan Mallondb5bf412010-06-04 17:11:24 +120077};
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000078
Bill Pemberton145e2872012-12-07 09:26:23 -050079static int ep93xx_soc_platform_probe(struct platform_device *pdev)
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000080{
Lars-Peter Clausen237eeb12013-11-28 08:50:34 +010081 return devm_snd_dmaengine_pcm_register(&pdev->dev,
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020082 &ep93xx_dmaengine_pcm_config,
83 SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
84 SND_DMAENGINE_PCM_FLAG_NO_DT |
85 SND_DMAENGINE_PCM_FLAG_COMPAT);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000086}
87
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000088static struct platform_driver ep93xx_pcm_driver = {
89 .driver = {
90 .name = "ep93xx-pcm-audio",
91 .owner = THIS_MODULE,
92 },
93
94 .probe = ep93xx_soc_platform_probe,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000095};
Ryan Mallondb5bf412010-06-04 17:11:24 +120096
Axel Linee18f632011-11-24 12:07:55 +080097module_platform_driver(ep93xx_pcm_driver);
Ryan Mallondb5bf412010-06-04 17:11:24 +120098
Ryan Mallon1c5454e2011-06-15 14:45:36 +100099MODULE_AUTHOR("Ryan Mallon");
Ryan Mallondb5bf412010-06-04 17:11:24 +1200100MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
101MODULE_LICENSE("GPL");
Mika Westerberg93068162011-09-11 12:28:49 +0300102MODULE_ALIAS("platform:ep93xx-pcm-audio");