Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3414753rwa; Tue, 23 Aug 2022 04:30:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR62oUW47E15wJzwOwz83X2Cr8L8U2orKiERWpJYQ9eytknr3bagK8BvxKxEI/evuc12ig4c X-Received: by 2002:a17:90b:4b47:b0:1f7:2e06:5752 with SMTP id mi7-20020a17090b4b4700b001f72e065752mr2871316pjb.187.1661254132604; Tue, 23 Aug 2022 04:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254132; cv=none; d=google.com; s=arc-20160816; b=qG1CpnZGH7ErHVzqEwgt0xZChFg+IxCWe1I1gXygaI21n6b8PXyhLv3xowfHRN8T3F LC8LouhiCiRbME1HUQDAQ6hafDh57PPU4R5WhRnNaeRbmCV7hWA8NrAUAbdMQeoS1lGT VLpsOb8R0rJhD6n7HrmcFUR/q0/m+SiKYuhX2KzbPYYJt8DoCZyC8MkBAsdKLE5H2wUR 7CkVr/LW0sOXSHJxMQpYLSJ/drJs2xB1BzLtjK816PaGAyBePBZG9rlX6togFz1mqwBJ o9RgNLRfbrn7zs6Fg0XswUxyTew+6UdhaLfArTqw0/6eKg1xGHSvn1OPqV161ga/gGoZ NUVw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uTLBNs8qTfitymtPN20Eb6JqoJidjnAj8nys26bojIA=; b=kd23koKQ0oEAK3hlJCsSIyTYMifiuhabNavRb7C12j+ES4RR4F/28FDjOy54Zqbmne DHfYrEU6iD81iGf5BZeRlk6p77+u6h5hvsEURpAkX606y5Sg0jP/+ayG3DNRnrGzfrvG olmsirvJoni6DgwlkXRtR6L0RdDvuRYs1UAqQz174+YLO+shfnlaV4cWPYbrjhmpA9N5 EcMt+Rc0yRVzaV1lCAlCZcJNkIQW9eUrDxz646CX/zGhP4aoWQT5l7gzBCFEUMlYCPtl U5CpR4dTiE8HjeSXdZ74PgKWZXZUtW8usGBnPJDGix6TXiEiQKePQk6kZB8zw5z9aXgF zkfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AGJ+Ukm9; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc2-20020a17090b1c0200b001faa7b96ca0si14269069pjb.13.2022.08.23.04.28.41; Tue, 23 Aug 2022 04:28:52 -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=@linuxfoundation.org header.s=korg header.b=AGJ+Ukm9; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353501AbiHWKNk (ORCPT + 99 others); Tue, 23 Aug 2022 06:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352745AbiHWKGN (ORCPT ); Tue, 23 Aug 2022 06:06:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57FE37D1DF; Tue, 23 Aug 2022 01:52:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D59F1B81C3B; Tue, 23 Aug 2022 08:52:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37DB5C433C1; Tue, 23 Aug 2022 08:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244762; bh=mTvSXMU+FqVYUEjrCpZyNd5/4xWQ8kzPmC4oXbY4SGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AGJ+Ukm9luCKS1uMs/PnUY6PGIt27cY1BaMktiMYQYqLOd2SdLQr7iwb+qWczQMmp QqbDt2OmX9mBAUO/9RbbJj5vTWAXaK/KAwIQOiqs50XVw8VlQ1MMDlsHceeZfySN1v x/du1tquA4keQBo9YEC0ZmkvzvphhJQhejgYYMR0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Martin=20Povi=C5=A1er?= , Mark Brown Subject: [PATCH 5.15 118/244] ASoC: tas2770: Set correct FSYNC polarity Date: Tue, 23 Aug 2022 10:24:37 +0200 Message-Id: <20220823080102.960633658@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: Martin Povišer commit e9ac31f0a5d0e246b046c20348954519f91a297f upstream. Fix setting of FSYNC polarity for DAI formats other than I2S. Also add support for polarity inversion. Fixes: 1a476abc723e ("tas2770: add tas2770 smart PA kernel driver") Signed-off-by: Martin Povišer Link: https://lore.kernel.org/r/20220808141246.5749-2-povik+lin@cutebit.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/codecs/tas2770.c | 20 +++++++++++++++++++- sound/soc/codecs/tas2770.h | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -337,7 +337,7 @@ static int tas2770_set_fmt(struct snd_so struct snd_soc_component *component = dai->component; struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component); - u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0; + u8 tdm_rx_start_slot = 0, invert_fpol = 0, fpol_preinv = 0, asi_cfg_1 = 0; int ret; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -349,9 +349,15 @@ static int tas2770_set_fmt(struct snd_so } switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_IF: + invert_fpol = 1; + fallthrough; case SND_SOC_DAIFMT_NB_NF: asi_cfg_1 |= TAS2770_TDM_CFG_REG1_RX_RSING; break; + case SND_SOC_DAIFMT_IB_IF: + invert_fpol = 1; + fallthrough; case SND_SOC_DAIFMT_IB_NF: asi_cfg_1 |= TAS2770_TDM_CFG_REG1_RX_FALING; break; @@ -369,15 +375,19 @@ static int tas2770_set_fmt(struct snd_so switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: tdm_rx_start_slot = 1; + fpol_preinv = 0; break; case SND_SOC_DAIFMT_DSP_A: tdm_rx_start_slot = 0; + fpol_preinv = 1; break; case SND_SOC_DAIFMT_DSP_B: tdm_rx_start_slot = 1; + fpol_preinv = 1; break; case SND_SOC_DAIFMT_LEFT_J: tdm_rx_start_slot = 0; + fpol_preinv = 1; break; default: dev_err(tas2770->dev, @@ -391,6 +401,14 @@ static int tas2770_set_fmt(struct snd_so if (ret < 0) return ret; + ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0, + TAS2770_TDM_CFG_REG0_FPOL_MASK, + (fpol_preinv ^ invert_fpol) + ? TAS2770_TDM_CFG_REG0_FPOL_RSING + : TAS2770_TDM_CFG_REG0_FPOL_FALING); + if (ret < 0) + return ret; + return 0; } --- a/sound/soc/codecs/tas2770.h +++ b/sound/soc/codecs/tas2770.h @@ -41,6 +41,9 @@ #define TAS2770_TDM_CFG_REG0_31_44_1_48KHZ 0x6 #define TAS2770_TDM_CFG_REG0_31_88_2_96KHZ 0x8 #define TAS2770_TDM_CFG_REG0_31_176_4_192KHZ 0xa +#define TAS2770_TDM_CFG_REG0_FPOL_MASK BIT(0) +#define TAS2770_TDM_CFG_REG0_FPOL_RSING 0 +#define TAS2770_TDM_CFG_REG0_FPOL_FALING 1 /* TDM Configuration Reg1 */ #define TAS2770_TDM_CFG_REG1 TAS2770_REG(0X0, 0x0B) #define TAS2770_TDM_CFG_REG1_MASK GENMASK(5, 1)