Skip to content

Commit

Permalink
ASoC: Fix Blackfin I2S _pointer() implementation return in bounds values
Browse files Browse the repository at this point in the history
The Blackfin DMA controller can report one frame beyond the end of the
buffer in the wraparound case but ALSA requires that the pointer always
be in the buffer. Do the wraparound to handle this. A similar bug is
likely to apply to the other Blackfin PCM drivers but the code is less
obvious to inspection and I don't have a user to test.

Reported-by: Kieran O'Leary <Kieran.O'Leary@wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@kernel.org
  • Loading branch information
Mark Brown committed Jun 29, 2011
1 parent 53dea36 commit e999dc5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sound/soc/blackfin/bf5xx-i2s-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,20 @@ static snd_pcm_uframes_t bf5xx_pcm_pointer(struct snd_pcm_substream *substream)
pr_debug("%s enter\n", __func__);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
diff = sport_curr_offset_tx(sport);
frames = bytes_to_frames(substream->runtime, diff);
} else {
diff = sport_curr_offset_rx(sport);
frames = bytes_to_frames(substream->runtime, diff);
}

/*
* TX at least can report one frame beyond the end of the
* buffer if we hit the wraparound case - clamp to within the
* buffer as the ALSA APIs require.
*/
if (diff == snd_pcm_lib_buffer_bytes(substream))
diff = 0;

frames = bytes_to_frames(substream->runtime, diff);

return frames;
}

Expand Down

0 comments on commit e999dc5

Please sign in to comment.