Page MenuHomeFreeBSD
Paste P627

remove snd_uaudio default_* sysctls
ActivePublic

Authored by christos on Feb 3 2024, 8:15 PM.
Tags
None
Referenced Files
F76211761: remove snd_uaudio default_* sysctls
Feb 3 2024, 8:15 PM
Subscribers
None
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index 917b6bd3f238..360dcad8ff2a 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -93,9 +93,6 @@
#include <dev/sound/chip.h>
#include "feeder_if.h"
-static int uaudio_default_rate = 0; /* use rate list */
-static int uaudio_default_bits = 32;
-static int uaudio_default_channels = 0; /* use default */
static int uaudio_buffer_ms = 2;
static bool uaudio_handle_hid = true;
@@ -103,12 +100,6 @@ static SYSCTL_NODE(_hw_usb, OID_AUTO, uaudio, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"USB uaudio");
SYSCTL_BOOL(_hw_usb_uaudio, OID_AUTO, handle_hid, CTLFLAG_RWTUN,
&uaudio_handle_hid, 0, "uaudio handles any HID volume/mute keys, if set");
-SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_rate, CTLFLAG_RWTUN,
- &uaudio_default_rate, 0, "uaudio default sample rate");
-SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_bits, CTLFLAG_RWTUN,
- &uaudio_default_bits, 0, "uaudio default sample bits");
-SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RWTUN,
- &uaudio_default_channels, 0, "uaudio default sample channels");
static int
uaudio_buffer_ms_sysctl(SYSCTL_HANDLER_ARGS)
@@ -149,6 +140,7 @@ SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, debug, CTLFLAG_RWTUN,
#define UAUDIO_RECURSE_LIMIT 255 /* rounds */
#define UAUDIO_CHANNELS_MAX MIN(64, AFMT_CHANNEL_MAX)
#define UAUDIO_MATRIX_MAX 8 /* channels */
+#define UAUDIO_BITS_MAX 32
#define MAKE_WORD(h,l) (((h) << 8) | (l))
#define BIT_TEST(bm,bno) (((bm)[(bno) / 8] >> (7 - ((bno) % 8))) & 1)
@@ -2148,51 +2140,34 @@ static const uint32_t uaudio_rate_list[CHAN_MAX_ALT] = {
static void
uaudio_chan_fill_info(struct uaudio_softc *sc, struct usb_device *udev)
{
- uint32_t rate = uaudio_default_rate;
- uint8_t z;
- uint8_t bits = uaudio_default_bits;
- uint8_t y;
- uint8_t channels = uaudio_default_channels;
- uint8_t x;
+ uint8_t channels_max, x, y, z;
- bits -= (bits % 8);
- if ((bits == 0) || (bits > 32)) {
- /* set a valid value */
- bits = 32;
+ 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;
+ break;
+ default:
+ channels_max = UAUDIO_CHANNELS_MAX;
+ break;
}
- 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)
- channels = UAUDIO_CHANNELS_MAX;
if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND))
sc->sc_sndstat_valid = 1;
/* try to search for a valid config */
-
- for (x = channels; x; x--) {
- for (y = bits; y; y -= 8) {
- /* try user defined rate, if any */
- if (rate != 0)
- 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 (x = channels_max; x; x--) {
+ for (y = UAUDIO_BITS_MAX; y; y -= 8) {
+ for (z = 0; uaudio_rate_list[z]; z++) {
+ uaudio_chan_fill_info_sub(sc, udev,
+ uaudio_rate_list[z], x, y);
+ }
}
}
if (sc->sc_sndstat_valid)