From patchwork Thu Nov 26 14:07:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Mouiche X-Patchwork-Id: 7707351 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E8EE1BF90C for ; Thu, 26 Nov 2015 14:09:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2668220790 for ; Thu, 26 Nov 2015 14:09:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id DDE5E20666 for ; Thu, 26 Nov 2015 14:09:19 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D1CD626680E; Thu, 26 Nov 2015 15:09:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id ADA4C2666E8; Thu, 26 Nov 2015 15:08:01 +0100 (CET) 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 B2156262632; Thu, 26 Nov 2015 15:07:58 +0100 (CET) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by alsa0.perex.cz (Postfix) with ESMTP id D8A5F261AD8 for ; Thu, 26 Nov 2015 15:07:52 +0100 (CET) Received: by wmuu63 with SMTP id u63so22955972wmu.0 for ; Thu, 26 Nov 2015 06:07:52 -0800 (PST) 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=A7xLMKLvhrvwfDFsRD8o6G/VpLsdT89XVO0VtIBPcL0=; b=qByD9Wcj3B8ADBPU0TxVlJkqKyJnj9TwfCg2bb5NzkFtJU0z9iaK7ULcCBzARIhu5H B2J6I2GwLDt+gMColi3pxUSfppeGEDUUBs4gjRz0YwUF7LHyvVaMtIZ/JmqXOs6aBBYt /m1EIBpw7mJPBfV+8umJc3U+77Wk7aq7APPdR2bIGhS9+7z8pVtNbx/1BnzsF3hTckQp w8inTfLxo94jRjQyBZNXqbUsu1Aog5sdoCETuKbN+fSUK5juOZC+a5lzlce+6xwrbR8t USlX3g3fxy4dE0HDhD9TSdxUXAQ546yBKMhdW4NrzASWstVgo9qbGsEJkVUB8qPVwThH QF+w== 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=A7xLMKLvhrvwfDFsRD8o6G/VpLsdT89XVO0VtIBPcL0=; b=BhXR4ST6OPA1G4bG5yibOz8OxA9seGFCkoJ+vYVUJ8BEhUeuWKkPe/TzapycDt05Kz v+mUP79R2nSUPFHYZ1+9ECDr/eMSAzA9zbmm/t1bHsYLr3h1j4cj9VjArsBck1BQJe21 mfpbARepnQqEiKMDD0TvaI/qpowRb3syY8OenC9CZ6+OqJHIDpEWqQKWegoc3/D6kOpa dG/LvzgmJqnLMRGZd4yfRbZyPPXQ4zbaFQFVkZen246gROXxmrnTIxASFO6fOCGXNjjb CM+MOr/M1QsO9x1a/HlH57c5xetlz8LiV6yYIaBtVhAkRDEZrzwbvulUf4hpGixOmk8X twhg== X-Gm-Message-State: ALoCoQljngGUdQSzQpeaV78wWdWseyI/xwyH1ao3mCD5A/JAc7+OfrZc5bxIEm9/IMdSwrAmJRgs X-Received: by 10.194.110.5 with SMTP id hw5mr57643790wjb.154.1448546872648; Thu, 26 Nov 2015 06:07:52 -0800 (PST) Received: from amolinux.invoxia.net ([94.228.188.198]) by smtp.gmail.com with ESMTPSA id v196sm2907777wmv.10.2015.11.26.06.07.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Nov 2015 06:07:51 -0800 (PST) From: Arnaud Mouiche To: Caleb Crome , Roberto Fichera , Markus Pargmann , Fabio Estevam , "shawn.guo@linaro.org" , alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com Date: Thu, 26 Nov 2015 15:07:21 +0100 Message-Id: <1448546842-4584-5-git-send-email-arnaud.mouiche@invoxia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448546842-4584-1-git-send-email-arnaud.mouiche@invoxia.com> References: <1448546842-4584-1-git-send-email-arnaud.mouiche@invoxia.com> Cc: Arnaud Mouiche Subject: [alsa-devel] [PATCH 4/5] ASoC: fsl_ssi: Fix channel slipping in Playback at startup 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 Previously, SCR.SSIEN and SCR.TE were enabled at once if no capture stream was also running. This may not give a chance for the DMA to write the first sample in TX FIFO before the streaming starts on the PCM bus, inserting void samples first. Those void samples are then responsible for slipping the channels. Signed-off-by: Arnaud Mouiche --- sound/soc/fsl/fsl_ssi.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 78ea6e1..c71e194 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -436,8 +436,39 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, config_done: /* Enabling of subunits is done after configuration */ - if (enable) + if (enable) { + if (ssi_private->use_dma && (vals->scr & CCSR_SSI_SCR_TE)) { + /* + * Be sure the Tx FIFO is filled when TE is set. + * Otherwise, there are some chances to start the + * playback with some void samples inserted first, + * generating a channel slip. + * + * First, SSIEN must be set, to let the FIFO be filled. + * + * Notes: + * - Limit this fix to the DMA case until FIQ cases can + * be tested. + * - Limit the length of the busy loop to not lock the + * system too long, even if 1-2 loops are sufficient + * in general. + */ + int i; + int max_loop = 100; + regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, + CCSR_SSI_SCR_SSIEN); + for (i=0; i < max_loop; i++) { + u32 sfcsr; + regmap_read(regs, CCSR_SSI_SFCSR, &sfcsr); + if (CCSR_SSI_SFCSR_TFCNT0(sfcsr)) break; + } + if (i == max_loop) { + dev_err(ssi_private->dev, + "Timeout waiting TX FIFO filling\n"); + } + } regmap_update_bits(regs, CCSR_SSI_SCR, vals->scr, vals->scr); + } }