aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-24 06:24:05 -0400
committerMark Brown <broonie@linaro.org>2013-10-24 06:24:05 -0400
commit70e0db2f7434961c778466708c032e76775b7f1e (patch)
treee762eb159000dc98090306e3a57d1ae0459312d5 /sound/soc
parent48ce3ec16a618de7fbeb8c3462f8022984f53a1d (diff)
parent90130d2e8f75c7181cef514e8a1491925f386a16 (diff)
Merge remote-tracking branch 'asoc/topic/dma' into asoc-next
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/cirrus/ep93xx-pcm.c13
-rw-r--r--sound/soc/fsl/imx-pcm-dma.c4
-rw-r--r--sound/soc/samsung/i2s.c9
-rw-r--r--sound/soc/soc-generic-dmaengine-pcm.c101
-rw-r--r--sound/soc/tegra/tegra_pcm.c1
5 files changed, 100 insertions, 28 deletions
diff --git a/sound/soc/cirrus/ep93xx-pcm.c b/sound/soc/cirrus/ep93xx-pcm.c
index 0e9f56e0d4b2..cfe517e68009 100644
--- a/sound/soc/cirrus/ep93xx-pcm.c
+++ b/sound/soc/cirrus/ep93xx-pcm.c
@@ -57,9 +57,22 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
57 return false; 57 return false;
58} 58}
59 59
60static struct dma_chan *ep93xx_compat_request_channel(
61 struct snd_soc_pcm_runtime *rtd,
62 struct snd_pcm_substream *substream)
63{
64 struct snd_dmaengine_dai_dma_data *dma_data;
65
66 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
67
68 return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter,
69 dma_data);
70}
71
60static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = { 72static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
61 .pcm_hardware = &ep93xx_pcm_hardware, 73 .pcm_hardware = &ep93xx_pcm_hardware,
62 .compat_filter_fn = ep93xx_pcm_dma_filter, 74 .compat_filter_fn = ep93xx_pcm_dma_filter,
75 .compat_request_channel = ep93xx_compat_request_channel,
63 .prealloc_buffer_size = 131072, 76 .prealloc_buffer_size = 131072,
64}; 77};
65 78
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c
index 4dc1296688e9..aee23077080a 100644
--- a/sound/soc/fsl/imx-pcm-dma.c
+++ b/sound/soc/fsl/imx-pcm-dma.c
@@ -25,12 +25,10 @@
25 25
26static bool filter(struct dma_chan *chan, void *param) 26static bool filter(struct dma_chan *chan, void *param)
27{ 27{
28 struct snd_dmaengine_dai_dma_data *dma_data = param;
29
30 if (!imx_dma_is_general_purpose(chan)) 28 if (!imx_dma_is_general_purpose(chan))
31 return false; 29 return false;
32 30
33 chan->private = dma_data->filter_data; 31 chan->private = param;
34 32
35 return true; 33 return true;
36} 34}
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index b302f3b7a587..3e08b6c0f7ba 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -702,13 +702,6 @@ static int i2s_hw_params(struct snd_pcm_substream *substream,
702 } 702 }
703 writel(mod, i2s->addr + I2SMOD); 703 writel(mod, i2s->addr + I2SMOD);
704 704
705 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
706 snd_soc_dai_set_dma_data(dai, substream,
707 (void *)&i2s->dma_playback);
708 else
709 snd_soc_dai_set_dma_data(dai, substream,
710 (void *)&i2s->dma_capture);
711
712 i2s->frmclk = params_rate(params); 705 i2s->frmclk = params_rate(params);
713 706
714 return 0; 707 return 0;
@@ -970,6 +963,8 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
970 } 963 }
971 clk_prepare_enable(i2s->clk); 964 clk_prepare_enable(i2s->clk);
972 965
966 snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
967
973 if (other) { 968 if (other) {
974 other->addr = i2s->addr; 969 other->addr = i2s->addr;
975 other->clk = i2s->clk; 970 other->clk = i2s->clk;
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index e29ec3cd84b1..0c469cbbe881 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -36,6 +36,15 @@ static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p)
36 return container_of(p, struct dmaengine_pcm, platform); 36 return container_of(p, struct dmaengine_pcm, platform);
37} 37}
38 38
39static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm,
40 struct snd_pcm_substream *substream)
41{
42 if (!pcm->chan[substream->stream])
43 return NULL;
44
45 return pcm->chan[substream->stream]->device->dev;
46}
47
39/** 48/**
40 * snd_dmaengine_pcm_prepare_slave_config() - Generic prepare_slave_config callback 49 * snd_dmaengine_pcm_prepare_slave_config() - Generic prepare_slave_config callback
41 * @substream: PCM substream 50 * @substream: PCM substream
@@ -75,12 +84,19 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream,
75 struct snd_soc_pcm_runtime *rtd = substream->private_data; 84 struct snd_soc_pcm_runtime *rtd = substream->private_data;
76 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); 85 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
77 struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); 86 struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
87 int (*prepare_slave_config)(struct snd_pcm_substream *substream,
88 struct snd_pcm_hw_params *params,
89 struct dma_slave_config *slave_config);
78 struct dma_slave_config slave_config; 90 struct dma_slave_config slave_config;
79 int ret; 91 int ret;
80 92
81 if (pcm->config->prepare_slave_config) { 93 if (!pcm->config)
82 ret = pcm->config->prepare_slave_config(substream, params, 94 prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
83 &slave_config); 95 else
96 prepare_slave_config = pcm->config->prepare_slave_config;
97
98 if (prepare_slave_config) {
99 ret = prepare_slave_config(substream, params, &slave_config);
84 if (ret) 100 if (ret)
85 return ret; 101 return ret;
86 102
@@ -92,28 +108,54 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream,
92 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); 108 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
93} 109}
94 110
95static int dmaengine_pcm_open(struct snd_pcm_substream *substream) 111static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream)
96{ 112{
97 struct snd_soc_pcm_runtime *rtd = substream->private_data; 113 struct snd_soc_pcm_runtime *rtd = substream->private_data;
98 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); 114 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
115 struct device *dma_dev = dmaengine_dma_dev(pcm, substream);
99 struct dma_chan *chan = pcm->chan[substream->stream]; 116 struct dma_chan *chan = pcm->chan[substream->stream];
117 struct snd_dmaengine_dai_dma_data *dma_data;
118 struct dma_slave_caps dma_caps;
119 struct snd_pcm_hardware hw;
100 int ret; 120 int ret;
101 121
102 ret = snd_soc_set_runtime_hwparams(substream, 122 if (pcm->config && pcm->config->pcm_hardware)
123 return snd_soc_set_runtime_hwparams(substream,
103 pcm->config->pcm_hardware); 124 pcm->config->pcm_hardware);
104 if (ret)
105 return ret;
106 125
107 return snd_dmaengine_pcm_open(substream, chan); 126 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
127
128 memset(&hw, 0, sizeof(hw));
129 hw.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
130 SNDRV_PCM_INFO_INTERLEAVED;
131 hw.periods_min = 2;
132 hw.periods_max = UINT_MAX;
133 hw.period_bytes_min = 256;
134 hw.period_bytes_max = dma_get_max_seg_size(dma_dev);
135 hw.buffer_bytes_max = SIZE_MAX;
136 hw.fifo_size = dma_data->fifo_size;
137
138 ret = dma_get_slave_caps(chan, &dma_caps);
139 if (ret == 0) {
140 if (dma_caps.cmd_pause)
141 hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME;
142 }
143
144 return snd_soc_set_runtime_hwparams(substream, &hw);
108} 145}
109 146
110static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, 147static int dmaengine_pcm_open(struct snd_pcm_substream *substream)
111 struct snd_pcm_substream *substream)
112{ 148{
113 if (!pcm->chan[substream->stream]) 149 struct snd_soc_pcm_runtime *rtd = substream->private_data;
114 return NULL; 150 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
151 struct dma_chan *chan = pcm->chan[substream->stream];
152 int ret;
115 153
116 return pcm->chan[substream->stream]->device->dev; 154 ret = dmaengine_pcm_set_runtime_hwparams(substream);
155 if (ret)
156 return ret;
157
158 return snd_dmaengine_pcm_open(substream, chan);
117} 159}
118 160
119static void dmaengine_pcm_free(struct snd_pcm *pcm) 161static void dmaengine_pcm_free(struct snd_pcm *pcm)
@@ -126,6 +168,9 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel(
126 struct snd_pcm_substream *substream) 168 struct snd_pcm_substream *substream)
127{ 169{
128 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); 170 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
171 struct snd_dmaengine_dai_dma_data *dma_data;
172
173 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
129 174
130 if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) && pcm->chan[0]) 175 if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) && pcm->chan[0])
131 return pcm->chan[0]; 176 return pcm->chan[0];
@@ -134,22 +179,42 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel(
134 return pcm->config->compat_request_channel(rtd, substream); 179 return pcm->config->compat_request_channel(rtd, substream);
135 180
136 return snd_dmaengine_pcm_request_channel(pcm->config->compat_filter_fn, 181 return snd_dmaengine_pcm_request_channel(pcm->config->compat_filter_fn,
137 snd_soc_dai_get_dma_data(rtd->cpu_dai, substream)); 182 dma_data->filter_data);
138} 183}
139 184
140static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) 185static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
141{ 186{
142 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); 187 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
143 const struct snd_dmaengine_pcm_config *config = pcm->config; 188 const struct snd_dmaengine_pcm_config *config = pcm->config;
189 struct device *dev = rtd->platform->dev;
190 struct snd_dmaengine_dai_dma_data *dma_data;
144 struct snd_pcm_substream *substream; 191 struct snd_pcm_substream *substream;
192 size_t prealloc_buffer_size;
193 size_t max_buffer_size;
145 unsigned int i; 194 unsigned int i;
146 int ret; 195 int ret;
147 196
197 if (config && config->prealloc_buffer_size) {
198 prealloc_buffer_size = config->prealloc_buffer_size;
199 max_buffer_size = config->pcm_hardware->buffer_bytes_max;
200 } else {
201 prealloc_buffer_size = 512 * 1024;
202 max_buffer_size = SIZE_MAX;
203 }
204
205
148 for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { 206 for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) {
149 substream = rtd->pcm->streams[i].substream; 207 substream = rtd->pcm->streams[i].substream;
150 if (!substream) 208 if (!substream)
151 continue; 209 continue;
152 210
211 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
212
213 if (!pcm->chan[i] &&
214 (pcm->flags & SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME))
215 pcm->chan[i] = dma_request_slave_channel(dev,
216 dma_data->chan_name);
217
153 if (!pcm->chan[i] && (pcm->flags & SND_DMAENGINE_PCM_FLAG_COMPAT)) { 218 if (!pcm->chan[i] && (pcm->flags & SND_DMAENGINE_PCM_FLAG_COMPAT)) {
154 pcm->chan[i] = dmaengine_pcm_compat_request_channel(rtd, 219 pcm->chan[i] = dmaengine_pcm_compat_request_channel(rtd,
155 substream); 220 substream);
@@ -165,8 +230,8 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
165 ret = snd_pcm_lib_preallocate_pages(substream, 230 ret = snd_pcm_lib_preallocate_pages(substream,
166 SNDRV_DMA_TYPE_DEV, 231 SNDRV_DMA_TYPE_DEV,
167 dmaengine_dma_dev(pcm, substream), 232 dmaengine_dma_dev(pcm, substream),
168 config->prealloc_buffer_size, 233 prealloc_buffer_size,
169 config->pcm_hardware->buffer_bytes_max); 234 max_buffer_size);
170 if (ret) 235 if (ret)
171 goto err_free; 236 goto err_free;
172 } 237 }
@@ -222,7 +287,9 @@ static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm,
222{ 287{
223 unsigned int i; 288 unsigned int i;
224 289
225 if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_DT) || !dev->of_node) 290 if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT |
291 SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) ||
292 !dev->of_node)
226 return; 293 return;
227 294
228 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) { 295 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) {
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index f056f632557c..7b2d23ba69b3 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -56,7 +56,6 @@ static const struct snd_pcm_hardware tegra_pcm_hardware = {
56static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = { 56static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = {
57 .pcm_hardware = &tegra_pcm_hardware, 57 .pcm_hardware = &tegra_pcm_hardware,
58 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, 58 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
59 .compat_filter_fn = NULL,
60 .prealloc_buffer_size = PAGE_SIZE * 8, 59 .prealloc_buffer_size = PAGE_SIZE * 8,
61}; 60};
62 61