aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-19 10:23:15 -0400
committerMark Brown <broonie@linaro.org>2013-12-11 19:28:57 -0500
commit3688569e8173e84cd95d98f158245e17bca4f593 (patch)
tree7f163d739333a2249ef7155d17a7cc00fdea814d
parentbeaec3aab661e450511b8d84f079e47a4145dfb7 (diff)
ASoC: samsung: Provide helper for DMA init
In preparation for using the dmaengine helpers in ASoC rather than the dmaengine wrappers for the Samsung API wrap the configuration of dma_data. The dmaengine code expects different data to that used by the legacy API. Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/samsung/ac97.c51
-rw-r--r--sound/soc/samsung/dma.c8
-rw-r--r--sound/soc/samsung/dma.h3
-rw-r--r--sound/soc/samsung/i2s.c7
-rw-r--r--sound/soc/samsung/pcm.c18
5 files changed, 42 insertions, 45 deletions
diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c
index 350ba23a9893..4a88e36c82ec 100644
--- a/sound/soc/samsung/ac97.c
+++ b/sound/soc/samsung/ac97.c
@@ -221,24 +221,6 @@ static struct snd_ac97_bus_ops s3c_ac97_ops = {
221 .reset = s3c_ac97_cold_reset, 221 .reset = s3c_ac97_cold_reset,
222}; 222};
223 223
224static int s3c_ac97_hw_params(struct snd_pcm_substream *substream,
225 struct snd_pcm_hw_params *params,
226 struct snd_soc_dai *dai)
227{
228 struct snd_soc_pcm_runtime *rtd = substream->private_data;
229 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
230 struct s3c_dma_params *dma_data;
231
232 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
233 dma_data = &s3c_ac97_pcm_out;
234 else
235 dma_data = &s3c_ac97_pcm_in;
236
237 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
238
239 return 0;
240}
241
242static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, 224static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd,
243 struct snd_soc_dai *dai) 225 struct snd_soc_dai *dai)
244{ 226{
@@ -279,21 +261,6 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd,
279 return 0; 261 return 0;
280} 262}
281 263
282static int s3c_ac97_hw_mic_params(struct snd_pcm_substream *substream,
283 struct snd_pcm_hw_params *params,
284 struct snd_soc_dai *dai)
285{
286 struct snd_soc_pcm_runtime *rtd = substream->private_data;
287 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
288
289 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
290 return -ENODEV;
291 else
292 snd_soc_dai_set_dma_data(cpu_dai, substream, &s3c_ac97_mic_in);
293
294 return 0;
295}
296
297static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, 264static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream,
298 int cmd, struct snd_soc_dai *dai) 265 int cmd, struct snd_soc_dai *dai)
299{ 266{
@@ -329,15 +296,27 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream,
329} 296}
330 297
331static const struct snd_soc_dai_ops s3c_ac97_dai_ops = { 298static const struct snd_soc_dai_ops s3c_ac97_dai_ops = {
332 .hw_params = s3c_ac97_hw_params,
333 .trigger = s3c_ac97_trigger, 299 .trigger = s3c_ac97_trigger,
334}; 300};
335 301
336static const struct snd_soc_dai_ops s3c_ac97_mic_dai_ops = { 302static const struct snd_soc_dai_ops s3c_ac97_mic_dai_ops = {
337 .hw_params = s3c_ac97_hw_mic_params,
338 .trigger = s3c_ac97_mic_trigger, 303 .trigger = s3c_ac97_mic_trigger,
339}; 304};
340 305
306static int s3c_ac97_dai_probe(struct snd_soc_dai *dai)
307{
308 samsung_asoc_init_dma_data(dai, &s3c_ac97_pcm_out, &s3c_ac97_pcm_in);
309
310 return 0;
311}
312
313static int s3c_ac97_mic_dai_probe(struct snd_soc_dai *dai)
314{
315 samsung_asoc_init_dma_data(dai, NULL, &s3c_ac97_mic_in);
316
317 return 0;
318}
319
341static struct snd_soc_dai_driver s3c_ac97_dai[] = { 320static struct snd_soc_dai_driver s3c_ac97_dai[] = {
342 [S3C_AC97_DAI_PCM] = { 321 [S3C_AC97_DAI_PCM] = {
343 .name = "samsung-ac97", 322 .name = "samsung-ac97",
@@ -354,6 +333,7 @@ static struct snd_soc_dai_driver s3c_ac97_dai[] = {
354 .channels_max = 2, 333 .channels_max = 2,
355 .rates = SNDRV_PCM_RATE_8000_48000, 334 .rates = SNDRV_PCM_RATE_8000_48000,
356 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 335 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
336 .probe = s3c_ac97_dai_probe,
357 .ops = &s3c_ac97_dai_ops, 337 .ops = &s3c_ac97_dai_ops,
358 }, 338 },
359 [S3C_AC97_DAI_MIC] = { 339 [S3C_AC97_DAI_MIC] = {
@@ -365,6 +345,7 @@ static struct snd_soc_dai_driver s3c_ac97_dai[] = {
365 .channels_max = 1, 345 .channels_max = 1,
366 .rates = SNDRV_PCM_RATE_8000_48000, 346 .rates = SNDRV_PCM_RATE_8000_48000,
367 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 347 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
348 .probe = s3c_ac97_mic_dai_probe,
368 .ops = &s3c_ac97_mic_dai_ops, 349 .ops = &s3c_ac97_mic_dai_ops,
369 }, 350 },
370}; 351};
diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c
index fe2748b494d4..ee23194f7ab8 100644
--- a/sound/soc/samsung/dma.c
+++ b/sound/soc/samsung/dma.c
@@ -441,6 +441,14 @@ static struct snd_soc_platform_driver samsung_asoc_platform = {
441 .pcm_free = dma_free_dma_buffers, 441 .pcm_free = dma_free_dma_buffers,
442}; 442};
443 443
444void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,
445 struct s3c_dma_params *playback,
446 struct s3c_dma_params *capture)
447{
448 snd_soc_dai_init_dma_data(dai, playback, capture);
449}
450EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data);
451
444int samsung_asoc_dma_platform_register(struct device *dev) 452int samsung_asoc_dma_platform_register(struct device *dev)
445{ 453{
446 return snd_soc_register_platform(dev, &samsung_asoc_platform); 454 return snd_soc_register_platform(dev, &samsung_asoc_platform);
diff --git a/sound/soc/samsung/dma.h b/sound/soc/samsung/dma.h
index 0e86315a3eaf..fb09a1c5f75b 100644
--- a/sound/soc/samsung/dma.h
+++ b/sound/soc/samsung/dma.h
@@ -22,6 +22,9 @@ struct s3c_dma_params {
22 char *ch_name; 22 char *ch_name;
23}; 23};
24 24
25void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,
26 struct s3c_dma_params *playback,
27 struct s3c_dma_params *capture);
25int samsung_asoc_dma_platform_register(struct device *dev); 28int samsung_asoc_dma_platform_register(struct device *dev);
26void samsung_asoc_dma_platform_unregister(struct device *dev); 29void samsung_asoc_dma_platform_unregister(struct device *dev);
27 30
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index a5cbdb4f1655..eab0050d4579 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -946,8 +946,11 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
946 struct i2s_dai *i2s = to_info(dai); 946 struct i2s_dai *i2s = to_info(dai);
947 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 947 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai;
948 948
949 if (other && other->clk) /* If this is probe on secondary */ 949 if (other && other->clk) { /* If this is probe on secondary */
950 samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback,
951 NULL);
950 goto probe_exit; 952 goto probe_exit;
953 }
951 954
952 i2s->addr = ioremap(i2s->base, 0x100); 955 i2s->addr = ioremap(i2s->base, 0x100);
953 if (i2s->addr == NULL) { 956 if (i2s->addr == NULL) {
@@ -963,7 +966,7 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
963 } 966 }
964 clk_prepare_enable(i2s->clk); 967 clk_prepare_enable(i2s->clk);
965 968
966 snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); 969 samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
967 970
968 if (other) { 971 if (other) {
969 other->addr = i2s->addr; 972 other->addr = i2s->addr;
diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c
index e54256fc4b2c..6a5e4bf6ac96 100644
--- a/sound/soc/samsung/pcm.c
+++ b/sound/soc/samsung/pcm.c
@@ -275,7 +275,6 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
275{ 275{
276 struct snd_soc_pcm_runtime *rtd = substream->private_data; 276 struct snd_soc_pcm_runtime *rtd = substream->private_data;
277 struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(rtd->cpu_dai); 277 struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(rtd->cpu_dai);
278 struct s3c_dma_params *dma_data;
279 void __iomem *regs = pcm->regs; 278 void __iomem *regs = pcm->regs;
280 struct clk *clk; 279 struct clk *clk;
281 int sclk_div, sync_div; 280 int sclk_div, sync_div;
@@ -284,13 +283,6 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
284 283
285 dev_dbg(pcm->dev, "Entered %s\n", __func__); 284 dev_dbg(pcm->dev, "Entered %s\n", __func__);
286 285
287 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
288 dma_data = pcm->dma_playback;
289 else
290 dma_data = pcm->dma_capture;
291
292 snd_soc_dai_set_dma_data(rtd->cpu_dai, substream, dma_data);
293
294 /* Strictly check for sample size */ 286 /* Strictly check for sample size */
295 switch (params_format(params)) { 287 switch (params_format(params)) {
296 case SNDRV_PCM_FORMAT_S16_LE: 288 case SNDRV_PCM_FORMAT_S16_LE:
@@ -461,10 +453,20 @@ static const struct snd_soc_dai_ops s3c_pcm_dai_ops = {
461 .set_fmt = s3c_pcm_set_fmt, 453 .set_fmt = s3c_pcm_set_fmt,
462}; 454};
463 455
456static int s3c_pcm_dai_probe(struct snd_soc_dai *dai)
457{
458 struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(dai);
459
460 snd_soc_dai_init_dma_data(dai, pcm->dma_playback, pcm->dma_capture);
461
462 return 0;
463}
464
464#define S3C_PCM_RATES SNDRV_PCM_RATE_8000_96000 465#define S3C_PCM_RATES SNDRV_PCM_RATE_8000_96000
465 466
466#define S3C_PCM_DAI_DECLARE \ 467#define S3C_PCM_DAI_DECLARE \
467 .symmetric_rates = 1, \ 468 .symmetric_rates = 1, \
469 .probe = s3c_pcm_dai_probe, \
468 .ops = &s3c_pcm_dai_ops, \ 470 .ops = &s3c_pcm_dai_ops, \
469 .playback = { \ 471 .playback = { \
470 .channels_min = 2, \ 472 .channels_min = 2, \