Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/audio/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct dai_data {
int xrun; /* true if we are doing xrun recovery */

uint32_t dai_pos_blks; /* position in bytes (nearest block) */
uint64_t start_position; /* position on start */

/* host can read back this value without IPC */
uint64_t *dai_pos;
Expand Down Expand Up @@ -487,6 +488,17 @@ static int dai_reset(struct comp_dev *dev)
return 0;
}

static void dai_update_start_position(struct comp_dev *dev)
{
struct dai_data *dd = comp_get_drvdata(dev);

/* update starting wallclock */
platform_dai_wallclock(dev, &dd->wallclock);

/* update start position */
dd->start_position = dev->position;
}

/* used to pass standard and bespoke command (with data) to component */
static int dai_comp_trigger(struct comp_dev *dev, int cmd)
{
Expand Down Expand Up @@ -520,8 +532,7 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd)
dd->xrun = 0;
}

/* update starting wallclock */
platform_dai_wallclock(dev, &dd->wallclock);
dai_update_start_position(dev);
break;
case COMP_TRIGGER_RELEASE:
/* before release, we clear the buffer data to 0s,
Expand All @@ -547,8 +558,7 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd)
dd->xrun = 0;
}

/* update starting wallclock */
platform_dai_wallclock(dev, &dd->wallclock);
dai_update_start_position(dev);
break;
case COMP_TRIGGER_XRUN:
trace_dai_with_ids(dev, "dai_comp_trigger(), XRUN");
Expand Down Expand Up @@ -578,7 +588,7 @@ static int dai_check_for_xrun(struct comp_dev *dev, uint32_t copy_bytes)
return 0;

/* no data yet, we're just starting */
if (!dev->position)
if (dd->start_position == dev->position)
return PPL_STATUS_PATH_STOP;

/* xrun occurred */
Expand Down Expand Up @@ -616,7 +626,7 @@ static int dai_copy(struct comp_dev *dev)
ret = dma_start(dd->chan);
if (ret < 0)
return ret;
platform_dai_wallclock(dev, &dd->wallclock);
dai_update_start_position(dev);

return 0;
}
Expand Down