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> |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 19 | #include <sound/core.h> |
| 20 | #include <sound/pcm.h> |
| 21 | #include <sound/pcm_params.h> |
| 22 | #include <sound/dmaengine_pcm.h> |
| 23 | #include <sound/soc.h> |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 24 | |
| 25 | #include "dma.h" |
| 26 | |
Sylwester Nawrocki | 42a74e7 | 2016-07-21 20:03:50 +0200 | [diff] [blame] | 27 | int samsung_asoc_dma_platform_register(struct device *dev, dma_filter_fn filter, |
| 28 | const char *tx, const char *rx) |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 29 | { |
Sylwester Nawrocki | 42a74e7 | 2016-07-21 20:03:50 +0200 | [diff] [blame] | 30 | unsigned int flags = SND_DMAENGINE_PCM_FLAG_COMPAT; |
Sylwester Nawrocki | 42a74e7 | 2016-07-21 20:03:50 +0200 | [diff] [blame] | 31 | struct snd_dmaengine_pcm_config *pcm_conf; |
| 32 | |
| 33 | pcm_conf = devm_kzalloc(dev, sizeof(*pcm_conf), GFP_KERNEL); |
| 34 | if (!pcm_conf) |
| 35 | return -ENOMEM; |
| 36 | |
| 37 | pcm_conf->prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config; |
| 38 | pcm_conf->compat_filter_fn = filter; |
| 39 | |
Sylwester Nawrocki | b8ab0cc | 2017-01-17 14:16:42 +0100 | [diff] [blame] | 40 | if (dev->of_node) { |
| 41 | pcm_conf->chan_names[SNDRV_PCM_STREAM_PLAYBACK] = tx; |
| 42 | pcm_conf->chan_names[SNDRV_PCM_STREAM_CAPTURE] = rx; |
| 43 | } else { |
| 44 | flags |= SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME; |
| 45 | } |
Sylwester Nawrocki | 42a74e7 | 2016-07-21 20:03:50 +0200 | [diff] [blame] | 46 | |
| 47 | return devm_snd_dmaengine_pcm_register(dev, pcm_conf, flags); |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 48 | } |
| 49 | EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_register); |
| 50 | |
Mark Brown | d37bdf7 | 2013-12-05 14:14:52 +0000 | [diff] [blame] | 51 | MODULE_AUTHOR("Mark Brown <broonie@linaro.org>"); |
| 52 | MODULE_DESCRIPTION("Samsung dmaengine ASoC driver"); |
| 53 | MODULE_LICENSE("GPL"); |