mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: lx6464es: fix period byte count for 16-bit streams
@ 2026-07-23  8:57 raoxu
  2026-07-26  6:53 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-07-23  8:57 UTC (permalink / raw)
  To: perex; +Cc: tiwai, rongqianfeng, raoxu, linux-sound, linux-kernel, stable

From: Xu Rao <raoxu@uniontech.com>

The lx6464es driver advertises both 16-bit and packed 24-bit PCM formats,
but lx_trigger_start() and lx_interrupt_request_new_buffer() calculate the
DMA period size as runtime->period_size * runtime->channels * 3.  That is
only correct for the packed 24-bit formats.

For 16-bit streams the driver submits buffers that are 50% larger than the
actual ALSA period and advances the DMA address by the same wrong amount.
For example, with 2 channels, 256 frames and 4 periods, the third buffer
already extends beyond the ALSA buffer and the fourth buffer starts outside
it.

Use snd_pcm_lib_period_bytes() so the byte count matches the runtime
format, channel count and period size.

Fixes: 02bec4904508 ("ALSA: lx6464es - driver for the digigram lx6464es interface")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
 sound/pci/lx6464es/lx6464es.c | 5 +----
 sound/pci/lx6464es/lx_core.c  | 5 +----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 96df00db51d5..3b40ec071379 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -402,11 +402,8 @@ static void lx_trigger_start(struct lx6464es *chip, struct lx_stream *lx_stream)

 	int err;

-	const u32 channels = substream->runtime->channels;
-	const u32 bytes_per_frame = channels * 3;
-	const u32 period_size = substream->runtime->period_size;
 	const u32 periods = substream->runtime->periods;
-	const u32 period_bytes = period_size * bytes_per_frame;
+	const u32 period_bytes = snd_pcm_lib_period_bytes(substream);

 	dma_addr_t buf = substream->dma_buffer.addr;
 	int i;
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
index 6f0843cfb3be..9909f1067871 100644
--- a/sound/pci/lx6464es/lx_core.c
+++ b/sound/pci/lx6464es/lx_core.c
@@ -969,10 +969,7 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip,
 	const unsigned int is_capture = lx_stream->is_capture;
 	int err;

-	const u32 channels = substream->runtime->channels;
-	const u32 bytes_per_frame = channels * 3;
-	const u32 period_size = substream->runtime->period_size;
-	const u32 period_bytes = period_size * bytes_per_frame;
+	const u32 period_bytes = snd_pcm_lib_period_bytes(substream);
 	const u32 pos = lx_stream->frame_pos;
 	const u32 next_pos = ((pos+1) == substream->runtime->periods) ?
 		0 : pos + 1;
--
2.50.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: lx6464es: fix period byte count for 16-bit streams
  2026-07-23  8:57 [PATCH] ALSA: lx6464es: fix period byte count for 16-bit streams raoxu
@ 2026-07-26  6:53 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-07-26  6:53 UTC (permalink / raw)
  To: raoxu; +Cc: perex, tiwai, rongqianfeng, linux-sound, linux-kernel, stable

On Thu, 23 Jul 2026 10:57:10 +0200,
raoxu wrote:
> 
> From: Xu Rao <raoxu@uniontech.com>
> 
> The lx6464es driver advertises both 16-bit and packed 24-bit PCM formats,
> but lx_trigger_start() and lx_interrupt_request_new_buffer() calculate the
> DMA period size as runtime->period_size * runtime->channels * 3.  That is
> only correct for the packed 24-bit formats.
> 
> For 16-bit streams the driver submits buffers that are 50% larger than the
> actual ALSA period and advances the DMA address by the same wrong amount.
> For example, with 2 channels, 256 frames and 4 periods, the third buffer
> already extends beyond the ALSA buffer and the fourth buffer starts outside
> it.
> 
> Use snd_pcm_lib_period_bytes() so the byte count matches the runtime
> format, channel count and period size.
> 
> Fixes: 02bec4904508 ("ALSA: lx6464es - driver for the digigram lx6464es interface")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Rao <raoxu@uniontech.com>

Thanks, applied now.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-26  6:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-23  8:57 [PATCH] ALSA: lx6464es: fix period byte count for 16-bit streams raoxu
2026-07-26  6:53 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®