From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.6.132.125 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796185395; b=FLyOrLf7LHEv6Ot2hL/2YVHyRZwXAWEzZGaMR8cIj0n+PbLds5NH268n+gUjF5lOBTpo EOqq5vZlc74zu+1GeK/xOIJt24EmT7F0Q8DYJJdcTwLrzGw8bqwTy+WQuP9B3EiyYdDWz IlsffugaWEYIyPO3maFRTROvKyeZlUzQvn5pjFc/7aiYI4Or9PGs5JIpzp4dguIrDwKa3 v/zhumBGCReKdEJhtby2+j8Jb6qnnYQcGaplt478PpU0sJWSlblnp2MwA6deK0qt2L+gm D6V8e9UCAoPChep+WCRT8kMtm6fstyBFJv4tZCYhDqnCfFO3+tGLOBStYV/a+5pEbvw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796185395; h=DMARC-Filter:DKIM-Signature:X-SONIC-DKIM-SIGN:X-YMail-OSG:X-Sonic-MF: X-Sonic-ID:Received:Received:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=OPnc3urw89dKRfCP/zniBMl68mpDYLjSemVXOeGAmKo=; b=nRpJzj8B94krWr9PfpSyhHHIVktu7FrxdeUnC2aLYT18RS6qIsCThHC/NthicLYAI4zS pwtQQ8gzGcaGTFyFRJ22TirR/ZA0YTpDhOEiHoi3mIaJ/xVXTX2G3bz2qMqkrfRnforZx qteUx3aBQoB1s3ZEIzOP7aJMrUuUleZPLgqLaL2FW9gnMJ1qsEzu0apjUErmSRHrR+Xjz VDlSPDZsRgP3oJhxyanspdsfTs2qDIHf76Xp5ssr8J9v115A9TxUDFc//bAvaeRa2yEFR aW2XyETiUNOYGqOG0V3lzA60fn0bbd4jWJ7CIXth9sftlwfVm6z5TmbK60Jrp5WNYCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=yahoo.com; spf=pass smtp.mailfrom=yahoo.com; dkim=pass header.d=yahoo.com header.i=@yahoo.com header.a=rsa-sha256 header.s=s2048 header.b=gMSP9UaA; arc=none smtp.remote-ip=74.6.132.125 Received: from sonic314-15.consmr.mail.bf2.yahoo.com (sonic314-15.consmr.mail.bf2.yahoo.com [74.6.132.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98152606A32A for ; Wed, 2 Dec 2026 04:23:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98152606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=yahoo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yahoo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.a=rsa-sha256 header.s=s2048 header.b=gMSP9UaA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796185393; bh=OPnc3urw89dKRfCP/zniBMl68mpDYLjSemVXOeGAmKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To:Content-Type; b=gMSP9UaAecM4CcKQOioYstQll0T04pma+9Cq9qkOOvdr9PalfDczkQM4mf84rj1RJc5U82C0d1wMW62mI4oeFndhXOGsGKWeCk1rn+cX1ihbUCrL6KqtFUZo/gRD5nVxL/dN+YAen8gEmhLYa7fx+pEVHRx+7cGa7splhSSTFReSj/UwAfDNVLxEWO0euoZUuIYwcr7cYB90ztsJjsfpmT9ktYt4YD6x3hz3K+4dgyUFzHsJyJLK7HZDOlt0ciXqlTYkeU6awJCop1ntKkgVOdM2IHS0ZbFVUxJy0o7yTg3AUDpUrCfTD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k4NNE8u3Az_ndstjbrlF1vZTUu3iVocjS nsN2OnXIh9TOHzKuq5joglK0v1feQw5l7AuxCXt.sf9sevUu7jPwVdWC5In3KGrs2ZoxlUw2XX7k FaZgzADV6rrkAjDLl8_ZEz8fId3.BsKBWKDWs0mGWn5E4dA0RmB1B5IltiRpqwCNxHF2YDm0JVLE 9E2xbBhzjmrcDdZj7lfssuYeO22DhJ..trCjZYxAf_ZU1OrYfsR7mP8Pw0FxnGKkaISEE74nKFOf sUupRGdO_uxWcggrL.rLIo85EjVPbK4Z1KHn.MQ5TFvs_jjsF5FEwdMvz6QF0BmhVl5HU13m5uLx 1.nCEWsrlTQybhRX3TJwx6VT9748tWegEirW6J4a3XNRkkKDt7jzYv.lY0sRUdT7IEHOgARAbOrt v2LRiZySrO7mdaY_H4dk7c8AkTXVXwS.OOaha0bwwtZuI99S_UpiAaH7ONA43KDZLMcmh86WtuzD QHt.UDTEW3tJh8AOBKItYuFuKS9VHkb3g7GbNg4UOsCvuevYpqKVLiZ2RA2vHgBlXCjB61AEWV8C md2yI9DZ6r8G7V00Pzh_TGDsfQ.1XqYUeeMPIG_3ZnQB.UmjV4LPwPS8Ru8Y3hoyOu_13hWih7kk JMAuTu35Jf9swX_oxMnFTmDyWC2NZKP5hFZSwOEF_C9qGHf3MKMOZu3SuQkSoSa6CKiOfxwwDLSj UMVtTrNR0jnA- X-Sonic-MF: X-Sonic-ID: 860a9ffd-281d-4341-a129-ee479d8b17b2 Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.bf2.yahoo.com with HTTP; Wed, 2 Dec 2026 04:23:13 +0000 Received: by hermes--production-ne1-768f77cf86-d49lr (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID b4832c03f7603fc3738aaf23d9537159; Wed, 02 Dec 2026 04:23:09 +0000 (UTC) From: Miles Ramage To: Nicholas Johnson , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Jamie Steele , Miles Ramage Subject: [RFC PATCH 0/5] ALSA: quantum: fix high sample rates and duplex attach Date: Tue, 1 Dec 2026 22:22:26 -0600 Message-ID: <20261202042231.42930-1-miles.ramage@yahoo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <59ad0f62-dd4c-4d42-b50a-ab91bf469fb7@gmail.com> References: <59ad0f62-dd4c-4d42-b50a-ab91bf469fb7@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(-)