[RFC PATCH 4/5] ALSA: quantum: preallocate enough buffer for two full periods

From: Miles Ramage

Date: Tue Dec 01 2026 - 23:23:52 EST


ALSA limits the buffer to the preallocated size, 64 KiB. That is 630
frames at 26 channels and 910 at 18, so a client asking for 512-frame
periods cannot get two of them, and hw_params fails:

speaker-test -D hw:Quantum2626 -c 18 -r 96000 -F S32_LE
Buffer size range from 64 to 910
...
Setting of hwparams failed: Invalid argument

Preallocate 2 MiB per substream. That covers the ~250 ms buffers the
vendor Windows driver uses in every speed band (12032 frames x 26
channels at 48 kHz, 24064 x 18 at 96 kHz, 48128 x 8 at 192 kHz).

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Miles Ramage <miles.ramage@xxxxxxxxx>
---
sound/pci/quantum/quantum_pcm.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/pci/quantum/quantum_pcm.c b/sound/pci/quantum/quantum_pcm.c
index 5575072..2891974 100644
--- a/sound/pci/quantum/quantum_pcm.c
+++ b/sound/pci/quantum/quantum_pcm.c
@@ -644,8 +644,14 @@ int snd_quantum_pcm_new(struct quantum_chip *chip)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
&quantum_ops);

+ /*
+ * ALSA caps the buffer at the preallocated size. 64 KiB allowed only
+ * 630 frames at 26 channels and 910 at 18, too few for two 512-frame
+ * periods. 2 MiB covers the ~250 ms buffers the vendor driver uses in
+ * every speed band.
+ */
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
- &chip->pci->dev, 64 * 1024,
+ &chip->pci->dev, 2 * 1024 * 1024,
16 * 1024 * 1024);

return 0;
--
2.56.1