[alsa-devel] Lost dB volumes on USB headset between 2.6.38 and 3.0

Takashi Iwai tiwai at suse.de
Fri Aug 19 08:15:27 CEST 2011


At Fri, 19 Aug 2011 07:53:44 +0200,
Takashi Iwai wrote:
> 
> At Fri, 19 Aug 2011 06:55:54 +0800,
> Raymond Yau wrote:
> > 
> > 2011/8/18 Takashi Iwai <tiwai at suse.de>:
> > > At Tue, 16 Aug 2011 13:31:52 +0100,
> > > Colin Guthrie wrote:
> > >>
> > >> > diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> > >> > index c04d7c7..cdd19d7 100644
> > >> > --- a/sound/usb/mixer.c
> > >> > +++ b/sound/usb/mixer.c
> > >> > @@ -152,6 +152,7 @@ static inline void check_mapped_dB(const struct usbmix_name_map *p,
> > >> >     if (p && p->dB) {
> > >> >             cval->dBmin = p->dB->min;
> > >> >             cval->dBmax = p->dB->max;
> > >> > +           cval->initialized = 1;
> > >> >     }
> > >> >  }
> > >> >
> > >> > @@ -1092,7 +1093,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
> > >> >                             " Switch" : " Volume");
> > >> >             if (control == UAC_FU_VOLUME) {
> > >> >                     check_mapped_dB(map, cval);
> > >> > -                   if (cval->dBmin < cval->dBmax) {
> > >> > +                   if (cval->dBmin < cval->dBmax || !cval->initialized) {
> > >> >                             kctl->tlv.c = mixer_vol_tlv;
> > >> >                             kctl->vd[0].access |=
> > >> >                                     SNDRV_CTL_ELEM_ACCESS_TLV_READ |
> > >>
> > >>
> > >>
> > >> Not had a chance to test this yet but I will when I get a moment.
> > >
> > > Any chance to test the patch?
> > >
> > 
> > The patch seem fix the no dB scale problem , however the broken dB
> > test which you added seem redundant as cval->dBmin and cval->dBmax are
> > still zero because error in get_min_max() at build_feature_ctl() and
> > it seem that the valid dBmin and dBMax are calculated by get_min_max()
> > at mixer_ctl_feature_info() on my usb logitech web cam
> 
> Yeah, that's a known problem.  The dB-test is missing when reading dB
> failed at probing time and later it gives a wrong value.
> 
> We can add another dB-test later, and remove TLV bit from
> kcontrol.access on the fly.  But for that, we'd need to notify via
> SNDRV_CTL_EVENT_MASK_INFO, too.

I meant something like below.


Takashi

---
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index cdd19d7..78a5abd 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -881,8 +881,17 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
 		uinfo->value.integer.min = 0;
 		uinfo->value.integer.max = 1;
 	} else {
-		if (! cval->initialized)
-			get_min_max(cval,  0);
+		if (!cval->initialized) {
+			get_min_max(cval, 0);
+			if (cval->initialized && cval->dBmin >= cval->dBmax) {
+				kcontrol->vd[0].access &= 
+					~(SNDRV_CTL_ELEM_ACCESS_TLV_READ |
+					  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK);
+				snd_ctl_notify(cval->mixer->chip->card,
+					       SNDRV_CTL_EVENT_MASK_INFO,
+					       &kcontrol->id);
+			}
+		}
 		uinfo->value.integer.min = 0;
 		uinfo->value.integer.max =
 			(cval->max - cval->min + cval->res - 1) / cval->res;


More information about the Alsa-devel mailing list