Skip to content

Commit 35b91c3

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 all the 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 d687d55 commit 35b91c3

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);
@@ -499,8 +505,9 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
499505
goto free;
500506
}
501507

502-
/* no need to pause before reset or before pause release */
503-
if (state == SOF_IPC4_PIPE_RESET || cmd == SNDRV_PCM_TRIGGER_PAUSE_RELEASE)
508+
/* no need to pause before reset, EOS or before pause release */
509+
if (state == SOF_IPC4_PIPE_RESET || state == SOF_IPC4_PIPE_EOS ||
510+
cmd == SNDRV_PCM_TRIGGER_PAUSE_RELEASE)
504511
goto skip_pause_transition;
505512

506513
/*
@@ -602,6 +609,10 @@ static int sof_ipc4_pcm_trigger(struct snd_soc_component *component,
602609
case SNDRV_PCM_TRIGGER_STOP:
603610
state = SOF_IPC4_PIPE_PAUSED;
604611
break;
612+
case SND_COMPR_TRIGGER_DRAIN:
613+
case SND_COMPR_TRIGGER_PARTIAL_DRAIN:
614+
state = SOF_IPC4_PIPE_EOS;
615+
break;
605616
default:
606617
dev_err(component->dev, "%s: unhandled trigger cmd %d\n", __func__, cmd);
607618
return -EINVAL;

0 commit comments

Comments
 (0)