Skip to content

Commit 9018bc4

Browse files
softwareckikv2019i
authored andcommitted
zephyr: dai: Add support for xrun notifications in dai
Add support to dai for sending ipc4 notifications when dma reports an underrun/overrun occurrence. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent c11934d commit 9018bc4

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/audio/dai-zephyr.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
#include <stddef.h>
3737
#include <stdint.h>
3838

39+
#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
40+
#include <sof/ipc/notification_pool.h>
41+
#include <ipc4/notification.h>
42+
#endif
43+
3944
#include "copier/copier.h"
4045
#include "copier/dai_copier.h"
4146
#include "copier/copier_gain.h"
@@ -1462,6 +1467,32 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd)
14621467
return dai_common_trigger(dd, dev, cmd);
14631468
}
14641469

1470+
/* get status from dma and check for xrun */
1471+
static int dai_get_status(struct comp_dev *dev, struct dai_data *dd, struct dma_status *stat)
1472+
{
1473+
int ret = dma_get_status(dd->chan->dma->z_dev, dd->chan->index, stat);
1474+
#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
1475+
if (ret == -EPIPE && !dd->xrun_notification_sent) {
1476+
struct ipc_msg *notify = ipc_notification_pool_get(IPC4_RESOURCE_EVENT_SIZE);
1477+
1478+
if (notify) {
1479+
if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
1480+
copier_gateway_underrun_notif_msg_init(notify,
1481+
dev->pipeline->pipeline_id);
1482+
else
1483+
copier_gateway_overrun_notif_msg_init(notify,
1484+
dev->pipeline->pipeline_id);
1485+
1486+
ipc_msg_send(notify, notify->tx_data, false);
1487+
dd->xrun_notification_sent = true;
1488+
}
1489+
} else if (!ret) {
1490+
dd->xrun_notification_sent = false;
1491+
}
1492+
#endif
1493+
return ret;
1494+
}
1495+
14651496
/* report xrun occurrence */
14661497
static void dai_report_xrun(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes)
14671498
{
@@ -1499,7 +1530,7 @@ int dai_zephyr_multi_endpoint_copy(struct dai_data **dd, struct comp_dev *dev,
14991530
struct dma_status stat;
15001531

15011532
/* get data sizes from DMA */
1502-
ret = dma_get_status(dd[i]->chan->dma->z_dev, dd[i]->chan->index, &stat);
1533+
ret = dai_get_status(dev, dd[i], &stat);
15031534
switch (ret) {
15041535
case 0:
15051536
break;
@@ -1633,7 +1664,7 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
16331664
int ret;
16341665

16351666
/* get data sizes from DMA */
1636-
ret = dma_get_status(dd->chan->dma->z_dev, dd->chan->index, &stat);
1667+
ret = dai_get_status(dev, dd, &stat);
16371668
switch (ret) {
16381669
case 0:
16391670
break;

src/include/sof/lib/dai-zephyr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ struct dai_data {
158158
struct llp_slot_info slot_info;
159159
/* fast mode, use one byte memory to save repreated cycles */
160160
bool fast_mode;
161+
#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
162+
bool xrun_notification_sent;
163+
#endif
161164
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
162165
/* io performance measurement */
163166
struct io_perf_data_item *io_perf_bytes_count;

0 commit comments

Comments
 (0)