From patchwork Tue May 3 12:14:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Mouiche X-Patchwork-Id: 9003531 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 33F639F372 for ; Tue, 3 May 2016 13:03:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4CF7820259 for ; Tue, 3 May 2016 13:03:11 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4494D20225 for ; Tue, 3 May 2016 13:03:07 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 16C8226608F; Tue, 3 May 2016 15:03:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id CC8E4266192; Tue, 3 May 2016 14:45:00 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 54940266192; Tue, 3 May 2016 14:44:59 +0200 (CEST) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by alsa0.perex.cz (Postfix) with ESMTP id EB7CB266564 for ; Tue, 3 May 2016 14:14:17 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id e201so143696943wme.0 for ; Tue, 03 May 2016 05:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invoxia-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+UR/6g4AOww0JCETQIfDxV438GwTg7Y2uRZ5UiMUBdg=; b=t0CgcYB+bXHDHkVV8xxF/qFpKqTWZGaRnGgfOvhyQiwTUMBY9+c/RCiTJMEi/14DNx 2cIfnx3x3HU1tF4sG0/91rDo4kN2lQo6eojwqMGcLIPr+SmV7ZSE0TJ4D0Xk0BgpVM59 pmjTh6F9qRQyiZz4EyaHk9ZymvO3JIzcI+HkrsCZnD4J1MC39TaHT8ZNxh1ZTouMm7ES fTJVvmagzxxzatxGorL3QpoVLz3FCf87XBDkeexg7i1We0VhJ74WcnRNGH9N2/jJa238 SXVbsPlEl+cgK5Hx+xkwB4r8HtUoYu3nyIcU0WyxMycgdmRzkLlVp9J4icbeuFlS5vKm uZ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+UR/6g4AOww0JCETQIfDxV438GwTg7Y2uRZ5UiMUBdg=; b=d7WyMT3Daqrc//QKasq/glYPj5nO+fVqR26cSzggt2nj3o3DuGu2snFrDvIbpbbcWI +/G/EEahVacc0rtzuHXrpvax3+CfTGtEPYyQsSq8iae6esvmoKJqzBXWCnAhd9CgdS2K Vwq4F4ClPn4MB8yNXSxLkC+XMfe2KiALErDHE6nhPmlJ8u8Rdzo2mJlZg9gMq1VBqdKE hhR4eQ1yrZ2Wv8v0X/tXwiK/29i1QfBRDrXIrBN6o9j7NrluzLVVzYv1RqRseNlgxJI0 +SW0IjMxCRiKZgq/E81t6IXuGGb6/uz1HCYCbLOveEPRgYs9Y2hUVPusjM76OflBOCvO ZAFA== X-Gm-Message-State: AOPr4FX6FRAM/zuIrn7gVqhK0GojVdKNuvxaa1MhFjfpybDqu8jtzzEJPFYqOtkfqdCsy9ib X-Received: by 10.194.85.161 with SMTP id i1mr2711822wjz.95.1462277657526; Tue, 03 May 2016 05:14:17 -0700 (PDT) Received: from localhost.localdomain (AAnnecy-653-1-104-42.w90-41.abo.wanadoo.fr. [90.41.64.42]) by smtp.gmail.com with ESMTPSA id k133sm24323995wmg.7.2016.05.03.05.14.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 May 2016 05:14:16 -0700 (PDT) From: Arnaud Mouiche To: Timur Tabi , Nicolin Chen , Xiubo Li , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, festevam@gmail.com, caleb@crome.org Date: Tue, 3 May 2016 14:14:00 +0200 Message-Id: <1462277640-20052-7-git-send-email-arnaud.mouiche@invoxia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462277640-20052-1-git-send-email-arnaud.mouiche@invoxia.com> References: <1462277640-20052-1-git-send-email-arnaud.mouiche@invoxia.com> Cc: Arnaud Mouiche Subject: [alsa-devel] [PATCH v4 6/6] ASoC: fsl_ssi: Fix channel slipping on capture (or playback) restart in full duplex. X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Happened when the Playback (or Capture) is running continuously and Capture (or Playback) is restarted (xrun, manual stop/start...) Since the RX (or TX) FIFO are only reset when the whole SSI is disabled, pending samples from previous capture (or playback) session may still be present. They must be erased to not introduce channel slipping. FIFO Clear register fields are documented in IMX51, IMX35 reference manual. They are not documented in IMX50 or IMX6 RM, despite they are working as expected on IMX6SL and IMX6solo. Signed-off-by: Arnaud Mouiche Reviewed-by: Fabio Estevam Tested-by: Caleb Crome --- sound/soc/fsl/fsl_ssi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 6c0c72f..632ecc0 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -402,6 +402,26 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi_private *ssi_private, } /* + * Clear RX or TX FIFO to remove samples from the previous + * stream session which may be still present in the FIFO and + * may introduce bad samples and/or channel slipping. + * + * Note: The SOR is not documented in recent IMX datasheet, but + * is described in IMX51 reference manual at section 56.3.3.15. + */ +static void fsl_ssi_fifo_clear(struct fsl_ssi_private *ssi_private, + bool is_rx) +{ + if (is_rx) { + regmap_update_bits(ssi_private->regs, CCSR_SSI_SOR, + CCSR_SSI_SOR_RX_CLR, CCSR_SSI_SOR_RX_CLR); + } else { + regmap_update_bits(ssi_private->regs, CCSR_SSI_SOR, + CCSR_SSI_SOR_TX_CLR, CCSR_SSI_SOR_TX_CLR); + } +} + +/* * Calculate the bits that have to be disabled for the current stream that is * getting disabled. This keeps the bits enabled that are necessary for the * second stream to work if 'stream_active' is true. @@ -476,6 +496,8 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, * (online configuration) */ if (enable) { + fsl_ssi_fifo_clear(ssi_private, vals->scr & CCSR_SSI_SCR_RE); + regmap_update_bits(regs, CCSR_SSI_SRCR, vals->srcr, vals->srcr); regmap_update_bits(regs, CCSR_SSI_STCR, vals->stcr, vals->stcr); regmap_update_bits(regs, CCSR_SSI_SIER, vals->sier, vals->sier);