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;
}
/*
#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; \
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);
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;
/* 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;
}
/* 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;
}
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;
}
/*
* 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);
/*
/*
* R-Car sound mod
*/
+enum rsnd_mod_type {
+ RSND_MOD_SCU = 0,
+ RSND_MOD_SSI,
+ RSND_MOD_MAX,
+};
struct rsnd_mod_ops {
char *name;
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;
};
#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);
*/
#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;