Skip to content

Commit a8459f3

Browse files
committed
ASoC: SOF: ipc4-topology: Support init_ext_module_data for process modules
Add support for handling init_ext_module_data for process modules, which is going to be used by decoder and encoder type of process modules. The support is generic and it can be extended to other type of process modules or other module types than process with a small update of sof_ipc4_add_init_ext_module_data() function. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent af5353a commit a8459f3

3 files changed

Lines changed: 41 additions & 18 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3139,6 +3139,36 @@ static void sof_ipc4_add_init_ext_dp_memory_data(struct snd_sof_dev *sdev,
31393139
}
31403140
}
31413141

3142+
static void
3143+
sof_ipc4_add_init_ext_module_data(struct snd_sof_dev *sdev,
3144+
struct snd_sof_widget *swidget,
3145+
u32 *payload, u32 *ext_pos,
3146+
struct sof_ipc4_module_init_ext_object **hdr)
3147+
{
3148+
struct sof_ipc4_process *process = swidget->private;
3149+
u32 data_size;
3150+
void *data;
3151+
3152+
/*
3153+
* Check if widget is process module and if it is using
3154+
* init_ext_module_data
3155+
*/
3156+
if (!WIDGET_IS_PROCESS(swidget->id) || !process->init_ext_module_size)
3157+
return;
3158+
3159+
data_size = process->init_ext_module_size;
3160+
data = process->init_ext_module_data;
3161+
3162+
*hdr = (struct sof_ipc4_module_init_ext_object *)&payload[*ext_pos];
3163+
(*hdr)->header = SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_MODULE_DATA) |
3164+
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(data_size, sizeof(u32)));
3165+
*ext_pos += DIV_ROUND_UP(sizeof(*(*hdr)), sizeof(u32));
3166+
3167+
memcpy(&payload[*ext_pos], data, data_size);
3168+
3169+
*ext_pos += DIV_ROUND_UP(data_size, sizeof(u32));
3170+
}
3171+
31423172
static int sof_ipc4_widget_mod_init_msg_payload(struct snd_sof_dev *sdev,
31433173
struct snd_sof_widget *swidget,
31443174
struct sof_ipc4_msg *msg,
@@ -3151,40 +3181,28 @@ static int sof_ipc4_widget_mod_init_msg_payload(struct snd_sof_dev *sdev,
31513181
u32 *payload;
31523182
u32 ext_pos;
31533183

3154-
/*
3155-
* Only DP widgets currently add init-ext objects here. Avoid allocating
3156-
* a max-sized payload buffer for widgets that will immediately return 0.
3157-
*/
3158-
if (swidget->comp_domain != SOF_COMP_DOMAIN_DP)
3159-
return 0;
3160-
31613184
payload = kzalloc(sdev->ipc->max_payload_size, GFP_KERNEL);
31623185
if (!payload)
31633186
return -ENOMEM;
31643187

31653188
/* Add ext_init first and set objects array flag to 1 */
31663189
ext_init = (struct sof_ipc4_module_init_ext_init *)payload;
3190+
ext_init->word0 |= SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK;
31673191
ext_pos = DIV_ROUND_UP(sizeof(*ext_init), sizeof(u32));
31683192

31693193
/* Add object array objects after ext_init */
3170-
31713194
sof_ipc4_add_init_ext_dp_memory_data(sdev, swidget, payload, &ext_pos, &hdr);
31723195

3173-
/* Add following object array items here */
3196+
sof_ipc4_add_init_ext_module_data(sdev, swidget, payload, &ext_pos, &hdr);
31743197

3175-
if (!hdr) {
3176-
/*
3177-
* NOTE: Remove this early bail out, when struct
3178-
* sof_ipc4_module_init_ext_init alone has some
3179-
* function.
3180-
*/
3198+
/* Set last bit for the last object in the array */
3199+
if (hdr) {
3200+
hdr->header |= SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK;
3201+
} else {
31813202
kfree(payload);
31823203
return 0;
31833204
}
31843205

3185-
ext_init->word0 |= SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK;
3186-
hdr->header |= SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK;
3187-
31883206
/* Calculate final size and check that it fits to max payload size */
31893207
new_size = ext_pos * sizeof(u32) + ipc_size;
31903208
if (new_size > sdev->ipc->max_payload_size) {

sound/soc/sof/ipc4-topology.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ struct sof_ipc4_base_module_cfg_ext {
518518
* @msg: IPC4 message struct containing header and data info
519519
* @base_config_ext_size: Size of the base config extension data in bytes
520520
* @init_config: Module init config type (SOF_IPC4_MODULE_INIT_CONFIG_TYPE_*)
521+
* @init_ext_module_data: module_data for init_ext object
522+
* @init_ext_module_size: size of init_ext_module_data
521523
*/
522524
struct sof_ipc4_process {
523525
struct sof_ipc4_base_module_cfg base_config;
@@ -529,6 +531,8 @@ struct sof_ipc4_process {
529531
struct sof_ipc4_msg msg;
530532
u32 base_config_ext_size;
531533
u32 init_config;
534+
void *init_ext_module_data;
535+
size_t init_ext_module_size;
532536
};
533537

534538
bool sof_ipc4_copier_is_single_bitdepth(struct snd_sof_dev *sdev,

sound/soc/sof/sof-audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#define WIDGET_IS_AIF(id) ((id) == snd_soc_dapm_aif_in || (id) == snd_soc_dapm_aif_out)
4444
#define WIDGET_IS_AIF_OR_DAI(id) (WIDGET_IS_DAI(id) || WIDGET_IS_AIF(id))
4545
#define WIDGET_IS_COPIER(id) (WIDGET_IS_AIF_OR_DAI(id) || (id) == snd_soc_dapm_buffer)
46+
#define WIDGET_IS_PROCESS(id) ((id) == snd_soc_dapm_effect)
4647

4748
#define SOF_DAI_PARAM_INTEL_SSP_MCLK 0
4849
#define SOF_DAI_PARAM_INTEL_SSP_BCLK 1

0 commit comments

Comments
 (0)