Skip to content

Commit b6edaad

Browse files
committed
audio: dai-zephyr: minor cleanup of xrun handling code
Some minor improvements to make the xrun handling code easier to follow. The current implementation is checking for DAI DMA overrun/underrun conditions both at start of a copy callback (using data from DMA driver dma_get_status()), as well as at end of copy callback (using dma_reload()). There is also two separate mechanisms to report xruns, one specific to IPC4 (CONFIG_XRUN_NOTIFICATIONS_ENABLE) and one common method using component.h interface (comp_underrun() and comp_underrun()). Add documentation to the xrun helper functions and rename dai_report_xrun() to dai_report_reload_xrun() to better reflect the actual implementation. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 28d4665 commit b6edaad

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/audio/dai-zephyr.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,13 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd)
14681468
return dai_common_trigger(dd, dev, cmd);
14691469
}
14701470

1471-
/* get status from dma and check for xrun */
1471+
/**
1472+
* Get status from the DMA driver.
1473+
*
1474+
* After status call, a check for xrun condition is done and
1475+
* depending on configuration, a xrun report is optionally sent.
1476+
* See also xrun reporting done in dai_report_reload_xrun().
1477+
*/
14721478
static int dai_get_status(struct comp_dev *dev, struct dai_data *dd, struct dma_status *stat)
14731479
{
14741480
int ret = sof_dma_get_status(dd->chan->dma, dd->chan->index, stat);
@@ -1494,8 +1500,13 @@ static int dai_get_status(struct comp_dev *dev, struct dai_data *dd, struct dma_
14941500
return ret;
14951501
}
14961502

1497-
/* report xrun occurrence */
1498-
static void dai_report_xrun(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes)
1503+
/**
1504+
* Report xrun occurrence after DAI DMA driver reports
1505+
* an error for a reload attempt of 'bytes' of data.
1506+
*
1507+
* See also xrun detection done in dai_get_status().
1508+
*/
1509+
static void dai_report_reload_xrun(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes)
14991510
{
15001511
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
15011512
comp_err(dev, "underrun due to no data available");
@@ -1584,7 +1595,7 @@ int dai_zephyr_multi_endpoint_copy(struct dai_data **dd, struct comp_dev *dev,
15841595
for (i = 0; i < num_endpoints; i++) {
15851596
ret = sof_dma_reload(dd[i]->chan->dma, dd[i]->chan->index, 0);
15861597
if (ret < 0) {
1587-
dai_report_xrun(dd[i], dev, 0);
1598+
dai_report_reload_xrun(dd[i], dev, 0);
15881599
return ret;
15891600
}
15901601
}
@@ -1613,7 +1624,7 @@ int dai_zephyr_multi_endpoint_copy(struct dai_data **dd, struct comp_dev *dev,
16131624
copy_bytes = frames * audio_stream_frame_bytes(&dd[i]->dma_buffer->stream);
16141625
ret = sof_dma_reload(dd[i]->chan->dma, dd[i]->chan->index, copy_bytes);
16151626
if (ret < 0) {
1616-
dai_report_xrun(dd[i], dev, copy_bytes);
1627+
dai_report_reload_xrun(dd[i], dev, copy_bytes);
16171628
return ret;
16181629
}
16191630

@@ -1814,7 +1825,7 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
18141825

18151826
ret = sof_dma_reload(dd->chan->dma, dd->chan->index, copy_bytes);
18161827
if (ret < 0) {
1817-
dai_report_xrun(dd, dev, copy_bytes);
1828+
dai_report_reload_xrun(dd, dev, copy_bytes);
18181829
return ret;
18191830
}
18201831

0 commit comments

Comments
 (0)