Commit f0b04d8b authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: rsnd: control kctrl items acceptance anytime/runtime

Current SRC/DVC/CTU adds kctrl for each device,
and SRC can adjust its sampling rate during playback,
thus, this feature should be enabled only *during* playback.
This patch controls it more clearly
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8cce431a
...@@ -1065,6 +1065,9 @@ static int rsnd_kctrl_put(struct snd_kcontrol *kctrl, ...@@ -1065,6 +1065,9 @@ static int rsnd_kctrl_put(struct snd_kcontrol *kctrl,
struct rsnd_kctrl_cfg *cfg = kcontrol_to_cfg(kctrl); struct rsnd_kctrl_cfg *cfg = kcontrol_to_cfg(kctrl);
int i, change = 0; int i, change = 0;
if (!cfg->accept(cfg->io))
return 0;
for (i = 0; i < cfg->size; i++) { for (i = 0; i < cfg->size; i++) {
if (cfg->texts) { if (cfg->texts) {
change |= (uc->value.enumerated.item[i] != cfg->val[i]); change |= (uc->value.enumerated.item[i] != cfg->val[i]);
...@@ -1081,6 +1084,18 @@ static int rsnd_kctrl_put(struct snd_kcontrol *kctrl, ...@@ -1081,6 +1084,18 @@ static int rsnd_kctrl_put(struct snd_kcontrol *kctrl,
return change; return change;
} }
int rsnd_kctrl_accept_anytime(struct rsnd_dai_stream *io)
{
return 1;
}
int rsnd_kctrl_accept_runtime(struct rsnd_dai_stream *io)
{
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
return !!runtime;
}
struct rsnd_kctrl_cfg *rsnd_kctrl_init_m(struct rsnd_kctrl_cfg_m *cfg) struct rsnd_kctrl_cfg *rsnd_kctrl_init_m(struct rsnd_kctrl_cfg_m *cfg)
{ {
cfg->cfg.val = cfg->val; cfg->cfg.val = cfg->val;
...@@ -1099,6 +1114,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, ...@@ -1099,6 +1114,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod,
struct rsnd_dai_stream *io, struct rsnd_dai_stream *io,
struct snd_soc_pcm_runtime *rtd, struct snd_soc_pcm_runtime *rtd,
const unsigned char *name, const unsigned char *name,
int (*accept)(struct rsnd_dai_stream *io),
void (*update)(struct rsnd_dai_stream *io, void (*update)(struct rsnd_dai_stream *io,
struct rsnd_mod *mod), struct rsnd_mod *mod),
struct rsnd_kctrl_cfg *cfg, struct rsnd_kctrl_cfg *cfg,
...@@ -1133,6 +1149,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, ...@@ -1133,6 +1149,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod,
cfg->texts = texts; cfg->texts = texts;
cfg->max = max; cfg->max = max;
cfg->size = size; cfg->size = size;
cfg->accept = accept;
cfg->update = update; cfg->update = update;
cfg->card = card; cfg->card = card;
cfg->kctrl = kctrl; cfg->kctrl = kctrl;
......
...@@ -279,12 +279,14 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod, ...@@ -279,12 +279,14 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod,
/* CTU Pass */ /* CTU Pass */
ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU Pass", ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU Pass",
rsnd_kctrl_accept_anytime,
NULL, NULL,
&ctu->pass, RSND_MAX_CHANNELS, &ctu->pass, RSND_MAX_CHANNELS,
0xC); 0xC);
/* ROW0 */ /* ROW0 */
ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV0", ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV0",
rsnd_kctrl_accept_anytime,
NULL, NULL,
&ctu->sv0, RSND_MAX_CHANNELS, &ctu->sv0, RSND_MAX_CHANNELS,
0x00FFFFFF); 0x00FFFFFF);
...@@ -293,6 +295,7 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod, ...@@ -293,6 +295,7 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod,
/* ROW1 */ /* ROW1 */
ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV1", ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV1",
rsnd_kctrl_accept_anytime,
NULL, NULL,
&ctu->sv1, RSND_MAX_CHANNELS, &ctu->sv1, RSND_MAX_CHANNELS,
0x00FFFFFF); 0x00FFFFFF);
...@@ -301,6 +304,7 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod, ...@@ -301,6 +304,7 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod,
/* ROW2 */ /* ROW2 */
ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV2", ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV2",
rsnd_kctrl_accept_anytime,
NULL, NULL,
&ctu->sv2, RSND_MAX_CHANNELS, &ctu->sv2, RSND_MAX_CHANNELS,
0x00FFFFFF); 0x00FFFFFF);
...@@ -309,6 +313,7 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod, ...@@ -309,6 +313,7 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod,
/* ROW3 */ /* ROW3 */
ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV3", ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV3",
rsnd_kctrl_accept_anytime,
NULL, NULL,
&ctu->sv3, RSND_MAX_CHANNELS, &ctu->sv3, RSND_MAX_CHANNELS,
0x00FFFFFF); 0x00FFFFFF);
...@@ -317,6 +322,7 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod, ...@@ -317,6 +322,7 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod,
/* Reset */ /* Reset */
ret = rsnd_kctrl_new_s(mod, io, rtd, "CTU Reset", ret = rsnd_kctrl_new_s(mod, io, rtd, "CTU Reset",
rsnd_kctrl_accept_anytime,
rsnd_ctu_value_reset, rsnd_ctu_value_reset,
&ctu->reset, 1); &ctu->reset, 1);
......
...@@ -257,6 +257,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, ...@@ -257,6 +257,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
ret = rsnd_kctrl_new_m(mod, io, rtd, ret = rsnd_kctrl_new_m(mod, io, rtd,
is_play ? is_play ?
"DVC Out Playback Volume" : "DVC In Capture Volume", "DVC Out Playback Volume" : "DVC In Capture Volume",
rsnd_kctrl_accept_anytime,
rsnd_dvc_volume_update, rsnd_dvc_volume_update,
&dvc->volume, slots, &dvc->volume, slots,
0x00800000 - 1); 0x00800000 - 1);
...@@ -267,6 +268,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, ...@@ -267,6 +268,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
ret = rsnd_kctrl_new_m(mod, io, rtd, ret = rsnd_kctrl_new_m(mod, io, rtd,
is_play ? is_play ?
"DVC Out Mute Switch" : "DVC In Mute Switch", "DVC Out Mute Switch" : "DVC In Mute Switch",
rsnd_kctrl_accept_anytime,
rsnd_dvc_volume_update, rsnd_dvc_volume_update,
&dvc->mute, slots, &dvc->mute, slots,
1); 1);
...@@ -277,6 +279,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, ...@@ -277,6 +279,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
ret = rsnd_kctrl_new_s(mod, io, rtd, ret = rsnd_kctrl_new_s(mod, io, rtd,
is_play ? is_play ?
"DVC Out Ramp Switch" : "DVC In Ramp Switch", "DVC Out Ramp Switch" : "DVC In Ramp Switch",
rsnd_kctrl_accept_anytime,
rsnd_dvc_volume_update, rsnd_dvc_volume_update,
&dvc->ren, 1); &dvc->ren, 1);
if (ret < 0) if (ret < 0)
...@@ -285,6 +288,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, ...@@ -285,6 +288,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
ret = rsnd_kctrl_new_e(mod, io, rtd, ret = rsnd_kctrl_new_e(mod, io, rtd,
is_play ? is_play ?
"DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate", "DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate",
rsnd_kctrl_accept_anytime,
rsnd_dvc_volume_update, rsnd_dvc_volume_update,
&dvc->rup, &dvc->rup,
dvc_ramp_rate); dvc_ramp_rate);
...@@ -294,6 +298,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, ...@@ -294,6 +298,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
ret = rsnd_kctrl_new_e(mod, io, rtd, ret = rsnd_kctrl_new_e(mod, io, rtd,
is_play ? is_play ?
"DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate", "DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate",
rsnd_kctrl_accept_anytime,
rsnd_dvc_volume_update, rsnd_dvc_volume_update,
&dvc->rdown, &dvc->rdown,
dvc_ramp_rate); dvc_ramp_rate);
......
...@@ -598,6 +598,7 @@ struct rsnd_kctrl_cfg { ...@@ -598,6 +598,7 @@ struct rsnd_kctrl_cfg {
unsigned int size; unsigned int size;
u32 *val; u32 *val;
const char * const *texts; const char * const *texts;
int (*accept)(struct rsnd_dai_stream *io);
void (*update)(struct rsnd_dai_stream *io, struct rsnd_mod *mod); void (*update)(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
struct rsnd_dai_stream *io; struct rsnd_dai_stream *io;
struct snd_card *card; struct snd_card *card;
...@@ -615,12 +616,15 @@ struct rsnd_kctrl_cfg_s { ...@@ -615,12 +616,15 @@ struct rsnd_kctrl_cfg_s {
u32 val; u32 val;
}; };
int rsnd_kctrl_accept_anytime(struct rsnd_dai_stream *io);
int rsnd_kctrl_accept_runtime(struct rsnd_dai_stream *io);
struct rsnd_kctrl_cfg *rsnd_kctrl_init_m(struct rsnd_kctrl_cfg_m *cfg); struct rsnd_kctrl_cfg *rsnd_kctrl_init_m(struct rsnd_kctrl_cfg_m *cfg);
struct rsnd_kctrl_cfg *rsnd_kctrl_init_s(struct rsnd_kctrl_cfg_s *cfg); struct rsnd_kctrl_cfg *rsnd_kctrl_init_s(struct rsnd_kctrl_cfg_s *cfg);
int rsnd_kctrl_new(struct rsnd_mod *mod, int rsnd_kctrl_new(struct rsnd_mod *mod,
struct rsnd_dai_stream *io, struct rsnd_dai_stream *io,
struct snd_soc_pcm_runtime *rtd, struct snd_soc_pcm_runtime *rtd,
const unsigned char *name, const unsigned char *name,
int (*accept)(struct rsnd_dai_stream *io),
void (*update)(struct rsnd_dai_stream *io, void (*update)(struct rsnd_dai_stream *io,
struct rsnd_mod *mod), struct rsnd_mod *mod),
struct rsnd_kctrl_cfg *cfg, struct rsnd_kctrl_cfg *cfg,
...@@ -628,16 +632,16 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, ...@@ -628,16 +632,16 @@ int rsnd_kctrl_new(struct rsnd_mod *mod,
int size, int size,
u32 max); u32 max);
#define rsnd_kctrl_new_m(mod, io, rtd, name, update, cfg, size, max) \ #define rsnd_kctrl_new_m(mod, io, rtd, name, accept, update, cfg, size, max) \
rsnd_kctrl_new(mod, io, rtd, name, update, rsnd_kctrl_init_m(cfg), \ rsnd_kctrl_new(mod, io, rtd, name, accept, update, rsnd_kctrl_init_m(cfg), \
NULL, size, max) NULL, size, max)
#define rsnd_kctrl_new_s(mod, io, rtd, name, update, cfg, max) \ #define rsnd_kctrl_new_s(mod, io, rtd, name, accept, update, cfg, max) \
rsnd_kctrl_new(mod, io, rtd, name, update, rsnd_kctrl_init_s(cfg), \ rsnd_kctrl_new(mod, io, rtd, name, accept, update, rsnd_kctrl_init_s(cfg), \
NULL, 1, max) NULL, 1, max)
#define rsnd_kctrl_new_e(mod, io, rtd, name, update, cfg, texts) \ #define rsnd_kctrl_new_e(mod, io, rtd, name, accept, update, cfg, texts) \
rsnd_kctrl_new(mod, io, rtd, name, update, rsnd_kctrl_init_s(cfg), \ rsnd_kctrl_new(mod, io, rtd, name, accept, update, rsnd_kctrl_init_s(cfg), \
texts, 1, ARRAY_SIZE(texts)) texts, 1, ARRAY_SIZE(texts))
/* /*
......
...@@ -497,6 +497,7 @@ static int rsnd_src_pcm_new(struct rsnd_mod *mod, ...@@ -497,6 +497,7 @@ static int rsnd_src_pcm_new(struct rsnd_mod *mod,
rsnd_io_is_play(io) ? rsnd_io_is_play(io) ?
"SRC Out Rate Switch" : "SRC Out Rate Switch" :
"SRC In Rate Switch", "SRC In Rate Switch",
rsnd_kctrl_accept_anytime,
rsnd_src_set_convert_rate, rsnd_src_set_convert_rate,
&src->sen, 1); &src->sen, 1);
if (ret < 0) if (ret < 0)
...@@ -506,6 +507,7 @@ static int rsnd_src_pcm_new(struct rsnd_mod *mod, ...@@ -506,6 +507,7 @@ static int rsnd_src_pcm_new(struct rsnd_mod *mod,
rsnd_io_is_play(io) ? rsnd_io_is_play(io) ?
"SRC Out Rate" : "SRC Out Rate" :
"SRC In Rate", "SRC In Rate",
rsnd_kctrl_accept_runtime,
rsnd_src_set_convert_rate, rsnd_src_set_convert_rate,
&src->sync, 192000); &src->sync, 192000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment