Skip to content
Closed
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
17 changes: 16 additions & 1 deletion src/drivers/intel/ssp/ssp.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,18 @@ static void ssp_empty_rx_fifo(struct dai *dai)
uint64_t sample_ticks = clock_ticks_per_sample(PLATFORM_DEFAULT_CLOCK,
ssp->params.fsync_rate);
uint32_t retry = SSP_RX_FLUSH_RETRY_MAX;
bool read_ssdr = ssp->state[DAI_DIR_CAPTURE] <= COMP_STATE_PREPARE;
uint32_t entries;
uint32_t i;

#if CONFIG_DMA_SUSPEND_DRAIN
/*
* in drain mode, DMA is stopped before DAI,
* so flush must be done with direct register read
*/
read_ssdr = true;
#endif

/*
* To make sure all the RX FIFO entries are read out for the flushing,
* we need to wait a minimal SSP port delay after entries are all read,
Expand All @@ -87,7 +96,8 @@ static void ssp_empty_rx_fifo(struct dai *dai)
while ((ssp_read(dai, SSSR) & SSSR_RNE) && retry--) {
entries = SSCR3_RFL_VAL(ssp_read(dai, SSCR3));
dai_dbg(dai, "ssp_empty_rx_fifo(), before flushing, entries %d", entries);
for (i = 0; i < entries + 1; i++)

for (i = 0; read_ssdr && i < entries + 1; i++)
/* read to try empty fifo */
ssp_read(dai, SSDR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for readability I would be more explicit:

if (read_ssdr) {
	/* read to try empty fifo */
	for (i = 0; i < entries + 1; i++)
		ssp_read(dai, SSDR);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not just readability, there's no reason to test read_ssdr at every loop - though the compiler might be smart enough to move this up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the mainline version #7577 -- will resubmit to stable-2.2 once merged.


Expand Down Expand Up @@ -963,6 +973,11 @@ static void ssp_early_start(struct dai *dai, int direction)

key = k_spin_lock(&dai->lock);

if (direction == DAI_DIR_CAPTURE) {
/* RX fifo must be cleared before start */
ssp_empty_rx_fifo(dai);
}

/* request mclk/bclk */
ssp_pre_start(dai);

Expand Down