From patchwork Fri Nov 24 09:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Strozek X-Patchwork-Id: 169350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1041812vqx; Fri, 24 Nov 2023 01:51:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0NwOrOAonqH7ZNGL2u3bS36Q4h/psNPQjwRtQmNSP6I8A1HapCeeRpvMNcdPMkcHfvOja X-Received: by 2002:a05:6808:19a4:b0:3ac:aae1:6d64 with SMTP id bj36-20020a05680819a400b003acaae16d64mr2892597oib.2.1700819478422; Fri, 24 Nov 2023 01:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700819478; cv=none; d=google.com; s=arc-20160816; b=QWrS1u3UtMOGFILFUzRDRWq1rLbRU3vzqWxMbBA3HP480mM86UBskx+5b9UyxVIGAO 2kwYUCqQpDnw0baHKVJfySrjkLEXHUKhsKdAJLTxZNPEaE9I1yqsM87iOfGMsKsbWBQZ Nj2ihxV4/S2mQmMKA6OdwFyy9qH9Zc53f1pqi1B+O4ptt87P81q5fcESH3JgonBuTB1F nICeBXxhPjNfqimbh7eSvVH30UPJVNWheioTZegu4yjJTMwsgMIGCO0HMxMjNV9fI3N7 obeGeDpEnfXGYDfw05LQbfZKNLrBHWjLkG503w86wUPSGiNONLHY5bCq4ZApl1PHRa+U G9Hw== 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=0BSvJ7usnWbGiPGf6UjTYXjzO1zlA/tY5Les5VqpUOI=; fh=KySyJaCx6e9HlRw2D2oLQPSdTHBwZsIBeFoG7LcS+QY=; b=ooiuWX9HoiB98faiUNVMyQ+OqrodU7syoVcQ/QrB9Jodn66T0JM3A3W5zjotOfI09Z efOVLBZXuERlb4pqN53n5rYnljucJZ7SY34GO6I1kBQQGEfCGBV610ES5r9XRGDemz/k 5hILbuc9peBO5uoVYfIMQ2oC/PpuFXMvDOK1n7+X/H8+7ZO7TjnZb9VY77P3NZMz1PPF JWkZbQioj8RrA7zKLphDiJtORji+Z0VDsXW4WHBg7scBVbF7p0UqAxta9wgGw8LybbMD wV0+bWFB7d7T80sTfKBbIfJpjoCXYHmSCCf+gTNy1JTbrI6w24lUO3N6c/85OYnpK1X+ Xz6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=Jyxy9nFX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n6-20020a6543c6000000b005c1ce5625c9si3353922pgp.816.2023.11.24.01.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 01:51:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=Jyxy9nFX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AAA0C804E452; Fri, 24 Nov 2023 01:51:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbjKXJvD (ORCPT + 99 others); Fri, 24 Nov 2023 04:51:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345377AbjKXJul (ORCPT ); Fri, 24 Nov 2023 04:50:41 -0500 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E37A1710; Fri, 24 Nov 2023 01:50:47 -0800 (PST) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3AO6xNTZ010106; Fri, 24 Nov 2023 03:50:34 -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=0 BSvJ7usnWbGiPGf6UjTYXjzO1zlA/tY5Les5VqpUOI=; b=Jyxy9nFX8iQChZ0cS 0BqOsuaBamyyKCpuiVvHH0G92KfBp30rU7A9qdkw1LoGX1T6v9uYQO7Ap0VKWIua NXr64i11q6N++FXaQNvAX57YThBAFwkwQiH8uLXk/r4l6ZcpGgdpC1Vc84fRAlGv /XbelQ3KhDkuLUiLXg4gK4lawpm5ZoyaM8BNn+y4t+kgSRSetrR3EC42tTx0pqMw hXQ0i4Re7FpDedcfAimsvCCLb1+u/w9bzrErIPvF/pQbmeHUQ0SmmTKC9jmE27rX 2Nkn8C4/VPQI9D68je5kuPDvy15Yk2AC1XVMyWE7WVc4/MekNCiXWovdXBRyvn2c YYnHg== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3uetjpem55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 03:50:34 -0600 (CST) 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.39; Fri, 24 Nov 2023 09:50:32 +0000 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.39 via Frontend Transport; Fri, 24 Nov 2023 09:50:32 +0000 Received: from upx-tgl-008-ubuntu.ad.cirrus.com (upx-tgl-008-ubuntu.ad.cirrus.com [198.90.251.167]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 64696357F; Fri, 24 Nov 2023 09:50:32 +0000 (UTC) From: Maciej Strozek To: Mark Brown CC: James Schulman , David Rhodes , Liam Girdwood , , , , , Maciej Strozek Subject: [RESEND] ASoC: cs43130: Allow configuration of bit clock and frame inversion Date: Fri, 24 Nov 2023 09:50:30 +0000 Message-ID: <20231124095030.24539-1-mstrozek@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Proofpoint-GUID: UevVvw5fily_5khQIm2O0txDPIJE2xNH X-Proofpoint-ORIG-GUID: UevVvw5fily_5khQIm2O0txDPIJE2xNH X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 24 Nov 2023 01:51:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783438485497971733 X-GMAIL-MSGID: 1783438485497971733 Signed-off-by: Maciej Strozek Acked-by: Charles Keepax --- Resending patch which previously broke x86 allmodconfig [1], now rebased on for-next branch [1]: https://lore.kernel.org/all/ZVfLMIbCpShVAYBf@finisterre.sirena.org.uk/ sound/soc/codecs/cs43130.c | 42 ++++++++++++++++++++++++++++++++++++-- sound/soc/codecs/cs43130.h | 1 + 2 files changed, 41 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c index 4f16baf4eafb..0f3ead84665f 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -620,6 +620,27 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk, return -EINVAL; } + switch (cs43130->dais[dai_id].dai_invert) { + case SND_SOC_DAIFMT_NB_NF: + sclk_edge = 1; + lrck_edge = 0; + break; + case SND_SOC_DAIFMT_IB_NF: + sclk_edge = 0; + lrck_edge = 0; + break; + case SND_SOC_DAIFMT_NB_IF: + sclk_edge = 1; + lrck_edge = 1; + break; + case SND_SOC_DAIFMT_IB_IF: + sclk_edge = 0; + lrck_edge = 1; + break; + default: + return -EINVAL; + } + switch (cs43130->dais[dai_id].dai_mode) { case SND_SOC_DAIFMT_CBS_CFS: dai_mode_val = 0; @@ -632,8 +653,6 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk, } frm_size = bitwidth_sclk * params_channels(params); - sclk_edge = 1; - lrck_edge = 0; loc_ch1 = 0; loc_ch2 = bitwidth_sclk * (params_channels(params) - 1); @@ -1516,6 +1535,25 @@ static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: + cs43130->dais[codec_dai->id].dai_invert = SND_SOC_DAIFMT_NB_NF; + break; + case SND_SOC_DAIFMT_IB_NF: + cs43130->dais[codec_dai->id].dai_invert = SND_SOC_DAIFMT_IB_NF; + break; + case SND_SOC_DAIFMT_NB_IF: + cs43130->dais[codec_dai->id].dai_invert = SND_SOC_DAIFMT_NB_IF; + break; + case SND_SOC_DAIFMT_IB_IF: + cs43130->dais[codec_dai->id].dai_invert = SND_SOC_DAIFMT_IB_IF; + break; + default: + dev_err(cs43130->dev, "Unsupported invert mode 0x%x\n", + fmt & SND_SOC_DAIFMT_INV_MASK); + return -EINVAL; + } + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_I2S; diff --git a/sound/soc/codecs/cs43130.h b/sound/soc/codecs/cs43130.h index 694286b78d03..dbdb5b262f1b 100644 --- a/sound/soc/codecs/cs43130.h +++ b/sound/soc/codecs/cs43130.h @@ -497,6 +497,7 @@ struct cs43130_dai { unsigned int sclk; unsigned int dai_format; unsigned int dai_mode; + unsigned int dai_invert; }; struct cs43130_private {