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