From patchwork Wed Feb 27 06:31:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 10831265 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 14CBF1390 for ; Wed, 27 Feb 2019 06:32:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F140E2D12A for ; Wed, 27 Feb 2019 06:32:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5BA82D1D9; Wed, 27 Feb 2019 06:32:25 +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.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,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 1708B2D12A for ; Wed, 27 Feb 2019 06:32:25 +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 3EC9C15F4; Wed, 27 Feb 2019 07:31:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3EC9C15F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1551249143; bh=DEOHvYLrA2LXa4+MtThJIejGJn5N+qdW1U4cXsDnQN8=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=EQtLAmiXyVtsne+gh9FuoTul+Ec3rLKbbDYlz2Nw8ZI0CWdBMGqDoo7WGReNTBUou RCvvI0+iXRq/eIo/y4LZpJCR19x5hoLB1FpkmrWHidXCPyqRoV1frO+GAGIsIAkmnd VYcjjKRQv2lvlR2dLbQTyZwnRYnLCWqNw7GXIWNM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 41A9DF89699; Wed, 27 Feb 2019 07:31:19 +0100 (CET) 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 10DB9F8969B; Wed, 27 Feb 2019 07:31:18 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60070.outbound.protection.outlook.com [40.107.6.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 058DAF89676 for ; Wed, 27 Feb 2019 07:31:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 058DAF89676 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="hRldBZ5R" 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=Rc/2/CeF+Unank6iDzO9PN2zqLJ4ySDiDnxhpiUx6jA=; b=hRldBZ5RnGKYTxgsmm220feB3f2lfXXGF5Rzi4t/fRBkz1Cw1i4eiksDBSw+CFRVQiGhxB7eFAC4dO/lHysnG3kn3XpmsBV1/ZvRweHEf1981Cy0DneuXOjjctv23YDYTXGophnbI8Mre7Lpi/t+ddlOJmrYhOsz4Z5KaCRzlC8= Received: from VI1PR0402MB3392.eurprd04.prod.outlook.com (52.134.1.153) by VI1PR0402MB3326.eurprd04.prod.outlook.com (52.134.8.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.15; Wed, 27 Feb 2019 06:31:13 +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.1643.019; Wed, 27 Feb 2019 06:31:13 +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 V4] ASoC: fsl_esai: fix channel swap issue when stream starts Thread-Index: AQHUzmYIt8jQIersxU2uVCJkVAZpag== Date: Wed, 27 Feb 2019 06:31:12 +0000 Message-ID: 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: HK2PR06CA0019.apcprd06.prod.outlook.com (2603:1096:202:2e::31) 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: 8ebf6ad0-6fb9-4685-5d4d-08d69c7d2ae2 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3326; x-ms-traffictypediagnostic: VI1PR0402MB3326: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; VI1PR0402MB3326; 23:Uuf65fcjYsU1uo0e08YBz+hDjzyjVbxVMu4QK?= =?iso-8859-1?q?z2LPA3JsFFvzh92Go?= =?iso-8859-1?q?z653p8nbl8YzfL1xfOW6H4z0O6fk7wvX4j5wJt3Sb54w+qT63ublebPdjHaa?= =?iso-8859-1?q?YTqPbhj2vhHT0Cy/z7ORCO0gntOODq0f70bk3ZNqv5h5KzZNT9nNPEuqGyHV?= =?iso-8859-1?q?ekm/jzu2zkVnZQn2115mobIuS3P2BhMusAtPXg2SXDSKjRBvqrAF1x9Hg+oH?= =?iso-8859-1?q?gx0z+Qnusp1Add41uYaG17Vkhi/Hx6K/SpPFdI5mHHO0TB568/DwUsgegpWZ?= =?iso-8859-1?q?5QVs70VPwsYURA6dTQd11brijBxwCju8kw0Z8a7UGY6QcXCdpVUlaHIBi1Ar?= =?iso-8859-1?q?pH/i3skAQr/ytmcfahyOiTWE/zW9gJpmqoNYwIQZIQVxMQX9nkVVET/7l/CZ?= =?iso-8859-1?q?W+GKzwy6Qy9DddQN+qhyS9/QUuTWF/mxB/Q0XiKz4hF2sH9V1RUNovY+IjJL?= =?iso-8859-1?q?0xpq/5F29jLjR2oOInbwxWKRFMTOuYU/j0Jq34Ap2dVNJLltu/9hoPm9pRbP?= =?iso-8859-1?q?iah1hdC0Ca8l+8AAIXYzw87WqckWW3NigUBXBa7xXFfKmqdBRoSXnDfUVJ4J?= =?iso-8859-1?q?95zI/BCM/F4meG/yn/httfBBSBE41FkExJRKyLOHAAiR2jgW4JZhC7CBjc7Q?= =?iso-8859-1?q?Xaq/cBDghE0TMTTmpgEkfUhtozofTfsBlpoeU5gc0EHrSY3S/uEtcNkUv6/U?= =?iso-8859-1?q?TDi2Pm7vnk1I0EwBo0/0Qf17BQaLEx6TeNO9QEfApAts0AVpQh62zf7BvxjX?= =?iso-8859-1?q?3CVjXa3VPeVfnohP2vcjznFAVEnMSd1tcExQlY+XyWFVWjAKQC3f3PngCDJX?= =?iso-8859-1?q?psFWA4Bdu8+NEufO1oAqxKAOyTwGK3K+lOrwJjuJoJfopQ5+ckVuDNAf6qGj?= =?iso-8859-1?q?ZR6fByG4LTnGc34BERXzZAOAoVg957AGUZykAkiFGOcUn461QIPlierNCPqO?= =?iso-8859-1?q?gU6bprb8hzti/qlu7BN9szdLX0LWLY2fQgLnA2rxCzKfQrwqYycLFb6UNRJp?= =?iso-8859-1?q?70GIw+PycAkCXHtLKCieSK4rhyKodAZPvtXKkIG3BoXzWStRSo6ag/UKrNh4?= =?iso-8859-1?q?gTlYWiq/uZG71ykH4tBQor567Upo4pXIuaiv9oWlNiPGKFYlUb3SVjbW0r6/?= =?iso-8859-1?q?xJqrQVeFY5bt6mdU6qdtDBXNo6DLiUm/OUESG4bPJoE0P8T9f4JUKuuPmU9B?= =?iso-8859-1?q?Q=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(136003)(39860400002)(366004)(396003)(189003)(199004)(86362001)(6486002)(6436002)(478600001)(68736007)(71200400001)(6512007)(71190400001)(2201001)(476003)(2616005)(105586002)(106356001)(4326008)(486006)(66066001)(25786009)(305945005)(2501003)(7736002)(186003)(26005)(97736004)(256004)(14454004)(81166006)(81156014)(2906002)(110136005)(8676002)(36756003)(14444005)(50226002)(3846002)(6116002)(386003)(6506007)(118296001)(102836004)(52116002)(8936002)(99286004)(316002)(5660300002)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3326; 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: 7XMbdGRJW1OCrY1wiokf4BvIapV//3kWB6/rOX2T8QPCjPZMUKwDeFQf9WFawTi/k2tAgOP3tMjMuvXMwpRHw9oTeo2gHQUvkO5jVLxlK9HZND0e8mObW5rn6cmk1ikZqiifo/Ts4Q40/D8syuIHvWcMYLF6Sp5bPf4VhDgNYs98RVxlBw6mgUzRMoW6Gm6IkGWsFldobRZEMO1rGM0QGPRfVMacz2ZEjrkFtQVbNvN1/bhQiPMWkixTfUj4BCjruvKT2+Deq94BwLC5lDGdRyNKwFuQ8ZHkIm4d9gjORQsc51S3+2i/pxddrdVln3oxsZoFeEk0/vYHv+0JAjn79OmOYzA83t1kCBDmsFaqkFxHmi65zSjuYNUjA5gciz8tvGTlD6zX5m1S+UwKh3jYFipCKWaH/nEzKsUzFMdwopw= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ebf6ad0-6fb9-4685-5d4d-08d69c7d2ae2 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2019 06:31:09.5886 (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: VI1PR0402MB3326 Cc: "linuxppc-dev@lists.ozlabs.org" Subject: [alsa-devel] [PATCH V4] 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 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 beginning with the normal enable flow. This is hardware issue, but there is no errata, 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. Fixes commit 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver") Cc: Reviewed-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_esai.c | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index afe67c865330..3623aa9a6f2e 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: @@ -608,15 +603,38 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, for (i = 0; tx && i < channels; i++) regmap_write(esai_priv->regmap, REG_ESAI_ETDR, 0x0); + /* + * When set the TE/RE in the end of enablement flow, there + * will be channel swap issue for multi data line case. + * In order to workaround this issue, we switch the bit + * enablement sequence to below sequence + * 1) clear the xSMB & xSMA: which is done in probe and + * stop state. + * 2) set TE/RE + * 3) set xSMB + * 4) set xSMA: xSMA is the last one in this flow, which + * will trigger esai to start. + */ 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 +924,15 @@ static int fsl_esai_probe(struct platform_device *pdev) return ret; } + esai_priv->tx_mask = 0xFFFFFFFF; + esai_priv->rx_mask = 0xFFFFFFFF; + + /* 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) {