@@ -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
438433 /* nothing to trigger if the list is empty */
439434 if (!pipeline_list -> pipelines || !pipeline_list -> count )
@@ -450,9 +445,9 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
450445 if (pipeline -> use_chain_dma ) {
451446 struct sof_ipc4_timestamp_info * time_info ;
452447
453- time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [substream -> stream ]);
448+ time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [dir ]);
454449
455- ret = sof_ipc4_chain_dma_trigger (sdev , spcm , substream -> stream ,
450+ ret = sof_ipc4_chain_dma_trigger (sdev , spcm , dir ,
456451 pipeline_list , state , cmd );
457452 if (ret || !time_info )
458453 return ret ;
@@ -461,12 +456,16 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
461456 /*
462457 * Record the DAI position for delay reporting
463458 * To handle multiple pause/resume/xrun we need to add
464- * the positions to simulate how the firmware behaves
459+ * the positions to simulate how the firmware behaves.
460+ * Chained DAM does not support compress streams. We should
461+ * never get here with compress.
465462 */
466- u64 pos = snd_sof_pcm_get_dai_frame_counter (sdev , component ,
467- substream );
463+ if (substream ) {
464+ u64 pos = snd_sof_pcm_get_dai_frame_counter (sdev , component ,
465+ substream );
468466
469- time_info -> stream_end_offset += pos ;
467+ time_info -> stream_end_offset += pos ;
468+ }
470469 } else if (state == SOF_IPC4_PIPE_RESET ) {
471470 /* Reset the end offset as the stream is stopped */
472471 time_info -> stream_end_offset = 0 ;
@@ -527,7 +526,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
527526 */
528527 ret = sof_ipc4_set_multi_pipeline_state (sdev , SOF_IPC4_PIPE_PAUSED , trigger_list );
529528 if (ret < 0 ) {
530- spcm_err (spcm , substream -> stream , "failed to pause all pipelines\n" );
529+ spcm_err (spcm , dir , "failed to pause all pipelines\n" );
531530 goto free ;
532531 }
533532
@@ -546,7 +545,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
546545 * Invalidate the stream_start_offset to make sure that it is
547546 * going to be updated if the stream resumes
548547 */
549- time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [substream -> stream ]);
548+ time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [dir ]);
550549 if (time_info )
551550 time_info -> stream_start_offset = SOF_IPC4_INVALID_STREAM_POSITION ;
552551
@@ -556,7 +555,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
556555 /* else set the RUNNING/RESET state in the DSP */
557556 ret = sof_ipc4_set_multi_pipeline_state (sdev , state , trigger_list );
558557 if (ret < 0 ) {
559- spcm_err (spcm , substream -> stream ,
558+ spcm_err (spcm , dir ,
560559 "failed to set final state %d for all pipelines\n" ,
561560 state );
562561 /*
@@ -586,7 +585,8 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
586585}
587586
588587static int sof_ipc4_pcm_trigger (struct snd_soc_component * component ,
589- struct snd_pcm_substream * substream , int cmd )
588+ struct snd_pcm_substream * substream ,
589+ struct snd_sof_pcm * spcm , int cmd , int dir )
590590{
591591 int state ;
592592
@@ -608,14 +608,15 @@ static int sof_ipc4_pcm_trigger(struct snd_soc_component *component,
608608 }
609609
610610 /* set the pipeline state */
611- return sof_ipc4_trigger_pipelines (component , substream , state , cmd );
611+ return sof_ipc4_trigger_pipelines (component , substream , state , cmd , spcm , dir );
612612}
613613
614614static int sof_ipc4_pcm_hw_free (struct snd_soc_component * component ,
615- struct snd_pcm_substream * substream )
615+ struct snd_pcm_substream * substream ,
616+ struct snd_sof_pcm * spcm , int dir )
616617{
617618 /* command is not relevant with RESET, so just pass 0 */
618- return sof_ipc4_trigger_pipelines (component , substream , SOF_IPC4_PIPE_RESET , 0 );
619+ return sof_ipc4_trigger_pipelines (component , substream , SOF_IPC4_PIPE_RESET , 0 , spcm , dir );
619620}
620621
621622static int ipc4_ssp_dai_config_pcm_params_match (struct snd_sof_dev * sdev ,
0 commit comments