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 2/5] ALSA: quantum: track the device sample rate correctly
Date: Tue, 1 Dec 2026 22:22:28 -0600 [thread overview]
Message-ID: <20261202042231.42930-3-miles.ramage@yahoo.com> (raw)
In-Reply-To: <20261202042231.42930-1-miles.ramage@yahoo.com>
The driver assumes the device starts at 48 kHz, but the device keeps
its rate across driver loads. If it was left at another rate,
quantum_set_sample_rate(chip, 48000) returns early and the device
streams at the wrong rate. Read the clock source and sample rate during
probe, and cache the rate as unknown (zero) if that fails, so the next
hw_params sets it.
The clock-status event (channel 0x32, code 0x33) carries the sample
rate as a wire value, not in Hz. The device sends it after every rate
change, for example "source=0 rate=4" after switching to 96 kHz, and
the driver cached 4 as the rate. Decode it.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Miles Ramage <miles.ramage@yahoo.com>
---
sound/pci/quantum/quantum_main.c | 25 ++++++++++++++++++++++++-
sound/pci/quantum/quantum_tci.c | 3 ++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/sound/pci/quantum/quantum_main.c b/sound/pci/quantum/quantum_main.c
index 16c81cc..c7c73e8 100644
--- a/sound/pci/quantum/quantum_main.c
+++ b/sound/pci/quantum/quantum_main.c
@@ -113,7 +113,7 @@ static void quantum_device_init(struct quantum_chip *chip)
dev_dbg(&chip->pci->dev, "DFU payload size: 0x%08x\n",
dfu_payload_size);
- chip->sample_rate = 48000;
+ chip->sample_rate = 0; /* unknown until read from the device */
chip->clock_source = CLK_SOURCE_INTERNAL;
chip->powered_on = true;
}
@@ -552,6 +552,28 @@ void quantum_power_state_changed(struct quantum_chip *chip, bool powered_on)
}
}
+/*
+ * The device keeps its clock source and sample rate across driver loads, so
+ * read them rather than assuming the 48 kHz power-on default. Failure is not
+ * fatal: an unknown rate (zero) makes the next hw_params set it explicitly.
+ */
+static void quantum_read_initial_rate(struct quantum_chip *chip)
+{
+ unsigned int source, device_rate, clock_rate;
+
+ if (!quantum_get_clock_source(chip, &source) &&
+ !quantum_get_sample_rate(chip, &device_rate, &clock_rate)) {
+ chip->sample_rate = device_rate;
+ dev_dbg(&chip->pci->dev,
+ "initial rate %u Hz (clock %u Hz), source %u\n",
+ device_rate, clock_rate, source);
+ } else {
+ chip->sample_rate = 0;
+ dev_warn(&chip->pci->dev,
+ "could not read the initial sample rate\n");
+ }
+}
+
/* Device creation */
static int snd_quantum_create(struct snd_card *card, struct pci_dev *pci,
@@ -664,6 +686,7 @@ static int snd_quantum_create(struct snd_card *card, struct pci_dev *pci,
if (!ret) {
chip->tci_ready = true;
chip->tci_initialized = true;
+ quantum_read_initial_rate(chip);
err = snd_quantum_pcm_new(chip);
if (err) {
dev_err(&pci->dev, "PCM creation failed: %d\n", err);
diff --git a/sound/pci/quantum/quantum_tci.c b/sound/pci/quantum/quantum_tci.c
index 80dde86..ee7d6e7 100644
--- a/sound/pci/quantum/quantum_tci.c
+++ b/sound/pci/quantum/quantum_tci.c
@@ -173,7 +173,8 @@ void quantum_process_rx_messages(struct quantum_chip *chip)
"clock event: source=%u rate=%u\n",
wire_cs - 1, sr);
chip->clock_source = wire_cs - 1;
- chip->sample_rate = sr;
+ /* The rate is a wire value, not Hz. */
+ chip->sample_rate = quantum_wire_to_rate(sr);
}
break;
--
2.56.1
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 ` [RFC PATCH 0/5] ALSA: quantum: fix high sample rates and duplex attach Miles Ramage
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 ` Miles Ramage [this message]
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-3-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®