Skip to content

Commit dbb3c47

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 mdoules. 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 472f10b commit dbb3c47

3 files changed

Lines changed: 48 additions & 12 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,6 +3049,38 @@ static int sof_ipc4_control_setup(struct snd_sof_dev *sdev, struct snd_sof_contr
30493049
return 0;
30503050
}
30513051

3052+
static void
3053+
sof_ipc4_add_init_ext_module_data(struct snd_sof_dev *sdev,
3054+
struct snd_sof_widget *swidget,
3055+
u32 *payload, u32 *ext_pos,
3056+
struct sof_ipc4_module_init_ext_object **hdr)
3057+
{
3058+
u32 data_size;
3059+
void *data;
3060+
3061+
if (WIDGET_IS_PROCESS(swidget->id)) {
3062+
/* Check if process module uses init_ext_module_data */
3063+
struct sof_ipc4_process *process = swidget->private;
3064+
3065+
if (!process->init_ext_module_size)
3066+
return;
3067+
3068+
data_size = process->init_ext_module_size;
3069+
data = process->init_ext_module_data;
3070+
} else {
3071+
return;
3072+
}
3073+
3074+
*hdr = (struct sof_ipc4_module_init_ext_object *)&payload[*ext_pos];
3075+
(*hdr)->header = SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_MODULE_DATA) |
3076+
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(data_size, sizeof(u32)));
3077+
*ext_pos += DIV_ROUND_UP(sizeof(*(*hdr)), sizeof(u32));
3078+
3079+
memcpy(&payload[*ext_pos], data, data_size);
3080+
3081+
*ext_pos += DIV_ROUND_UP(data_size, sizeof(u32));
3082+
}
3083+
30523084
static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30533085
struct snd_sof_widget *swidget,
30543086
struct sof_ipc4_msg *msg,
@@ -3057,20 +3089,11 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30573089
{
30583090
struct sof_ipc4_mod_init_ext_dp_memory_data *dp_mem_data;
30593091
struct sof_ipc4_module_init_ext_init *ext_init;
3060-
struct sof_ipc4_module_init_ext_object *hdr;
3092+
struct sof_ipc4_module_init_ext_object *hdr = NULL;
30613093
int new_size;
30623094
u32 *payload;
30633095
u32 ext_pos;
30643096

3065-
/* For the moment the only reason for adding init_ext_init payload is DP
3066-
* memory data. If both stack and heap size are 0 (= use default), then
3067-
* there is no need for init_ext_init payload.
3068-
*/
3069-
if (swidget->comp_domain != SOF_COMP_DOMAIN_DP) {
3070-
msg->extension &= ~SOF_IPC4_MOD_EXT_EXTENDED_INIT_MASK;
3071-
return 0;
3072-
}
3073-
30743097
payload = kzalloc(sdev->ipc->max_payload_size, GFP_KERNEL);
30753098
if (!payload)
30763099
return -ENOMEM;
@@ -3085,7 +3108,7 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30853108
/* Add dp_memory_data if comp_domain indicates DP */
30863109
if (swidget->comp_domain == SOF_COMP_DOMAIN_DP) {
30873110
hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos];
3088-
hdr->header = SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK |
3111+
hdr->header =
30893112
SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA) |
30903113
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(sizeof(*dp_mem_data),
30913114
sizeof(u32)));
@@ -3097,7 +3120,15 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30973120
ext_pos += DIV_ROUND_UP(sizeof(*dp_mem_data), sizeof(u32));
30983121
}
30993122

3100-
/* If another array object is added, remember clear previous OBJ_LAST bit */
3123+
sof_ipc4_add_init_ext_module_data(sdev, swidget, payload, &ext_pos, &hdr);
3124+
3125+
/* Set last bit for the last object in the array */
3126+
if (hdr) {
3127+
hdr->header |= SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK;
3128+
} else {
3129+
kfree(payload);
3130+
return 0;
3131+
}
31013132

31023133
/* Calculate final size and check that it fits to max payload size */
31033134
new_size = ext_pos * sizeof(u32) + ipc_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)