Commit 30f41680 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

ASoC: SOF: topology: Make mixer widget parsing IPC agnostic

Define the list of tokens pertaining to the mixer widgets, parse and
save them as part of the swidget tuples array. Once topology parsing is
complete, these tokens will be applied to create the IPC structure for the
mixer component based on the topology widget_setup op in ipc3_tplg_ops.
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220314200520.1233427-10-ranjani.sridharan@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8a2e4a73
...@@ -190,6 +190,40 @@ static void sof_ipc3_widget_free_comp(struct snd_sof_widget *swidget) ...@@ -190,6 +190,40 @@ static void sof_ipc3_widget_free_comp(struct snd_sof_widget *swidget)
kfree(swidget->private); kfree(swidget->private);
} }
static int sof_ipc3_widget_setup_comp_mixer(struct snd_sof_widget *swidget)
{
struct snd_soc_component *scomp = swidget->scomp;
struct sof_ipc_comp_mixer *mixer;
size_t ipc_size = sizeof(*mixer);
int ret;
mixer = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
if (!mixer)
return -ENOMEM;
swidget->private = mixer;
/* configure mixer IPC message */
mixer->comp.type = SOF_COMP_MIXER;
mixer->config.hdr.size = sizeof(mixer->config);
/* parse one set of comp tokens */
ret = sof_update_ipc_object(scomp, &mixer->config, SOF_COMP_TOKENS,
swidget->tuples, swidget->num_tuples,
sizeof(mixer->config), 1);
if (ret < 0) {
kfree(swidget->private);
swidget->private = NULL;
return ret;
}
dev_dbg(scomp->dev, "loaded mixer %s\n", swidget->widget->name);
sof_dbg_comp_config(scomp, &mixer->config);
return 0;
}
static int sof_ipc3_widget_setup_comp_pipeline(struct snd_sof_widget *swidget) static int sof_ipc3_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
{ {
struct snd_soc_component *scomp = swidget->scomp; struct snd_soc_component *scomp = swidget->scomp;
...@@ -358,6 +392,12 @@ static enum sof_tokens host_token_list[] = { ...@@ -358,6 +392,12 @@ static enum sof_tokens host_token_list[] = {
SOF_COMP_TOKENS, SOF_COMP_TOKENS,
}; };
static enum sof_tokens comp_generic_token_list[] = {
SOF_CORE_TOKENS,
SOF_COMP_EXT_TOKENS,
SOF_COMP_TOKENS,
};
static enum sof_tokens buffer_token_list[] = { static enum sof_tokens buffer_token_list[] = {
SOF_BUFFER_TOKENS, SOF_BUFFER_TOKENS,
}; };
...@@ -383,6 +423,9 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc3_widget_ops[SND_SOC_DAPM_TY ...@@ -383,6 +423,9 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc3_widget_ops[SND_SOC_DAPM_TY
host_token_list, ARRAY_SIZE(host_token_list), NULL}, host_token_list, ARRAY_SIZE(host_token_list), NULL},
[snd_soc_dapm_buffer] = {sof_ipc3_widget_setup_comp_buffer, sof_ipc3_widget_free_comp, [snd_soc_dapm_buffer] = {sof_ipc3_widget_setup_comp_buffer, sof_ipc3_widget_free_comp,
buffer_token_list, ARRAY_SIZE(buffer_token_list), NULL}, buffer_token_list, ARRAY_SIZE(buffer_token_list), NULL},
[snd_soc_dapm_mixer] = {sof_ipc3_widget_setup_comp_mixer, sof_ipc3_widget_free_comp,
comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list),
NULL},
[snd_soc_dapm_scheduler] = {sof_ipc3_widget_setup_comp_pipeline, sof_ipc3_widget_free_comp, [snd_soc_dapm_scheduler] = {sof_ipc3_widget_setup_comp_pipeline, sof_ipc3_widget_free_comp,
pipeline_token_list, ARRAY_SIZE(pipeline_token_list), NULL}, pipeline_token_list, ARRAY_SIZE(pipeline_token_list), NULL},
[snd_soc_dapm_pga] = {sof_ipc3_widget_setup_comp_pga, sof_ipc3_widget_free_comp, [snd_soc_dapm_pga] = {sof_ipc3_widget_setup_comp_pga, sof_ipc3_widget_free_comp,
......
...@@ -1792,45 +1792,6 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_s ...@@ -1792,45 +1792,6 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_s
return ret; return ret;
} }
/*
* Mixer topology
*/
static int sof_widget_load_mixer(struct snd_soc_component *scomp, int index,
struct snd_sof_widget *swidget,
struct snd_soc_tplg_dapm_widget *tw)
{
struct snd_soc_tplg_private *private = &tw->priv;
struct sof_ipc_comp_mixer *mixer;
size_t ipc_size = sizeof(*mixer);
int ret;
mixer = (struct sof_ipc_comp_mixer *)
sof_comp_alloc(swidget, &ipc_size, index);
if (!mixer)
return -ENOMEM;
/* configure mixer IPC message */
mixer->comp.type = SOF_COMP_MIXER;
mixer->config.hdr.size = sizeof(mixer->config);
ret = sof_parse_tokens(scomp, &mixer->config, comp_tokens,
ARRAY_SIZE(comp_tokens), private->array,
le32_to_cpu(private->size));
if (ret != 0) {
dev_err(scomp->dev, "error: parse mixer.cfg tokens failed %d\n",
private->size);
kfree(mixer);
return ret;
}
sof_dbg_comp_config(scomp, &mixer->config);
swidget->private = mixer;
return 0;
}
/* /*
* Mux topology * Mux topology
*/ */
...@@ -2341,9 +2302,6 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, ...@@ -2341,9 +2302,6 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
list_add(&dai->list, &sdev->dai_list); list_add(&dai->list, &sdev->dai_list);
swidget->private = dai; swidget->private = dai;
break; break;
case snd_soc_dapm_mixer:
ret = sof_widget_load_mixer(scomp, index, swidget, tw);
break;
case snd_soc_dapm_pga: case snd_soc_dapm_pga:
if (!le32_to_cpu(tw->num_kcontrols)) { if (!le32_to_cpu(tw->num_kcontrols)) {
dev_err(scomp->dev, "invalid kcontrol count %d for volume\n", dev_err(scomp->dev, "invalid kcontrol count %d for volume\n",
...@@ -2353,6 +2311,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, ...@@ -2353,6 +2311,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
} }
fallthrough; fallthrough;
case snd_soc_dapm_mixer:
case snd_soc_dapm_buffer: case snd_soc_dapm_buffer:
case snd_soc_dapm_scheduler: case snd_soc_dapm_scheduler:
case snd_soc_dapm_aif_out: case snd_soc_dapm_aif_out:
......
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