From patchwork Tue Jan 26 12:20:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 371587 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 74E49C433DB for ; Tue, 26 Jan 2021 12:22:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E7651230FD for ; Tue, 26 Jan 2021 12:22:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7651230FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 613C3167E; Tue, 26 Jan 2021 13:21:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 613C3167E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1611663720; bh=Hfktci+wQiCWrx5GmUeS5H66RNpngb9jgi6ys2ZxCus=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=m9+DydGsH+MrXVdCiqCTbfe2PjMxBcWvdYWiNdlL5PnI6fJQIhje3/n0rAV1s25Km wqNpKgREEBJ7s8psajdnAzrPU9ESv7vdd3M8KTF/RaXQd7D7cVtgjdIG6uPSMvt4Ev Ae8H8hlQxIvjslvVb38mtkeCS0LSX0W5Uw05C/nA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B8CEFF8015B; Tue, 26 Jan 2021 13:21:09 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E371AF801D8; Tue, 26 Jan 2021 13:21:08 +0100 (CET) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 65D3EF8011C for ; Tue, 26 Jan 2021 13:21:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 65D3EF8011C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Kpx6+TDB" Received: by mail-wr1-x431.google.com with SMTP id v15so16218435wrx.4 for ; Tue, 26 Jan 2021 04:21:00 -0800 (PST) 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=PGay3cWIFfTGXVJgJYEz2HA9Nfskw8Lpr3d/5Y01BQU=; b=Kpx6+TDBpZzINbQVksCtDf0edv2+6ZBEuae37HH5PL1YKkPF3mQB7mjA4USFVymwI0 1WGoNA9amxJB5Ky+p6RMrPsOp4azcGY8T20WkQDoZJiekOWl95IcAU6ouaPQZCv2UvoU O511ccJ+jt3UaTfWSfz/jU14m2zlLErH32Aki/sGSdam1WPFaFrp9tCJsInJruPHaiLI rUtK4G08vKSV1UP3oIp21ccrVcqap1x9XWz88akff5f1rZrI5u19eo2AinJ5Cia16Wd8 hZtvQMdr3W1Ina2LkpIg6smf7yW6M9D1yDWSqTfS1a37OGS+cFrkiTX3imlgm6GeItvG IS5g== 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=PGay3cWIFfTGXVJgJYEz2HA9Nfskw8Lpr3d/5Y01BQU=; b=aNOvwH+G+CLYQFhmtjGqO81WhuDQjuzSveJRfzYGnBVLCrBil/xbX/+keRSHh22bfI T5/0NOMBUBe3aoi3GnQnU0t4dmwtWBYV57aiGRE8wLlXdzLGo8WtS6SwWNkkvh/D0kSV hbMyvOT5C/O24eupb9NZLyaSN9pzaOppNKrMwUVbiQ7q16k3N8WVrH9CdEP5PHcqJaJ9 9pZVL5vJZjDJsuVxbRF6RDvbkEyqpAIfuU1brUP2baGWSPgMec02pVmS7v1+k7i5JkgV Q4oQgTUhryoPMNCeYx52vVLM9n6UVIVDA90xe3h7OHKTIzXwisT2L/pfS4FNgXKZXaWN jtdg== X-Gm-Message-State: AOAM532VPJf3v/Xb/fKkbkVBmqiW0aLTankgeaCncydgaG1dGzUyhsXT LrYrszLVE7zHcvZtPPzKcx5fGQ== X-Google-Smtp-Source: ABdhPJzWuBSc18W8U//lbfGPeHuIY8wsRVGuX5eWxpbwLQ/2vTe2Y4EuBN6eZ3iPZmuNxCp5glRInw== X-Received: by 2002:adf:dd81:: with SMTP id x1mr5841474wrl.249.1611663659997; Tue, 26 Jan 2021 04:20:59 -0800 (PST) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id o124sm3218908wmb.5.2021.01.26.04.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 04:20:59 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [RFC PATCH 1/2] ASoC: soc-component: add snd_soc_component_read/write_field() Date: Tue, 26 Jan 2021 12:20:19 +0000 Message-Id: <20210126122020.19735-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, tiwai@suse.com, vkoul@kernel.org, Srinivas Kandagatla 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" It's often the case that we would write or read a particular field in register. With the current soc_component apis, reading a particular field in register would involve first read the register and then perform shift operations. Ex: to read from a field mask of 0xf0 val = snd_soc_component_read(component, reg); field = ((val & 0xf0) >> 0x4); This is sometimes prone to errors and code become less readable! With this new api we could just do field = snd_soc_component_read_field(component, reg, 0xf0); this makes it bit simple, easy to write and less error prone! This also applies to writing! There are various places in kernel which provides such field interfaces however soc_component seems to be missing this. This patch is inspired by FIELD_GET/FIELD_PREP macros in include/linux/bitfield.h Signed-off-by: Srinivas Kandagatla --- include/sound/soc-component.h | 6 ++++ sound/soc/soc-component.c | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 0bce41fefd30..5b47768222b7 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -353,6 +353,12 @@ int snd_soc_component_test_bits(struct snd_soc_component *component, unsigned int reg, unsigned int mask, unsigned int value); +unsigned int snd_soc_component_read_field(struct snd_soc_component *component, + unsigned int reg, unsigned int mask); +int snd_soc_component_write_field(struct snd_soc_component *component, + unsigned int reg, unsigned int mask, + unsigned int val); + /* component wide operations */ int snd_soc_component_set_sysclk(struct snd_soc_component *component, int clk_id, int source, diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 760523382f3c..6bdfc6f61ed6 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -12,6 +12,7 @@ #include #include +#define __soc_component_field_shift(x) (__builtin_ffs(x) - 1) #define soc_component_ret(dai, ret) _soc_component_ret(dai, __func__, ret) static inline int _soc_component_ret(struct snd_soc_component *component, const char *func, int ret) @@ -839,6 +840,67 @@ int snd_soc_component_update_bits_async(struct snd_soc_component *component, } EXPORT_SYMBOL_GPL(snd_soc_component_update_bits_async); +/** + * snd_soc_component_read_field() - Read register field value + * @component: Component to read from + * @reg: Register to read + * @mask: mask of the register field + * + * Return: read value of register field. + */ +unsigned int snd_soc_component_read_field(struct snd_soc_component *component, + unsigned int reg, unsigned int mask) +{ + unsigned int val; + + mutex_lock(&component->io_mutex); + val = soc_component_read_no_lock(component, reg); + if (mask) + val = (val & mask) >> __soc_component_field_shift(mask); + mutex_unlock(&component->io_mutex); + + return val; +} +EXPORT_SYMBOL_GPL(snd_soc_component_read_field); + +/** + * snd_soc_component_write_field() - write to register field + * @component: Component to write to + * @reg: Register to write + * @mask: mask of the register field to update + * @val: value of the field to write + * + * Return: 1 for change, otherwise 0. + */ +int snd_soc_component_write_field(struct snd_soc_component *component, + unsigned int reg, unsigned int mask, + unsigned int val) +{ + unsigned int old, new; + int ret = 0; + bool change; + + if (!mask) + return false; + + mutex_lock(&component->io_mutex); + + old = soc_component_read_no_lock(component, reg); + + val = val << __soc_component_field_shift(mask); + + new = (old & ~mask) | (val & mask); + + change = old != new; + if (change) + ret = soc_component_write_no_lock(component, reg, new); + + mutex_unlock(&component->io_mutex); + + return change; +} +EXPORT_SYMBOL_GPL(snd_soc_component_write_field); + /** * snd_soc_component_async_complete() - Ensure asynchronous I/O has completed * @component: Component for which to wait From patchwork Tue Jan 26 12:20:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 370659 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 6ED9EC433E0 for ; Tue, 26 Jan 2021 12:22:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9E2FE230FD for ; Tue, 26 Jan 2021 12:22:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E2FE230FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 D6BA117AF; Tue, 26 Jan 2021 13:22:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D6BA117AF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1611663776; bh=CbbIzrizcoPfQ5IG3j31n+bUwb19ahKPr9uM2AMKlxk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hOYuuhh3sLb8oGh55/jT6Ej4JRc7K39x+YudwEuY6JLbkk59KHNFRozFSdsSwCouQ axeYu/6I437wWyhBy13HiSl1CnmuYwUlNzBk8DPpf1qDjIiMviaMqXHm2/EAXfVQT0 9SDl8Yh9AnZzbVtG6TaCRLyqYN5tv4I4MHJQa85w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BA771F801ED; Tue, 26 Jan 2021 13:21:14 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 63FA9F80130; Tue, 26 Jan 2021 13:21:10 +0100 (CET) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 94A55F80130 for ; Tue, 26 Jan 2021 13:21:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 94A55F80130 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sQxtrAPD" Received: by mail-wm1-x334.google.com with SMTP id j18so2267145wmi.3 for ; Tue, 26 Jan 2021 04:21:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cT55FABjLyu7dYc21lezhM1CvuGo2h6vplhaEe339cE=; b=sQxtrAPDGHx28PS3PrAnLjW3O2df6d9uwXWZIEBDIGzcESNVEOPE1i+zgd7bz7+HFW +RJraLD8FsYZxVW3Enf2ePmMMCy+oWrGyz3uKQnWvsflUqX/KHiPbv5VpKXaAWe7qmyr RjZOdQiWWyLnLuwvhVN+T15cCq60JjjVz3KDudUNccZR3NF4f8wNcqNJJqGmBKw/4wOM zNhgx4fGWVwOZhX5Audny0MNcRjM3Ob4Ehc6G6OGfXki6SoqiVYeSXGYSguoMM2ivPkg cyFQxZFonRCYyNL0fxdOExiHNaNS/hQ5lljb4Rrnxj+VbmBAbCuKQlaw1tXuHWYylV61 iPUg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=cT55FABjLyu7dYc21lezhM1CvuGo2h6vplhaEe339cE=; b=DpParpfuyPZgQJoT3WCNit4cV1Nj2mpFTBSNLO/ok8r5jr5QiB8X5G7QDE3Ma42ijd N2/E3ZXo0lmwCp1kPo0XLzaiy9CFgQyJ422+DK0G4gxJ5z/3BjjK4qDoqG1nFMeSTXhM cbTgoKV5h2Eyj5BJ2fAlI/sR8yRlyBdidWYyPq8drG2SalNMWi0DSG+CxCfSqcUgSpAU IMq1noSRsnMPwt5dfDYq/whoDZruw3l7YIJABesdtbCwkKXCmvsNcIW5wcuDaZ4oYtKU TjoVCVsitaPLtlb1cti6YxocUffDgwSpqUX2B84jse5dVJ8ad72QeJWt6/pZfRA4qLxE 2+UA== X-Gm-Message-State: AOAM533qtSWEQky/E03Q52CWfcX2KWVRFOxt7rgjIqLTd5fjA87J1lhf DVB4g/RLxBgeOPuoFOx8j/7EcA== X-Google-Smtp-Source: ABdhPJz1Yn21nLtfD6Rp/dnNNMIkgoRGpyYiVEm1W+D0VRqMZ+wmEX21ZV0nZrNocfXjZpIHOgjH6g== X-Received: by 2002:a1c:1b83:: with SMTP id b125mr4528765wmb.8.1611663661202; Tue, 26 Jan 2021 04:21:01 -0800 (PST) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id o124sm3218908wmb.5.2021.01.26.04.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 04:21:00 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [RFC PATCH 2/2] ASoC: codecs: lpass-wsa-macro: make use of snd_soc_component_read_field() Date: Tue, 26 Jan 2021 12:20:20 +0000 Message-Id: <20210126122020.19735-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210126122020.19735-1-srinivas.kandagatla@linaro.org> References: <20210126122020.19735-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, tiwai@suse.com, vkoul@kernel.org, Srinivas Kandagatla 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" Make use of snd_soc_component_read_field() to make the code more readable! Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-wsa-macro.c | 43 ++++++++++++++---------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index 25f1df214ca5..5ebcd935ba89 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -40,9 +40,11 @@ #define CDC_WSA_TOP_I2S_CLK (0x00A4) #define CDC_WSA_TOP_I2S_RESET (0x00A8) #define CDC_WSA_RX_INP_MUX_RX_INT0_CFG0 (0x0100) -#define CDC_WSA_RX_INTX_1_MIX_INP2_SEL_MASK GENMASK(5, 3) -#define CDC_WSA_RX_INTX_2_SEL_MASK GENMASK(2, 0) +#define CDC_WSA_RX_INTX_1_MIX_INP0_SEL_MASK GENMASK(2, 0) +#define CDC_WSA_RX_INTX_1_MIX_INP1_SEL_MASK GENMASK(5, 3) #define CDC_WSA_RX_INP_MUX_RX_INT0_CFG1 (0x0104) +#define CDC_WSA_RX_INTX_2_SEL_MASK GENMASK(2, 0) +#define CDC_WSA_RX_INTX_1_MIX_INP2_SEL_MASK GENMASK(5, 3) #define CDC_WSA_RX_INP_MUX_RX_INT1_CFG0 (0x0108) #define CDC_WSA_RX_INP_MUX_RX_INT1_CFG1 (0x010C) #define CDC_WSA_RX_INP_MUX_RX_MIX_CFG0 (0x0110) @@ -229,8 +231,6 @@ #define NUM_INTERPOLATORS 2 #define WSA_NUM_CLKS_MAX 5 #define WSA_MACRO_MCLK_FREQ 19200000 -#define WSA_MACRO_MUX_INP_SHFT 0x3 -#define WSA_MACRO_MUX_INP_MASK1 0x07 #define WSA_MACRO_MUX_INP_MASK2 0x38 #define WSA_MACRO_MUX_CFG_OFFSET 0x8 #define WSA_MACRO_MUX_CFG1_OFFSET 0x4 @@ -843,7 +843,6 @@ static int wsa_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, u32 j, port; u16 int_mux_cfg0, int_mux_cfg1; u16 int_fs_reg; - u8 int_mux_cfg0_val, int_mux_cfg1_val; u8 inp0_sel, inp1_sel, inp2_sel; struct snd_soc_component *component = dai->component; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -865,15 +864,13 @@ static int wsa_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, */ for (j = 0; j < NUM_INTERPOLATORS; j++) { int_mux_cfg1 = int_mux_cfg0 + WSA_MACRO_MUX_CFG1_OFFSET; - int_mux_cfg0_val = snd_soc_component_read(component, - int_mux_cfg0); - int_mux_cfg1_val = snd_soc_component_read(component, - int_mux_cfg1); - inp0_sel = int_mux_cfg0_val & WSA_MACRO_MUX_INP_MASK1; - inp1_sel = (int_mux_cfg0_val >> WSA_MACRO_MUX_INP_SHFT) & - WSA_MACRO_MUX_INP_MASK1; - inp2_sel = (int_mux_cfg1_val >> WSA_MACRO_MUX_INP_SHFT) & - WSA_MACRO_MUX_INP_MASK1; + inp0_sel = snd_soc_component_read_field(component, int_mux_cfg0, + CDC_WSA_RX_INTX_1_MIX_INP0_SEL_MASK); + inp1_sel = snd_soc_component_read_field(component, int_mux_cfg0, + CDC_WSA_RX_INTX_1_MIX_INP1_SEL_MASK); + inp2_sel = snd_soc_component_read_field(component, int_mux_cfg1, + CDC_WSA_RX_INTX_1_MIX_INP2_SEL_MASK); + if ((inp0_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0) || (inp1_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0) || (inp2_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0)) { @@ -912,9 +909,9 @@ static int wsa_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, int_mux_cfg1 = CDC_WSA_RX_INP_MUX_RX_INT0_CFG1; for (j = 0; j < NUM_INTERPOLATORS; j++) { - int_mux_cfg1_val = snd_soc_component_read(component, - int_mux_cfg1) & - WSA_MACRO_MUX_INP_MASK1; + int_mux_cfg1_val = snd_soc_component_read_field(component, int_mux_cfg1, + CDC_WSA_RX_INTX_2_SEL_MASK); + if (int_mux_cfg1_val == int_2_inp + INTn_2_INP_SEL_RX0) { int_fs_reg = CDC_WSA_RX0_RX_PATH_MIX_CTL + WSA_MACRO_RX_PATH_OFFSET * j; @@ -1410,25 +1407,25 @@ static bool wsa_macro_adie_lb(struct snd_soc_component *component, int interp_idx) { u16 int_mux_cfg0, int_mux_cfg1; - u8 int_mux_cfg0_val, int_mux_cfg1_val; u8 int_n_inp0, int_n_inp1, int_n_inp2; int_mux_cfg0 = CDC_WSA_RX_INP_MUX_RX_INT0_CFG0 + interp_idx * 8; int_mux_cfg1 = int_mux_cfg0 + 4; - int_mux_cfg0_val = snd_soc_component_read(component, int_mux_cfg0); - int_mux_cfg1_val = snd_soc_component_read(component, int_mux_cfg1); - int_n_inp0 = int_mux_cfg0_val & 0x0F; + int_n_inp0 = snd_soc_component_read_field(component, int_mux_cfg0, + CDC_WSA_RX_INTX_1_MIX_INP0_SEL_MASK); if (int_n_inp0 == INTn_1_INP_SEL_DEC0 || int_n_inp0 == INTn_1_INP_SEL_DEC1) return true; - int_n_inp1 = int_mux_cfg0_val >> 4; + int_n_inp1 = snd_soc_component_read_field(component, int_mux_cfg0, + CDC_WSA_RX_INTX_1_MIX_INP1_SEL_MASK); if (int_n_inp1 == INTn_1_INP_SEL_DEC0 || int_n_inp1 == INTn_1_INP_SEL_DEC1) return true; - int_n_inp2 = int_mux_cfg1_val >> 4; + int_n_inp2 = snd_soc_component_read_field(component, int_mux_cfg1, + CDC_WSA_RX_INTX_1_MIX_INP2_SEL_MASK); if (int_n_inp2 == INTn_1_INP_SEL_DEC0 || int_n_inp2 == INTn_1_INP_SEL_DEC1) return true;