From patchwork Fri Nov 25 16:23:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13056140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A1617C4332F for ; Fri, 25 Nov 2022 16:25:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 889611756; Fri, 25 Nov 2022 17:24:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 889611756 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669393499; bh=XUfP3i5zZOPBlSdBYcxCJnf4K9znvQVeisyuaTP46LU=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=cnOIkzMDm+O5a+rVZS1P4znFPh5jCXt321Ty7Umt9FtMrNtKNqxTpcTh5jqkFQb3/ GqFYKp2tvzUe6COZGN7/An+fY8FjZPBYbSt8FRtHnoWPvMHBkNYJXiKtOEPFibWdIb H9/B96S6kNUK0bNkEHmo8LYBQVo2LodFA+lH+nag= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B05E5F804DA; Fri, 25 Nov 2022 17:23:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2FC43F80536; Fri, 25 Nov 2022 17:23:58 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 34C96F800F4 for ; Fri, 25 Nov 2022 17:23:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 34C96F800F4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="DiB+1EYN" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2APAeIaK029176; Fri, 25 Nov 2022 10:23:50 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=FTPAQaBI84T5fGmRvnjMMF29Uzq7na6tQmz0qrjkYdA=; b=DiB+1EYNnI89/NvVE4PdeuLN8EKbFEXcMMUfArTX+KzykwclaJ098DPMx2pcSdo7O6/h a9JYMlXVMJfSFO8Otz9Xl6Dlg9bVZQOafhdDqSv3SNPfavAffJDEaUcJvPVZBG00JF6M 5c1KSoFQ65zYKwfG6hut0RYBg/1gs2oGYIUoCbk8BEanpj0/HMY7WVjjLU9gEqCv1nwD 8G1LgKRFCQvzfwsXTVRDE4S/EAU94rJPaDuxVpMjZHq6IjFC3sqmuXwlxnTQzg3jsJLS mnOGvbmuyACN2+n+c+hdnp2LycyhjFP/GiNQLg116ZeMkzzpA3u1Dh/8lBLZ35MKAZe6 dw== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet7g82-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Nov 2022 10:23:50 -0600 Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Fri, 25 Nov 2022 10:23:48 -0600 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.20 via Frontend Transport; Fri, 25 Nov 2022 10:23:48 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id B4BF72BA; Fri, 25 Nov 2022 16:23:48 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 1/2] ASoC: ops: Correct bounds check for second channel on SX controls Date: Fri, 25 Nov 2022 16:23:47 +0000 Message-ID: <20221125162348.1288005-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 0OTHcAHjBB1bjxQ63tY1aa2bFHf3daZh X-Proofpoint-GUID: 0OTHcAHjBB1bjxQ63tY1aa2bFHf3daZh X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, guille.rodriguez@gmail.com, patches@opensource.cirrus.com, lgirdwood@gmail.com, david.rhodes@cirrus.com, james.schulman@cirrus.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Currently the check against the max value for the control is being applied after the value has had the minimum applied and been masked. But the max value simply indicates the number of volume levels on an SX control, and as such should just be applied on the raw value. Fixes: e9b397afabb8 ("ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx()") Signed-off-by: Charles Keepax --- sound/soc/soc-ops.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 1970bda074d8a..55b009d3c6815 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -464,16 +464,15 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, ret = err; if (snd_soc_volsw_is_stereo(mc)) { - unsigned int val2; - - val_mask = mask << rshift; - val2 = (ucontrol->value.integer.value[1] + min) & mask; + unsigned int val2 = ucontrol->value.integer.value[1]; if (mc->platform_max && val2 > mc->platform_max) return -EINVAL; if (val2 > max) return -EINVAL; + val_mask = mask << rshift; + val2 = (val2 + min) & mask; val2 = val2 << rshift; err = snd_soc_component_update_bits(component, reg2, val_mask, From patchwork Fri Nov 25 16:23:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13056141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D468C4332F for ; Fri, 25 Nov 2022 16:25:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5CC71174F; Fri, 25 Nov 2022 17:24:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5CC71174F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669393523; bh=yeuYvUtP5IVhQ6iSiTlsYLHvJvOZsbe8fDh+LCezd8k=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aB//8ZCFXXI+XTyDauif6wnbMJwnf20YsDRQoUQmPqrgjmD/949eHf/yX3AjW+GYa qsfTOU5cnbOSG6nOPV8f0EetmWcWq2jOw2ZM9D/FmZBAgT1qrsUwjTBRkhCfkjwsLB L3FATY/bKObMmrxKF2DYUbHXCNTH9s/Pz9n23fSc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 31F45F80557; Fri, 25 Nov 2022 17:24:01 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 28470F80558; Fri, 25 Nov 2022 17:24:00 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8825FF804C2 for ; Fri, 25 Nov 2022 17:23:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8825FF804C2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="gDDBXTDA" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2APCOf0w022885; Fri, 25 Nov 2022 10:23:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=zeZNUjzy57NN3Hk4KRXKIuEe9RIRWqCcj5tugPZ4Hfg=; b=gDDBXTDAyavtUn6nuU3vUjFEM6Q9ic4mVz4wOjnl5UG5jeJIAjfQkmQylUmIOjOucjAa ULJy4/DYKMtnhHhiM9pSIkNgVsEZQ4mSpx51adVTPZorfZnDey04egbZoIvxM/4DBQFB +pUvTWcehnNUsfOWo2tZOWYEPJFS2GxvdvKIQSlfIahqYDbBcf2A7fo3nW5ycOy/4nxm 5CIXrOm7QquduqRj36JF4f3EiXAxeUO6u6f/K32g9wVsiH3RrsUU2XalKfUA6V3w3Rz3 ACAACdUhsj0FNModvFwO5c0L4ZQIKd2ev1edIpeoPEpISYqNANkAzCPAxPxRNnrCPFIs jg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6yh00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Nov 2022 10:23:50 -0600 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Fri, 25 Nov 2022 10:23:48 -0600 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.20 via Frontend Transport; Fri, 25 Nov 2022 10:23:48 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id C4A6AB0E; Fri, 25 Nov 2022 16:23:48 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 2/2] ASoC: cs42l51: Correct PGA Volume minimum value Date: Fri, 25 Nov 2022 16:23:48 +0000 Message-ID: <20221125162348.1288005-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221125162348.1288005-1-ckeepax@opensource.cirrus.com> References: <20221125162348.1288005-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: -JUSEsmWA-GIksi0hAef8zf4O2sYWMCw X-Proofpoint-GUID: -JUSEsmWA-GIksi0hAef8zf4O2sYWMCw X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, guille.rodriguez@gmail.com, patches@opensource.cirrus.com, lgirdwood@gmail.com, david.rhodes@cirrus.com, james.schulman@cirrus.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The table in the datasheet actually shows the volume values in the wrong order, with the two -3dB values being reversed. This appears to have caused the lower of the two values to be used in the driver when the higher should have been, correct this mixup. Signed-off-by: Charles Keepax --- sound/soc/codecs/cs42l51.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 51721edd8f53c..e88d9ff95cdfc 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -143,7 +143,7 @@ static const struct snd_kcontrol_new cs42l51_snd_controls[] = { 0, 0xA0, 96, adc_att_tlv), SOC_DOUBLE_R_SX_TLV("PGA Volume", CS42L51_ALC_PGA_CTL, CS42L51_ALC_PGB_CTL, - 0, 0x19, 30, pga_tlv), + 0, 0x1A, 30, pga_tlv), SOC_SINGLE("Playback Deemphasis Switch", CS42L51_DAC_CTL, 3, 1, 0), SOC_SINGLE("Auto-Mute Switch", CS42L51_DAC_CTL, 2, 1, 0), SOC_SINGLE("Soft Ramp Switch", CS42L51_DAC_CTL, 1, 1, 0),