Skip to content

Commit 8e55ea1

Browse files
Olivier Moysanbroonie
authored andcommitted
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: 1e7f6e1 ("ASoC: stm32: dfsdm: add 16 bits audio record support") Signed-off-by: Olivier Moysan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a14bf98 commit 8e55ea1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sound/soc/stm/stm32_adfsdm.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ static const struct snd_soc_component_driver stm32_adfsdm_dai_component = {
153153
.name = "stm32_dfsdm_audio",
154154
};
155155

156-
static void memcpy_32to16(void *dest, const void *src, size_t n)
156+
static void stm32_memcpy_32to16(void *dest, const void *src, size_t n)
157157
{
158158
unsigned int i = 0;
159159
u16 *d = (u16 *)dest, *s = (u16 *)src;
160160

161161
s++;
162-
for (i = n; i > 0; i--) {
162+
for (i = n >> 1; i > 0; i--) {
163163
*d++ = *s++;
164164
s++;
165165
}
@@ -186,8 +186,8 @@ static int stm32_afsdm_pcm_cb(const void *data, size_t size, void *private)
186186

187187
if ((priv->pos + src_size) > buff_size) {
188188
if (format == SNDRV_PCM_FORMAT_S16_LE)
189-
memcpy_32to16(&pcm_buff[priv->pos], src_buff,
190-
buff_size - priv->pos);
189+
stm32_memcpy_32to16(&pcm_buff[priv->pos], src_buff,
190+
buff_size - priv->pos);
191191
else
192192
memcpy(&pcm_buff[priv->pos], src_buff,
193193
buff_size - priv->pos);
@@ -196,8 +196,8 @@ static int stm32_afsdm_pcm_cb(const void *data, size_t size, void *private)
196196
}
197197

198198
if (format == SNDRV_PCM_FORMAT_S16_LE)
199-
memcpy_32to16(&pcm_buff[priv->pos],
200-
&src_buff[src_size - cur_size], cur_size);
199+
stm32_memcpy_32to16(&pcm_buff[priv->pos],
200+
&src_buff[src_size - cur_size], cur_size);
201201
else
202202
memcpy(&pcm_buff[priv->pos], &src_buff[src_size - cur_size],
203203
cur_size);

0 commit comments

Comments
 (0)