From nobody Sun Feb 25 21:48:00 2024
X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Tjcmw5B1fz5C8mY;
Sun, 25 Feb 2024 21:48:00 +0000 (UTC)
(envelope-from git@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256
client-signature RSA-PSS (4096 bits) client-digest SHA256)
(Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK))
by mx1.freebsd.org (Postfix) with ESMTPS id 4Tjcmw4kWBz4bdk;
Sun, 25 Feb 2024 21:48:00 +0000 (UTC)
(envelope-from git@FreeBSD.org)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
t=1708897680;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding;
bh=LKmxxRwXRsN4J2ZOveO6/G72pZUNf81vlacNV4ZHg5A=;
b=HSjSbrw3758fpL5sGlYUjDwWkwwonS2M1L4LGOZ1x7HjLDZ0RJPzWM9q3vFnaMckqGbnkR
IsYJuwUjez1HsgAnR1j+LevWGHG0FEMFWHl8UjzX0uZ6qCcOmkfk1SV0kPdeAt7Fs9VZdJ
vm1OpQ7fGz1DSHk+Nkhn89o2I3ttCbpzUYa3p40GUaBVxocYOclm4LJFKk/guzgsg519wu
swPrYVVGukhfu0mu542ZCCkpk/wJWECmuOUhUYU/LuPeOzCfq0U0MA/9wslMAkw8OEzyX8
ubQy/CzoxlIm329AvSMWC0LT6XEtmt2m8tRhtaSR97MlHzalsHudhHlX7wgw6g==
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708897680; a=rsa-sha256; cv=none;
b=cQ565+PH22H2CKdw9oMCfvxKSwRvnkKje7VqUaMX1e4zlgvhd7sIvkdBTmAOAewvmZ+p0j
x4WOtc7u3fo2vYGBd+MxfYWLr+6PlQKCtBCdp2n4ugQzlGoSEonMc+CCBeY4yG4/KFRlDK
5VYnRx9J4deEJzqpKOjR3RJ3k7n8NIkj4kMKuSE+DhmRyZKMCkBXHzyLonTlGxLHPf8Qzi
TRxkT1ru4J5SvRR9EeXydS7Nnx7v8gjZJQnWCm9vRYj/WSbr/5K+oYGtXlxu8HVVDrMJhk
PDxm7vg12W7K99n2jA0+qJRmvQ9yrecnAzcLJdEpfEj1GUW30yRhr/MtISXVXA==
ARC-Authentication-Results: i=1;
mx1.freebsd.org;
none
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org;
s=dkim; t=1708897680;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding;
bh=LKmxxRwXRsN4J2ZOveO6/G72pZUNf81vlacNV4ZHg5A=;
b=AW4/pcEOHN290kTsdtHRJ4pZ8SrXFYQyKf9j6sdSDpc2sgA52utXr/BjEH4I27d3C/y+vV
qukutBcSra8dDgfmHBl2GGvarontEQA4pjYQ9hsMgeDuGJvIjv+5zawmtLfQaEjeQ3na9Q
atPV5HEOrM0QYoIkoAi0NFcviEvYXwNs/uXMl9INIxlLu4qTE5rHzZUf8mqvkXso9nBUwr
R2klMkXGqjpj3h4D1JV7zgUM7+mANQwMQhSTTpvqxvE6Qr4ICK4iW+fLcCATSCtDKeOkFZ
uFA0dfvzC+YIet/l+Pxc540WoxTolsK7MtnVdFfYuaxPRwCyL9ufLT0edfAiaQ==
Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
(Client did not present a certificate)
by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Tjcmw3fyxz11LD;
Sun, 25 Feb 2024 21:48:00 +0000 (UTC)
(envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org ([127.0.1.44])
by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41PLm0V3007193;
Sun, 25 Feb 2024 21:48:00 GMT
(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41PLm01B007190;
Sun, 25 Feb 2024 21:48:00 GMT
(envelope-from git)
Date: Sun, 25 Feb 2024 21:48:00 GMT
Message-Id: <202402252148.41PLm01B007190@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
dev-commits-src-main@FreeBSD.org
From: Ruslan Bukin
Subject: git: dc15f025062d - main - snd_hdspe(4): Optional unified
pcm device.
List-Id: Commit messages for all branches of the src repository
List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all
List-Help:
List-Post:
List-Subscribe:
List-Unsubscribe:
Sender: owner-dev-commits-src-all@freebsd.org
X-BeenThere: dev-commits-src-all@freebsd.org
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Git-Committer: br
X-Git-Repository: src
X-Git-Refname: refs/heads/main
X-Git-Reftype: branch
X-Git-Commit: dc15f025062da40ac3a2529b6c979c597b9eb94c
Auto-Submitted: auto-generated
The branch main has been updated by br:
URL: https://cgit.FreeBSD.org/src/commit/?id=dc15f025062da40ac3a2529b6c979c597b9eb94c
commit dc15f025062da40ac3a2529b6c979c597b9eb94c
Author: Florian Walpen
AuthorDate: 2024-02-25 21:39:36 +0000
Commit: Ruslan Bukin
CommitDate: 2024-02-25 21:39:36 +0000
snd_hdspe(4): Optional unified pcm device.
Add a sysctl tunable to unify all physical ports of an HDSPe sound card
into one pcm device, with up to 14 (AIO) or 36 (RayDAT) channels. This
makes all ports available in multi-channel audio software.
Differential Revision: https://reviews.freebsd.org/D43798
---
share/man/man4/snd_hdspe.4 | 23 ++++++++++++++++++++++-
sys/dev/sound/pci/hdspe-pcm.c | 9 ++++++++-
sys/dev/sound/pci/hdspe.c | 22 ++++++++++++++++++++--
3 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/share/man/man4/snd_hdspe.4 b/share/man/man4/snd_hdspe.4
index 7d8cc2adc1af..a8c7be538dd1 100644
--- a/share/man/man4/snd_hdspe.4
+++ b/share/man/man4/snd_hdspe.4
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 29, 2024
+.Dd February 9, 2024
.Dt SND_HDSPE 4
.Os
.Sh NAME
@@ -64,8 +64,29 @@ By default, each
.Xr pcm 4
device corresponds to a physical port on the sound card.
For ADAT ports, 8 channel, 4 channel and 2 channel formats are supported.
+The effective number of ADAT channels is 8 channels at single speed
+(32kHz-48kHz), 4 channels at double speed (64kHz-96kHz), and 2 channels at
+quad speed (128kHz-192kHz).
Depending on sample rate and channel format selected, not all pcm channels can
be mapped to ADAT channels and vice versa.
+.Sh LOADER TUNABLES
+These settings can be entered at the
+.Xr loader 8
+prompt or in
+.Xr loader.conf 5 .
+.Bl -tag -width indent
+.It Va hw.hdspe.unified_pcm
+If set to 1, all physical ports are combined into one unified pcm device.
+When opened in multi-channel audio software, this makes all ports available
+at the same time, and fully synchronized.
+For resulting channel numbers consult the following table:
+.El
+.Bl -column "HDSPe RayDAT" "Single Speed" "Double Speed" "Quad Speed"
+.Sy "Sound Card" Ta Sy "Single Speed" Ta Sy "Double Speed" Ta Sy "Quad Speed"
+.It "" Ta "Play | Rec" Ta "Play | Rec" Ta "Play | Rec"
+.It HDSPe AIO Ta " 16 | 14" Ta " 12 | 10" Ta " 10 | 8"
+.It HDSPe RayDAT Ta " 36 | 36" Ta " 20 | 20" Ta " 12 | 12"
+.El
.Sh SYSCTL TUNABLES
These settings and informational values can be accessed at runtime with the
.Xr sysctl 8
diff --git a/sys/dev/sound/pci/hdspe-pcm.c b/sys/dev/sound/pci/hdspe-pcm.c
index cf764f19a933..594a4f704028 100644
--- a/sys/dev/sound/pci/hdspe-pcm.c
+++ b/sys/dev/sound/pci/hdspe-pcm.c
@@ -41,6 +41,8 @@
#include
+#define HDSPE_MATRIX_MAX 8
+
struct hdspe_latency {
uint32_t n;
uint32_t period;
@@ -1007,6 +1009,7 @@ hdspe_pcm_attach(device_t dev)
char status[SND_STATUSLEN];
struct sc_pcminfo *scp;
const char *buf;
+ uint32_t pcm_flags;
int err;
int play, rec;
@@ -1025,7 +1028,11 @@ hdspe_pcm_attach(device_t dev)
* We don't register interrupt handler with snd_setup_intr
* in pcm device. Mark pcm device as MPSAFE manually.
*/
- pcm_setflags(dev, pcm_getflags(dev) | SD_F_MPSAFE);
+ pcm_flags = pcm_getflags(dev) | SD_F_MPSAFE;
+ if (hdspe_channel_count(scp->hc->ports, 8) > HDSPE_MATRIX_MAX)
+ /* Disable vchan conversion, too many channels. */
+ pcm_flags |= SD_F_BITPERFECT;
+ pcm_setflags(dev, pcm_flags);
play = (hdspe_channel_play_ports(scp->hc)) ? 1 : 0;
rec = (hdspe_channel_rec_ports(scp->hc)) ? 1 : 0;
diff --git a/sys/dev/sound/pci/hdspe.c b/sys/dev/sound/pci/hdspe.c
index 1d1068c9f8fe..0773362f2bc3 100644
--- a/sys/dev/sound/pci/hdspe.c
+++ b/sys/dev/sound/pci/hdspe.c
@@ -44,6 +44,14 @@
#include
+static bool hdspe_unified_pcm = false;
+
+static SYSCTL_NODE(_hw, OID_AUTO, hdspe, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
+ "PCI HDSPe");
+
+SYSCTL_BOOL(_hw_hdspe, OID_AUTO, unified_pcm, CTLFLAG_RWTUN,
+ &hdspe_unified_pcm, 0, "Combine physical ports in one unified pcm device");
+
static struct hdspe_clock_source hdspe_clock_source_table_rd[] = {
{ "internal", 0 << 1 | 1, HDSPE_STATUS1_CLOCK(15), 0, 0 },
{ "word", 0 << 1 | 0, HDSPE_STATUS1_CLOCK( 0), 1 << 24, 1 << 25 },
@@ -78,6 +86,11 @@ static struct hdspe_channel chan_map_aio[] = {
{ 0, NULL },
};
+static struct hdspe_channel chan_map_aio_uni[] = {
+ { HDSPE_CHAN_AIO_ALL, "all" },
+ { 0, NULL },
+};
+
static struct hdspe_channel chan_map_rd[] = {
{ HDSPE_CHAN_RAY_AES, "aes" },
{ HDSPE_CHAN_RAY_SPDIF, "s/pdif" },
@@ -88,6 +101,11 @@ static struct hdspe_channel chan_map_rd[] = {
{ 0, NULL },
};
+static struct hdspe_channel chan_map_rd_uni[] = {
+ { HDSPE_CHAN_RAY_ALL, "all" },
+ { 0, NULL },
+};
+
static void
hdspe_intr(void *p)
{
@@ -538,11 +556,11 @@ hdspe_attach(device_t dev)
switch (rev) {
case PCI_REVISION_AIO:
sc->type = HDSPE_AIO;
- chan_map = chan_map_aio;
+ chan_map = hdspe_unified_pcm ? chan_map_aio_uni : chan_map_aio;
break;
case PCI_REVISION_RAYDAT:
sc->type = HDSPE_RAYDAT;
- chan_map = chan_map_rd;
+ chan_map = hdspe_unified_pcm ? chan_map_rd_uni : chan_map_rd;
break;
default:
return (ENXIO);