blob: 67a73330db5e88e669c52f424dafa5045a0728d6 [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
Stephen Warren6f2032a2013-12-10 12:34:45 -070026#include "ep93xx-pcm.h"
27
Ryan Mallondb5bf412010-06-04 17:11:24 +120028static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
29 .info = (SNDRV_PCM_INFO_MMAP |
30 SNDRV_PCM_INFO_MMAP_VALID |
31 SNDRV_PCM_INFO_INTERLEAVED |
32 SNDRV_PCM_INFO_BLOCK_TRANSFER),
Ryan Mallondb5bf412010-06-04 17:11:24 +120033 .buffer_bytes_max = 131072,
34 .period_bytes_min = 32,
35 .period_bytes_max = 32768,
36 .periods_min = 1,
37 .periods_max = 32,
38 .fifo_size = 32,
39};
40
Mika Westerberg51e2cc02011-05-29 13:10:04 +030041static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
Ryan Mallondb5bf412010-06-04 17:11:24 +120042{
Mika Westerberg51e2cc02011-05-29 13:10:04 +030043 struct ep93xx_dma_data *data = filter_param;
Ryan Mallondb5bf412010-06-04 17:11:24 +120044
Mika Westerberg51e2cc02011-05-29 13:10:04 +030045 if (data->direction == ep93xx_dma_chan_direction(chan)) {
46 chan->private = data;
47 return true;
Ryan Mallondb5bf412010-06-04 17:11:24 +120048 }
Mika Westerberg51e2cc02011-05-29 13:10:04 +030049
50 return false;
Ryan Mallondb5bf412010-06-04 17:11:24 +120051}
52
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020053static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
54 .pcm_hardware = &ep93xx_pcm_hardware,
55 .compat_filter_fn = ep93xx_pcm_dma_filter,
56 .prealloc_buffer_size = 131072,
Ryan Mallondb5bf412010-06-04 17:11:24 +120057};
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000058
Stephen Warren6f2032a2013-12-10 12:34:45 -070059int devm_ep93xx_pcm_platform_register(struct device *dev)
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000060{
Stephen Warren6f2032a2013-12-10 12:34:45 -070061 return devm_snd_dmaengine_pcm_register(dev,
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020062 &ep93xx_dmaengine_pcm_config,
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020063 SND_DMAENGINE_PCM_FLAG_NO_DT |
64 SND_DMAENGINE_PCM_FLAG_COMPAT);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000065}
Stephen Warren6f2032a2013-12-10 12:34:45 -070066EXPORT_SYMBOL_GPL(devm_ep93xx_pcm_platform_register);
Ryan Mallondb5bf412010-06-04 17:11:24 +120067
Ryan Mallon1c5454e2011-06-15 14:45:36 +100068MODULE_AUTHOR("Ryan Mallon");
Ryan Mallondb5bf412010-06-04 17:11:24 +120069MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
70MODULE_LICENSE("GPL");