Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: SOF: ipc4-topology: add buffer type support

The corresponding IPC4 module of snd_soc_dapm_buffer widget is module
-to-module copier.
The module-to-module copier is a buffer-like component with demuxing
capabilities.
Rename the host_token_list to common_copier_token_list since it will
be used by host copier and module-to-module copier.
The setup callback is almost the same as sof_ipc4_widget_setup_pcm except
the gtw_cfg data, and the free callback is exactly the same as
sof_ipc4_widget_free_comp_pcm. To reduce the duplication, the commit
reuses the setup and free callbacks.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230126110637.25542-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Bard Liao and committed by
Mark Brown
7d573425 636be128

+52 -7
+50 -7
sound/soc/sof/ipc4-topology.c
··· 354 354 goto free_available_fmt; 355 355 } 356 356 357 + /* 358 + * This callback is used by host copier and module-to-module copier, 359 + * and only host copier needs to set gtw_cfg. 360 + */ 361 + if (!WIDGET_IS_AIF(swidget->id)) 362 + goto skip_gtw_cfg; 363 + 357 364 ret = sof_update_ipc_object(scomp, available_fmt->dma_buffer_size, 358 365 SOF_COPIER_GATEWAY_CFG_TOKENS, swidget->tuples, 359 366 swidget->num_tuples, sizeof(u32), ··· 387 380 } 388 381 dev_dbg(scomp->dev, "host copier '%s' node_type %u\n", swidget->widget->name, node_type); 389 382 390 - ipc4_copier->data.gtw_cfg.node_id = SOF_IPC4_NODE_TYPE(node_type); 383 + skip_gtw_cfg: 391 384 ipc4_copier->gtw_attr = kzalloc(sizeof(*ipc4_copier->gtw_attr), GFP_KERNEL); 392 385 if (!ipc4_copier->gtw_attr) { 393 386 ret = -ENOMEM; ··· 397 390 ipc4_copier->copier_config = (uint32_t *)ipc4_copier->gtw_attr; 398 391 ipc4_copier->data.gtw_cfg.config_length = 399 392 sizeof(struct sof_ipc4_gtw_attributes) >> 2; 393 + 394 + switch (swidget->id) { 395 + case snd_soc_dapm_aif_in: 396 + case snd_soc_dapm_aif_out: 397 + ipc4_copier->data.gtw_cfg.node_id = SOF_IPC4_NODE_TYPE(node_type); 398 + break; 399 + case snd_soc_dapm_buffer: 400 + ipc4_copier->data.gtw_cfg.node_id = SOF_IPC4_INVALID_NODE_ID; 401 + ipc4_copier->ipc_config_size = 0; 402 + break; 403 + default: 404 + dev_err(scomp->dev, "invalid widget type %d\n", swidget->id); 405 + ret = -EINVAL; 406 + goto free_gtw_attr; 407 + } 400 408 401 409 /* set up module info and message header */ 402 410 ret = sof_ipc4_widget_setup_msg(swidget, &ipc4_copier->msg); ··· 973 951 pipeline = pipe_widget->private; 974 952 pipeline->mem_usage = 0; 975 953 976 - if (WIDGET_IS_AIF(swidget->id)) { 954 + if (WIDGET_IS_AIF(swidget->id) || swidget->id == snd_soc_dapm_buffer) { 977 955 ipc4_copier = swidget->private; 978 956 } else if (WIDGET_IS_DAI(swidget->id)) { 979 957 struct snd_sof_dai *dai = swidget->private; ··· 1196 1174 &copier_data->gtw_cfg.config_length); 1197 1175 if (ret < 0) 1198 1176 return ret; 1177 + 1178 + break; 1179 + } 1180 + case snd_soc_dapm_buffer: 1181 + { 1182 + ipc4_copier = (struct sof_ipc4_copier *)swidget->private; 1183 + copier_data = &ipc4_copier->data; 1184 + available_fmt = &ipc4_copier->available_fmt; 1185 + 1186 + /* 1187 + * base_config->audio_fmt represent the input audio formats. Use 1188 + * the input format as the reference to match pcm params 1189 + */ 1190 + available_fmt->ref_audio_fmt = &available_fmt->base_config->audio_fmt; 1191 + ref_audio_fmt_size = sizeof(struct sof_ipc4_base_module_cfg); 1192 + ref_params = pipeline_params; 1199 1193 1200 1194 break; 1201 1195 } ··· 1503 1465 break; 1504 1466 case snd_soc_dapm_aif_in: 1505 1467 case snd_soc_dapm_aif_out: 1468 + case snd_soc_dapm_buffer: 1506 1469 { 1507 1470 struct sof_ipc4_copier *ipc4_copier = swidget->private; 1508 1471 ··· 2009 1970 return 0; 2010 1971 } 2011 1972 2012 - static enum sof_tokens host_token_list[] = { 1973 + static enum sof_tokens common_copier_token_list[] = { 2013 1974 SOF_COMP_TOKENS, 2014 1975 SOF_AUDIO_FMT_NUM_TOKENS, 2015 1976 SOF_AUDIO_FORMAT_BUFFER_SIZE_TOKENS, ··· 2065 2026 2066 2027 static const struct sof_ipc_tplg_widget_ops tplg_ipc4_widget_ops[SND_SOC_DAPM_TYPE_COUNT] = { 2067 2028 [snd_soc_dapm_aif_in] = {sof_ipc4_widget_setup_pcm, sof_ipc4_widget_free_comp_pcm, 2068 - host_token_list, ARRAY_SIZE(host_token_list), NULL, 2069 - sof_ipc4_prepare_copier_module, 2029 + common_copier_token_list, ARRAY_SIZE(common_copier_token_list), 2030 + NULL, sof_ipc4_prepare_copier_module, 2070 2031 sof_ipc4_unprepare_copier_module}, 2071 2032 [snd_soc_dapm_aif_out] = {sof_ipc4_widget_setup_pcm, sof_ipc4_widget_free_comp_pcm, 2072 - host_token_list, ARRAY_SIZE(host_token_list), NULL, 2073 - sof_ipc4_prepare_copier_module, 2033 + common_copier_token_list, ARRAY_SIZE(common_copier_token_list), 2034 + NULL, sof_ipc4_prepare_copier_module, 2074 2035 sof_ipc4_unprepare_copier_module}, 2075 2036 [snd_soc_dapm_dai_in] = {sof_ipc4_widget_setup_comp_dai, sof_ipc4_widget_free_comp_dai, 2076 2037 dai_token_list, ARRAY_SIZE(dai_token_list), NULL, ··· 2080 2041 dai_token_list, ARRAY_SIZE(dai_token_list), NULL, 2081 2042 sof_ipc4_prepare_copier_module, 2082 2043 sof_ipc4_unprepare_copier_module}, 2044 + [snd_soc_dapm_buffer] = {sof_ipc4_widget_setup_pcm, sof_ipc4_widget_free_comp_pcm, 2045 + common_copier_token_list, ARRAY_SIZE(common_copier_token_list), 2046 + NULL, sof_ipc4_prepare_copier_module, 2047 + sof_ipc4_unprepare_copier_module}, 2083 2048 [snd_soc_dapm_scheduler] = {sof_ipc4_widget_setup_comp_pipeline, 2084 2049 sof_ipc4_widget_free_comp_pipeline, 2085 2050 pipeline_token_list, ARRAY_SIZE(pipeline_token_list), NULL,
+2
sound/soc/sof/ipc4-topology.h
··· 53 53 54 54 #define ALH_MAX_NUMBER_OF_GTW 16 55 55 56 + #define SOF_IPC4_INVALID_NODE_ID 0xffffffff 57 + 56 58 /* 57 59 * The base of multi-gateways. Multi-gateways addressing starts from 58 60 * ALH_MULTI_GTW_BASE and there are ALH_MULTI_GTW_COUNT multi-sources