| From 44680793de15ac3605394c9a4814d2a32e90e0ef Mon Sep 17 00:00:00 2001 |
| From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| Date: Sun, 2 Mar 2014 23:42:55 -0800 |
| Subject: 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> |
| (cherry picked from commit a126021d144bae88a563db2b57b0ad5eb1ee66d9) |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| --- |
| sound/soc/sh/rcar/core.c | 42 +++++++++++++++++++++++------------------- |
| sound/soc/sh/rcar/rsnd.h | 12 ++++++++---- |
| sound/soc/sh/rcar/scu.c | 2 +- |
| 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) |
| void rsnd_mod_init(struct rsnd_priv *priv, |
| struct rsnd_mod *mod, |
| struct rsnd_mod_ops *ops, |
| + enum rsnd_mod_type type, |
| int id) |
| { |
| mod->priv = priv; |
| mod->id = id; |
| mod->ops = ops; |
| - INIT_LIST_HEAD(&mod->list); |
| + mod->type = type; |
| } |
| |
| /* |
| @@ -307,9 +308,12 @@ void rsnd_dma_quit(struct rsnd_priv *priv, |
| |
| #define rsnd_dai_call(rdai, io, fn) \ |
| ({ \ |
| - struct rsnd_mod *mod, *n; \ |
| - int ret = 0; \ |
| - for_each_rsnd_mod(mod, n, (io)) { \ |
| + struct rsnd_mod *mod; \ |
| + int ret = 0, i; \ |
| + for (i = 0; i < RSND_MOD_MAX; i++) { \ |
| + mod = (io)->mod[i]; \ |
| + if (!mod) \ |
| + continue; \ |
| ret = rsnd_mod_call(mod, fn, (rdai), (io)); \ |
| if (ret < 0) \ |
| break; \ |
| @@ -317,14 +321,13 @@ void rsnd_dma_quit(struct rsnd_priv *priv, |
| ret; \ |
| }) |
| |
| -static int rsnd_dai_connect(struct rsnd_dai *rdai, |
| - struct rsnd_mod *mod, |
| +static int rsnd_dai_connect(struct rsnd_mod *mod, |
| struct rsnd_dai_stream *io) |
| { |
| if (!mod) |
| return -EIO; |
| |
| - if (!list_empty(&mod->list)) { |
| + if (io->mod[mod->type]) { |
| struct rsnd_priv *priv = rsnd_mod_to_priv(mod); |
| struct device *dev = rsnd_priv_to_dev(priv); |
| |
| @@ -334,15 +337,15 @@ static int rsnd_dai_connect(struct rsnd_dai *rdai, |
| return -EIO; |
| } |
| |
| - list_add_tail(&mod->list, &io->head); |
| + io->mod[mod->type] = mod; |
| mod->io = io; |
| |
| return 0; |
| } |
| |
| -static int rsnd_dai_disconnect(struct rsnd_mod *mod) |
| +static int rsnd_dai_disconnect(struct rsnd_mod *mod, struct rsnd_dai_stream *io) |
| { |
| - list_del_init(&mod->list); |
| + io->mod[mod->type] = NULL; |
| mod->io = NULL; |
| |
| return 0; |
| @@ -596,7 +599,7 @@ static int rsnd_path_init(struct rsnd_priv *priv, |
| /* SCU */ |
| mod = rsnd_scu_mod_get(priv, id); |
| if (mod) { |
| - ret = rsnd_dai_connect(rdai, mod, io); |
| + ret = rsnd_dai_connect(mod, io); |
| if (ret < 0) |
| return ret; |
| } |
| @@ -604,7 +607,7 @@ static int rsnd_path_init(struct rsnd_priv *priv, |
| /* SSI */ |
| mod = rsnd_ssi_mod_get(priv, id); |
| if (mod) { |
| - ret = rsnd_dai_connect(rdai, mod, io); |
| + ret = rsnd_dai_connect(mod, io); |
| if (ret < 0) |
| return ret; |
| } |
| @@ -616,14 +619,18 @@ static int rsnd_path_exit(struct rsnd_priv *priv, |
| struct rsnd_dai *rdai, |
| struct rsnd_dai_stream *io) |
| { |
| - struct rsnd_mod *mod, *n; |
| - int ret = 0; |
| + struct rsnd_mod *mod; |
| + int ret = 0, i; |
| |
| /* |
| * remove all mod from rdai |
| */ |
| - for_each_rsnd_mod(mod, n, io) |
| - ret |= rsnd_dai_disconnect(mod); |
| + for (i = 0; i < RSND_MOD_MAX; i++) { |
| + mod = io->mod[i]; |
| + if (!mod) |
| + continue; |
| + ret |= rsnd_dai_disconnect(mod, io); |
| + } |
| |
| return ret; |
| } |
| @@ -671,9 +678,6 @@ static int rsnd_dai_probe(struct platform_device *pdev, |
| /* |
| * init rsnd_dai |
| */ |
| - INIT_LIST_HEAD(&rdai[i].playback.head); |
| - INIT_LIST_HEAD(&rdai[i].capture.head); |
| - |
| snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i); |
| |
| /* |
| 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, |
| /* |
| * R-Car sound mod |
| */ |
| +enum rsnd_mod_type { |
| + RSND_MOD_SCU = 0, |
| + RSND_MOD_SSI, |
| + RSND_MOD_MAX, |
| +}; |
| |
| struct rsnd_mod_ops { |
| char *name; |
| @@ -155,9 +160,9 @@ struct rsnd_mod_ops { |
| struct rsnd_dai_stream; |
| struct rsnd_mod { |
| int id; |
| + enum rsnd_mod_type type; |
| struct rsnd_priv *priv; |
| struct rsnd_mod_ops *ops; |
| - struct list_head list; /* connect to rsnd_dai playback/capture */ |
| struct rsnd_dma dma; |
| struct rsnd_dai_stream *io; |
| }; |
| @@ -167,12 +172,11 @@ struct rsnd_mod { |
| #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) |
| #define rsnd_mod_to_io(mod) ((mod)->io) |
| #define rsnd_mod_id(mod) ((mod)->id) |
| -#define for_each_rsnd_mod(pos, n, io) \ |
| - list_for_each_entry_safe(pos, n, &(io)->head, list) |
| |
| void rsnd_mod_init(struct rsnd_priv *priv, |
| struct rsnd_mod *mod, |
| struct rsnd_mod_ops *ops, |
| + enum rsnd_mod_type type, |
| int id); |
| char *rsnd_mod_name(struct rsnd_mod *mod); |
| |
| @@ -181,8 +185,8 @@ char *rsnd_mod_name(struct rsnd_mod *mod); |
| */ |
| #define RSND_DAI_NAME_SIZE 16 |
| struct rsnd_dai_stream { |
| - struct list_head head; /* head of rsnd_mod list */ |
| struct snd_pcm_substream *substream; |
| + struct rsnd_mod *mod[RSND_MOD_MAX]; |
| int byte_pos; |
| int period_pos; |
| 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, |
| ops = &rsnd_scu_non_gen2_ops; |
| } |
| |
| - rsnd_mod_init(priv, &scu->mod, ops, i); |
| + rsnd_mod_init(priv, &scu->mod, ops, RSND_MOD_SCU, i); |
| |
| dev_dbg(dev, "SCU%d probed\n", i); |
| } |
| 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, |
| dev_dbg(dev, "SSI%d use PIO transfer\n", i); |
| } |
| |
| - rsnd_mod_init(priv, &ssi->mod, ops, i); |
| + rsnd_mod_init(priv, &ssi->mod, ops, RSND_MOD_SSI, i); |
| |
| rsnd_ssi_parent_clk_setup(priv, ssi); |
| } |
| -- |
| 2.1.2 |
| |