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