Commit 6570f991 authored by Lad Prabhakar's avatar Lad Prabhakar Committed by Mark Brown

ASoC: sh: rz-ssi: Drop calling rz_ssi_pio_recv() recursively

Instead of recursively calling rz_ssi_pio_recv() use a while loop
to read the samples from RX fifo.

This also fixes an issue where the return value of rz_ssi_pio_recv()
was ignored when called recursively.

Fixes: 03e786bd ("ASoC: sh: Add RZ/G2L SSIF-2 driver")
Reported-by: default avatarPavel Machek <pavel@denx.de>
Signed-off-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20220110094711.8574-2-prabhakar.mahadev-lad.rj@bp.renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6cbff4b3
...@@ -411,20 +411,23 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) ...@@ -411,20 +411,23 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
{ {
struct snd_pcm_substream *substream = strm->substream; struct snd_pcm_substream *substream = strm->substream;
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
bool done = false;
u16 *buf; u16 *buf;
int fifo_samples; int fifo_samples;
int frames_left; int frames_left;
int samples = 0; int samples;
int i; int i;
if (!rz_ssi_stream_is_valid(ssi, strm)) if (!rz_ssi_stream_is_valid(ssi, strm))
return -EINVAL; return -EINVAL;
runtime = substream->runtime; runtime = substream->runtime;
while (!done) {
/* frames left in this period */ /* frames left in this period */
frames_left = runtime->period_size - (strm->buffer_pos % frames_left = runtime->period_size -
runtime->period_size); (strm->buffer_pos % runtime->period_size);
if (frames_left == 0) if (!frames_left)
frames_left = runtime->period_size; frames_left = runtime->period_size;
/* Samples in RX FIFO */ /* Samples in RX FIFO */
...@@ -432,6 +435,7 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) ...@@ -432,6 +435,7 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
SSIFSR_RDC_SHIFT) & SSIFSR_RDC_MASK; SSIFSR_RDC_SHIFT) & SSIFSR_RDC_MASK;
/* Only read full frames at a time */ /* Only read full frames at a time */
samples = 0;
while (frames_left && (fifo_samples >= runtime->channels)) { while (frames_left && (fifo_samples >= runtime->channels)) {
samples += runtime->channels; samples += runtime->channels;
fifo_samples -= runtime->channels; fifo_samples -= runtime->channels;
...@@ -439,8 +443,8 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) ...@@ -439,8 +443,8 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
} }
/* not enough samples yet */ /* not enough samples yet */
if (samples == 0) if (!samples)
return 0; break;
/* calculate new buffer index */ /* calculate new buffer index */
buf = (u16 *)(runtime->dma_area); buf = (u16 *)(runtime->dma_area);
...@@ -453,12 +457,10 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) ...@@ -453,12 +457,10 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
rz_ssi_reg_mask_setl(ssi, SSIFSR, SSIFSR_RDF, 0); rz_ssi_reg_mask_setl(ssi, SSIFSR, SSIFSR_RDF, 0);
rz_ssi_pointer_update(strm, samples / runtime->channels); rz_ssi_pointer_update(strm, samples / runtime->channels);
/* /* check if there are no more samples in the RX FIFO */
* If we finished this period, but there are more samples in if (!(!frames_left && fifo_samples >= runtime->channels))
* the RX FIFO, call this function again done = true;
*/ }
if (frames_left == 0 && fifo_samples >= runtime->channels)
rz_ssi_pio_recv(ssi, strm);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment