
At Tue, 08 Nov 2011 09:49:13 +0100, Alexey Fisher wrote:
Hallo all, Takashi,
there is one regression in current linux main tree:
cval->res quirks do not work any more. See usb/mixer.c:1150 Are there was some work in this area or may be some one bisected this bug down?
Are you referring to the device 046d:09a4, which sets the mixer range manually? If yes, does the patch below work?
Takashi
--- diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 60f65ac..92feff1 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -765,6 +765,28 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl) * interface to ALSA control for feature/mixer units */
+/* convert from USB descriptions to dB scale + * USB descriptions contain the dB scale in 1/256 dB unit + * while ALSA TLV contains in 1/100 dB unit + */ +static int convert_cval_to_dB(struct usb_mixer_elem_info *cval) +{ + cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256; + cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256; + if (cval->dBmin > cval->dBmax) { + /* something is wrong; assume it's either from/to 0dB */ + if (cval->dBmin < 0) + cval->dBmax = 0; + else if (cval->dBmin > 0) + cval->dBmin = 0; + if (cval->dBmin > cval->dBmax) { + /* totally crap, return an error */ + return -EINVAL; + } + } + return 0; +} + /* * retrieve the minimum and maximum values for the specified control */ @@ -844,24 +866,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) cval->initialized = 1; }
- /* USB descriptions contain the dB scale in 1/256 dB unit - * while ALSA TLV contains in 1/100 dB unit - */ - cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256; - cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256; - if (cval->dBmin > cval->dBmax) { - /* something is wrong; assume it's either from/to 0dB */ - if (cval->dBmin < 0) - cval->dBmax = 0; - else if (cval->dBmin > 0) - cval->dBmin = 0; - if (cval->dBmin > cval->dBmax) { - /* totally crap, return an error */ - return -EINVAL; - } - } - - return 0; + return convert_cval_to_dB(cval); }
@@ -1134,6 +1139,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, snd_printk(KERN_INFO "set volume quirk for UDA1321/N101 chip\n"); cval->max = -256; + convert_cval_to_dB(cval); } break;
@@ -1144,6 +1150,8 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, cval->min = 6080; cval->max = 8768; cval->res = 192; + cval->initialized = 1; + convert_cval_to_dB(cval); } break;