From patchwork Mon Feb 25 02:48:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 10828147 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 1018E1575 for ; Mon, 25 Feb 2019 02:49:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F07F42A6C3 for ; Mon, 25 Feb 2019 02:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E45882A846; Mon, 25 Feb 2019 02:49: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.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 07AFB2A6C3 for ; Mon, 25 Feb 2019 02:49:20 +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 EEE921623; Mon, 25 Feb 2019 03:48:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EEE921623 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1551062958; bh=M/jjgD5Ti76KLIJP5Hj0vMJ3LhxZZ9KX9lo93e9PNPk=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=mm9x9X3WMqu2VPcYyRd6IHjXQuJCKQ30mpT9kGvCzOGzS2/oZJM/qqrRaQRr7tL/x 8F6Fp4jFS8dmGTVdnaNBMkd9j6PyBz+EblQhr0QMxOBTDk8OhvJ9UdJNnWKsnx6WQ8 Jw6gNxr++AVghT+a4KllLZYzsCQBV1sGoQ7ko4Oc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1806BF89620; Mon, 25 Feb 2019 03:48:27 +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 6C5CEF8961F; Mon, 25 Feb 2019 03:48:25 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150040.outbound.protection.outlook.com [40.107.15.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C39EEF808F7 for ; Mon, 25 Feb 2019 03:48:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C39EEF808F7 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="KU6PqEUy" 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=xFBIAYB2fLNowTYUmSAslKMJnDADeImgirFtgTecDWA=; b=KU6PqEUybDRT0omfvW8eBb/3Lbe+IOKuXnGW923kIV4LemKVibMqMnWzfDAJm7vrPRfavn4AnTR6pIqKfBqkJqTVoGseqcUeNi3QIOlznqPpLT0Ow5LPxWBlUJdZtJWdtudifyYOX98kX/VGn+nb5WZwYiyrN0dXfATMLpLHQQk= Received: from VI1PR0402MB3392.eurprd04.prod.outlook.com (52.134.1.153) by VI1PR0402MB3696.eurprd04.prod.outlook.com (52.134.15.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.20; Mon, 25 Feb 2019 02:48:18 +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; Mon, 25 Feb 2019 02:48:18 +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 V2] ASoC: fsl_esai: fix channel swap issue when stream starts Thread-Index: AQHUzLSQvgZScKxEQk2/qwsWCp5NqQ== Date: Mon, 25 Feb 2019 02:48:18 +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: HK0PR03CA0086.apcprd03.prod.outlook.com (2603:1096:203:72::26) 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: 4b520516-9207-4894-883f-08d69acbb241 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3696; x-ms-traffictypediagnostic: VI1PR0402MB3696: x-microsoft-exchange-diagnostics: =?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?iso-8859-1?q?50JWoeQt/4t1gL4PU96nv4CVCsVTENX4YN168QTFzYULzzuftYzyFoh1giGs?= =?iso-8859-1?q?Ge2wixiHG0SV8nUZMxxR01RKwsxPpuSGHuviKlsxp5guvjsQtEDV62+dbUKx?= =?iso-8859-1?q?OKWqD1g4bhO8/40xopiHeGEOs4iV75YtL8JXp1gFa7sLYoMCuz1pE9VCQkAn?= =?iso-8859-1?q?+izbOMFQWp1KRIdq3JzbAeF4RITpyyetxLBBRNQiyljNezbDkCaNlU9rMohI?= =?iso-8859-1?q?9q3cSvPyBzOVA7EeiAiei5GNr7qTbmnGi/EOwD/Ml9w7C+eb/nN1i8ytNPk3?= =?iso-8859-1?q?DdxXsoVvrlEYolAOfIeVCc5f+Wp7vYZS42oE59g/YSl8yRzYV4O4yHen3Xlk?= =?iso-8859-1?q?4=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 095972DF2F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(346002)(136003)(39860400002)(376002)(199004)(189003)(2201001)(110136005)(66066001)(71200400001)(71190400001)(386003)(8936002)(102836004)(478600001)(6512007)(2906002)(50226002)(5660300002)(97736004)(6506007)(99286004)(2501003)(53936002)(52116002)(6436002)(316002)(86362001)(68736007)(2616005)(36756003)(486006)(305945005)(7736002)(186003)(476003)(81166006)(8676002)(81156014)(3846002)(6116002)(6486002)(118296001)(4326008)(25786009)(256004)(14444005)(106356001)(26005)(105586002)(14454004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3696; H:VI1PR0402MB3392.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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: 1TTS6LXJfI5m6/Q1NeafiJ9pUmjAHKL3lPtQOR4ddDUVl5sE8d/SuVmVh7mi2tZa3sFnpdaIQTKzld42OF0v5L77KCmaaMYJO2hAE+15Eq82bkPPi7jT+8u3n7dfl3J+D7Q4npRnUAqHts+NFYNkgWlOiY+gdF3m2BfGnOiOYv93KNGZrEN6ac65WV43oEX97NcSg8Z1chqdnhhc8K24ZptpxFaTC4lDnyPtPKRq107qQN2JU+wmOXnffhP0Y3lcjifoC10kCx0QeMy6E0N/EPaAuTb+bm6bdA54AtjNlkcOjm7c35QF8eFxhCG8l7xiS3n+7JE9OM29v1TymeqmyWI5jaUINiWn+WE/azELbQhTANElTFSLXrbJ/idPjhAX4eearLovbDLi9FdzBThnaYydMxtQ6TBKI6YcLUI+3aw= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b520516-9207-4894-883f-08d69acbb241 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Feb 2019 02:48:14.9880 (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: VI1PR0402MB3696 Cc: "linuxppc-dev@lists.ozlabs.org" Subject: [alsa-devel] [PATCH V2] 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 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver") Cc: Reviewed-by: Fabio Estevam Signed-off-by: Shengjiu Wang --- Changes in v2 - update commit comments. 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) {