From patchwork Wed Aug 21 10:02:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 171944 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp743771ily; Wed, 21 Aug 2019 03:02:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwBCw+4vipMR0lur+4SlvoeCSj5zcsw26l0q091JOdbVmMh6fb9SBr1nWbWtgTO+ONF2m9 X-Received: by 2002:a63:290:: with SMTP id 138mr26107486pgc.402.1566381753975; Wed, 21 Aug 2019 03:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566381753; cv=none; d=google.com; s=arc-20160816; b=jKhFRKeB5wfYn3IN6jucnfk1JaNEI8CClxelYnCxsxsjUI87pSRxrcsT+Phx7ViekP 8wA6ArMZ2+97GeKrt977L1lB24KFzhlZjiyRBZoDu4ZV8DC3Ph3+2I3n/1FeNIPjCiXR gej4Wp5E2aooFcAKqFMlsE/Z3dAn3v5QaN3BELZgEOaipXVAwf0tB/ySKTBXlKukdd5r WSyTa8OsVQUYsaqMOpvk6K580G/INUzfaqE0dUMn+0Plws4HrMH8AgnFOiapdPBp1SXd hgfibTpwEbRk8iUHbkAaX5kMRbOV2oKxg9IV7Yc8Px+0k/aE9dU1+fYqJa5NFO8RH2Fa ff3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=K/D2OOa3rUCb1UxCtROHFgWT7WT32fJQ0RqabewlpP4=; b=HyvB+Z4lOTBOu2rbQebzu/Fvj1k2yhU7EXLinm23Q0bigEN1oAf1vEbc6n4B+Lb5p+ SHi26rP+xQ5/XXJE3XYXxT+nXowLbYaY/4gEC9FUFMFKB/IxY0YyC/e+5eLFlJBVhRZP JwbpNSY6L4MXqiirIUFaXUE0Opcv0b4YY57L4s8JYNLTe+Hb6rqYh1fyAL8sbE2SqW2R ujshUiYFjJ+lwzNLcCcdnywABQ/2A/dd4Mb7GCFC7l588JQz8hLYqBew5S6n1p8Rb76i XIhamryf/cdTa6rMdDevW+tZiaHfwxIH0NS2x5kE0rG0rJ141E+wj36f5CuulnhYGxol ZfmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NH79btyX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si7577906plm.434.2019.08.21.03.02.33; Wed, 21 Aug 2019 03:02:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NH79btyX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727367AbfHUKCc (ORCPT + 28 others); Wed, 21 Aug 2019 06:02:32 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40204 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbfHUKCc (ORCPT ); Wed, 21 Aug 2019 06:02:32 -0400 Received: by mail-wm1-f66.google.com with SMTP id c5so1290928wmb.5 for ; Wed, 21 Aug 2019 03:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K/D2OOa3rUCb1UxCtROHFgWT7WT32fJQ0RqabewlpP4=; b=NH79btyXC6dVG3wkr4Fdx1Yq1A2e9kJmz8GnS4AUbk05BLqhDM/T4FXlmBmPj+yea1 INXWJGh6G3Om7sI6e+Mrri8adjfEu4PPc3WfgUiN3UxBQ3Ddvlst3wGWHUE2VFV/pxI1 kzBNpMH9JwNPiEJ8rllBzIvIvHOjSB2lgHeL4kL9zFSIC1RTbqs2UEVu7/k3myQlYqdx VY5FAdjqWKhfXl06TAKYs6XkranuHu44+/dWSOZNAnf31G+d40FE3x0r9Y4LQNrXiIUV 8EymqI3vlQg2CZAgP5U4dz2pZSUnoKdSDHjwZKaJ7mhWcanv+G6yX+4ovVVyYI+9feSs eNLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K/D2OOa3rUCb1UxCtROHFgWT7WT32fJQ0RqabewlpP4=; b=UZZ1GebxkZvEkwHJlEqvZA2DSJu+ebWTNuoawHNeqjYpa+6mmyclq2fOAaqa6rIU6T +c1gRFnPbe1LoeoH94vcVeSOJAsa75Api/XHAxt1pVDsNxOMC9P9dxXX13I6VEfyVNTU 6EQSeXDKq8ac8BbmRKU0Tw/BSSCayUE5wDg0qmf5KcxvzZMsOS1AmSUSInmQ92U+Vc1s OXiiWfj1XN+PM+w7grgjZbhNsX3oyGvN3f9JIjpbSrm8IipSy72rkHkMJA6H2YaScr2v EC7sTisOTNWgHHYKpH3Bzqj40f21pichd8czSbNC1fPfJQYFld+Ecn/tuIh3avIZ13eA 05Bg== X-Gm-Message-State: APjAAAXOZnBKDJ1MSOjfepm4kfsWPMCRaDp9RdPs22hZ/3sMdwu2YSqZ 6UvdwZRcH+l+a1N6NKEZoqDQGA== X-Received: by 2002:a1c:721a:: with SMTP id n26mr4968409wmc.88.1566381749694; Wed, 21 Aug 2019 03:02:29 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id j9sm24102676wrx.66.2019.08.21.03.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2019 03:02:29 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, Deepa Madiregama , Banajit Goswami , Meng Wang , Srinivas Kandagatla Subject: [PATCH] ALSA: usb-audio: Fix the mixer control range limiting issue Date: Wed, 21 Aug 2019 11:02:25 +0100 Message-Id: <20190821100225.9254-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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(-) -- 2.21.0 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)