Merge branches 'pm-cpufreq' and 'pm-devfreq'
[profile/ivi/kernel-x86-ivi.git] / sound / soc / samsung / dmaengine.c
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
21 #include <sound/core.h>
22 #include <sound/pcm.h>
23 #include <sound/pcm_params.h>
24 #include <sound/dmaengine_pcm.h>
25 #include <sound/soc.h>
26 #include <sound/soc-dai.h>
27
28 #include "dma.h"
29
30 #ifdef CONFIG_ARCH_S3C64XX
31 #define filter_fn pl08x_filter_id
32 #else
33 #define filter_fn NULL
34 #endif
35
36 static const struct snd_dmaengine_pcm_config samsung_dmaengine_pcm_config = {
37         .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
38         .compat_filter_fn = filter_fn,
39 };
40
41 void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,
42                                 struct s3c_dma_params *playback,
43                                 struct s3c_dma_params *capture)
44 {
45         struct snd_dmaengine_dai_dma_data *playback_data = NULL;
46         struct snd_dmaengine_dai_dma_data *capture_data = NULL;
47
48         if (playback) {
49                 playback_data = &playback->dma_data;
50                 playback_data->filter_data = (void *)playback->channel;
51                 playback_data->chan_name = playback->ch_name;
52                 playback_data->addr = playback->dma_addr;
53                 playback_data->addr_width = playback->dma_size;
54         }
55         if (capture) {
56                 capture_data = &capture->dma_data;
57                 capture_data->filter_data = (void *)capture->channel;
58                 capture_data->chan_name = capture->ch_name;
59                 capture_data->addr = capture->dma_addr;
60                 capture_data->addr_width = capture->dma_size;
61         }
62
63         snd_soc_dai_init_dma_data(dai, playback_data, capture_data);
64 }
65 EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data);
66
67 int samsung_asoc_dma_platform_register(struct device *dev)
68 {
69         return snd_dmaengine_pcm_register(dev, &samsung_dmaengine_pcm_config,
70                                           SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME |
71                                           SND_DMAENGINE_PCM_FLAG_COMPAT);
72 }
73 EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_register);
74
75 void samsung_asoc_dma_platform_unregister(struct device *dev)
76 {
77         return snd_dmaengine_pcm_unregister(dev);
78 }
79 EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_unregister);
80
81 MODULE_AUTHOR("Mark Brown <broonie@linaro.org>");
82 MODULE_DESCRIPTION("Samsung dmaengine ASoC driver");
83 MODULE_LICENSE("GPL");