dai-zephyr: Fix the ordering of DAI and DMA triggers

During start trigger, the DMA is be started first followed by the DAI. The
same order should also apply for the release triggers. Conversely, during
stop/pause the DAI must be stopped first before the DMA.

But some platforms cannot handle the conventional ordering during the
stop/pause triggers. Add a new config,
COMP_DAI_STOP_TRIGGER_ORDER_REVERSE, that will be used to reverse the
DMA and DAI trigger order during stop/pause. Also, fix the stop case to
use the new config to reverse the ordering instead of
COMP_DMA_SUSPEND_DRAIN.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This commit is contained in:
Ranjani Sridharan 2023-03-16 14:52:50 -07:00 committed by Kai Vehmanen
parent 56abcade56
commit a6a80ec97a
2 changed files with 21 additions and 4 deletions

View File

@ -20,6 +20,13 @@ config COMP_DAI
help
Select for DAI component
config COMP_DAI_STOP_TRIGGER_ORDER_REVERSE
bool "Reverse the ordering of DMA and DAI triggers during STOP/PAUSE"
help
Select if the ordering of DMA and DAI triggers during stop/pause should be reversed.
The normal order during stop/pause is to stop DAI before stopping DMA. This option will
allow reversing the order to do DMA stop before stopping DAI.
config COMP_DAI_GROUP
bool "DAI Grouping support"
default y

View File

@ -1066,11 +1066,12 @@ static int dai_comp_trigger_internal(struct comp_dev *dev, int cmd)
if (ret < 0)
return ret;
/* start the DAI */
dai_trigger_op(dd->dai, cmd, dev->direction);
ret = dma_start(dd->chan->dma->z_dev, dd->chan->index);
if (ret < 0)
return ret;
/* start the DAI */
dai_trigger_op(dd->dai, cmd, dev->direction);
} else {
dd->xrun = 0;
}
@ -1092,7 +1093,7 @@ static int dai_comp_trigger_internal(struct comp_dev *dev, int cmd)
* drain the FIFO in order to stop the channel
* as soon as possible.
*/
#if CONFIG_DMA_SUSPEND_DRAIN
#if CONFIG_COMP_DAI_TRIGGER_ORDER_REVERSE
ret = dma_stop(dd->chan->dma->z_dev, dd->chan->index);
dai_trigger_op(dd->dai, cmd, dev->direction);
#else
@ -1106,14 +1107,23 @@ static int dai_comp_trigger_internal(struct comp_dev *dev, int cmd)
break;
case COMP_TRIGGER_PAUSE:
comp_dbg(dev, "dai_comp_trigger_internal(), PAUSE");
#if CONFIG_COMP_DAI_TRIGGER_ORDER_REVERSE
if (prev_state == COMP_STATE_ACTIVE) {
ret = dma_suspend(dd->chan->dma->z_dev, dd->chan->index);
} else {
comp_warn(dev, "dma was stopped earlier");
ret = 0;
}
dai_trigger_op(dd->dai, cmd, dev->direction);
#else
dai_trigger_op(dd->dai, cmd, dev->direction);
if (prev_state == COMP_STATE_ACTIVE) {
ret = dma_suspend(dd->chan->dma->z_dev, dd->chan->index);
} else {
comp_warn(dev, "dma was stopped earlier");
ret = 0;
}
#endif
break;
case COMP_TRIGGER_PRE_START:
case COMP_TRIGGER_PRE_RELEASE: