From patchwork Tue Feb 26 03:12:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 10829369 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 E451B15AC for ; Tue, 26 Feb 2019 03:39:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB4702B182 for ; Tue, 26 Feb 2019 03:39:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B94FE2B1C5; Tue, 26 Feb 2019 03:39:09 +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 E27402B182 for ; Tue, 26 Feb 2019 03:39:08 +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 F035515EC; Tue, 26 Feb 2019 04:12:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F035515EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1551150805; bh=yIBL/7iJvrK/HZe6AFSTXpyk4fRm0xF02XUJrP9Eo94=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=rcqX37dXdBTxgzJgEDEgegARe1nWgMOwJdOiv+awMcDqb6ntSXfW/QX1iwF/91rSr EuI+tUxymzGj/jRnPShCiW+Szn0dKLODXeO0eIMbTmg4KdjsMS4TgkmdpjMKOCIs5l vn9TWXayhmgEA6yzBaktTEobQT3jIhXW/Nfu1cQs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4FE56F89656; Tue, 26 Feb 2019 04:12:34 +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 247CEF89665; Tue, 26 Feb 2019 04:12:33 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::625]) (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 85A16F80734 for ; Tue, 26 Feb 2019 04:12:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 85A16F80734 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="aRwZKVpU" 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=PMijb/44lgRkrsRp9Kmr/g3Wxe/fUSywPN1K5JZrDzQ=; b=aRwZKVpUnmAw2X+3gWztwvtEBvdExYQZBVLU8cNr+05Ahcd8LURecj88eViUKbGwgU6NYUYlsxYjAlxhf1iUolVuSQcCUpYdDs3the/QD39iqfEqozZ4Itll/dJmwjsLLKnAiMs64z4ZZRyZujVdSfVgs1OtxqEwZ9r28EgwAgk= Received: from VI1PR0402MB3392.eurprd04.prod.outlook.com (52.134.1.153) by VI1PR0402MB3805.eurprd04.prod.outlook.com (52.134.16.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.16; Tue, 26 Feb 2019 03:12:26 +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; Tue, 26 Feb 2019 03:12:26 +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 V3] ASoC: fsl_esai: fix channel swap issue when stream starts Thread-Index: AQHUzYEZNqiYMhmT3kyzaOJ9QeioVA== Date: Tue, 26 Feb 2019 03:12:25 +0000 Message-ID: <6a5f6ddf5c1683106b0cadd5691cd2d9cfe2c997.1551150582.git.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: HK2PR04CA0056.apcprd04.prod.outlook.com (2603:1096:202:14::24) 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: 0b54777f-c12e-4f52-51c8-08d69b983b72 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:VI1PR0402MB3805; x-ms-traffictypediagnostic: VI1PR0402MB3805: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; VI1PR0402MB3805; 23:Pcp+S7gAxcOG5lqdTU6rb1Ila3ojXnkNaOvDY?= =?iso-8859-1?q?W3BmpBveiU7rcInw4?= =?iso-8859-1?q?M2Z90+jb+/JgMnmgzzxWyJRDvYhh0QCYZ74iP+LvbWWJnPNfgUdc+DF5HE/n?= =?iso-8859-1?q?ltLCWGJT8c9DIMh/7qEVxAkfKs43OihN3KmR/y58j2J4gLYHbu+2Gxv6/sGC?= =?iso-8859-1?q?XHU2ztSZzoIz3buVdFuj6Jilm2tGSR0wVhcdnChqk+EwoGq59LvY5YfJuNBy?= =?iso-8859-1?q?F5RN+j9CnHtsKpKehJVizehY0K79TxImNE8Kajum+qIaq9v0q6eweKZYZsHK?= =?iso-8859-1?q?l0VQ2a0Q9Dy3vhvf0M40qvoQRNcssP//70Qesu4hjo2TR74it8025G75/LOS?= =?iso-8859-1?q?WSaCw8RS3nsuEUll+UfH0qkWxizl2YcdFNg5NnmqtB9VM/glCxPXEP8PKVnO?= =?iso-8859-1?q?HMpPka0cGlErId6fm+Gn+G23kNcENOrHqFFucTjU1q6kEEF5ZH8aozrcNFNY?= =?iso-8859-1?q?Xq/S9yIBkz78dV0JvSiKV/VSqkh+pU6PO559fHwO2cMOU1yJTiV7ip6Rpfm1?= =?iso-8859-1?q?jlfBzEXOU+1jZTGB6VeJYHStYrKVE9IQhPThZ6Cd8Q4Lwlfc1YRZgNhYBbKO?= =?iso-8859-1?q?R4HF9JkZYos7tzaLSvYGCXpKUYWVJ6HpEUQPcXN/G7tYFM9TpI63/TbPAD1D?= =?iso-8859-1?q?jbT6DR3EuWsQp5s0XVS/KEr2N+tPZlJRdugunjewWfmJNcdKCHGc9sxPDJWV?= =?iso-8859-1?q?ccVQtikEbeUAOD4zzx/rCGGp5wnG4iKYY1Z1Ip0+P8m5lhWMr7xY9EZFgOuK?= =?iso-8859-1?q?ctVZbDYF6QiuRElGMG7Wy3BMQpYJIPTcRg3J1ZzpiKNY38VhP/ZdH6OkoK63?= =?iso-8859-1?q?cMCXhnlIz/eKB8OtHGImjs1K7BSmtbc2nbYjUWfjzuLlQVt9ghSknntWkU4M?= =?iso-8859-1?q?FvRA8TDik23R9/k4NwUGbJiacVOCTLcyYX+35PoMDO2wjk3kiZoKgquimAje?= =?iso-8859-1?q?DqTsKPvGFV8ZjMAx3sBGqv5uxaZ7WkYTedn99WPveVW1EwvG+NcfVqRvHLp9?= =?iso-8859-1?q?zH9sr9ZusNiuS4TbUd6lUoNYphfgFDQ65Uw/dX4CkD01aOZaolqCFkrJbdfP?= =?iso-8859-1?q?/3kPgU9r2quiVIb0tgwqK70qilf4dBwMSn+D53kgfx0YoOynoT06RQrVysaI?= =?iso-8859-1?q?147Q5NG8S2CwRMfq0oS+huuTA7Kt0tqmEUrTvjvwRdGFecvau8s2fZMcHtpB?= =?iso-8859-1?q?g=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 096029FF66 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(53936002)(6486002)(7736002)(305945005)(99286004)(14444005)(6512007)(97736004)(50226002)(6436002)(256004)(106356001)(86362001)(105586002)(2501003)(2201001)(316002)(8676002)(110136005)(8936002)(102836004)(81156014)(71190400001)(81166006)(36756003)(2906002)(478600001)(26005)(4326008)(68736007)(25786009)(486006)(476003)(6116002)(3846002)(2616005)(118296001)(5660300002)(71200400001)(52116002)(186003)(14454004)(66066001)(6506007)(386003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3805; 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: lSBqMmXvH9t89F7eYPYbwT+TyzmuyEJCslO5KSSiZj4yXi0Lui/BQ1J9FPpKKLuM5JpyXVGJ8pZJbDDEQnQfsPljkTAqdajiuwAPgWR08+zqfI7HwxTqBKqrXhoWvM3Q7V8SJAkDrEdNNe6Z84ZicK2kzpEMRbApavuzuaLkszrGgKBb66PDrE/fLVUbQkSVHhLXUg0FreUBOVHcEQtlXdsjz7CSm2qSSOIHP9rNGhMIC0MzQzO+aAOSqUzhiOvTtXfNqgDKZWgUjRDoN/3Ye9n/MiI/min8het61nyNGgB82WvBmAxCiZe6FkOg1JRweuHsI6K1wAniFFbJQPmHEYrUKxs03Agp3CC1hfPPyf7zAAPa+RQs1zZvAWsPC1d1FuuONIjO+ME8217s6gpJd6xSkJ1+ORQlk5FMaF4hQgs= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b54777f-c12e-4f52-51c8-08d69b983b72 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2019 03:12:22.9818 (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: VI1PR0402MB3805 Cc: "linuxppc-dev@lists.ozlabs.org" Subject: [alsa-devel] [PATCH V3] 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 Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen --- changes in v3 - initialize tx_mask and rx_mask in probe sound/soc/fsl/fsl_esai.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index afe67c865330..7ee91c28b636 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,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) {