blob: fa72acd8d3341770abd918e036b6f67f1ea3ffee [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Ryan Mallondb5bf412010-06-04 17:11:24 +12002/*
3 * linux/sound/arm/ep93xx-pcm.c - EP93xx ALSA PCM interface
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 * Copyright (C) 2006 Applied Data Systems
7 *
8 * Rewritten for the SoC audio subsystem (Based on PXA2xx code):
Ryan Mallon1c5454e2011-06-15 14:45:36 +10009 * Copyright (c) 2008 Ryan Mallon
Ryan Mallondb5bf412010-06-04 17:11:24 +120010 */
11
12#include <linux/module.h>
13#include <linux/init.h>
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020014#include <linux/platform_device.h>
Mika Westerberg51e2cc02011-05-29 13:10:04 +030015#include <linux/dmaengine.h>
Ryan Mallondb5bf412010-06-04 17:11:24 +120016
Ryan Mallondb5bf412010-06-04 17:11:24 +120017#include <sound/pcm.h>
Ryan Mallondb5bf412010-06-04 17:11:24 +120018#include <sound/soc.h>
Lars-Peter Clausend7a42e12012-03-05 14:02:15 +010019#include <sound/dmaengine_pcm.h>
Ryan Mallondb5bf412010-06-04 17:11:24 +120020
Arnd Bergmanna3b29242012-08-24 15:12:11 +020021#include <linux/platform_data/dma-ep93xx.h>
Ryan Mallondb5bf412010-06-04 17:11:24 +120022
Stephen Warren6f2032a2013-12-10 12:34:45 -070023#include "ep93xx-pcm.h"
24
Ryan Mallondb5bf412010-06-04 17:11:24 +120025static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
26 .info = (SNDRV_PCM_INFO_MMAP |
27 SNDRV_PCM_INFO_MMAP_VALID |
28 SNDRV_PCM_INFO_INTERLEAVED |
29 SNDRV_PCM_INFO_BLOCK_TRANSFER),
Ryan Mallondb5bf412010-06-04 17:11:24 +120030 .buffer_bytes_max = 131072,
31 .period_bytes_min = 32,
32 .period_bytes_max = 32768,
33 .periods_min = 1,
34 .periods_max = 32,
35 .fifo_size = 32,
36};
37
Mika Westerberg51e2cc02011-05-29 13:10:04 +030038static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
Ryan Mallondb5bf412010-06-04 17:11:24 +120039{
Mika Westerberg51e2cc02011-05-29 13:10:04 +030040 struct ep93xx_dma_data *data = filter_param;
Ryan Mallondb5bf412010-06-04 17:11:24 +120041
Mika Westerberg51e2cc02011-05-29 13:10:04 +030042 if (data->direction == ep93xx_dma_chan_direction(chan)) {
43 chan->private = data;
44 return true;
Ryan Mallondb5bf412010-06-04 17:11:24 +120045 }
Mika Westerberg51e2cc02011-05-29 13:10:04 +030046
47 return false;
Ryan Mallondb5bf412010-06-04 17:11:24 +120048}
49
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020050static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
51 .pcm_hardware = &ep93xx_pcm_hardware,
52 .compat_filter_fn = ep93xx_pcm_dma_filter,
53 .prealloc_buffer_size = 131072,
Ryan Mallondb5bf412010-06-04 17:11:24 +120054};
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000055
Stephen Warren6f2032a2013-12-10 12:34:45 -070056int devm_ep93xx_pcm_platform_register(struct device *dev)
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000057{
Stephen Warren6f2032a2013-12-10 12:34:45 -070058 return devm_snd_dmaengine_pcm_register(dev,
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020059 &ep93xx_dmaengine_pcm_config,
Lars-Peter Clausene27e8a62013-04-20 19:29:05 +020060 SND_DMAENGINE_PCM_FLAG_NO_DT |
61 SND_DMAENGINE_PCM_FLAG_COMPAT);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000062}
Stephen Warren6f2032a2013-12-10 12:34:45 -070063EXPORT_SYMBOL_GPL(devm_ep93xx_pcm_platform_register);
Ryan Mallondb5bf412010-06-04 17:11:24 +120064
Ryan Mallon1c5454e2011-06-15 14:45:36 +100065MODULE_AUTHOR("Ryan Mallon");
Ryan Mallondb5bf412010-06-04 17:11:24 +120066MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
67MODULE_LICENSE("GPL");