@@ -412,28 +412,23 @@ static int sof_ipc4_chain_dma_trigger(struct snd_sof_dev *sdev,
412412}
413413
414414static int sof_ipc4_trigger_pipelines (struct snd_soc_component * component ,
415- struct snd_pcm_substream * substream , int state , int cmd )
415+ struct snd_pcm_substream * substream , int state , int cmd ,
416+ struct snd_sof_pcm * spcm , int dir )
416417{
417418 struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (component );
418- struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
419419 struct snd_sof_pcm_stream_pipeline_list * pipeline_list ;
420420 struct sof_ipc4_fw_data * ipc4_data = sdev -> private ;
421421 struct ipc4_pipeline_set_state_data * trigger_list ;
422422 struct snd_sof_widget * pipe_widget ;
423423 struct sof_ipc4_pipeline * pipeline ;
424424 struct snd_sof_pipeline * spipe ;
425- struct snd_sof_pcm * spcm ;
426425 u8 * pipe_priority ;
427426 int ret ;
428427 int i ;
429428
430- spcm = snd_sof_find_spcm_dai (component , rtd );
431- if (!spcm )
432- return - EINVAL ;
429+ spcm_dbg (spcm , dir , "cmd: %d, state: %d\n" , cmd , state );
433430
434- spcm_dbg (spcm , substream -> stream , "cmd: %d, state: %d\n" , cmd , state );
435-
436- pipeline_list = & spcm -> stream [substream -> stream ].pipeline_list ;
431+ pipeline_list = & spcm -> stream [dir ].pipeline_list ;
437432 guard (mutex )(& ipc4_data -> pipeline_state_mutex );
438433
439434 /* nothing to trigger if the list is empty */
@@ -454,9 +449,9 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
454449 if (pipeline -> use_chain_dma ) {
455450 struct sof_ipc4_timestamp_info * time_info ;
456451
457- time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [substream -> stream ]);
452+ time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [dir ]);
458453
459- ret = sof_ipc4_chain_dma_trigger (sdev , spcm , substream -> stream ,
454+ ret = sof_ipc4_chain_dma_trigger (sdev , spcm , dir ,
460455 pipeline_list , state , cmd );
461456 if (ret || !time_info )
462457 return ret ;
@@ -465,12 +460,16 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
465460 /*
466461 * Record the DAI position for delay reporting
467462 * To handle multiple pause/resume/xrun we need to add
468- * the positions to simulate how the firmware behaves
463+ * the positions to simulate how the firmware behaves.
464+ * Chained DMA does not support compress streams. We should
465+ * never get here with compress.
469466 */
470- u64 pos = snd_sof_pcm_get_dai_frame_counter (sdev , component ,
471- substream );
467+ if (substream ) {
468+ u64 pos = snd_sof_pcm_get_dai_frame_counter (sdev , component ,
469+ substream );
472470
473- time_info -> stream_end_offset += pos ;
471+ time_info -> stream_end_offset += pos ;
472+ }
474473 } else if (state == SOF_IPC4_PIPE_RESET ) {
475474 /* Reset the end offset as the stream is stopped */
476475 time_info -> stream_end_offset = 0 ;
@@ -533,7 +532,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
533532 */
534533 ret = sof_ipc4_set_multi_pipeline_state (sdev , SOF_IPC4_PIPE_PAUSED , trigger_list );
535534 if (ret < 0 ) {
536- spcm_err (spcm , substream -> stream , "failed to pause all pipelines\n" );
535+ spcm_err (spcm , dir , "failed to pause all pipelines\n" );
537536 /*
538537 * workaround: if the firmware is crashed or the IPC timed out
539538 * while setting the pipeline state we must ignore the error
@@ -566,7 +565,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
566565 * Invalidate the stream_start_offset to make sure that it is
567566 * going to be updated if the stream resumes
568567 */
569- time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [substream -> stream ]);
568+ time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [dir ]);
570569 if (time_info )
571570 time_info -> stream_start_offset = SOF_IPC4_INVALID_STREAM_POSITION ;
572571
@@ -576,7 +575,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
576575 /* else set the RUNNING/RESET state in the DSP */
577576 ret = sof_ipc4_set_multi_pipeline_state (sdev , state , trigger_list );
578577 if (ret < 0 ) {
579- spcm_err (spcm , substream -> stream ,
578+ spcm_err (spcm , dir ,
580579 "failed to set final state %d for all pipelines\n" ,
581580 state );
582581 /*
@@ -609,7 +608,8 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
609608}
610609
611610static int sof_ipc4_pcm_trigger (struct snd_soc_component * component ,
612- struct snd_pcm_substream * substream , int cmd )
611+ struct snd_pcm_substream * substream ,
612+ struct snd_sof_pcm * spcm , int cmd , int dir )
613613{
614614 int state ;
615615
@@ -631,14 +631,15 @@ static int sof_ipc4_pcm_trigger(struct snd_soc_component *component,
631631 }
632632
633633 /* set the pipeline state */
634- return sof_ipc4_trigger_pipelines (component , substream , state , cmd );
634+ return sof_ipc4_trigger_pipelines (component , substream , state , cmd , spcm , dir );
635635}
636636
637637static int sof_ipc4_pcm_hw_free (struct snd_soc_component * component ,
638- struct snd_pcm_substream * substream )
638+ struct snd_pcm_substream * substream ,
639+ struct snd_sof_pcm * spcm , int dir )
639640{
640641 /* command is not relevant with RESET, so just pass 0 */
641- return sof_ipc4_trigger_pipelines (component , substream , SOF_IPC4_PIPE_RESET , 0 );
642+ return sof_ipc4_trigger_pipelines (component , substream , SOF_IPC4_PIPE_RESET , 0 , spcm , dir );
642643}
643644
644645static int ipc4_ssp_dai_config_pcm_params_match (struct snd_sof_dev * sdev ,
0 commit comments