@@ -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+
30523084static 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 ;
0 commit comments