From nobody Mon Feb 26 23:22:51 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 4TkGqw3ZGbz5BtbX; Mon, 26 Feb 2024 23:22:52 +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 4TkGqw01jbz4V0V; Mon, 26 Feb 2024 23:22:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708989772; 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=2CR7WRs0CWLNu8eLdJRZrPMKQw3XpgFJk9Zhgn4PMJE=; b=SH54hU0QxxeApK+t0xo/Iv/508iCpSZMrEZPVuH23M8QSxD7hHMV00uCfV8D8VIhQg+PJj 0IczrgUcuJvEBpwz+rMssjRGUbNWtiuQZexFw7oylfFdAMu4aM1IgvG+fqv/0siuFpevpr Dk1QsQidFYmMQga1g4PlGYN4IZWxjdaYEPAHWnVXrPfAmVcftH/U3AwftaMamsj89sA20/ sY9DJCHEtEeRwrNEzZRsjfpJfZDiDRRwCuH+W1lKu4jPSjHskHYD+pHPBUbwQxtJdLG0e/ A20VjI7IFhxdAl960yfLRDLHkUjPXye3kh3CeDFNHYLNslNQZQSyUsXLtVYngg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708989772; a=rsa-sha256; cv=none; b=WpoZIbFJa8RHuXM152sb06VADfZk6NB0qqkaJTG5ARVfJ+85IwET6uAn0Adk1hCBYdLWbp SeTacY2hoyn7dzTE0CAEuzdeAh2RR+EE5UaE8nwWVBVhbHCkWbtzb9FRU4ALdZm7tCUazE z0+s+sAjzsGhs/CzH/85AEpR+CgJ2+B//4vtFk0fIxkbaMAJG++FlneB1FI0H3y5+Bwejt tVITAp/yRl13uekiWcmcCf6xYgQdbXlKmM/w8WWL1DV43DBiQkrXMYh0WGoOnU/evu2vl9 AUXAj6iY7caufKYnh+HZbEersII1W3gKcyT1sRJsd3PcdGSoI6LpvvDYyxT8jQ== 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=1708989772; 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=2CR7WRs0CWLNu8eLdJRZrPMKQw3XpgFJk9Zhgn4PMJE=; b=Vm0ESl6CKjj3xO85QC+7WuEVUteny7W3rZz/QGSvAhN2AoBja7iaN2RLBL22HWleRfu9uS HGrDj91OUBO4A1kQ/88U1D8ohz895Jit38+7H5W+KrHnQtxIF1j10HEZ4lYHtLXhGY1ksX liSrC24P3TguG1+cLlRgm5h5rZW/Hn8N0GpxCDmEdYADmHvGMK0DWwzAfmeSv6iYf6QyHF CUSkvgRxt30lcpvr1yBMqeSi4NJvak7Sk+PqjComnR+o5eNh3TPxu/QVk7D9XTWrkeKt8v 7BmjX5ejRNQ19ujryvqVKKRCO7/+Iu94d+lzH5Z279RbEhVdNmnZWp7mqN6O8w== 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 4TkGqv6DM2zpLw; Mon, 26 Feb 2024 23:22:51 +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 41QNMpHW028666; Mon, 26 Feb 2024 23:22:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41QNMpCj028663; Mon, 26 Feb 2024 23:22:51 GMT (envelope-from git) Date: Mon, 26 Feb 2024 23:22:51 GMT Message-Id: <202402262322.41QNMpCj028663@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 4c6b20d4b3e3 - stable/14 - snd_uaudio(4): Fix config detection with defaults set. 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: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 4c6b20d4b3e3054e1f37f20976c6b68685adb53f Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=4c6b20d4b3e3054e1f37f20976c6b68685adb53f commit 4c6b20d4b3e3054e1f37f20976c6b68685adb53f Author: Florian Walpen AuthorDate: 2024-02-12 11:05:27 +0000 Commit: Christos Margiolis CommitDate: 2024-02-26 23:22:31 +0000 snd_uaudio(4): Fix config detection with defaults set. Let the USB audio descriptor iteration detect configurations with more channels and larger sample size, even when the following global sysctl tunables are set to a lower value: hw.usb.uaudio.default_channels hw.usb.uaudio.default_bits This improves utility and is closer to the meaning of default. Also, do not create duplicate sample rate entries. MFC after: 2 weeks Reviewed by: christos Differential Revision: https://reviews.freebsd.org/D43679 (cherry picked from commit 42fdcd9fd917764d84edcc43e252a90cade78f80) --- sys/dev/sound/usb/uaudio.c | 68 +++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index b0bf815f7797..eb4b676d5e7d 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -94,7 +94,7 @@ #include "feeder_if.h" static int uaudio_default_rate = 0; /* use rate list */ -static int uaudio_default_bits = 32; +static int uaudio_default_bits = 0; /* use default sample size */ static int uaudio_default_channels = 0; /* use default */ static int uaudio_buffer_ms = 4; static bool uaudio_handle_hid = true; @@ -150,6 +150,7 @@ SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, debug, CTLFLAG_RWTUN, #define UAUDIO_NFRAMES 64 /* must be factor of 8 due HS-USB */ #define UAUDIO_NCHANBUFS 2 /* number of outstanding request */ #define UAUDIO_RECURSE_LIMIT 255 /* rounds */ +#define UAUDIO_BITS_MAX 32 /* maximum sample size in bits */ #define UAUDIO_CHANNELS_MAX MIN(64, AFMT_CHANNEL_MAX) #define UAUDIO_MATRIX_MAX 8 /* channels */ @@ -2203,31 +2204,37 @@ uaudio_chan_fill_info(struct uaudio_softc *sc, struct usb_device *udev) uint8_t bits = uaudio_default_bits; uint8_t y; uint8_t channels = uaudio_default_channels; + uint8_t channels_max; uint8_t x; bits -= (bits % 8); - if ((bits == 0) || (bits > 32)) { + if ((bits == 0) || (bits > UAUDIO_BITS_MAX)) { /* set a valid value */ - bits = 32; + bits = UAUDIO_BITS_MAX; } - if (channels == 0) { - switch (usbd_get_speed(udev)) { - case USB_SPEED_LOW: - case USB_SPEED_FULL: - /* - * Due to high bandwidth usage and problems - * with HIGH-speed split transactions we - * disable surround setups on FULL-speed USB - * by default - */ - channels = 4; - break; - default: - channels = UAUDIO_CHANNELS_MAX; - break; - } - } else if (channels > UAUDIO_CHANNELS_MAX) + + if (channels > UAUDIO_CHANNELS_MAX) channels = UAUDIO_CHANNELS_MAX; + switch (usbd_get_speed(udev)) { + case USB_SPEED_LOW: + case USB_SPEED_FULL: + /* + * Due to high bandwidth usage and problems + * with HIGH-speed split transactions we + * disable surround setups on FULL-speed USB + * by default + */ + channels_max = 4; + /* more channels on request */ + if (channels > channels_max) + channels_max = channels; + break; + default: + channels_max = UAUDIO_CHANNELS_MAX; + break; + } + if (channels == 0) + channels = channels_max; if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND)) sc->sc_sndstat_valid = 1; @@ -2241,9 +2248,26 @@ uaudio_chan_fill_info(struct uaudio_softc *sc, struct usb_device *udev) uaudio_chan_fill_info_sub(sc, udev, rate, x, y); /* try find a matching rate, if any */ - for (z = 0; uaudio_rate_list[z]; z++) - uaudio_chan_fill_info_sub(sc, udev, uaudio_rate_list[z], x, y); + for (z = 0; uaudio_rate_list[z]; z++) { + if (uaudio_rate_list[z] != rate) + uaudio_chan_fill_info_sub(sc, udev, + uaudio_rate_list[z], x, y); + } + + /* after default value in first round, proceed with max bits */ + if (y == bits) + y = UAUDIO_BITS_MAX + 8; + /* skip default value subsequently */ + if (y == (bits + 8)) + y -= 8; } + + /* after default value in first round, proceed with max channels */ + if (x == channels) + x = channels_max + 1; + /* skip default value subsequently */ + if (x == (channels + 1)) + x--; } if (sc->sc_sndstat_valid) sbuf_finish(&sc->sc_sndstat);