Skip to content

Commit 111d66f

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: topology: Make siggen widget parsing IPC agnostic
Define the list of tokens pertaining to the siggen 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 tone component based on the topology widget_setup op in ipc3_tplg_ops. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20220314200520.1233427-14-ranjani.sridharan@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent cb7ed49 commit 111d66f

File tree

2 files changed

+37
-59
lines changed

2 files changed

+37
-59
lines changed

sound/soc/sof/ipc3-topology.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,39 @@ static void sof_ipc3_widget_free_comp(struct snd_sof_widget *swidget)
212212
kfree(swidget->private);
213213
}
214214

215+
static int sof_ipc3_widget_setup_comp_tone(struct snd_sof_widget *swidget)
216+
{
217+
struct snd_soc_component *scomp = swidget->scomp;
218+
struct sof_ipc_comp_tone *tone;
219+
size_t ipc_size = sizeof(*tone);
220+
int ret;
221+
222+
tone = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
223+
if (!tone)
224+
return -ENOMEM;
225+
226+
swidget->private = tone;
227+
228+
/* configure siggen IPC message */
229+
tone->comp.type = SOF_COMP_TONE;
230+
tone->config.hdr.size = sizeof(tone->config);
231+
232+
/* parse one set of comp tokens */
233+
ret = sof_update_ipc_object(scomp, &tone->config, SOF_COMP_TOKENS, swidget->tuples,
234+
swidget->num_tuples, sizeof(tone->config), 1);
235+
if (ret < 0) {
236+
kfree(swidget->private);
237+
swidget->private = NULL;
238+
return ret;
239+
}
240+
241+
dev_dbg(scomp->dev, "tone %s: frequency %d amplitude %d\n",
242+
swidget->widget->name, tone->frequency, tone->amplitude);
243+
sof_dbg_comp_config(scomp, &tone->config);
244+
245+
return 0;
246+
}
247+
215248
static int sof_ipc3_widget_setup_comp_mixer(struct snd_sof_widget *swidget)
216249
{
217250
struct snd_soc_component *scomp = swidget->scomp;
@@ -585,6 +618,9 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc3_widget_ops[SND_SOC_DAPM_TY
585618
src_token_list, ARRAY_SIZE(src_token_list), NULL},
586619
[snd_soc_dapm_asrc] = {sof_ipc3_widget_setup_comp_asrc, sof_ipc3_widget_free_comp,
587620
asrc_token_list, ARRAY_SIZE(asrc_token_list), NULL},
621+
[snd_soc_dapm_siggen] = {sof_ipc3_widget_setup_comp_tone, sof_ipc3_widget_free_comp,
622+
comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list),
623+
NULL},
588624
[snd_soc_dapm_scheduler] = {sof_ipc3_widget_setup_comp_pipeline, sof_ipc3_widget_free_comp,
589625
pipeline_token_list, ARRAY_SIZE(pipeline_token_list), NULL},
590626
[snd_soc_dapm_pga] = {sof_ipc3_widget_setup_comp_pga, sof_ipc3_widget_free_comp,

sound/soc/sof/topology.c

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,6 @@ static const struct sof_topology_token dai_link_tokens[] = {
629629
offsetof(struct sof_ipc_dai_config, dai_index)},
630630
};
631631

632-
/* Tone */
633-
static const struct sof_topology_token tone_tokens[] = {
634-
};
635-
636632
/* EFFECT */
637633
static const struct sof_topology_token process_tokens[] = {
638634
{SOF_TKN_PROCESS_TYPE, SND_SOC_TPLG_TUPLE_TYPE_STRING,
@@ -1770,58 +1766,6 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_s
17701766
return ret;
17711767
}
17721768

1773-
/*
1774-
* Signal Generator Topology
1775-
*/
1776-
1777-
static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index,
1778-
struct snd_sof_widget *swidget,
1779-
struct snd_soc_tplg_dapm_widget *tw)
1780-
{
1781-
struct snd_soc_tplg_private *private = &tw->priv;
1782-
struct sof_ipc_comp_tone *tone;
1783-
size_t ipc_size = sizeof(*tone);
1784-
int ret;
1785-
1786-
tone = (struct sof_ipc_comp_tone *)
1787-
sof_comp_alloc(swidget, &ipc_size, index);
1788-
if (!tone)
1789-
return -ENOMEM;
1790-
1791-
/* configure siggen IPC message */
1792-
tone->comp.type = SOF_COMP_TONE;
1793-
tone->config.hdr.size = sizeof(tone->config);
1794-
1795-
ret = sof_parse_tokens(scomp, tone, tone_tokens,
1796-
ARRAY_SIZE(tone_tokens), private->array,
1797-
le32_to_cpu(private->size));
1798-
if (ret != 0) {
1799-
dev_err(scomp->dev, "error: parse tone tokens failed %d\n",
1800-
le32_to_cpu(private->size));
1801-
goto err;
1802-
}
1803-
1804-
ret = sof_parse_tokens(scomp, &tone->config, comp_tokens,
1805-
ARRAY_SIZE(comp_tokens), private->array,
1806-
le32_to_cpu(private->size));
1807-
if (ret != 0) {
1808-
dev_err(scomp->dev, "error: parse tone.cfg tokens failed %d\n",
1809-
le32_to_cpu(private->size));
1810-
goto err;
1811-
}
1812-
1813-
dev_dbg(scomp->dev, "tone %s: frequency %d amplitude %d\n",
1814-
swidget->widget->name, tone->frequency, tone->amplitude);
1815-
sof_dbg_comp_config(scomp, &tone->config);
1816-
1817-
swidget->private = tone;
1818-
1819-
return 0;
1820-
err:
1821-
kfree(tone);
1822-
return ret;
1823-
}
1824-
18251769
static int sof_get_control_data(struct snd_soc_component *scomp,
18261770
struct snd_soc_dapm_widget *widget,
18271771
struct sof_widget_data *wdata,
@@ -2152,13 +2096,11 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
21522096
case snd_soc_dapm_aif_in:
21532097
case snd_soc_dapm_src:
21542098
case snd_soc_dapm_asrc:
2099+
case snd_soc_dapm_siggen:
21552100
case snd_soc_dapm_mux:
21562101
case snd_soc_dapm_demux:
21572102
ret = sof_widget_parse_tokens(scomp, swidget, tw, token_list, token_list_size);
21582103
break;
2159-
case snd_soc_dapm_siggen:
2160-
ret = sof_widget_load_siggen(scomp, index, swidget, tw);
2161-
break;
21622104
case snd_soc_dapm_effect:
21632105
ret = sof_widget_load_process(scomp, index, swidget, tw);
21642106
break;

0 commit comments

Comments
 (0)