Skip to content

Commit fed3d97

Browse files
committed
ASoC: SOF: ipc4-topology: Add support for siggen widget
Add support for the siggen type widgets in order to support hostless pipelines with the tone generator module in the firmware. Signed-off-by: Ranjani Sridharan <[email protected]>
1 parent 1934f8e commit fed3d97

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,52 @@ static int sof_ipc4_widget_setup_comp_mixer(struct snd_sof_widget *swidget)
10631063
return ret;
10641064
}
10651065

1066+
static int sof_ipc4_widget_setup_comp_siggen(struct snd_sof_widget *swidget)
1067+
{
1068+
struct snd_soc_component *scomp = swidget->scomp;
1069+
struct snd_sof_pipeline *spipe = swidget->spipe;
1070+
struct sof_ipc4_siggen *siggen;
1071+
int ret;
1072+
1073+
dev_dbg(scomp->dev, "Updating IPC structure for %s\n", swidget->widget->name);
1074+
1075+
siggen = kzalloc(sizeof(*siggen), GFP_KERNEL);
1076+
if (!siggen)
1077+
return -ENOMEM;
1078+
1079+
swidget->private = siggen;
1080+
1081+
ret = sof_ipc4_get_audio_fmt(scomp, swidget, &siggen->available_fmt,
1082+
&siggen->data.base_config);
1083+
if (ret)
1084+
goto err;
1085+
1086+
spipe->core_mask |= BIT(swidget->core);
1087+
1088+
ret = sof_ipc4_widget_setup_msg(swidget, &siggen->msg);
1089+
if (ret)
1090+
goto err;
1091+
1092+
return 0;
1093+
err:
1094+
sof_ipc4_free_audio_fmt(&siggen->available_fmt);
1095+
kfree(siggen);
1096+
swidget->private = NULL;
1097+
return ret;
1098+
}
1099+
1100+
static void sof_ipc4_widget_free_comp_siggen(struct snd_sof_widget *swidget)
1101+
{
1102+
struct sof_ipc4_siggen *siggen = swidget->private;
1103+
1104+
if (!siggen)
1105+
return;
1106+
1107+
sof_ipc4_free_audio_fmt(&siggen->available_fmt);
1108+
kfree(swidget->private);
1109+
swidget->private = NULL;
1110+
}
1111+
10661112
static int sof_ipc4_widget_setup_comp_src(struct snd_sof_widget *swidget)
10671113
{
10681114
struct snd_soc_component *scomp = swidget->scomp;
@@ -2479,6 +2525,34 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
24792525
return 0;
24802526
}
24812527

2528+
static int sof_ipc4_prepare_siggen_module(struct snd_sof_widget *swidget,
2529+
struct snd_pcm_hw_params *fe_params,
2530+
struct snd_sof_platform_stream_params *platform_params,
2531+
struct snd_pcm_hw_params *pipeline_params, int dir)
2532+
{
2533+
struct snd_soc_component *scomp = swidget->scomp;
2534+
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
2535+
struct sof_ipc4_siggen *siggen = swidget->private;
2536+
struct sof_ipc4_available_audio_format *available_fmt = &siggen->available_fmt;
2537+
struct sof_ipc4_audio_format *out_fmt;
2538+
2539+
/* use the first available output format to set the base config audio format */
2540+
if (available_fmt->num_output_formats != 1) {
2541+
dev_err(sdev->dev, "siggen should only have one available output format");
2542+
return -EINVAL;
2543+
}
2544+
out_fmt = &available_fmt->output_pin_fmts[0].audio_fmt;
2545+
2546+
/* copy output format */
2547+
memcpy(&siggen->data.base_config.audio_fmt, out_fmt, sizeof(struct sof_ipc4_audio_format));
2548+
siggen->data.base_config.obs = available_fmt->output_pin_fmts[0].buffer_size;
2549+
2550+
/* update pipeline memory usage */
2551+
sof_ipc4_update_resource_usage(sdev, swidget, &siggen->data.base_config, dir);
2552+
2553+
return 0;
2554+
}
2555+
24822556
static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
24832557
struct snd_pcm_hw_params *fe_params,
24842558
struct snd_sof_platform_stream_params *platform_params,
@@ -3162,6 +3236,16 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget
31623236
msg = &asrc->msg;
31633237
break;
31643238
}
3239+
case snd_soc_dapm_siggen:
3240+
{
3241+
struct sof_ipc4_siggen *siggen = swidget->private;
3242+
3243+
ipc_size = sizeof(siggen->data);
3244+
ipc_data = &siggen->data;
3245+
3246+
msg = &siggen->msg;
3247+
break;
3248+
}
31653249
case snd_soc_dapm_effect:
31663250
{
31673251
struct sof_ipc4_process *process = swidget->private;
@@ -3852,6 +3936,13 @@ static enum sof_tokens mixer_token_list[] = {
38523936
SOF_COMP_EXT_TOKENS,
38533937
};
38543938

3939+
static enum sof_tokens siggen_token_list[] = {
3940+
SOF_COMP_TOKENS,
3941+
SOF_AUDIO_FMT_NUM_TOKENS,
3942+
SOF_OUT_AUDIO_FORMAT_TOKENS,
3943+
SOF_COMP_EXT_TOKENS,
3944+
};
3945+
38553946
static enum sof_tokens src_token_list[] = {
38563947
SOF_COMP_TOKENS,
38573948
SOF_SRC_TOKENS,
@@ -3924,6 +4015,10 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc4_widget_ops[SND_SOC_DAPM_TY
39244015
process_token_list, ARRAY_SIZE(process_token_list),
39254016
NULL, sof_ipc4_prepare_process_module,
39264017
NULL},
4018+
[snd_soc_dapm_siggen] = {sof_ipc4_widget_setup_comp_siggen,
4019+
sof_ipc4_widget_free_comp_siggen,
4020+
siggen_token_list, ARRAY_SIZE(siggen_token_list), NULL,
4021+
sof_ipc4_prepare_siggen_module, NULL},
39274022
};
39284023

39294024
const struct sof_ipc_tplg_ops ipc4_tplg_ops = {

sound/soc/sof/ipc4-topology.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,27 @@ struct sof_ipc4_src {
462462
struct sof_ipc4_msg msg;
463463
};
464464

465+
/*
466+
* struct sof_ipc4_siggen_data - IPC data for siggen
467+
* @base_config: IPC base config data
468+
* @sink_rate: Output rate for sink module
469+
*/
470+
struct sof_ipc4_siggen_data {
471+
struct sof_ipc4_base_module_cfg base_config;
472+
} __packed __aligned(4);
473+
474+
/**
475+
* struct sof_ipc4_siggen - siggen config data
476+
* @data: IPC base config data
477+
* @available_fmt: Available audio format
478+
* @msg: IPC4 message struct containing header and data info
479+
*/
480+
struct sof_ipc4_siggen {
481+
struct sof_ipc4_siggen_data data;
482+
struct sof_ipc4_available_audio_format available_fmt;
483+
struct sof_ipc4_msg msg;
484+
};
485+
465486
/*
466487
* struct sof_ipc4_asrc_data - IPC data for ASRC
467488
* @base_config: IPC base config data

0 commit comments

Comments
 (0)