ASoC: rsnd: use for_each_rsnd_mod_xxx() on rsnd_dai_call()
Current rsnd driver is using too complex macro for for-loop of each mod. rsnd_dai_call() is especially defined as very complex macro. It is easier to read just a little bit by using for_each_rsnd_mod_xxx() and new rsnd_status_update() Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
b3ca3fbeb2
commit
5f222a2921
|
@ -371,33 +371,6 @@ struct rsnd_mod *rsnd_mod_next(int *iterator,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define rsnd_mod_call(idx, io, func, param...) \
|
|
||||||
({ \
|
|
||||||
struct rsnd_priv *priv = rsnd_mod_to_priv(mod); \
|
|
||||||
struct rsnd_mod *mod = (io)->mod[idx]; \
|
|
||||||
struct device *dev = rsnd_priv_to_dev(priv); \
|
|
||||||
u32 *status = mod->get_status(io, mod, idx); \
|
|
||||||
u32 mask = 0xF << __rsnd_mod_shift_##func; \
|
|
||||||
u8 val = (*status >> __rsnd_mod_shift_##func) & 0xF; \
|
|
||||||
u8 add = ((val + __rsnd_mod_add_##func) & 0xF); \
|
|
||||||
int ret = 0; \
|
|
||||||
int call = (val == __rsnd_mod_call_##func) && (mod)->ops->func; \
|
|
||||||
if (add == 0xF) \
|
|
||||||
call = 0; \
|
|
||||||
else \
|
|
||||||
*status = (*status & ~mask) + \
|
|
||||||
(add << __rsnd_mod_shift_##func); \
|
|
||||||
dev_dbg(dev, "%s[%d]\t0x%08x %s\n", \
|
|
||||||
rsnd_mod_name(mod), rsnd_mod_id(mod), \
|
|
||||||
*status, call ? #func : ""); \
|
|
||||||
if (call) \
|
|
||||||
ret = (mod)->ops->func(mod, io, param); \
|
|
||||||
if (ret) \
|
|
||||||
dev_dbg(dev, "%s[%d] : rsnd_mod_call error %d\n", \
|
|
||||||
rsnd_mod_name(mod), rsnd_mod_id(mod), ret); \
|
|
||||||
ret; \
|
|
||||||
})
|
|
||||||
|
|
||||||
static enum rsnd_mod_type rsnd_mod_sequence[][RSND_MOD_MAX] = {
|
static enum rsnd_mod_type rsnd_mod_sequence[][RSND_MOD_MAX] = {
|
||||||
{
|
{
|
||||||
/* CAPTURE */
|
/* CAPTURE */
|
||||||
|
@ -432,19 +405,49 @@ static enum rsnd_mod_type rsnd_mod_sequence[][RSND_MOD_MAX] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define rsnd_dai_call(fn, io, param...) \
|
static int rsnd_status_update(u32 *status,
|
||||||
({ \
|
int shift, int add, int timing)
|
||||||
struct rsnd_mod *mod; \
|
{
|
||||||
int type, is_play = rsnd_io_is_play(io); \
|
u32 mask = 0xF << shift;
|
||||||
int ret = 0, i; \
|
u8 val = (*status >> shift) & 0xF;
|
||||||
for (i = 0; i < RSND_MOD_MAX; i++) { \
|
u8 next_val = (val + add) & 0xF;
|
||||||
type = rsnd_mod_sequence[is_play][i]; \
|
int func_call = (val == timing);
|
||||||
mod = (io)->mod[type]; \
|
|
||||||
if (!mod) \
|
if (next_val == 0xF) /* underflow case */
|
||||||
continue; \
|
func_call = 0;
|
||||||
ret |= rsnd_mod_call(type, io, fn, param); \
|
else
|
||||||
} \
|
*status = (*status & ~mask) + (next_val << shift);
|
||||||
ret; \
|
|
||||||
|
return func_call;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define rsnd_dai_call(fn, io, param...) \
|
||||||
|
({ \
|
||||||
|
struct rsnd_priv *priv = rsnd_io_to_priv(io); \
|
||||||
|
struct device *dev = rsnd_priv_to_dev(priv); \
|
||||||
|
struct rsnd_mod *mod; \
|
||||||
|
int is_play = rsnd_io_is_play(io); \
|
||||||
|
int ret = 0, i; \
|
||||||
|
enum rsnd_mod_type *types = rsnd_mod_sequence[is_play]; \
|
||||||
|
for_each_rsnd_mod_arrays(i, mod, io, types, RSND_MOD_MAX) { \
|
||||||
|
int tmp = 0; \
|
||||||
|
u32 *status = mod->get_status(io, mod, types[i]); \
|
||||||
|
int func_call = rsnd_status_update(status, \
|
||||||
|
__rsnd_mod_shift_##fn, \
|
||||||
|
__rsnd_mod_add_##fn, \
|
||||||
|
__rsnd_mod_call_##fn); \
|
||||||
|
dev_dbg(dev, "%s[%d]\t0x%08x %s\n", \
|
||||||
|
rsnd_mod_name(mod), rsnd_mod_id(mod), *status, \
|
||||||
|
(func_call && (mod)->ops->fn) ? #fn : ""); \
|
||||||
|
if (func_call && (mod)->ops->fn) \
|
||||||
|
tmp = (mod)->ops->fn(mod, io, param); \
|
||||||
|
if (tmp) \
|
||||||
|
dev_err(dev, "%s[%d] : %s error %d\n", \
|
||||||
|
rsnd_mod_name(mod), rsnd_mod_id(mod), \
|
||||||
|
#fn, tmp); \
|
||||||
|
ret |= tmp; \
|
||||||
|
} \
|
||||||
|
ret; \
|
||||||
})
|
})
|
||||||
|
|
||||||
int rsnd_dai_connect(struct rsnd_mod *mod,
|
int rsnd_dai_connect(struct rsnd_mod *mod,
|
||||||
|
|
Loading…
Reference in New Issue