mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-20 08:22:39 +00:00
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>
This commit is contained in:
parent
9bfed6cf4f
commit
a126021d14
@ -121,12 +121,13 @@ char *rsnd_mod_name(struct rsnd_mod *mod)
|
|||||||
void rsnd_mod_init(struct rsnd_priv *priv,
|
void rsnd_mod_init(struct rsnd_priv *priv,
|
||||||
struct rsnd_mod *mod,
|
struct rsnd_mod *mod,
|
||||||
struct rsnd_mod_ops *ops,
|
struct rsnd_mod_ops *ops,
|
||||||
|
enum rsnd_mod_type type,
|
||||||
int id)
|
int id)
|
||||||
{
|
{
|
||||||
mod->priv = priv;
|
mod->priv = priv;
|
||||||
mod->id = id;
|
mod->id = id;
|
||||||
mod->ops = ops;
|
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) \
|
#define rsnd_dai_call(rdai, io, fn) \
|
||||||
({ \
|
({ \
|
||||||
struct rsnd_mod *mod, *n; \
|
struct rsnd_mod *mod; \
|
||||||
int ret = 0; \
|
int ret = 0, i; \
|
||||||
for_each_rsnd_mod(mod, n, (io)) { \
|
for (i = 0; i < RSND_MOD_MAX; i++) { \
|
||||||
|
mod = (io)->mod[i]; \
|
||||||
|
if (!mod) \
|
||||||
|
continue; \
|
||||||
ret = rsnd_mod_call(mod, fn, (rdai), (io)); \
|
ret = rsnd_mod_call(mod, fn, (rdai), (io)); \
|
||||||
if (ret < 0) \
|
if (ret < 0) \
|
||||||
break; \
|
break; \
|
||||||
@ -317,14 +321,13 @@ void rsnd_dma_quit(struct rsnd_priv *priv,
|
|||||||
ret; \
|
ret; \
|
||||||
})
|
})
|
||||||
|
|
||||||
static int rsnd_dai_connect(struct rsnd_dai *rdai,
|
static int rsnd_dai_connect(struct rsnd_mod *mod,
|
||||||
struct rsnd_mod *mod,
|
|
||||||
struct rsnd_dai_stream *io)
|
struct rsnd_dai_stream *io)
|
||||||
{
|
{
|
||||||
if (!mod)
|
if (!mod)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
if (!list_empty(&mod->list)) {
|
if (io->mod[mod->type]) {
|
||||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
||||||
struct device *dev = rsnd_priv_to_dev(priv);
|
struct device *dev = rsnd_priv_to_dev(priv);
|
||||||
|
|
||||||
@ -334,15 +337,15 @@ static int rsnd_dai_connect(struct rsnd_dai *rdai,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_add_tail(&mod->list, &io->head);
|
io->mod[mod->type] = mod;
|
||||||
mod->io = io;
|
mod->io = io;
|
||||||
|
|
||||||
return 0;
|
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;
|
mod->io = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -596,7 +599,7 @@ static int rsnd_path_init(struct rsnd_priv *priv,
|
|||||||
/* SCU */
|
/* SCU */
|
||||||
mod = rsnd_scu_mod_get(priv, id);
|
mod = rsnd_scu_mod_get(priv, id);
|
||||||
if (mod) {
|
if (mod) {
|
||||||
ret = rsnd_dai_connect(rdai, mod, io);
|
ret = rsnd_dai_connect(mod, io);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -604,7 +607,7 @@ static int rsnd_path_init(struct rsnd_priv *priv,
|
|||||||
/* SSI */
|
/* SSI */
|
||||||
mod = rsnd_ssi_mod_get(priv, id);
|
mod = rsnd_ssi_mod_get(priv, id);
|
||||||
if (mod) {
|
if (mod) {
|
||||||
ret = rsnd_dai_connect(rdai, mod, io);
|
ret = rsnd_dai_connect(mod, io);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -616,14 +619,18 @@ static int rsnd_path_exit(struct rsnd_priv *priv,
|
|||||||
struct rsnd_dai *rdai,
|
struct rsnd_dai *rdai,
|
||||||
struct rsnd_dai_stream *io)
|
struct rsnd_dai_stream *io)
|
||||||
{
|
{
|
||||||
struct rsnd_mod *mod, *n;
|
struct rsnd_mod *mod;
|
||||||
int ret = 0;
|
int ret = 0, i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* remove all mod from rdai
|
* remove all mod from rdai
|
||||||
*/
|
*/
|
||||||
for_each_rsnd_mod(mod, n, io)
|
for (i = 0; i < RSND_MOD_MAX; i++) {
|
||||||
ret |= rsnd_dai_disconnect(mod);
|
mod = io->mod[i];
|
||||||
|
if (!mod)
|
||||||
|
continue;
|
||||||
|
ret |= rsnd_dai_disconnect(mod, io);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -671,9 +678,6 @@ static int rsnd_dai_probe(struct platform_device *pdev,
|
|||||||
/*
|
/*
|
||||||
* init rsnd_dai
|
* 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);
|
snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -135,6 +135,11 @@ void rsnd_dma_quit(struct rsnd_priv *priv,
|
|||||||
/*
|
/*
|
||||||
* R-Car sound mod
|
* R-Car sound mod
|
||||||
*/
|
*/
|
||||||
|
enum rsnd_mod_type {
|
||||||
|
RSND_MOD_SCU = 0,
|
||||||
|
RSND_MOD_SSI,
|
||||||
|
RSND_MOD_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
struct rsnd_mod_ops {
|
struct rsnd_mod_ops {
|
||||||
char *name;
|
char *name;
|
||||||
@ -155,9 +160,9 @@ struct rsnd_mod_ops {
|
|||||||
struct rsnd_dai_stream;
|
struct rsnd_dai_stream;
|
||||||
struct rsnd_mod {
|
struct rsnd_mod {
|
||||||
int id;
|
int id;
|
||||||
|
enum rsnd_mod_type type;
|
||||||
struct rsnd_priv *priv;
|
struct rsnd_priv *priv;
|
||||||
struct rsnd_mod_ops *ops;
|
struct rsnd_mod_ops *ops;
|
||||||
struct list_head list; /* connect to rsnd_dai playback/capture */
|
|
||||||
struct rsnd_dma dma;
|
struct rsnd_dma dma;
|
||||||
struct rsnd_dai_stream *io;
|
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_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma)
|
||||||
#define rsnd_mod_to_io(mod) ((mod)->io)
|
#define rsnd_mod_to_io(mod) ((mod)->io)
|
||||||
#define rsnd_mod_id(mod) ((mod)->id)
|
#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,
|
void rsnd_mod_init(struct rsnd_priv *priv,
|
||||||
struct rsnd_mod *mod,
|
struct rsnd_mod *mod,
|
||||||
struct rsnd_mod_ops *ops,
|
struct rsnd_mod_ops *ops,
|
||||||
|
enum rsnd_mod_type type,
|
||||||
int id);
|
int id);
|
||||||
char *rsnd_mod_name(struct rsnd_mod *mod);
|
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
|
#define RSND_DAI_NAME_SIZE 16
|
||||||
struct rsnd_dai_stream {
|
struct rsnd_dai_stream {
|
||||||
struct list_head head; /* head of rsnd_mod list */
|
|
||||||
struct snd_pcm_substream *substream;
|
struct snd_pcm_substream *substream;
|
||||||
|
struct rsnd_mod *mod[RSND_MOD_MAX];
|
||||||
int byte_pos;
|
int byte_pos;
|
||||||
int period_pos;
|
int period_pos;
|
||||||
int byte_per_period;
|
int byte_per_period;
|
||||||
|
@ -659,7 +659,7 @@ int rsnd_scu_probe(struct platform_device *pdev,
|
|||||||
ops = &rsnd_scu_non_gen2_ops;
|
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);
|
dev_dbg(dev, "SCU%d probed\n", i);
|
||||||
}
|
}
|
||||||
|
@ -584,7 +584,7 @@ int rsnd_ssi_probe(struct platform_device *pdev,
|
|||||||
dev_dbg(dev, "SSI%d use PIO transfer\n", i);
|
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);
|
rsnd_ssi_parent_clk_setup(priv, ssi);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user