From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [regression] probably in mixer.c code Date: Tue, 08 Nov 2011 10:59:01 +0100 Message-ID: References: <4EB8ED09.2090301@fisher-privat.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 6B83824353 for ; Tue, 8 Nov 2011 10:59:04 +0100 (CET) In-Reply-To: <4EB8ED09.2090301@fisher-privat.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Alexey Fisher Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org 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;