[alsa-devel] [PATCH]: sound/usb/mixer.c: Volume quirks compare empty string kctl->id.name.

Takashi Iwai tiwai at suse.de
Mon May 14 17:13:51 CEST 2012


At Mon, 7 May 2012 09:51:29 +0200,
Christian Melki wrote:
> 
> > > Hi,
> > > 
> > > Sorry to mail you directly. But I have tried to mail several times to 
> > > the mailing list but I don't get through. Everything checks out fine, 
> > > no html etc, other mailing lists work fine, but not alsa devel.
> > > Anyway, could you please have a look at this?
> > 
> > Could you resend the patch but just add me, Clemens and Daniel to Cc, so that it reaches to main developers for usb-audio?  Even if we take your patch as is, it'd be needed to be applicable via git-am.
> > 
> > 
> > thanks,
> > 
> > Takashi
> 
> Hi.
> 
> I noticied that volume quirks in usb-audio did not get applied.
> This is because kctl->id.name gets built properly _after_ calling the quirk adjustments.
> My solution is a bit ugly, but check_mapped_dB needs the adjustment before getting called.
> I split the call over the switch. If someone feels like writing something cleaner, please feel free.
> This works for me atleast.

It's not ugly, but it'd be better to split the code to handle the name
string, call get_min_max_*(), then the rest for FU.

Could you check whether the patch below works?


thanks,

Takashi

---
From: Takashi Iwai <tiwai at suse.de>
Subject: [PATCH] ALSA: usb-audio - Call get_min_max_*() after determining the
 name string

get_min_max_with_quirks() must be called after the control id name
string is determined, but the current code changes the id name string
after calling the function.

Reported-by: Christian Melki <christian.melki at ericsson.com>
Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
 sound/usb/mixer.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 3d70245..4f40ba8 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1141,9 +1141,6 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
 		len = snd_usb_copy_string_desc(state, nameid,
 				kctl->id.name, sizeof(kctl->id.name));
 
-	/* get min/max values */
-	get_min_max_with_quirks(cval, 0, kctl);
-
 	switch (control) {
 	case UAC_FU_MUTE:
 	case UAC_FU_VOLUME:
@@ -1175,17 +1172,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
 		}
 		append_ctl_name(kctl, control == UAC_FU_MUTE ?
 				" Switch" : " Volume");
-		if (control == UAC_FU_VOLUME) {
-			check_mapped_dB(map, cval);
-			if (cval->dBmin < cval->dBmax || !cval->initialized) {
-				kctl->tlv.c = snd_usb_mixer_vol_tlv;
-				kctl->vd[0].access |= 
-					SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-					SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
-			}
-		}
 		break;
-
 	default:
 		if (! len)
 			strlcpy(kctl->id.name, audio_feature_info[control-1].name,
@@ -1193,6 +1180,19 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
 		break;
 	}
 
+	/* get min/max values */
+	get_min_max_with_quirks(cval, 0, kctl);
+
+	if (control == UAC_FU_VOLUME) {
+		check_mapped_dB(map, cval);
+		if (cval->dBmin < cval->dBmax || !cval->initialized) {
+			kctl->tlv.c = snd_usb_mixer_vol_tlv;
+			kctl->vd[0].access |=
+				SNDRV_CTL_ELEM_ACCESS_TLV_READ |
+				SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
+		}
+	}
+
 	range = (cval->max - cval->min) / cval->res;
 	/* Are there devices with volume range more than 255? I use a bit more
 	 * to be sure. 384 is a resolution magic number found on Logitech
-- 
1.7.9.2



More information about the Alsa-devel mailing list