Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4518468iog; Tue, 21 Jun 2022 23:42:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vgI4HEsnuMmYVBtLRvMA0q01FbEaFQ/BIKTXBLYQFhmN4QdOX2v8bJxQWnPtszl453s1Hw X-Received: by 2002:a17:90b:f91:b0:1ec:a026:5637 with SMTP id ft17-20020a17090b0f9100b001eca0265637mr17707425pjb.198.1655880125788; Tue, 21 Jun 2022 23:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655880125; cv=none; d=google.com; s=arc-20160816; b=YX9ThRWZybKI3v25A2jJCxriCUep1kZ1Q/GVK+vpacVJQWat4N2HqebbyYU1zJrKpy MU7a1VCgJEcCwvBpy4lFqKl6LBZ9+eNtRoJMYp1SkP4Xh6jUhpaWdC9Tu+dMOooGLQc7 MopKeu0SJGEYuupJQUd85ap5DAEivg6MCoMtOIGfsLvlNvq7YGmZhWpFuMoqqEresaJZ CxvDSoBY7QNdfFejLkOZHtMmK1iKdzU2blOZkUkhyfIPtoIfiKveCu2jFqX+Tnkh5iEz gZaSh3p1VmIlk4WJj1lHU6nyXg1eOBs7NRPapxhSX4b69cbX29cr2fsXYD2mLknDIzHH 89wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Exzm/TXSqD/Huvr9EUdQ5bsQgg0FbL+KozVE0rZYqD4=; b=zn5GqINKYs+OqFamzr7SovyCdDWDxrdbP076IF4nHsvX1dG2xZWLMdmQb235e2bNP0 p2/C9CQIbPQldU47zhm4I2j32FSHwq/lcwv7Symm4sjSfNSPl1G4Wc6PRivqXn1EfTt7 XYZM9CAHsdnQ5ubrYzvAx49Rt10LsLt0TqjezLk9FX/lzkSdgakzw4S6F6Dothq9qcAH AZ6NLtI6RPn/wt8GfHK9xef7VmG4yhR8nGIUEeTm3xKMie5G6InNAH8Zhlhdv6ITaq+/ 0qygLNU0LnWp8KNM4HGYFyrEAmFK3yXx6IySxvQ6a++uXulp55BJk3ZUT5mGteanGyG9 U6WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qHQLTuz+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020a635c05000000b00408c5943df5si21107865pgb.38.2022.06.21.23.41.54; Tue, 21 Jun 2022 23:42:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qHQLTuz+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232656AbiFVGSR (ORCPT + 99 others); Wed, 22 Jun 2022 02:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbiFVGSQ (ORCPT ); Wed, 22 Jun 2022 02:18:16 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A92EE1C; Tue, 21 Jun 2022 23:18:15 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id e40so9854647eda.2; Tue, 21 Jun 2022 23:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Exzm/TXSqD/Huvr9EUdQ5bsQgg0FbL+KozVE0rZYqD4=; b=qHQLTuz+Hgm1AtobLz/J6k/+zw6PveTJjpiZGYiyr9Q4LXqwdCH/Z3iNOnVExvRHuS xfwh6As67tnPwKJ1GQhbPDCe4WFletfstvuemoc3gqz9ODfu35fmeOBo288nmSfu+e23 WJHRw8yNGl2UrjQ2s0V6wOkvdSnLKGMqmJ/delTBuFsRYASRTC91MjLTAXmZ8MQWo0Hu +CuAbzHl7IrDaNNs+QanH6V0RQA7o+WXdoMgsVD5dVR+CLnjY990wT6uuO/J+SsjJUjW /QmqrIGdY6iQoy3C6opnhwh5jSzUIj+Ekc12s0go0icKPg9FpZjHoAUD+k9imenW2hyP mL9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Exzm/TXSqD/Huvr9EUdQ5bsQgg0FbL+KozVE0rZYqD4=; b=ABF267xEGOVj70jO5eQcUCgHQp3PYblgHLB0J68fBHLJA2IyZzQr5pEgX5++GZdpSx lDmdxJeg8iTLjQg80kZSDSWmoct8rUWAJvgKW/bbY9YEGXgiikEe5RPNi+65XhlDJUZN qfG1qq1tRSGUwNSmN7jGjGXgxvR5sVHHMhw5m6LlXywpcCVDd30NfBcruuCL/6gD/U1I ZrOFv+f8DBWh5jQm0Iri5/Nh2fn8DsCNt6+GjtTNsARrFCLp6HrD70vGtzmiElDRVLQm dVAFV6RwESMZJd/OmVDcNTJQbuC3NNnXeI19RG5CMxN36caa9w1RG1iP9NPPirGwA3JT NHCA== X-Gm-Message-State: AJIora87MDV6cbkrgpMTZNlkOTYHNguN2r8Peqhqbct9RbbK4lRdp43+ dNcTgH0PTcrAHQmWXqfNG5I= X-Received: by 2002:a05:6402:4390:b0:42e:b7e:e9ac with SMTP id o16-20020a056402439000b0042e0b7ee9acmr2215633edc.97.1655878693636; Tue, 21 Jun 2022 23:18:13 -0700 (PDT) Received: from localhost.localdomain ([185.107.95.225]) by smtp.gmail.com with ESMTPSA id x16-20020aa7cd90000000b0042fb3badd48sm14040764edv.9.2022.06.21.23.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 23:18:13 -0700 (PDT) From: Yassine Oudjana X-Google-Original-From: Yassine Oudjana To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: Yassine Oudjana , Yassine Oudjana , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: wcd9335: Use int array instead of bitmask for TX mixers Date: Wed, 22 Jun 2022 10:17:45 +0400 Message-Id: <20220622061745.35399-1-y.oudjana@protonmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yassine Oudjana Currently slim_tx_mixer_get reports all TX mixers as enabled when at least one is, due to it reading the entire tx_port_value bitmask without testing the specific bit corresponding to a TX port. Furthermore, using the same bitmask for all capture DAIs makes setting one mixer affect them all. To prevent this, and since the SLIM TX muxes effectively only connect to one of the mixers at a time, turn tx_port_value into an int array storing the DAI index each of the ports is connected to. Signed-off-by: Yassine Oudjana --- sound/soc/codecs/wcd9335.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c index 7d40a61b03b0..a4d92f7aef9e 100644 --- a/sound/soc/codecs/wcd9335.c +++ b/sound/soc/codecs/wcd9335.c @@ -342,7 +342,7 @@ struct wcd9335_codec { struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY]; unsigned int rx_port_value[WCD9335_RX_MAX]; - unsigned int tx_port_value; + unsigned int tx_port_value[WCD9335_TX_MAX]; int hph_l_gain; int hph_r_gain; u32 rx_bias_count; @@ -1334,8 +1334,13 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kc, struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc); struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc); + struct soc_mixer_control *mixer = + (struct soc_mixer_control *)kc->private_value; + int dai_id = widget->shift; + int port_id = mixer->shift; - ucontrol->value.integer.value[0] = wcd->tx_port_value; + ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id] == dai_id; return 0; } @@ -1358,12 +1363,12 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc, case AIF2_CAP: case AIF3_CAP: /* only add to the list if value not set */ - if (enable && !(wcd->tx_port_value & BIT(port_id))) { - wcd->tx_port_value |= BIT(port_id); + if (enable && wcd->tx_port_value[port_id] != dai_id) { + wcd->tx_port_value[port_id] = dai_id; list_add_tail(&wcd->tx_chs[port_id].list, &wcd->dai[dai_id].slim_ch_list); - } else if (!enable && (wcd->tx_port_value & BIT(port_id))) { - wcd->tx_port_value &= ~BIT(port_id); + } else if (!enable && wcd->tx_port_value[port_id] == dai_id) { + wcd->tx_port_value[port_id] = -1; list_del_init(&wcd->tx_chs[port_id].list); } break; -- 2.36.1