Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 2 | /* |
| 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 Mallon | 1c5454e | 2011-06-15 14:45:36 +1000 | [diff] [blame] | 9 | * Copyright (c) 2008 Ryan Mallon |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/init.h> |
Lars-Peter Clausen | e27e8a6 | 2013-04-20 19:29:05 +0200 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Mika Westerberg | 51e2cc0 | 2011-05-29 13:10:04 +0300 | [diff] [blame] | 15 | #include <linux/dmaengine.h> |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 16 | |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 17 | #include <sound/pcm.h> |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 18 | #include <sound/soc.h> |
Lars-Peter Clausen | d7a42e1 | 2012-03-05 14:02:15 +0100 | [diff] [blame] | 19 | #include <sound/dmaengine_pcm.h> |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 20 | |
Arnd Bergmann | a3b2924 | 2012-08-24 15:12:11 +0200 | [diff] [blame] | 21 | #include <linux/platform_data/dma-ep93xx.h> |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 22 | |
Stephen Warren | 6f2032a | 2013-12-10 12:34:45 -0700 | [diff] [blame] | 23 | #include "ep93xx-pcm.h" |
| 24 | |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 25 | static 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 Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 30 | .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 Westerberg | 51e2cc0 | 2011-05-29 13:10:04 +0300 | [diff] [blame] | 38 | static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param) |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 39 | { |
Mika Westerberg | 51e2cc0 | 2011-05-29 13:10:04 +0300 | [diff] [blame] | 40 | struct ep93xx_dma_data *data = filter_param; |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 41 | |
Mika Westerberg | 51e2cc0 | 2011-05-29 13:10:04 +0300 | [diff] [blame] | 42 | if (data->direction == ep93xx_dma_chan_direction(chan)) { |
| 43 | chan->private = data; |
| 44 | return true; |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 45 | } |
Mika Westerberg | 51e2cc0 | 2011-05-29 13:10:04 +0300 | [diff] [blame] | 46 | |
| 47 | return false; |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 48 | } |
| 49 | |
Lars-Peter Clausen | e27e8a6 | 2013-04-20 19:29:05 +0200 | [diff] [blame] | 50 | static 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 Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 54 | }; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 55 | |
Stephen Warren | 6f2032a | 2013-12-10 12:34:45 -0700 | [diff] [blame] | 56 | int devm_ep93xx_pcm_platform_register(struct device *dev) |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 57 | { |
Stephen Warren | 6f2032a | 2013-12-10 12:34:45 -0700 | [diff] [blame] | 58 | return devm_snd_dmaengine_pcm_register(dev, |
Lars-Peter Clausen | e27e8a6 | 2013-04-20 19:29:05 +0200 | [diff] [blame] | 59 | &ep93xx_dmaengine_pcm_config, |
Lars-Peter Clausen | e27e8a6 | 2013-04-20 19:29:05 +0200 | [diff] [blame] | 60 | SND_DMAENGINE_PCM_FLAG_NO_DT | |
| 61 | SND_DMAENGINE_PCM_FLAG_COMPAT); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 62 | } |
Stephen Warren | 6f2032a | 2013-12-10 12:34:45 -0700 | [diff] [blame] | 63 | EXPORT_SYMBOL_GPL(devm_ep93xx_pcm_platform_register); |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 64 | |
Ryan Mallon | 1c5454e | 2011-06-15 14:45:36 +1000 | [diff] [blame] | 65 | MODULE_AUTHOR("Ryan Mallon"); |
Ryan Mallon | db5bf41 | 2010-06-04 17:11:24 +1200 | [diff] [blame] | 66 | MODULE_DESCRIPTION("EP93xx ALSA PCM interface"); |
| 67 | MODULE_LICENSE("GPL"); |