Skip to content

Conversation

@LaurentiuM1234
Copy link

This is a rough attempt of adding support for the drain operation on compress streams.

Added new ipc stream structure that will be used by the FW
in order to notify the host that the drain operation is done.

For the moment, the structure contains only the reply header
since that's the only information we care about but, by
adding a new ipc stream structure, we can send more information
from FW regarding the drain operation if need be.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Since we want to notify the host when the drain operation is
done in the FW, this change will enable the FW to send an IPC
message to the host in order to signal that the draining is
done.

Upon receiving the notification, the host signals to ALSA's
compress-offload API that the draining is over so it can
continue its workflow.

As of now, the drain operation is only implemented for
compress streams.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
The purpose of this change is to allow the compress API
to send the TRIG_DRAIN IPC message to the FW so it can
start the draining operation.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
break;
case SNDRV_PCM_TRIGGER_DRAIN:
stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_DRAIN;
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably need a different behavior for capture and playback.

From the alsa-lib PCM documentation https://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#ga49afc5b8527f30c33fafa476533c9f86

"
For playback wait for all pending frames to be played and then stop the PCM. For capture stop PCM permitting to retrieve residual frames.
"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, most likely so

* reply then the drain operation finished successfully.
*/
if (spcm->pcm.compress)
snd_compr_drain_notify(stream->cstream);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what happens when the drain is finished? Don't we need a TRIGGER_STOP or something?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drain can be possible without stop if there are somehow two consecutive streams being fed, you do a partial drain for the first stream before starting the next one (useful for gapless playback I guess? Not 100% sure). I'd guess stop should wait until a drain finishes though.

@LaurentiuM1234
Copy link
Author

Closing this for now because it's really bad. Will reopen when I'll have a more solid solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants