Skip to content

Commit a735dc0

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 63216b4 commit a735dc0

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
@@ -3029,6 +3029,38 @@ static int sof_ipc4_control_setup(struct snd_sof_dev *sdev, struct snd_sof_contr
30293029
return 0;
30303030
}
30313031

3032+
static void
3033+
sof_ipc4_add_init_ext_module_data(struct snd_sof_dev *sdev,
3034+
struct snd_sof_widget *swidget,
3035+
u32 *payload, u32 *ext_pos,
3036+
struct sof_ipc4_module_init_ext_object **hdr)
3037+
{
3038+
u32 data_size;
3039+
void *data;
3040+
3041+
if (WIDGET_IS_PROCESS(swidget->id)) {
3042+
/* Check if process module uses init_ext_module_data */
3043+
struct sof_ipc4_process *process = swidget->private;
3044+
3045+
if (!process->init_ext_module_size)
3046+
return;
3047+
3048+
data_size = process->init_ext_module_size;
3049+
data = process->init_ext_module_data;
3050+
} else {
3051+
return;
3052+
}
3053+
3054+
*hdr = (struct sof_ipc4_module_init_ext_object *)&payload[*ext_pos];
3055+
(*hdr)->header = SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_MODULE_DATA) |
3056+
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(data_size, sizeof(u32)));
3057+
*ext_pos += DIV_ROUND_UP(sizeof(*(*hdr)), sizeof(u32));
3058+
3059+
memcpy(&payload[*ext_pos], data, data_size);
3060+
3061+
*ext_pos += DIV_ROUND_UP(data_size, sizeof(u32));
3062+
}
3063+
30323064
static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30333065
struct snd_sof_widget *swidget,
30343066
struct sof_ipc4_msg *msg,
@@ -3037,20 +3069,11 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30373069
{
30383070
struct sof_ipc4_mod_init_ext_dp_memory_data *dp_mem_data;
30393071
struct sof_ipc4_module_init_ext_init *ext_init;
3040-
struct sof_ipc4_module_init_ext_object *hdr;
3072+
struct sof_ipc4_module_init_ext_object *hdr = NULL;
30413073
int new_size;
30423074
u32 *payload;
30433075
u32 ext_pos;
30443076

3045-
/* For the moment the only reason for adding init_ext_init payload is DP
3046-
* memory data. If both stack and heap size are 0 (= use default), then
3047-
* there is no need for init_ext_init payload.
3048-
*/
3049-
if (swidget->comp_domain != SOF_COMP_DOMAIN_DP) {
3050-
msg->extension &= ~SOF_IPC4_MOD_EXT_EXTENDED_INIT_MASK;
3051-
return 0;
3052-
}
3053-
30543077
payload = kzalloc(sdev->ipc->max_payload_size, GFP_KERNEL);
30553078
if (!payload)
30563079
return -ENOMEM;
@@ -3065,7 +3088,7 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30653088
/* Add dp_memory_data if comp_domain indicates DP */
30663089
if (swidget->comp_domain == SOF_COMP_DOMAIN_DP) {
30673090
hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos];
3068-
hdr->header = SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK |
3091+
hdr->header =
30693092
SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA) |
30703093
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(sizeof(*dp_mem_data),
30713094
sizeof(u32)));
@@ -3077,7 +3100,15 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30773100
ext_pos += DIV_ROUND_UP(sizeof(*dp_mem_data), sizeof(u32));
30783101
}
30793102

3080-
/* If another array object is added, remember clear previous OBJ_LAST bit */
3103+
sof_ipc4_add_init_ext_module_data(sdev, swidget, payload, &ext_pos, &hdr);
3104+
3105+
/* Set last bit for the last object in the array */
3106+
if (hdr) {
3107+
hdr->header |= SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK;
3108+
} else {
3109+
kfree(payload);
3110+
return 0;
3111+
}
30813112

30823113
/* Calculate final size and check that it fits to max payload size */
30833114
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)