Skip to content

Commit 1c81a85

Browse files
ujfalusilgirdwood
authored andcommitted
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 1dcfa47 commit 1c81a85

3 files changed

Lines changed: 50 additions & 36 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,22 +3121,38 @@ static void sof_ipc4_add_init_ext_dp_memory_data(struct snd_sof_dev *sdev,
31213121
u32 *payload, u32 *ext_pos,
31223122
struct sof_ipc4_module_init_ext_object **hdr)
31233123
{
3124-
/* Add memory_data if comp_domain indicates DP */
3125-
if (swidget->comp_domain == SOF_COMP_DOMAIN_DP) {
3126-
struct sof_ipc4_mod_init_ext_dp_memory_data *dp_mem_data;
3127-
3128-
*hdr = (struct sof_ipc4_module_init_ext_object *)&payload[*ext_pos];
3129-
(*hdr)->header =
3130-
SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA) |
3131-
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(sizeof(*dp_mem_data),
3132-
sizeof(u32)));
3133-
*ext_pos += DIV_ROUND_UP(sizeof(**hdr), sizeof(u32));
3134-
dp_mem_data = (struct sof_ipc4_mod_init_ext_dp_memory_data *)&payload[*ext_pos];
3135-
dp_mem_data->domain_id = swidget->domain_id;
3136-
dp_mem_data->stack_bytes = swidget->stack_bytes;
3137-
dp_mem_data->heap_bytes = swidget->heap_bytes;
3138-
*ext_pos += DIV_ROUND_UP(sizeof(*dp_mem_data), sizeof(u32));
3139-
}
3124+
struct sof_ipc4_mod_init_ext_dp_memory_data *dp_mem_data;
3125+
3126+
*hdr = (struct sof_ipc4_module_init_ext_object *)&payload[*ext_pos];
3127+
(*hdr)->header =
3128+
SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA) |
3129+
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(sizeof(*dp_mem_data),
3130+
sizeof(u32)));
3131+
*ext_pos += DIV_ROUND_UP(sizeof(**hdr), sizeof(u32));
3132+
dp_mem_data = (struct sof_ipc4_mod_init_ext_dp_memory_data *)&payload[*ext_pos];
3133+
dp_mem_data->domain_id = swidget->domain_id;
3134+
dp_mem_data->stack_bytes = swidget->stack_bytes;
3135+
dp_mem_data->heap_bytes = swidget->heap_bytes;
3136+
*ext_pos += DIV_ROUND_UP(sizeof(*dp_mem_data), sizeof(u32));
3137+
}
3138+
3139+
static void
3140+
sof_ipc4_add_init_ext_module_data(struct snd_sof_dev *sdev,
3141+
struct sof_ipc4_process *process,
3142+
u32 *payload, u32 *ext_pos,
3143+
struct sof_ipc4_module_init_ext_object **hdr)
3144+
{
3145+
u32 data_size = process->init_ext_module_size;
3146+
void *data = process->init_ext_module_data;
3147+
3148+
*hdr = (struct sof_ipc4_module_init_ext_object *)&payload[*ext_pos];
3149+
(*hdr)->header = SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_MODULE_DATA) |
3150+
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(data_size, sizeof(u32)));
3151+
*ext_pos += DIV_ROUND_UP(sizeof(*(*hdr)), sizeof(u32));
3152+
3153+
memcpy(&payload[*ext_pos], data, data_size);
3154+
3155+
*ext_pos += DIV_ROUND_UP(data_size, sizeof(u32));
31403156
}
31413157

31423158
static int sof_ipc4_widget_mod_init_msg_payload(struct snd_sof_dev *sdev,
@@ -3145,17 +3161,16 @@ static int sof_ipc4_widget_mod_init_msg_payload(struct snd_sof_dev *sdev,
31453161
void *ipc_data, u32 ipc_size,
31463162
void **new_data)
31473163
{
3148-
struct sof_ipc4_module_init_ext_init *ext_init;
3164+
struct sof_ipc4_process *process = swidget->private;
31493165
struct sof_ipc4_module_init_ext_object *hdr = NULL;
3166+
struct sof_ipc4_module_init_ext_init *ext_init;
3167+
bool in_dp_domain = swidget->comp_domain == SOF_COMP_DOMAIN_DP;
3168+
bool has_ext_data = WIDGET_IS_PROCESS(swidget->id) && process->init_ext_module_size;
31503169
int new_size;
31513170
u32 *payload;
31523171
u32 ext_pos;
31533172

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)
3173+
if (!in_dp_domain && !has_ext_data)
31593174
return 0;
31603175

31613176
payload = kzalloc(sdev->ipc->max_payload_size, GFP_KERNEL);
@@ -3164,25 +3179,19 @@ static int sof_ipc4_widget_mod_init_msg_payload(struct snd_sof_dev *sdev,
31643179

31653180
/* Add ext_init first and set objects array flag to 1 */
31663181
ext_init = (struct sof_ipc4_module_init_ext_init *)payload;
3182+
ext_init->word0 |= SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK;
31673183
ext_pos = DIV_ROUND_UP(sizeof(*ext_init), sizeof(u32));
31683184

31693185
/* Add object array objects after ext_init */
3186+
if (in_dp_domain)
3187+
sof_ipc4_add_init_ext_dp_memory_data(sdev, swidget, payload,
3188+
&ext_pos, &hdr);
31703189

3171-
sof_ipc4_add_init_ext_dp_memory_data(sdev, swidget, payload, &ext_pos, &hdr);
3172-
3173-
/* Add following object array items here */
3190+
if (has_ext_data)
3191+
sof_ipc4_add_init_ext_module_data(sdev, process, payload,
3192+
&ext_pos, &hdr);
31743193

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-
*/
3181-
kfree(payload);
3182-
return 0;
3183-
}
3184-
3185-
ext_init->word0 |= SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK;
3194+
/* Set last bit for the last object in the array */
31863195
hdr->header |= SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK;
31873196

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