xref: /openbmc/linux/sound/soc/samsung/dmaengine.c (revision 8c749ce9)
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>
20 #include <linux/platform_data/dma-s3c24xx.h>
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 
31 static struct snd_dmaengine_pcm_config samsung_dmaengine_pcm_config = {
32 	.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
33 };
34 
35 void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,
36 				struct s3c_dma_params *playback,
37 				struct s3c_dma_params *capture)
38 {
39 	struct snd_dmaengine_dai_dma_data *playback_data = NULL;
40 	struct snd_dmaengine_dai_dma_data *capture_data = NULL;
41 
42 	if (playback) {
43 		playback_data = &playback->dma_data;
44 		playback_data->filter_data = playback->slave;
45 		playback_data->chan_name = playback->ch_name;
46 		playback_data->addr = playback->dma_addr;
47 		playback_data->addr_width = playback->dma_size;
48 	}
49 	if (capture) {
50 		capture_data = &capture->dma_data;
51 		capture_data->filter_data = capture->slave;
52 		capture_data->chan_name = capture->ch_name;
53 		capture_data->addr = capture->dma_addr;
54 		capture_data->addr_width = capture->dma_size;
55 	}
56 
57 	snd_soc_dai_init_dma_data(dai, playback_data, capture_data);
58 }
59 EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data);
60 
61 int samsung_asoc_dma_platform_register(struct device *dev,
62 				       dma_filter_fn filter)
63 {
64 	samsung_dmaengine_pcm_config.compat_filter_fn = filter;
65 
66 	return devm_snd_dmaengine_pcm_register(dev,
67 			&samsung_dmaengine_pcm_config,
68 			SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME |
69 			SND_DMAENGINE_PCM_FLAG_COMPAT);
70 }
71 EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_register);
72 
73 MODULE_AUTHOR("Mark Brown <broonie@linaro.org>");
74 MODULE_DESCRIPTION("Samsung dmaengine ASoC driver");
75 MODULE_LICENSE("GPL");
76