aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/mxs
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-02-22 04:49:07 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-22 08:21:49 -0500
commit95a771ca16ad63cfd665bebadbc543857db6fa4e (patch)
tree1d7b2eb1d8f02a3528dd47619bc8436b001e7a3a /sound/soc/mxs
parent4564d10f3066a1abf5053936684e2c8495163def (diff)
ASoC: mxs-pcm: Request DMA channel early
Request the DMA channel in the PCM open callback instead of the hwparams callback, this allows us to let open fail if no dma channel is available. This also fixes a bug where the channel will be requested multiple times if hwparams is called multiple times. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/mxs')
-rw-r--r--sound/soc/mxs/mxs-pcm.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/sound/soc/mxs/mxs-pcm.c b/sound/soc/mxs/mxs-pcm.c
index 06c18ecffbb4..5b8c8d314060 100644
--- a/sound/soc/mxs/mxs-pcm.c
+++ b/sound/soc/mxs/mxs-pcm.c
@@ -85,8 +85,7 @@ static bool filter(struct dma_chan *chan, void *param)
85 return true; 85 return true;
86} 86}
87 87
88static int mxs_dma_alloc(struct snd_pcm_substream *substream, 88static int mxs_dma_alloc(struct snd_pcm_substream *substream)
89 struct snd_pcm_hw_params *params)
90{ 89{
91 struct snd_soc_pcm_runtime *rtd = substream->private_data; 90 struct snd_soc_pcm_runtime *rtd = substream->private_data;
92 struct snd_pcm_runtime *runtime = substream->runtime; 91 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -112,11 +111,7 @@ static int snd_mxs_pcm_hw_params(struct snd_pcm_substream *substream,
112 struct mxs_pcm_runtime_data *iprtd = runtime->private_data; 111 struct mxs_pcm_runtime_data *iprtd = runtime->private_data;
113 unsigned long dma_addr; 112 unsigned long dma_addr;
114 struct dma_chan *chan; 113 struct dma_chan *chan;
115 int ret;
116 114
117 ret = mxs_dma_alloc(substream, params);
118 if (ret)
119 return ret;
120 chan = iprtd->dma_chan; 115 chan = iprtd->dma_chan;
121 116
122 iprtd->periods = params_periods(params); 117 iprtd->periods = params_periods(params);
@@ -143,19 +138,6 @@ static int snd_mxs_pcm_hw_params(struct snd_pcm_substream *substream,
143 return 0; 138 return 0;
144} 139}
145 140
146static int snd_mxs_pcm_hw_free(struct snd_pcm_substream *substream)
147{
148 struct snd_pcm_runtime *runtime = substream->runtime;
149 struct mxs_pcm_runtime_data *iprtd = runtime->private_data;
150
151 if (iprtd->dma_chan) {
152 dma_release_channel(iprtd->dma_chan);
153 iprtd->dma_chan = NULL;
154 }
155
156 return 0;
157}
158
159static int snd_mxs_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 141static int snd_mxs_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
160{ 142{
161 struct snd_pcm_runtime *runtime = substream->runtime; 143 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -208,6 +190,12 @@ static int snd_mxs_open(struct snd_pcm_substream *substream)
208 return ret; 190 return ret;
209 } 191 }
210 192
193 ret = mxs_dma_alloc(substream);
194 if (ret) {
195 kfree(iprtd);
196 return ret;
197 }
198
211 snd_soc_set_runtime_hwparams(substream, &snd_mxs_hardware); 199 snd_soc_set_runtime_hwparams(substream, &snd_mxs_hardware);
212 200
213 return 0; 201 return 0;
@@ -218,6 +206,7 @@ static int snd_mxs_close(struct snd_pcm_substream *substream)
218 struct snd_pcm_runtime *runtime = substream->runtime; 206 struct snd_pcm_runtime *runtime = substream->runtime;
219 struct mxs_pcm_runtime_data *iprtd = runtime->private_data; 207 struct mxs_pcm_runtime_data *iprtd = runtime->private_data;
220 208
209 dma_release_channel(iprtd->dma_chan);
221 kfree(iprtd); 210 kfree(iprtd);
222 211
223 return 0; 212 return 0;
@@ -239,7 +228,6 @@ static struct snd_pcm_ops mxs_pcm_ops = {
239 .close = snd_mxs_close, 228 .close = snd_mxs_close,
240 .ioctl = snd_pcm_lib_ioctl, 229 .ioctl = snd_pcm_lib_ioctl,
241 .hw_params = snd_mxs_pcm_hw_params, 230 .hw_params = snd_mxs_pcm_hw_params,
242 .hw_free = snd_mxs_pcm_hw_free,
243 .trigger = snd_mxs_pcm_trigger, 231 .trigger = snd_mxs_pcm_trigger,
244 .pointer = snd_mxs_pcm_pointer, 232 .pointer = snd_mxs_pcm_pointer,
245 .mmap = snd_mxs_pcm_mmap, 233 .mmap = snd_mxs_pcm_mmap,