From patchwork Thu Nov 26 15:05:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Mouiche X-Patchwork-Id: 7707501 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 F24799F2E9 for ; Thu, 26 Nov 2015 15:08:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27A1520640 for ; Thu, 26 Nov 2015 15:08:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 802DA20573 for ; Thu, 26 Nov 2015 15:08:30 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1821D266854; Thu, 26 Nov 2015 16:08:29 +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, NO_DNS_FOR_FROM,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 2A21A2650F2; Thu, 26 Nov 2015 16:06:24 +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 E988E261A7C; Thu, 26 Nov 2015 16:06:19 +0100 (CET) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by alsa0.perex.cz (Postfix) with ESMTP id 87AF12606F6 for ; Thu, 26 Nov 2015 16:06:14 +0100 (CET) Received: by wmec201 with SMTP id c201so25968209wme.1 for ; Thu, 26 Nov 2015 07:06:14 -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=flO3d8VRJhQBRBKscq1zewCWBbxhCAb1a0aEQEdNnhc=; b=x2nxSSa2Aag6Ia/d4XsuhLEONMwJqSsIgBU5K2qyau3hDeKW9WbGwYav51bMWmbwOI n4RFgzqF5V4mJXHe+3MzxtPC5Jg3MTblbQFwIuZfd9o4OmdMc4lsT8avtZQURictTSBR O1kaSIr2x2QXOOXDn/aoiLoPYUI4Avg97gyGmZg+TnQYDzpgHMFMKZLIJChy2wtVdomL bYPnXL+mJuKY7nFkzm9tJG/3HX9HSdOiNB3YTyKQmzYhD4pbtiAb8Fa1tR3sNC/QC5fs B4DI82ys9wsxwQLxplnX6DeGI2211iW4PAk9Ub6lgrdJ8yuWrU7sf97bsjAw540OxsIg Kqsg== 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=flO3d8VRJhQBRBKscq1zewCWBbxhCAb1a0aEQEdNnhc=; b=lJWXw24Gr0Y/wHJDBn9YoUkJVToC4G085cEd0bO2fQ+D3Hx7puh95tZAMZCN2biB94 iL47l+frkYjuhVaUJv6Ze7oXQYalBdIL59nJdVCDR8Dsr+DEO04yQnVJn4wTodloGzNh KRMnwsW8qBwFPlIApqKZdPw+ING8iynA/NuTQS3+pHXTV3V3LYUr4UJoreILpeCSqiXm WFvI5d4HmyRZ23ZYVVb92fYQhaMs43pmt1i8IDz/F35cQRjMmNy/Ne3fKt1vowFo/nY3 DIGkoQThb8JI5YlcO+ZuAIvNO6/bFKTkc0tTcycRL0EfORdG+CSm7ne4bnzje0mTgxEb 5uZw== X-Gm-Message-State: ALoCoQmlJ/3eD/TW0+e76simFBk7hsTjoegJNAo17wzz2cA6m6t+oWOBRKxBCfGhkoTefa+4II0m X-Received: by 10.28.224.86 with SMTP id x83mr4555397wmg.36.1448550374180; Thu, 26 Nov 2015 07:06:14 -0800 (PST) Received: from amolinux.invoxia.net ([94.228.188.198]) by smtp.gmail.com with ESMTPSA id gl4sm1079618wjd.17.2015.11.26.07.06.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Nov 2015 07:06:13 -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 16:05:40 +0100 Message-Id: <1448550341-11765-6-git-send-email-arnaud.mouiche@invoxia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448550341-11765-1-git-send-email-arnaud.mouiche@invoxia.com> References: <1448550341-11765-1-git-send-email-arnaud.mouiche@invoxia.com> Cc: Arnaud Mouiche Subject: [alsa-devel] [PATCH v2 5/6] 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 | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 78ea6e1..9d5c677 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -436,8 +436,40 @@ 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); + } }