aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-04-03 05:06:02 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-03 13:12:33 -0400
commit85c9f9c5f9d09ea43daf4f1a8b81d3c7b7394d27 (patch)
tree832dd28c2f8e763d4a9fc62559db8454af04abef
parent5fa70f71dbf33603b0d29b33d8da128b266eb733 (diff)
ASoC: dmaengine-pcm: Add a common DAI DMA data struct
This patch adds a common DMA data struct which can be used by DAI drivers to communicate their DMA configuration requirements to the DMA pcm driver. Having a common data structure for this allows us to implement common functions on top of them, which can be used by multiple platforms. This patch also introduces a new function to initialize certain fields of a dma_slave_config struct from the common DAI DMA data struct. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--include/sound/dmaengine_pcm.h24
-rw-r--r--sound/soc/soc-dmaengine-pcm.c37
2 files changed, 61 insertions, 0 deletions
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h
index f8a70312adb8..95620428a59b 100644
--- a/include/sound/dmaengine_pcm.h
+++ b/include/sound/dmaengine_pcm.h
@@ -44,4 +44,28 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream);
44 44
45struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream); 45struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream);
46 46
47/**
48 * struct snd_dmaengine_dai_dma_data - DAI DMA configuration data
49 * @addr: Address of the DAI data source or destination register.
50 * @addr_width: Width of the DAI data source or destination register.
51 * @maxburst: Maximum number of words(note: words, as in units of the
52 * src_addr_width member, not bytes) that can be send to or received from the
53 * DAI in one burst.
54 * @slave_id: Slave requester id for the DMA channel.
55 * @filter_data: Custom DMA channel filter data, this will usually be used when
56 * requesting the DMA channel.
57 */
58struct snd_dmaengine_dai_dma_data {
59 dma_addr_t addr;
60 enum dma_slave_buswidth addr_width;
61 u32 maxburst;
62 unsigned int slave_id;
63 void *filter_data;
64};
65
66void snd_dmaengine_pcm_set_config_from_dai_data(
67 const struct snd_pcm_substream *substream,
68 const struct snd_dmaengine_dai_dma_data *dma_data,
69 struct dma_slave_config *config);
70
47#endif 71#endif
diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c
index 7c24dedff971..a9a300acb506 100644
--- a/sound/soc/soc-dmaengine-pcm.c
+++ b/sound/soc/soc-dmaengine-pcm.c
@@ -95,6 +95,43 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream,
95} 95}
96EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config); 96EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config);
97 97
98/**
99 * snd_dmaengine_pcm_set_config_from_dai_data() - Initializes a dma slave config
100 * using DAI DMA data.
101 * @substream: PCM substream
102 * @dma_data: DAI DMA data
103 * @slave_config: DMA slave configuration
104 *
105 * Initializes the {dst,src}_addr, {dst,src}_maxburst, {dst,src}_addr_width and
106 * slave_id fields of the DMA slave config from the same fields of the DAI DMA
107 * data struct. The src and dst fields will be initialized depending on the
108 * direction of the substream. If the substream is a playback stream the dst
109 * fields will be initialized, if it is a capture stream the src fields will be
110 * initialized. The {dst,src}_addr_width field will only be initialized if the
111 * addr_width field of the DAI DMA data struct is not equal to
112 * DMA_SLAVE_BUSWIDTH_UNDEFINED.
113 */
114void snd_dmaengine_pcm_set_config_from_dai_data(
115 const struct snd_pcm_substream *substream,
116 const struct snd_dmaengine_dai_dma_data *dma_data,
117 struct dma_slave_config *slave_config)
118{
119 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
120 slave_config->dst_addr = dma_data->addr;
121 slave_config->dst_maxburst = dma_data->maxburst;
122 if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED)
123 slave_config->dst_addr_width = dma_data->addr_width;
124 } else {
125 slave_config->src_addr = dma_data->addr;
126 slave_config->src_maxburst = dma_data->maxburst;
127 if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED)
128 slave_config->src_addr_width = dma_data->addr_width;
129 }
130
131 slave_config->slave_id = dma_data->slave_id;
132}
133EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_set_config_from_dai_data);
134
98static void dmaengine_pcm_dma_complete(void *arg) 135static void dmaengine_pcm_dma_complete(void *arg)
99{ 136{
100 struct snd_pcm_substream *substream = arg; 137 struct snd_pcm_substream *substream = arg;