mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
ASoC: stm32: dfsdm: fix 16 bits record
In stm32_afsdm_pcm_cb function, the transfer size is provided in bytes.
However, samples are copied as 16 bits words from iio buffer.
Divide by two the transfer size, to copy the right number of samples.
Fixes: 1e7f6e1c69
("ASoC: stm32: dfsdm: add 16 bits audio record support")
Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Link: https://lore.kernel.org/r/20200110131131.3191-1-olivier.moysan@st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
a14bf98c04
commit
8e55ea1912
1 changed files with 6 additions and 6 deletions
|
@ -153,13 +153,13 @@ static const struct snd_soc_component_driver stm32_adfsdm_dai_component = {
|
|||
.name = "stm32_dfsdm_audio",
|
||||
};
|
||||
|
||||
static void memcpy_32to16(void *dest, const void *src, size_t n)
|
||||
static void stm32_memcpy_32to16(void *dest, const void *src, size_t n)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
u16 *d = (u16 *)dest, *s = (u16 *)src;
|
||||
|
||||
s++;
|
||||
for (i = n; i > 0; i--) {
|
||||
for (i = n >> 1; i > 0; i--) {
|
||||
*d++ = *s++;
|
||||
s++;
|
||||
}
|
||||
|
@ -186,8 +186,8 @@ static int stm32_afsdm_pcm_cb(const void *data, size_t size, void *private)
|
|||
|
||||
if ((priv->pos + src_size) > buff_size) {
|
||||
if (format == SNDRV_PCM_FORMAT_S16_LE)
|
||||
memcpy_32to16(&pcm_buff[priv->pos], src_buff,
|
||||
buff_size - priv->pos);
|
||||
stm32_memcpy_32to16(&pcm_buff[priv->pos], src_buff,
|
||||
buff_size - priv->pos);
|
||||
else
|
||||
memcpy(&pcm_buff[priv->pos], src_buff,
|
||||
buff_size - priv->pos);
|
||||
|
@ -196,8 +196,8 @@ static int stm32_afsdm_pcm_cb(const void *data, size_t size, void *private)
|
|||
}
|
||||
|
||||
if (format == SNDRV_PCM_FORMAT_S16_LE)
|
||||
memcpy_32to16(&pcm_buff[priv->pos],
|
||||
&src_buff[src_size - cur_size], cur_size);
|
||||
stm32_memcpy_32to16(&pcm_buff[priv->pos],
|
||||
&src_buff[src_size - cur_size], cur_size);
|
||||
else
|
||||
memcpy(&pcm_buff[priv->pos], &src_buff[src_size - cur_size],
|
||||
cur_size);
|
||||
|
|
Loading…
Reference in a new issue