diff mbox series

Revert "ALSA: usb-audio: Name feature ctl using output if input is PCM"

Message ID 20240316083744.28126-1-tiwai@suse.de (mailing list archive)
State Accepted
Commit c53898eb60ed8fa314c6903805a42e234881e4df
Headers show
Series Revert "ALSA: usb-audio: Name feature ctl using output if input is PCM" | expand

Commit Message

Takashi Iwai March 16, 2024, 8:37 a.m. UTC
This reverts commit 1601cd53c7e3197181277326dbfc131d20a74e46.

This fix is applied globally to all devices, and it may change the
existing control names.  When the devices are managed with the fixed
configuration like UCM, such control name mismatch may lead to
significant regressions.

For avoiding that kind of regression, we would need to apply such
changes conditionally, but it'd take time to settle down.
While the original fix is a good thing in general, in order to address
the regression, let's revert the change for now.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=218605
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/mixer.c | 49 ++++++++++++++---------------------------------
 1 file changed, 14 insertions(+), 35 deletions(-)

Comments

Niklāvs Koļesņikovs March 16, 2024, 5:10 p.m. UTC | #1
If it's relevant:

Reported-and-tested-by: Niklāvs Koļesņikovs <pinkflames.linux@gmail.com>

sestd., 2024. g. 16. marts, plkst. 10:37 — lietotājs Takashi Iwai
(<tiwai@suse.de>) rakstīja:
>
> This reverts commit 1601cd53c7e3197181277326dbfc131d20a74e46.
>
> This fix is applied globally to all devices, and it may change the
> existing control names.  When the devices are managed with the fixed
> configuration like UCM, such control name mismatch may lead to
> significant regressions.
>
> For avoiding that kind of regression, we would need to apply such
> changes conditionally, but it'd take time to settle down.
> While the original fix is a good thing in general, in order to address
> the regression, let's revert the change for now.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218605
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>  sound/usb/mixer.c | 49 ++++++++++++++---------------------------------
>  1 file changed, 14 insertions(+), 35 deletions(-)
>
> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index 81256ab56835..409fc1164694 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -1652,34 +1652,6 @@ static const struct usb_feature_control_info *get_feature_control_info(int contr
>         return NULL;
>  }
>
> -static int feature_unit_mutevol_ctl_name(struct usb_mixer_interface *mixer,
> -                                        struct snd_kcontrol *kctl,
> -                                        struct usb_audio_term *iterm,
> -                                        struct usb_audio_term *oterm)
> -{
> -       struct usb_audio_term *aterm, *bterm;
> -       bool output_first;
> -       int len = 0;
> -
> -       /*
> -        * If the input terminal is USB Streaming, we try getting the name of
> -        * the output terminal first in hopes of getting something more
> -        * descriptive than "PCM".
> -        */
> -       output_first = iterm && !(iterm->type >> 16) && (iterm->type & 0xff00) == 0x0100;
> -
> -       aterm = output_first ? oterm : iterm;
> -       bterm = output_first ? iterm : oterm;
> -
> -       if (aterm)
> -               len = get_term_name(mixer->chip, aterm, kctl->id.name,
> -                                   sizeof(kctl->id.name), 1);
> -       if (!len && bterm)
> -               len = get_term_name(mixer->chip, bterm, kctl->id.name,
> -                                   sizeof(kctl->id.name), 1);
> -       return len;
> -}
> -
>  static void __build_feature_ctl(struct usb_mixer_interface *mixer,
>                                 const struct usbmix_name_map *imap,
>                                 unsigned int ctl_mask, int control,
> @@ -1761,15 +1733,22 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,
>         case UAC_FU_MUTE:
>         case UAC_FU_VOLUME:
>                 /*
> -                * Determine the control name:
> -                * - If a name id is given in descriptor, use it.
> -                * - If input and output terminals are present, try to derive
> -                *   the name from either of these.
> -                * - Otherwise, make up a name using the feature unit ID.
> +                * determine the control name.  the rule is:
> +                * - if a name id is given in descriptor, use it.
> +                * - if the connected input can be determined, then use the name
> +                *   of terminal type.
> +                * - if the connected output can be determined, use it.
> +                * - otherwise, anonymous name.
>                  */
>                 if (!len) {
> -                       len = feature_unit_mutevol_ctl_name(mixer, kctl, iterm,
> -                                                           oterm);
> +                       if (iterm)
> +                               len = get_term_name(mixer->chip, iterm,
> +                                                   kctl->id.name,
> +                                                   sizeof(kctl->id.name), 1);
> +                       if (!len && oterm)
> +                               len = get_term_name(mixer->chip, oterm,
> +                                                   kctl->id.name,
> +                                                   sizeof(kctl->id.name), 1);
>                         if (!len)
>                                 snprintf(kctl->id.name, sizeof(kctl->id.name),
>                                          "Feature %d", unitid);
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 81256ab56835..409fc1164694 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1652,34 +1652,6 @@  static const struct usb_feature_control_info *get_feature_control_info(int contr
 	return NULL;
 }
 
-static int feature_unit_mutevol_ctl_name(struct usb_mixer_interface *mixer,
-					 struct snd_kcontrol *kctl,
-					 struct usb_audio_term *iterm,
-					 struct usb_audio_term *oterm)
-{
-	struct usb_audio_term *aterm, *bterm;
-	bool output_first;
-	int len = 0;
-
-	/*
-	 * If the input terminal is USB Streaming, we try getting the name of
-	 * the output terminal first in hopes of getting something more
-	 * descriptive than "PCM".
-	 */
-	output_first = iterm && !(iterm->type >> 16) && (iterm->type & 0xff00) == 0x0100;
-
-	aterm = output_first ? oterm : iterm;
-	bterm = output_first ? iterm : oterm;
-
-	if (aterm)
-		len = get_term_name(mixer->chip, aterm, kctl->id.name,
-				    sizeof(kctl->id.name), 1);
-	if (!len && bterm)
-		len = get_term_name(mixer->chip, bterm, kctl->id.name,
-				    sizeof(kctl->id.name), 1);
-	return len;
-}
-
 static void __build_feature_ctl(struct usb_mixer_interface *mixer,
 				const struct usbmix_name_map *imap,
 				unsigned int ctl_mask, int control,
@@ -1761,15 +1733,22 @@  static void __build_feature_ctl(struct usb_mixer_interface *mixer,
 	case UAC_FU_MUTE:
 	case UAC_FU_VOLUME:
 		/*
-		 * Determine the control name:
-		 * - If a name id is given in descriptor, use it.
-		 * - If input and output terminals are present, try to derive
-		 *   the name from either of these.
-		 * - Otherwise, make up a name using the feature unit ID.
+		 * determine the control name.  the rule is:
+		 * - if a name id is given in descriptor, use it.
+		 * - if the connected input can be determined, then use the name
+		 *   of terminal type.
+		 * - if the connected output can be determined, use it.
+		 * - otherwise, anonymous name.
 		 */
 		if (!len) {
-			len = feature_unit_mutevol_ctl_name(mixer, kctl, iterm,
-							    oterm);
+			if (iterm)
+				len = get_term_name(mixer->chip, iterm,
+						    kctl->id.name,
+						    sizeof(kctl->id.name), 1);
+			if (!len && oterm)
+				len = get_term_name(mixer->chip, oterm,
+						    kctl->id.name,
+						    sizeof(kctl->id.name), 1);
 			if (!len)
 				snprintf(kctl->id.name, sizeof(kctl->id.name),
 					 "Feature %d", unitid);