From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9590BC3A59E for ; Wed, 21 Aug 2019 17:05:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 72EE92332A for ; Wed, 21 Aug 2019 17:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729798AbfHURFD (ORCPT ); Wed, 21 Aug 2019 13:05:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:54928 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726828AbfHURFD (ORCPT ); Wed, 21 Aug 2019 13:05:03 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F0D76AF1F; Wed, 21 Aug 2019 17:05:01 +0000 (UTC) Date: Wed, 21 Aug 2019 19:05:01 +0200 Message-ID: From: Takashi Iwai To: Srinivas Kandagatla Cc: broonie@kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, Deepa Madiregama , Banajit Goswami , Meng Wang Subject: Re: [PATCH] ALSA: usb-audio: Fix the mixer control range limiting issue In-Reply-To: <20190821100225.9254-1-srinivas.kandagatla@linaro.org> References: <20190821100225.9254-1-srinivas.kandagatla@linaro.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Aug 2019 12:02:25 +0200, Srinivas Kandagatla wrote: > > From: Deepa Madiregama > > - mixer_ctl_set() function is limiting the volume level > to particular range. This results in incorrect initial > volume setting for that device. > - In USB mixer while calculating the dBmin/dBmax values > resolution factor is hardcoded to 256 which results in > populating the wrong values for dBmin/dBmax. > - Fix is to use appropriate resolution factor while > calculating the dBmin/dBmax values. This change doesn't sound right. Basically the values returned from USB-audio FEATURE UNIT or MIXER UNIT are always in 1/256 dB unit, per definition. And we pass dB min/max to user-space as TLV_DB_MINMAX(), i.e. TLV points just both min and max, no matter what scale is. I believe that the current code is correct in this regard. So, it's either a firmware bug that gives the wrong values back, or the case we still don't cover, e.g. multiple RANGE values for UAC2/UAC3. Please check what exactly doesn't work as expected. Which value is returned from the USB-audio device and what is wrongly interpreted. thanks, Takashi > Signed-off-by: Deepa Madiregama > Signed-off-by: Banajit Goswami > Signed-off-by: Meng Wang > Signed-off-by: Srinivas Kandagatla > --- > sound/usb/mixer.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c > index 5070a6a76ab3..a67448327d07 100644 > --- a/sound/usb/mixer.c > +++ b/sound/usb/mixer.c > @@ -1248,8 +1248,10 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval, > /* 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; > + cval->dBmin = > + (convert_signed_value(cval, cval->min) * 100) / (cval->res); > + cval->dBmax = > + (convert_signed_value(cval, cval->max) * 100) / (cval->res); > if (cval->dBmin > cval->dBmax) { > /* something is wrong; assume it's either from/to 0dB */ > if (cval->dBmin < 0) > -- > 2.21.0 >