From patchwork Thu Feb 21 09:53:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 10823657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2985B1399 for ; Thu, 21 Feb 2019 10:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 148172A6C2 for ; Thu, 21 Feb 2019 10:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0860B2D425; Thu, 21 Feb 2019 10:44:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7DF432A6C2 for ; Thu, 21 Feb 2019 10:44:18 +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 B20FD15EA; Thu, 21 Feb 2019 11:43:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B20FD15EA Authentication-Results: alsa0.perex.cz; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="MNHVxrJe" Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B7013F89639; Thu, 21 Feb 2019 11:31:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B7013F89639 Authentication-Results: alsa1.perex.cz; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="MNHVxrJe" X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id E82B2F80776; Thu, 21 Feb 2019 10:53:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E82B2F80776 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00087.outbound.protection.outlook.com [40.107.0.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 24A45F806EA for ; Thu, 21 Feb 2019 10:53:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 24A45F806EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eoNp5mjQP/OLqlcP86W2iW4a2yHyRVQvjxVQm3xfNOw=; b=MNHVxrJeQjUAoa4VFSH73wmk0Kux4/QOn9cgDxBn9XnOY/s+Owdl3SBMgBqpk85+TcwMRCzttD1R5DvE3zG0012k/n5zQtAjZz0sUwXWv3iHAdRPejcXzJYY/lYnJ62VAJH35tQcR6oM3uV2tuH1yHMWEK82JksIr+i3fZkaIvs= Received: from VI1PR0402MB3392.eurprd04.prod.outlook.com (52.134.1.153) by VI1PR0402MB2720.eurprd04.prod.outlook.com (10.175.22.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.16; Thu, 21 Feb 2019 09:53:04 +0000 Received: from VI1PR0402MB3392.eurprd04.prod.outlook.com ([fe80::407:6e30:6a9d:2a22]) by VI1PR0402MB3392.eurprd04.prod.outlook.com ([fe80::407:6e30:6a9d:2a22%3]) with mapi id 15.20.1622.018; Thu, 21 Feb 2019 09:53:04 +0000 From: "S.j. Wang" To: "timur@kernel.org" , "nicoleotsuka@gmail.com" , "Xiubo.Lee@gmail.com" , "festevam@gmail.com" , "broonie@kernel.org" , "alsa-devel@alsa-project.org" Thread-Topic: [PATCH] ASoC: fsl_esai: fix channel swap issue when stream starts Thread-Index: AQHUycs9fdqkcg+Cg0iNVs6jgStKdg== Date: Thu, 21 Feb 2019 09:53:04 +0000 Message-ID: <1550742787-3268-1-git-send-email-shengjiu.wang@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.9.1 x-clientproxiedby: HK0PR03CA0079.apcprd03.prod.outlook.com (2603:1096:203:72::19) To VI1PR0402MB3392.eurprd04.prod.outlook.com (2603:10a6:803:3::25) authentication-results: spf=none (sender IP is ) smtp.mailfrom=shengjiu.wang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 851839d0-7bc2-4ff9-47df-08d697e25f6d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB2720; x-ms-traffictypediagnostic: VI1PR0402MB2720: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; VI1PR0402MB2720; 23:loQDTmUCHMLws6tNSDWGoz7ZM6CLqyU9DCVn4?= =?iso-8859-1?q?r9E84ubVTtpQDQl3R?= =?iso-8859-1?q?sLxqQi0l10IvtkDxi+bCGjgOsVr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0JN/yD7FUc?= =?iso-8859-1?q?y0X+8GUAkAANZT+8auUSiMDr3ErZehV4VIXv4t8mxHjaSLRZ9IJ0ztV2qblP?= =?iso-8859-1?q?M0xw7NndN/UCdzKsmwhSTIPLQrhEpi+SrPCKh+/prp3yV8xmo8y3ajT2BWVY?= =?iso-8859-1?q?XLnyFaK0Xe+WqQ5AOskJP+Z3LIrpoMegHfgcAepcyvuZ11VruRfNpoxrXegW?= =?iso-8859-1?q?h1TvqjLL8+899v3NntiIBU1hubpeHu1LSrtocdcA=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09555FB1AD x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(346002)(376002)(366004)(189003)(199004)(81166006)(81156014)(106356001)(86362001)(316002)(8676002)(26005)(186003)(7736002)(105586002)(305945005)(2501003)(71190400001)(71200400001)(256004)(478600001)(14444005)(5660300002)(8936002)(14454004)(53936002)(50226002)(2201001)(25786009)(476003)(36756003)(6512007)(4326008)(6506007)(486006)(386003)(2616005)(110136005)(2906002)(52116002)(66066001)(6116002)(3846002)(97736004)(99286004)(6486002)(6436002)(102836004)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2720; H:VI1PR0402MB3392.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: oQvpNx9awX7DWTdNLY2S8dOyWroaeXDySw0Q8yu3kaq0evHK4smX1eRnI0t594bI79mi4t7li8tBnp11Q7WDksdLMhos8JUICqYH2CalCbSxa7WKr1x9WkYqLoVrHjnoPEzH2X7FJlfFR49NuWNgsftkXvbb161BvTy9u6NCTafmz0C+Z1JhP4ES/USa2FnVyRgHLYmDVdnfGl8iVCo8Fd0tSCk6NME5o4+kT5kDqEsSYsH0uqQVTTkKcZeXTh/AxgIY61nTt8tku2oQHrVVc07HNBCmbAyMCvmsRCm/qqe0ZpXJlP0IIRHl6O9VkyqLQIpVaE2CHvU6GOtZtSxkA0+CAh52iMDbA+7w6MvOms9B4HiZZ9+g1vdC4eE5mCri7f4Rys6uY3IWzbxTZ7kdomow3h3clhJWn1+rQoKcTK8= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 851839d0-7bc2-4ff9-47df-08d697e25f6d X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Feb 2019 09:53:01.5007 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2720 Cc: "linuxppc-dev@lists.ozlabs.org" Subject: [alsa-devel] [PATCH] ASoC: fsl_esai: fix channel swap issue when stream starts 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Shengjiu Wang There is very low possibility ( < 0.1% ) that channel swap happened in beginning when multi output/input pin is enabled. The issue is that hardware can't send data to correct pin in the begginning with the normal enable flow. This is hardware issue, the workaround flow is that: Each time playback/recording, firstly clear the xSMA/xSMB, then enable TE/RE, then enable xSMB and xSMA (xSMB must be enabled before xSMA). Which is to use the xSMA as the trigger start register, previously the xCR_TE or xCR_RE is the bit for starting Signed-off-by: Shengjiu Wang Reviewed-by: Fabio Estevam --- sound/soc/fsl/fsl_esai.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index afe67c865330..23bd0ad4ac31 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -54,6 +54,8 @@ struct fsl_esai { u32 fifo_depth; u32 slot_width; u32 slots; + u32 tx_mask; + u32 rx_mask; u32 hck_rate[2]; u32 sck_rate[2]; bool hck_dir[2]; @@ -361,21 +363,13 @@ static int fsl_esai_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask, regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR, ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMA, - ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(tx_mask)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMB, - ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(tx_mask)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMA, - ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(rx_mask)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMB, - ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(rx_mask)); - esai_priv->slot_width = slot_width; esai_priv->slots = slots; + esai_priv->tx_mask = tx_mask; + esai_priv->rx_mask = rx_mask; return 0; } @@ -596,6 +590,7 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; u8 i, channels = substream->runtime->channels; u32 pins = DIV_ROUND_UP(channels, esai_priv->slots); + u32 mask; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -611,12 +606,23 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, tx ? ESAI_xCR_TE(pins) : ESAI_xCR_RE(pins)); + mask = tx ? esai_priv->tx_mask : esai_priv->rx_mask; + + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx), + ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(mask)); + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx), + ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(mask)); + break; case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, 0); + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx), + ESAI_xSMA_xS_MASK, 0); + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx), + ESAI_xSMB_xS_MASK, 0); /* Disable and reset FIFO */ regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), @@ -906,6 +912,12 @@ static int fsl_esai_probe(struct platform_device *pdev) return ret; } + /* Clear the TSMA, TSMB, RSMA, RSMB */ + regmap_write(esai_priv->regmap, REG_ESAI_TSMA, 0); + regmap_write(esai_priv->regmap, REG_ESAI_TSMB, 0); + regmap_write(esai_priv->regmap, REG_ESAI_RSMA, 0); + regmap_write(esai_priv->regmap, REG_ESAI_RSMB, 0); + ret = devm_snd_soc_register_component(&pdev->dev, &fsl_esai_component, &fsl_esai_dai, 1); if (ret) {