Skip to content

Commit 4442f5f

Browse files
committed
ASoC: SOF: ipc4-pcm: Handle COMPR DRAIN triggers as EOS pipeline state
The DRAIN trigger is received by a compr device when user space wrote the all data to the buffer and it is waiting for the decoding to be completed. Set the pipeline state to EOS in firmware so it can expect the stream to be stopping anytime soon. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 9cb4611 commit 4442f5f

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

sound/soc/sof/ipc4-pcm.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ sof_ipc4_add_pipeline_to_trigger_list(struct snd_sof_dev *sdev, int state,
153153
struct snd_sof_widget *pipe_widget = spipe->pipe_widget;
154154
struct sof_ipc4_pipeline *pipeline = pipe_widget->private;
155155

156-
if (pipeline->skip_during_fe_trigger && state != SOF_IPC4_PIPE_RESET)
156+
if (pipeline->skip_during_fe_trigger && state != SOF_IPC4_PIPE_RESET &&
157+
state != SOF_IPC4_PIPE_EOS)
157158
return;
158159

159160
switch (state) {
@@ -173,7 +174,12 @@ sof_ipc4_add_pipeline_to_trigger_list(struct snd_sof_dev *sdev, int state,
173174
true);
174175
break;
175176
case SOF_IPC4_PIPE_PAUSED:
176-
/* Pause the pipeline only when its started_count is 1 more than paused_count */
177+
case SOF_IPC4_PIPE_EOS:
178+
/*
179+
* Pause the pipeline only when its started_count is 1 more than
180+
* paused_count.
181+
* Same rule applies to EOS state.
182+
*/
177183
if (spipe->paused_count == (spipe->started_count - 1))
178184
sof_ipc4_add_pipeline_by_priority(trigger_list, pipe_widget, pipe_priority,
179185
true);
@@ -493,8 +499,9 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
493499
goto free;
494500
}
495501

496-
/* no need to pause before reset or before pause release */
497-
if (state == SOF_IPC4_PIPE_RESET || cmd == SNDRV_PCM_TRIGGER_PAUSE_RELEASE)
502+
/* no need to pause before reset, EOS or before pause release */
503+
if (state == SOF_IPC4_PIPE_RESET || state == SOF_IPC4_PIPE_EOS ||
504+
cmd == SNDRV_PCM_TRIGGER_PAUSE_RELEASE)
498505
goto skip_pause_transition;
499506

500507
/*
@@ -579,6 +586,10 @@ static int sof_ipc4_pcm_trigger(struct snd_soc_component *component,
579586
case SNDRV_PCM_TRIGGER_STOP:
580587
state = SOF_IPC4_PIPE_PAUSED;
581588
break;
589+
case SND_COMPR_TRIGGER_DRAIN:
590+
case SND_COMPR_TRIGGER_PARTIAL_DRAIN:
591+
state = SOF_IPC4_PIPE_EOS;
592+
break;
582593
default:
583594
dev_err(component->dev, "%s: unhandled trigger cmd %d\n", __func__, cmd);
584595
return -EINVAL;

0 commit comments

Comments
 (0)