Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Apr 2020 16:26:16 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r359878 - stable/10/sys/dev/sound/usb
Message-ID:  <202004131626.03DGQGgE086947@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Apr 13 16:26:15 2020
New Revision: 359878
URL: https://svnweb.freebsd.org/changeset/base/359878

Log:
  MFC r359323:
  Be more intelligent when classifying USB audio terminal types, so that we
  don't end up using SOUND_MIXER_VOLUME for all undefined types.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==============================================================================
--- stable/10/sys/dev/sound/usb/uaudio.c	Mon Apr 13 16:25:44 2020	(r359877)
+++ stable/10/sys/dev/sound/usb/uaudio.c	Mon Apr 13 16:26:15 2020	(r359878)
@@ -4515,52 +4515,61 @@ static const struct uaudio_tt_to_feature uaudio_tt_to_
 	{UATF_MULTITRACK, SOUND_MIXER_VOLUME},
 	{0xffff, SOUND_MIXER_VOLUME},
 
-	/* default */
-	{0x0000, SOUND_MIXER_VOLUME},
+	/* end */
+	{}
 };
 
 static uint16_t
-uaudio_mixer_feature_name(const struct uaudio_terminal_node *iot,
-    struct uaudio_mixer_node *mix)
+uaudio_mixer_feature_name_sub(uint16_t terminal_type)
 {
 	const struct uaudio_tt_to_feature *uat = uaudio_tt_to_feature;
-	uint16_t terminal_type = uaudio_mixer_determine_class(iot, mix);
+	uint16_t retval;
 
-	if ((mix->class == UAC_RECORD) && (terminal_type == 0)) {
-		return (SOUND_MIXER_IMIX);
-	}
-	while (uat->terminal_type) {
-		if (uat->terminal_type == terminal_type) {
-			break;
+	while (1) {
+		if (uat->terminal_type == 0) {
+			switch (terminal_type >> 8) {
+			case UATI_UNDEFINED >> 8:
+				retval = SOUND_MIXER_RECLEV;
+				goto done;
+			case UATO_UNDEFINED >> 8:
+				retval = SOUND_MIXER_PCM;
+				goto done;
+			default:
+				retval = SOUND_MIXER_VOLUME;
+				goto done;
+			}
+		} else if (uat->terminal_type == terminal_type) {
+			retval = uat->feature;
+			goto done;
 		}
 		uat++;
 	}
-
+done:
 	DPRINTF("terminal_type=0x%04x -> %d\n",
-	    terminal_type, uat->feature);
+	    terminal_type, retval);
+	return (retval);
+}
 
-	return (uat->feature);
+static uint16_t
+uaudio_mixer_feature_name(const struct uaudio_terminal_node *iot,
+    struct uaudio_mixer_node *mix)
+{
+	uint16_t terminal_type = uaudio_mixer_determine_class(iot, mix);
+
+	if (mix->class == UAC_RECORD && terminal_type == 0)
+		return (SOUND_MIXER_IMIX);
+	return (uaudio_mixer_feature_name_sub(terminal_type));
 }
 
 static uint16_t
 uaudio20_mixer_feature_name(const struct uaudio_terminal_node *iot,
     struct uaudio_mixer_node *mix)
 {
-	const struct uaudio_tt_to_feature *uat;
 	uint16_t terminal_type = uaudio20_mixer_determine_class(iot, mix);
 
-	if ((mix->class == UAC_RECORD) && (terminal_type == 0))
+	if (mix->class == UAC_RECORD && terminal_type == 0)
 		return (SOUND_MIXER_IMIX);
-	
-	for (uat = uaudio_tt_to_feature; uat->terminal_type != 0; uat++) {
-		if (uat->terminal_type == terminal_type)
-			break;
-	}
-
-	DPRINTF("terminal_type=0x%04x -> %d\n",
-	    terminal_type, uat->feature);
-
-	return (uat->feature);
+	return (uaudio_mixer_feature_name_sub(terminal_type));
 }
 
 static const struct uaudio_terminal_node *



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004131626.03DGQGgE086947>