Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * dmaengine.c - Samsung dmaengine wrapper |
| 3 | * |
| 4 | * Author: Mark Brown <broonie@linaro.org> |
| 5 | * Copyright 2013 Linaro |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * version 2 as published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/amba/pl08x.h> |
Vasily Khoruzhick | 87b132b | 2014-06-23 23:24:04 +0300 | [diff] [blame] | 20 | #include <linux/platform_data/dma-s3c24xx.h> |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 21 | |
| 22 | #include <sound/core.h> |
| 23 | #include <sound/pcm.h> |
| 24 | #include <sound/pcm_params.h> |
| 25 | #include <sound/dmaengine_pcm.h> |
| 26 | #include <sound/soc.h> |
| 27 | #include <sound/soc-dai.h> |
| 28 | |
| 29 | #include "dma.h" |
| 30 | |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 31 | void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, |
| 32 | struct s3c_dma_params *playback, |
| 33 | struct s3c_dma_params *capture) |
| 34 | { |
| 35 | struct snd_dmaengine_dai_dma_data *playback_data = NULL; |
| 36 | struct snd_dmaengine_dai_dma_data *capture_data = NULL; |
| 37 | |
| 38 | if (playback) { |
| 39 | playback_data = &playback->dma_data; |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 40 | playback_data->filter_data = playback->slave; |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 41 | playback_data->chan_name = playback->ch_name; |
| 42 | playback_data->addr = playback->dma_addr; |
| 43 | playback_data->addr_width = playback->dma_size; |
| 44 | } |
| 45 | if (capture) { |
| 46 | capture_data = &capture->dma_data; |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 47 | capture_data->filter_data = capture->slave; |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 48 | capture_data->chan_name = capture->ch_name; |
| 49 | capture_data->addr = capture->dma_addr; |
| 50 | capture_data->addr_width = capture->dma_size; |
| 51 | } |
| 52 | |
| 53 | snd_soc_dai_init_dma_data(dai, playback_data, capture_data); |
| 54 | } |
| 55 | EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data); |
| 56 | |
Sylwester Nawrocki | 42a74e7 | 2016-07-21 20:03:50 +0200 | [diff] [blame] | 57 | int samsung_asoc_dma_platform_register(struct device *dev, dma_filter_fn filter, |
| 58 | const char *tx, const char *rx) |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 59 | { |
Sylwester Nawrocki | 42a74e7 | 2016-07-21 20:03:50 +0200 | [diff] [blame] | 60 | unsigned int flags = SND_DMAENGINE_PCM_FLAG_COMPAT; |
Arnd Bergmann | 9bdca82 | 2015-11-18 22:31:11 +0100 | [diff] [blame] | 61 | |
Sylwester Nawrocki | 42a74e7 | 2016-07-21 20:03:50 +0200 | [diff] [blame] | 62 | struct snd_dmaengine_pcm_config *pcm_conf; |
| 63 | |
| 64 | pcm_conf = devm_kzalloc(dev, sizeof(*pcm_conf), GFP_KERNEL); |
| 65 | if (!pcm_conf) |
| 66 | return -ENOMEM; |
| 67 | |
| 68 | pcm_conf->prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config; |
| 69 | pcm_conf->compat_filter_fn = filter; |
| 70 | |
| 71 | if (dev->of_node) { |
| 72 | pcm_conf->chan_names[SNDRV_PCM_STREAM_PLAYBACK] = tx; |
| 73 | pcm_conf->chan_names[SNDRV_PCM_STREAM_CAPTURE] = rx; |
| 74 | } else { |
| 75 | flags |= SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME; |
| 76 | } |
| 77 | |
| 78 | return devm_snd_dmaengine_pcm_register(dev, pcm_conf, flags); |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 79 | } |
| 80 | EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_register); |
| 81 | |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 82 | MODULE_AUTHOR("Mark Brown <broonie@linaro.org>"); |
| 83 | MODULE_DESCRIPTION("Samsung dmaengine ASoC driver"); |
| 84 | MODULE_LICENSE("GPL"); |