@@ -460,49 +460,55 @@ static int ipc4_load_library(struct ipc4_message_request *ipc4)
460460
461461static int ipc4_process_chain_dma (struct ipc4_message_request * ipc4 )
462462{
463- struct ipc4_chain_dma cdma ;
463+ #if CONFIG_COMP_CHAIN_DMA
464+ struct ipc_comp_dev * cdma_comp ;
464465 struct ipc * ipc = ipc_get ();
465- bool delay = false;
466- int ret = memcpy_s (& cdma , sizeof (cdma ), ipc4 , sizeof (* ipc4 ));
466+ struct ipc4_chain_dma cdma ;
467+ int comp_id ;
468+ int ret ;
467469
470+ ret = memcpy_s (& cdma , sizeof (cdma ), ipc4 , sizeof (* ipc4 ));
468471 if (ret < 0 )
469472 return IPC4_FAILURE ;
470473
471- if (cdma .primary .r .allocate && cdma .extension .r .fifo_size ) {
472- ret = ipc4_create_chain_dma (ipc , & cdma );
473- if (ret ) {
474- tr_err (& ipc_tr , "failed to create chain dma %d" , ret );
475- return ret ;
476- }
474+ comp_id = IPC4_COMP_ID (cdma .primary .r .host_dma_id + IPC4_MAX_MODULE_COUNT , 0 );
475+ cdma_comp = ipc_get_comp_by_id (ipc , comp_id );
477476
478- /* if enable is not set, chain dma pipeline is not going to be triggered */
479- if (! cdma . primary . r . enable )
480- return ret ;
481- }
477+ if (! cdma_comp && cdma . primary . r . allocate && cdma . primary . r . enable ) {
478+ ret = ipc4_chain_manager_create ( & cdma );
479+ if ( ret < 0 )
480+ return IPC4_FAILURE ;
482481
483- atomic_set (& msg_data .delayed_reply , 1 );
484- ret = ipc4_trigger_chain_dma (ipc , & cdma , & delay );
485- /* it is not scheduled in another thread */
486- if (!delay ) {
487- atomic_set (& msg_data .delayed_reply , 0 );
488- msg_data .delayed_error = 0 ;
489- } else if (!cdma .primary .r .allocate ) {
490- uint32_t pipeline_id = IPC4_COMP_ID (cdma .primary .r .host_dma_id
491- + IPC4_MAX_MODULE_COUNT ,
492- cdma .primary .r .link_dma_id );
493-
494- /* waiting for pipeline reset done */
495- ipc_wait_for_compound_msg ();
496- ret = ipc_pipeline_free (ipc , pipeline_id );
482+ cdma_comp = ipc_get_comp_by_id (ipc , comp_id );
483+ if (!cdma_comp ) {
484+ comp_free (cdma_comp -> cd );
485+ return IPC4_FAILURE ;
486+ }
487+
488+ ret = ipc4_chain_dma_state (cdma_comp -> cd , & cdma );
497489 if (ret < 0 ) {
498- tr_err (& ipc_tr , "failed to free chain dma %d" , ret );
499- ret = IPC4_BAD_STATE ;
500- } else {
501- ret = IPC4_SUCCESS ;
490+ comp_free (cdma_comp -> cd );
491+ return IPC4_FAILURE ;
502492 }
493+
494+ return IPC4_SUCCESS ;
503495 }
504496
505- return ret ;
497+ cdma_comp = ipc_get_comp_by_id (ipc , comp_id );
498+ if (!cdma_comp )
499+ return IPC4_FAILURE ;
500+
501+ ret = ipc4_chain_dma_state (cdma_comp -> cd , & cdma );
502+ if (ret < 0 )
503+ return IPC4_INVALID_CHAIN_STATE_TRANSITION ;
504+
505+ if (!cdma .primary .r .allocate && !cdma .primary .r .enable )
506+ list_item_del (& cdma_comp -> list );
507+
508+ return IPC4_SUCCESS ;
509+ #else
510+ return IPC4_UNAVAILABLE ;
511+ #endif
506512}
507513
508514static int ipc4_process_glb_message (struct ipc4_message_request * ipc4 )
0 commit comments