aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/sh/rcar
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2014-03-03 02:42:47 -0500
committerMark Brown <broonie@linaro.org>2014-03-03 23:13:48 -0500
commit9bfed6cf4fa2cd2c5e80431244348b0c5d933cf5 (patch)
tree8c93b20c91a435b423a8549901afedd1e45f77e9 /sound/soc/sh/rcar
parent697dce94ed37e0653e5bba593f11e2b14877cd63 (diff)
ASoC: rsnd: run rsnd_path_init() when probe() timing
Current rsnd SSIU/SSI/SCU/SRU path is set when playback/capture starts up. But it is meaningless method, since the path is based on platform and can be set in probe() timing. This patch sets the path on probe() timing. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/sh/rcar')
-rw-r--r--sound/soc/sh/rcar/core.c94
-rw-r--r--sound/soc/sh/rcar/gen.c56
-rw-r--r--sound/soc/sh/rcar/rsnd.h9
3 files changed, 78 insertions, 81 deletions
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index f0745af316be..96cb78612a7d 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -317,9 +317,9 @@ void rsnd_dma_quit(struct rsnd_priv *priv,
317 ret; \ 317 ret; \
318}) 318})
319 319
320int rsnd_dai_connect(struct rsnd_dai *rdai, 320static int rsnd_dai_connect(struct rsnd_dai *rdai,
321 struct rsnd_mod *mod, 321 struct rsnd_mod *mod,
322 struct rsnd_dai_stream *io) 322 struct rsnd_dai_stream *io)
323{ 323{
324 if (!mod) 324 if (!mod)
325 return -EIO; 325 return -EIO;
@@ -340,7 +340,7 @@ int rsnd_dai_connect(struct rsnd_dai *rdai,
340 return 0; 340 return 0;
341} 341}
342 342
343int rsnd_dai_disconnect(struct rsnd_mod *mod) 343static int rsnd_dai_disconnect(struct rsnd_mod *mod)
344{ 344{
345 list_del_init(&mod->list); 345 list_del_init(&mod->list);
346 mod->io = NULL; 346 mod->io = NULL;
@@ -418,10 +418,6 @@ static int rsnd_dai_stream_init(struct rsnd_dai_stream *io,
418{ 418{
419 struct snd_pcm_runtime *runtime = substream->runtime; 419 struct snd_pcm_runtime *runtime = substream->runtime;
420 420
421 if (!list_empty(&io->head))
422 return -EIO;
423
424 INIT_LIST_HEAD(&io->head);
425 io->substream = substream; 421 io->substream = substream;
426 io->byte_pos = 0; 422 io->byte_pos = 0;
427 io->period_pos = 0; 423 io->period_pos = 0;
@@ -476,10 +472,6 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
476 if (ret < 0) 472 if (ret < 0)
477 goto dai_trigger_end; 473 goto dai_trigger_end;
478 474
479 ret = rsnd_gen_path_init(priv, rdai, io);
480 if (ret < 0)
481 goto dai_trigger_end;
482
483 ret = rsnd_dai_call(rdai, io, init); 475 ret = rsnd_dai_call(rdai, io, init);
484 if (ret < 0) 476 if (ret < 0)
485 goto dai_trigger_end; 477 goto dai_trigger_end;
@@ -497,10 +489,6 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
497 if (ret < 0) 489 if (ret < 0)
498 goto dai_trigger_end; 490 goto dai_trigger_end;
499 491
500 ret = rsnd_gen_path_exit(priv, rdai, io);
501 if (ret < 0)
502 goto dai_trigger_end;
503
504 ret = rsnd_platform_call(priv, dai, stop, ssi_id); 492 ret = rsnd_platform_call(priv, dai, stop, ssi_id);
505 if (ret < 0) 493 if (ret < 0)
506 goto dai_trigger_end; 494 goto dai_trigger_end;
@@ -576,6 +564,70 @@ static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
576 .set_fmt = rsnd_soc_dai_set_fmt, 564 .set_fmt = rsnd_soc_dai_set_fmt,
577}; 565};
578 566
567static int rsnd_path_init(struct rsnd_priv *priv,
568 struct rsnd_dai *rdai,
569 struct rsnd_dai_stream *io)
570{
571 struct rsnd_mod *mod;
572 int ret;
573 int id;
574
575 /*
576 * Gen1 is created by SRU/SSI, and this SRU is base module of
577 * Gen2's SCU/SSIU/SSI. (Gen2 SCU/SSIU came from SRU)
578 *
579 * Easy image is..
580 * Gen1 SRU = Gen2 SCU + SSIU + etc
581 *
582 * Gen2 SCU path is very flexible, but, Gen1 SRU (SCU parts) is
583 * using fixed path.
584 *
585 * Then, SSI id = SCU id here
586 */
587 /* get SSI's ID */
588 mod = rsnd_ssi_mod_get_frm_dai(priv,
589 rsnd_dai_id(priv, rdai),
590 rsnd_dai_is_play(rdai, io));
591 if (!mod)
592 return 0;
593 id = rsnd_mod_id(mod);
594 ret = 0;
595
596 /* SCU */
597 mod = rsnd_scu_mod_get(priv, id);
598 if (mod) {
599 ret = rsnd_dai_connect(rdai, mod, io);
600 if (ret < 0)
601 return ret;
602 }
603
604 /* SSI */
605 mod = rsnd_ssi_mod_get(priv, id);
606 if (mod) {
607 ret = rsnd_dai_connect(rdai, mod, io);
608 if (ret < 0)
609 return ret;
610 }
611
612 return ret;
613}
614
615static int rsnd_path_exit(struct rsnd_priv *priv,
616 struct rsnd_dai *rdai,
617 struct rsnd_dai_stream *io)
618{
619 struct rsnd_mod *mod, *n;
620 int ret = 0;
621
622 /*
623 * remove all mod from rdai
624 */
625 for_each_rsnd_mod(mod, n, io)
626 ret |= rsnd_dai_disconnect(mod);
627
628 return ret;
629}
630
579static int rsnd_dai_probe(struct platform_device *pdev, 631static int rsnd_dai_probe(struct platform_device *pdev,
580 struct rsnd_priv *priv) 632 struct rsnd_priv *priv)
581{ 633{
@@ -634,12 +686,14 @@ static int rsnd_dai_probe(struct platform_device *pdev,
634 drv[i].playback.formats = RSND_FMTS; 686 drv[i].playback.formats = RSND_FMTS;
635 drv[i].playback.channels_min = 2; 687 drv[i].playback.channels_min = 2;
636 drv[i].playback.channels_max = 2; 688 drv[i].playback.channels_max = 2;
689 rsnd_path_init(priv, &rdai[i], &rdai[i].playback);
637 } 690 }
638 if (cmod) { 691 if (cmod) {
639 drv[i].capture.rates = RSND_RATES; 692 drv[i].capture.rates = RSND_RATES;
640 drv[i].capture.formats = RSND_FMTS; 693 drv[i].capture.formats = RSND_FMTS;
641 drv[i].capture.channels_min = 2; 694 drv[i].capture.channels_min = 2;
642 drv[i].capture.channels_max = 2; 695 drv[i].capture.channels_max = 2;
696 rsnd_path_init(priv, &rdai[i], &rdai[i].capture);
643 } 697 }
644 698
645 dev_dbg(dev, "%s (%s/%s)\n", rdai[i].name, 699 dev_dbg(dev, "%s (%s/%s)\n", rdai[i].name,
@@ -653,6 +707,14 @@ static int rsnd_dai_probe(struct platform_device *pdev,
653static void rsnd_dai_remove(struct platform_device *pdev, 707static void rsnd_dai_remove(struct platform_device *pdev,
654 struct rsnd_priv *priv) 708 struct rsnd_priv *priv)
655{ 709{
710 struct rsnd_dai *rdai;
711 int i;
712
713 for (i = 0; i < rsnd_rdai_nr(priv); i++) {
714 rdai = rsnd_dai_get(priv, i);
715 rsnd_path_exit(priv, rdai, &rdai->playback);
716 rsnd_path_exit(priv, rdai, &rdai->capture);
717 }
656} 718}
657 719
658/* 720/*
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
index bcb98f4be831..4f2c1d0c6970 100644
--- a/sound/soc/sh/rcar/gen.c
+++ b/sound/soc/sh/rcar/gen.c
@@ -155,62 +155,6 @@ static int rsnd_gen_regmap_init(struct rsnd_priv *priv,
155 return 0; 155 return 0;
156} 156}
157 157
158int rsnd_gen_path_init(struct rsnd_priv *priv,
159 struct rsnd_dai *rdai,
160 struct rsnd_dai_stream *io)
161{
162 struct rsnd_mod *mod;
163 int ret;
164 int id;
165
166 /*
167 * Gen1 is created by SRU/SSI, and this SRU is base module of
168 * Gen2's SCU/SSIU/SSI. (Gen2 SCU/SSIU came from SRU)
169 *
170 * Easy image is..
171 * Gen1 SRU = Gen2 SCU + SSIU + etc
172 *
173 * Gen2 SCU path is very flexible, but, Gen1 SRU (SCU parts) is
174 * using fixed path.
175 *
176 * Then, SSI id = SCU id here
177 */
178
179 /* get SSI's ID */
180 mod = rsnd_ssi_mod_get_frm_dai(priv,
181 rsnd_dai_id(priv, rdai),
182 rsnd_dai_is_play(rdai, io));
183 id = rsnd_mod_id(mod);
184
185 /* SCU */
186 mod = rsnd_scu_mod_get(priv, id);
187 ret = rsnd_dai_connect(rdai, mod, io);
188 if (ret < 0)
189 return ret;
190
191 /* SSI */
192 mod = rsnd_ssi_mod_get(priv, id);
193 ret = rsnd_dai_connect(rdai, mod, io);
194
195 return ret;
196}
197
198int rsnd_gen_path_exit(struct rsnd_priv *priv,
199 struct rsnd_dai *rdai,
200 struct rsnd_dai_stream *io)
201{
202 struct rsnd_mod *mod, *n;
203 int ret = 0;
204
205 /*
206 * remove all mod from rdai
207 */
208 for_each_rsnd_mod(mod, n, io)
209 ret |= rsnd_dai_disconnect(mod);
210
211 return ret;
212}
213
214/* 158/*
215 * Gen2 159 * Gen2
216 */ 160 */
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 3962a50977e5..6a25203e0f08 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -210,9 +210,6 @@ struct rsnd_dai {
210 i++) 210 i++)
211 211
212struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id); 212struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id);
213int rsnd_dai_disconnect(struct rsnd_mod *mod);
214int rsnd_dai_connect(struct rsnd_dai *rdai, struct rsnd_mod *mod,
215 struct rsnd_dai_stream *io);
216int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io); 213int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io);
217int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai); 214int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai);
218#define rsnd_dai_get_platform_info(rdai) ((rdai)->info) 215#define rsnd_dai_get_platform_info(rdai) ((rdai)->info)
@@ -229,12 +226,6 @@ int rsnd_gen_probe(struct platform_device *pdev,
229 struct rsnd_priv *priv); 226 struct rsnd_priv *priv);
230void rsnd_gen_remove(struct platform_device *pdev, 227void rsnd_gen_remove(struct platform_device *pdev,
231 struct rsnd_priv *priv); 228 struct rsnd_priv *priv);
232int rsnd_gen_path_init(struct rsnd_priv *priv,
233 struct rsnd_dai *rdai,
234 struct rsnd_dai_stream *io);
235int rsnd_gen_path_exit(struct rsnd_priv *priv,
236 struct rsnd_dai *rdai,
237 struct rsnd_dai_stream *io);
238void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, 229void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
239 struct rsnd_mod *mod, 230 struct rsnd_mod *mod,
240 enum rsnd_reg reg); 231 enum rsnd_reg reg);