From: Miles Ramage <miles.ramage@yahoo.com>
To: Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Jamie Steele <steele.jamie1991@gmail.com>,
Miles Ramage <miles.ramage@yahoo.com>
Subject: [RFC PATCH 0/5] ALSA: quantum: fix high sample rates and duplex attach
Date: Tue, 1 Dec 2026 22:22:26 -0600 [thread overview]
Message-ID: <20261202042231.42930-1-miles.ramage@yahoo.com> (raw)
In-Reply-To: <59ad0f62-dd4c-4d42-b50a-ab91bf469fb7@gmail.com>
Hi Nicholas, Jamie,
This series answers Jamie's question about rate switching on the
Quantum 2626 [1]. It applies on top of RFC v1 [2], not mainline:
b4 am 20260820083646.11383-1-nicholas.johnson-opensource@outlook.com.au
With it applied, the 2626 plays at all six rates, and capture and full
duplex work at 48, 96 and 192 kHz. Without it, the device stays at
48 kHz whatever rate is requested, which matches Jamie's report of
~48,000 frames/s at 96 kHz and a 10 s playback taking about 20 s.
The protocol details come from black-box observation: QEMU trace logs
of a 2626 passed through (VFIO) to a Windows guest running the vendor
driver, which record every BAR0 access [3]. No vendor code was
disassembled or copied.
What was wrong
==============
1. Set-rate request (patch 1). The 0x32 request carries the clock
source and a rate code (1 = 44.1 kHz ... 6 = 192 kHz), two u32s,
and is answered with a status word. The RFC sends the rate in Hz as
one u32. In the Windows trace the request is 16 bytes and the status
reply arrives 210-250 ms later. With the patch, Linux produces the
same message sequence: a 16-byte request, a 12-byte status reply
about 225 ms later, then the get-rate read-back.
2. Cached rate (patch 2). The driver assumed 48 kHz at probe, but the
device keeps its rate across driver loads, so a request for 48 kHz
could be skipped. The clock-status event (0x32/0x33) also carries a
rate code, not Hz ("source=0 rate=4" after a switch to 96 kHz), and
was cached as the rate.
3. Channel count (patch 3). Channel-count register 0x10200 reads 0x1a1a,
0x1212 and 0x0808 in the three speed bands: 26, 18 and 8 channels,
from ADAT S/MUX. Windows streams at those widths. pcm_open() only
accepted 26, so a device left at 96 kHz could not be opened at all.
The patch ties channels and rate together with hw rules and waits
for the register to match after a rate change.
4. Buffer size (patch 4). The 64 KiB preallocation capped the buffer
at 630 frames with 26 channels and 910 with 18, too small for two
512-frame periods. hw_params failed at 96 kHz.
5. Duplex attach (patch 5). A direction started while the other was
running waited until the sampled DMA position was exactly frame 0.
That position is sampled a few frames late, so it was rarely zero,
and ALSA timed out after 100 ms (arecord: "read error:
Input/output error"). The patch detects the wrap from the cycle
counter instead. This bug affects every rate.
Testing
=======
Quantum 2626 (1c67:0104), Fedora 45, kernel 7.3.6, internal clock.
- Playback at 44.1, 48, 88.2, 96, 176.4 and 192 kHz (speaker-test,
26/18/8 channels), including switching 48 -> 96 -> 192 kHz and back
down.
- Capture and full duplex at 48, 96 and 192 kHz, plus capture started
while playback was already running.
- Loopback with a balanced cable from line out 3 to line in 3, playing
a 1 kHz sine. At 96 kHz, through direct ALSA (512/1536 frames,
duplex) and through PipeWire: no missing or repeated samples, THD+N
-88 dB, harmonics below -104 dB. At 192 kHz through PipeWire: no
missing or repeated samples, harmonics below -104 dB.
- PipeWire Pro Audio with a JACK-client amp simulator, at 96 and
192 kHz.
All patches build cleanly with W=1 and pass checkpatch --strict.
Known limitations and questions
===============================
1. PipeWire and rate-dependent channel counts. PipeWire's Pro Audio
nodes fix their channel count when they are created. Forcing the
graph to another speed band leaves the device in its old band, and
every other cycle reads no data. It works with a WirePlumber rule
per band (audio.rate, audio.channels and, for 8 channels, explicit
AUX positions) and recreating the nodes. Should the driver instead
expose a fixed 26-channel PCM and repack to the hardware frame,
with silence in the missing channels, or keep the rate-dependent
counts as hdspm does and leave this to userspace? We would
appreciate guidance before going further either way.
2. Joining or leaving direction. hw_params() and hw_free() for one
direction stop the shared engine, rebuild both page tables and
restart it from frame 0 (about 0.4 ms). The running direction's
position can jump by up to one buffer. This is unchanged from v1.
3. Not tested: external clock sources, capture and duplex in the
44.1 kHz family, S/PDIF and ADAT I/O, and suspend/resume.
4. The mixer's rate control shows 192 kHz while the rate is unknown
(zero), which patch 2 makes possible. That comes from the mixer's
existing mapping and is not changed here.
Thanks to Jamie for the original report and the test setup in [1].
[1] https://github.com/jamie-steele/presonus-quantum-linux/issues/34
[2] https://lore.kernel.org/all/20260820083646.11383-1-nicholas.johnson-opensource@outlook.com.au/
[3] https://github.com/jamie-steele/presonus-quantum-linux/pull/54
Miles Ramage (5):
ALSA: quantum: send the sample-rate wire value when setting the rate
ALSA: quantum: track the device sample rate correctly
ALSA: quantum: tie the channel count to the sample rate
ALSA: quantum: preallocate enough buffer for two full periods
ALSA: quantum: let a second direction attach to a running stream
sound/pci/quantum/quantum.h | 49 ++++++++++++++
sound/pci/quantum/quantum_dma.c | 3 +
sound/pci/quantum/quantum_main.c | 37 ++++++++--
sound/pci/quantum/quantum_pcm.c | 103 ++++++++++++++++++++--------
sound/pci/quantum/quantum_tci.c | 113 +++++++++++++++++++++++++++++--
5 files changed, 268 insertions(+), 37 deletions(-)
next prev parent reply other threads:[~2026-12-02 4:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 8:36 [RFC PATCH 0/1] ALSA: add PreSonus Quantum PCI driver Nicholas Johnson
2026-08-20 8:36 ` [RFC PATCH 1/1] ALSA: pci: " Nicholas Johnson
2026-08-21 12:44 ` [RFC PATCH] " Markus Elfring
2026-08-21 13:00 ` Markus Elfring
2026-08-21 13:34 ` [RFC PATCH 1/1] " Markus Elfring
2026-08-21 14:24 ` [RFC PATCH] " Markus Elfring
2026-08-21 18:10 ` Markus Elfring
2026-08-22 14:20 ` Markus Elfring
2026-08-22 15:21 ` [RFC PATCH 1/1] " Matthew Wilcox
2026-09-18 18:34 ` [RFC] " Markus Elfring
2026-10-24 16:13 ` [RFC PATCH 0/1] ALSA: " Jamie Steele
2026-12-02 4:22 ` Miles Ramage [this message]
2026-12-02 4:22 ` [RFC PATCH 1/5] ALSA: quantum: send the sample-rate wire value when setting the rate Miles Ramage
2026-12-02 4:22 ` [RFC PATCH 2/5] ALSA: quantum: track the device sample rate correctly Miles Ramage
2026-12-02 4:22 ` [RFC PATCH 3/5] ALSA: quantum: tie the channel count to the sample rate Miles Ramage
2026-12-02 4:22 ` [RFC PATCH 4/5] ALSA: quantum: preallocate enough buffer for two full periods Miles Ramage
2026-12-02 4:22 ` [RFC PATCH 5/5] ALSA: quantum: let a second direction attach to a running stream Miles Ramage
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202042231.42930-1-miles.ramage@yahoo.com \
--to=miles.ramage@yahoo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=nicholas.johnson-opensource@outlook.com.au \
--cc=perex@perex.cz \
--cc=steele.jamie1991@gmail.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®