sof icon indicating copy to clipboard operation
sof copied to clipboard

[FEATURE] Implement DRAIN for compress audio pipeline

Open dbaluta opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe.

Implement compress API drain

Describe the solution you'd like

Compress API provides SNDRV_PCM_TRIGGER_DRAIN and SOF also offers command SOF_IPC_STREAM_TRIG_DRAIN but we need to implement the actual functionality both in Linux kernel driver and SOF FW

Linux kernel:

  • forwards SOF_IPC_STREAM_TRIG_DRAIN to FW and waits (?) for FW to confirm that drain is done

SOF firmware:

  • module adapter (?) implements drain.

Edit: @LaurentiuM1234 @dbaluta @plbossart @ranj063 I'm trying to find initial ideas on how to implement DRAIN for compress audio.

dbaluta avatar Aug 04 '22 08:08 dbaluta

Main questions here:

  1. How does the kernel know that DRAIN has finished?
  2. Do we need a new IPC from FW to Linux kernel driver to announce that drain has finished?

dbaluta avatar Aug 04 '22 11:08 dbaluta

@dbaluta fwiw, IPC4 does have a pipeline state change IPC to indicate the drain has stopped, but we need to add this to ipc3 too.

lgirdwood avatar Aug 04 '22 12:08 lgirdwood

@lgirdwood do you mean End Of Stream state?

src/ipc/ipc4/handler.c


/* Ipc4 pipeline message <------> ipc3 pipeline message
 * RUNNING     <-------> TRIGGER START
 * INIT + PAUSED  <-------> PIPELINE COMPLETE
 * INIT + RESET <-------> PIPELINE COMPLETE
 * PAUSED      <-------> TRIGER_PAUSE
 * RESET       <-------> TRIGER_STOP + RESET
 * EOS(end of stream) <-------> NOT SUPPORT NOW                                                                                                                                                                    
 *
 *   IPC4 pipeline state machine
 *
 *                      INIT
 *                       |    \
 *                       |   __\|
 *                       |
 *                       |     RESET
 *                       |     _   _
 *                       |     /| |\
 *                       |    /    /\
 *                      \|/ |/_   /  \
 *        RUNNING <--> PAUSE _   /    \
 *            /  \      /|\ |\  /      \
 *           /    \      |    \/        \
 *          /      \     |    /\         \
 *         /        \    |   /  \         \
 *       |/_        _\|  |  /    \        _\|
 *     ERROR Stop       EOS       |______\ SAVE
 *                                      /
 */

dbaluta avatar Aug 04 '22 16:08 dbaluta

@lgirdwood do you mean End Of Stream state?

src/ipc/ipc4/handler.c


/* Ipc4 pipeline message <------> ipc3 pipeline message
 * RUNNING     <-------> TRIGGER START
 * INIT + PAUSED  <-------> PIPELINE COMPLETE
 * INIT + RESET <-------> PIPELINE COMPLETE
 * PAUSED      <-------> TRIGER_PAUSE
 * RESET       <-------> TRIGER_STOP + RESET
 * EOS(end of stream) <-------> NOT SUPPORT NOW                                                                                                                                                                    
 *
 *   IPC4 pipeline state machine
 *
 *                      INIT
 *                       |    \
 *                       |   __\|
 *                       |
 *                       |     RESET
 *                       |     _   _
 *                       |     /| |\
 *                       |    /    /\
 *                      \|/ |/_   /  \
 *        RUNNING <--> PAUSE _   /    \
 *            /  \      /|\ |\  /      \
 *           /    \      |    \/        \
 *          /      \     |    /\         \
 *         /        \    |   /  \         \
 *       |/_        _\|  |  /    \        _\|
 *     ERROR Stop       EOS       |______\ SAVE
 *                                      /
 */

Yes, a similar IPC3 mechanism could be used to indicate "I've finished playing the stream"

lgirdwood avatar Aug 10 '22 14:08 lgirdwood