diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2014-03-03 02:42:55 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-03 23:13:49 -0500 |
commit | a126021d144bae88a563db2b57b0ad5eb1ee66d9 (patch) | |
tree | eacaea15f124d1fa8789eda17267b40b3ddcaad7 | |
parent | 9bfed6cf4fa2cd2c5e80431244348b0c5d933cf5 (diff) |
ASoC: rsnd: use mod array instead of list on rdai
struct rsnd_dai_stream used list for mod list.
It added only odd flexibility to current driver, and
it is a factor which makes extendibility difficult.
rsnd use mod array instead of list from now.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | sound/soc/sh/rcar/core.c | 42 | ||||
-rw-r--r-- | sound/soc/sh/rcar/rsnd.h | 12 | ||||
-rw-r--r-- | sound/soc/sh/rcar/scu.c | 2 | ||||
-rw-r--r-- | sound/soc/sh/rcar/ssi.c | 2 |
4 files changed, 33 insertions, 25 deletions
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 96cb78612a7d..416b0782503a 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c | |||
@@ -121,12 +121,13 @@ char *rsnd_mod_name(struct rsnd_mod *mod) | |||
121 | void rsnd_mod_init(struct rsnd_priv *priv, | 121 | void rsnd_mod_init(struct rsnd_priv *priv, |
122 | struct rsnd_mod *mod, | 122 | struct rsnd_mod *mod, |
123 | struct rsnd_mod_ops *ops, | 123 | struct rsnd_mod_ops *ops, |
124 | enum rsnd_mod_type type, | ||
124 | int id) | 125 | int id) |
125 | { | 126 | { |
126 | mod->priv = priv; | 127 | mod->priv = priv; |
127 | mod->id = id; | 128 | mod->id = id; |
128 | mod->ops = ops; | 129 | mod->ops = ops; |
129 | INIT_LIST_HEAD(&mod->list); | 130 | mod->type = type; |
130 | } | 131 | } |
131 | 132 | ||
132 | /* | 133 | /* |
@@ -307,9 +308,12 @@ void rsnd_dma_quit(struct rsnd_priv *priv, | |||
307 | 308 | ||
308 | #define rsnd_dai_call(rdai, io, fn) \ | 309 | #define rsnd_dai_call(rdai, io, fn) \ |
309 | ({ \ | 310 | ({ \ |
310 | struct rsnd_mod *mod, *n; \ | 311 | struct rsnd_mod *mod; \ |
311 | int ret = 0; \ | 312 | int ret = 0, i; \ |
312 | for_each_rsnd_mod(mod, n, (io)) { \ | 313 | for (i = 0; i < RSND_MOD_MAX; i++) { \ |
314 | mod = (io)->mod[i]; \ | ||
315 | if (!mod) \ | ||
316 | continue; \ | ||
313 | ret = rsnd_mod_call(mod, fn, (rdai), (io)); \ | 317 | ret = rsnd_mod_call(mod, fn, (rdai), (io)); \ |
314 | if (ret < 0) \ | 318 | if (ret < 0) \ |
315 | break; \ | 319 | break; \ |
@@ -317,14 +321,13 @@ void rsnd_dma_quit(struct rsnd_priv *priv, | |||
317 | ret; \ | 321 | ret; \ |
318 | }) | 322 | }) |
319 | 323 | ||
320 | static int rsnd_dai_connect(struct rsnd_dai *rdai, | 324 | static int rsnd_dai_connect(struct rsnd_mod *mod, |
321 | struct rsnd_mod *mod, | ||
322 | struct rsnd_dai_stream *io) | 325 | struct rsnd_dai_stream *io) |
323 | { | 326 | { |
324 | if (!mod) | 327 | if (!mod) |
325 | return -EIO; | 328 | return -EIO; |
326 | 329 | ||
327 | if (!list_empty(&mod->list)) { | 330 | if (io->mod[mod->type]) { |
328 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | 331 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); |
329 | struct device *dev = rsnd_priv_to_dev(priv); | 332 | struct device *dev = rsnd_priv_to_dev(priv); |
330 | 333 | ||
@@ -334,15 +337,15 @@ static int rsnd_dai_connect(struct rsnd_dai *rdai, | |||
334 | return -EIO; | 337 | return -EIO; |
335 | } | 338 | } |
336 | 339 | ||
337 | list_add_tail(&mod->list, &io->head); | 340 | io->mod[mod->type] = mod; |
338 | mod->io = io; | 341 | mod->io = io; |
339 | 342 | ||
340 | return 0; | 343 | return 0; |
341 | } | 344 | } |
342 | 345 | ||
343 | static int rsnd_dai_disconnect(struct rsnd_mod *mod) | 346 | static int rsnd_dai_disconnect(struct rsnd_mod *mod, struct rsnd_dai_stream *io) |
344 | { | 347 | { |
345 | list_del_init(&mod->list); | 348 | io->mod[mod->type] = NULL; |
346 | mod->io = NULL; | 349 | mod->io = NULL; |
347 | 350 | ||
348 | return 0; | 351 | return 0; |
@@ -596,7 +599,7 @@ static int rsnd_path_init(struct rsnd_priv *priv, | |||
596 | /* SCU */ | 599 | /* SCU */ |
597 | mod = rsnd_scu_mod_get(priv, id); | 600 | mod = rsnd_scu_mod_get(priv, id); |
598 | if (mod) { | 601 | if (mod) { |
599 | ret = rsnd_dai_connect(rdai, mod, io); | 602 | ret = rsnd_dai_connect(mod, io); |
600 | if (ret < 0) | 603 | if (ret < 0) |
601 | return ret; | 604 | return ret; |
602 | } | 605 | } |
@@ -604,7 +607,7 @@ static int rsnd_path_init(struct rsnd_priv *priv, | |||
604 | /* SSI */ | 607 | /* SSI */ |
605 | mod = rsnd_ssi_mod_get(priv, id); | 608 | mod = rsnd_ssi_mod_get(priv, id); |
606 | if (mod) { | 609 | if (mod) { |
607 | ret = rsnd_dai_connect(rdai, mod, io); | 610 | ret = rsnd_dai_connect(mod, io); |
608 | if (ret < 0) | 611 | if (ret < 0) |
609 | return ret; | 612 | return ret; |
610 | } | 613 | } |
@@ -616,14 +619,18 @@ static int rsnd_path_exit(struct rsnd_priv *priv, | |||
616 | struct rsnd_dai *rdai, | 619 | struct rsnd_dai *rdai, |
617 | struct rsnd_dai_stream *io) | 620 | struct rsnd_dai_stream *io) |
618 | { | 621 | { |
619 | struct rsnd_mod *mod, *n; | 622 | struct rsnd_mod *mod; |
620 | int ret = 0; | 623 | int ret = 0, i; |
621 | 624 | ||
622 | /* | 625 | /* |
623 | * remove all mod from rdai | 626 | * remove all mod from rdai |
624 | */ | 627 | */ |
625 | for_each_rsnd_mod(mod, n, io) | 628 | for (i = 0; i < RSND_MOD_MAX; i++) { |
626 | ret |= rsnd_dai_disconnect(mod); | 629 | mod = io->mod[i]; |
630 | if (!mod) | ||
631 | continue; | ||
632 | ret |= rsnd_dai_disconnect(mod, io); | ||
633 | } | ||
627 | 634 | ||
628 | return ret; | 635 | return ret; |
629 | } | 636 | } |
@@ -671,9 +678,6 @@ static int rsnd_dai_probe(struct platform_device *pdev, | |||
671 | /* | 678 | /* |
672 | * init rsnd_dai | 679 | * init rsnd_dai |
673 | */ | 680 | */ |
674 | INIT_LIST_HEAD(&rdai[i].playback.head); | ||
675 | INIT_LIST_HEAD(&rdai[i].capture.head); | ||
676 | |||
677 | snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i); | 681 | snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i); |
678 | 682 | ||
679 | /* | 683 | /* |
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 6a25203e0f08..7767a8f1994a 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -135,6 +135,11 @@ void rsnd_dma_quit(struct rsnd_priv *priv, | |||
135 | /* | 135 | /* |
136 | * R-Car sound mod | 136 | * R-Car sound mod |
137 | */ | 137 | */ |
138 | enum rsnd_mod_type { | ||
139 | RSND_MOD_SCU = 0, | ||
140 | RSND_MOD_SSI, | ||
141 | RSND_MOD_MAX, | ||
142 | }; | ||
138 | 143 | ||
139 | struct rsnd_mod_ops { | 144 | struct rsnd_mod_ops { |
140 | char *name; | 145 | char *name; |
@@ -155,9 +160,9 @@ struct rsnd_mod_ops { | |||
155 | struct rsnd_dai_stream; | 160 | struct rsnd_dai_stream; |
156 | struct rsnd_mod { | 161 | struct rsnd_mod { |
157 | int id; | 162 | int id; |
163 | enum rsnd_mod_type type; | ||
158 | struct rsnd_priv *priv; | 164 | struct rsnd_priv *priv; |
159 | struct rsnd_mod_ops *ops; | 165 | struct rsnd_mod_ops *ops; |
160 | struct list_head list; /* connect to rsnd_dai playback/capture */ | ||
161 | struct rsnd_dma dma; | 166 | struct rsnd_dma dma; |
162 | struct rsnd_dai_stream *io; | 167 | struct rsnd_dai_stream *io; |
163 | }; | 168 | }; |
@@ -167,12 +172,11 @@ struct rsnd_mod { | |||
167 | #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) | 172 | #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) |
168 | #define rsnd_mod_to_io(mod) ((mod)->io) | 173 | #define rsnd_mod_to_io(mod) ((mod)->io) |
169 | #define rsnd_mod_id(mod) ((mod)->id) | 174 | #define rsnd_mod_id(mod) ((mod)->id) |
170 | #define for_each_rsnd_mod(pos, n, io) \ | ||
171 | list_for_each_entry_safe(pos, n, &(io)->head, list) | ||
172 | 175 | ||
173 | void rsnd_mod_init(struct rsnd_priv *priv, | 176 | void rsnd_mod_init(struct rsnd_priv *priv, |
174 | struct rsnd_mod *mod, | 177 | struct rsnd_mod *mod, |
175 | struct rsnd_mod_ops *ops, | 178 | struct rsnd_mod_ops *ops, |
179 | enum rsnd_mod_type type, | ||
176 | int id); | 180 | int id); |
177 | char *rsnd_mod_name(struct rsnd_mod *mod); | 181 | char *rsnd_mod_name(struct rsnd_mod *mod); |
178 | 182 | ||
@@ -181,8 +185,8 @@ char *rsnd_mod_name(struct rsnd_mod *mod); | |||
181 | */ | 185 | */ |
182 | #define RSND_DAI_NAME_SIZE 16 | 186 | #define RSND_DAI_NAME_SIZE 16 |
183 | struct rsnd_dai_stream { | 187 | struct rsnd_dai_stream { |
184 | struct list_head head; /* head of rsnd_mod list */ | ||
185 | struct snd_pcm_substream *substream; | 188 | struct snd_pcm_substream *substream; |
189 | struct rsnd_mod *mod[RSND_MOD_MAX]; | ||
186 | int byte_pos; | 190 | int byte_pos; |
187 | int period_pos; | 191 | int period_pos; |
188 | int byte_per_period; | 192 | int byte_per_period; |
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c index 882e837d39d1..81264ecd82ac 100644 --- a/sound/soc/sh/rcar/scu.c +++ b/sound/soc/sh/rcar/scu.c | |||
@@ -659,7 +659,7 @@ int rsnd_scu_probe(struct platform_device *pdev, | |||
659 | ops = &rsnd_scu_non_gen2_ops; | 659 | ops = &rsnd_scu_non_gen2_ops; |
660 | } | 660 | } |
661 | 661 | ||
662 | rsnd_mod_init(priv, &scu->mod, ops, i); | 662 | rsnd_mod_init(priv, &scu->mod, ops, RSND_MOD_SCU, i); |
663 | 663 | ||
664 | dev_dbg(dev, "SCU%d probed\n", i); | 664 | dev_dbg(dev, "SCU%d probed\n", i); |
665 | } | 665 | } |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 38a62a883b83..480dde5076b7 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
@@ -584,7 +584,7 @@ int rsnd_ssi_probe(struct platform_device *pdev, | |||
584 | dev_dbg(dev, "SSI%d use PIO transfer\n", i); | 584 | dev_dbg(dev, "SSI%d use PIO transfer\n", i); |
585 | } | 585 | } |
586 | 586 | ||
587 | rsnd_mod_init(priv, &ssi->mod, ops, i); | 587 | rsnd_mod_init(priv, &ssi->mod, ops, RSND_MOD_SSI, i); |
588 | 588 | ||
589 | rsnd_ssi_parent_clk_setup(priv, ssi); | 589 | rsnd_ssi_parent_clk_setup(priv, ssi); |
590 | } | 590 | } |