From patchwork Sun Apr 8 04:40:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10328171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 463E5604D4 for ; Sun, 8 Apr 2018 05:06:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C5AF289E1 for ; Sun, 8 Apr 2018 05:06:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20E3F2911C; Sun, 8 Apr 2018 05:06:52 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A935289E1 for ; Sun, 8 Apr 2018 05:06:50 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 410F7267235; Sun, 8 Apr 2018 06:41:14 +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 AF16C267265; Sun, 8 Apr 2018 06:41:12 +0200 (CEST) Received: from mail-pl0-f47.google.com (mail-pl0-f47.google.com [209.85.160.47]) by alsa0.perex.cz (Postfix) with ESMTP id 348C9267070 for ; Sun, 8 Apr 2018 06:41:09 +0200 (CEST) Received: by mail-pl0-f47.google.com with SMTP id 59-v6so3095189plc.13 for ; Sat, 07 Apr 2018 21:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h9Ra3sCDlwGXw8Df4lls8K3mtMqvq/d3DufiqdA9WRk=; b=pYWbfdRo+vxztvFqz3Sc5LfSaIEQ2O7ZpFVlRhsMaIquYJXi93YEMPk1V3MzqVXPGC 8Lc0uBAum+C3Ya16JiQ+nt6O+mrlm5hwVwzC4KgLUzHyV2qcuW4qPROR7D+PUT9ID6kJ 7UxL6I9FmUBKP/Jf/NG2BgA75CeN8JqB8qEFsHCOwrXKycxYUYY5mnj1lToBgelE5E/u /c2BkHd98Rs/l5HsHk2asexxGbnyyHewcld7T+TL6Jghn633mcLs8AdFtNZu6tkbtEB5 T3G2NQl29clw9k734yENz9fxepLaTLKbvzV6C98ij4tVaF0OlgvsahzVegfXSU4rCEUS 9z2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h9Ra3sCDlwGXw8Df4lls8K3mtMqvq/d3DufiqdA9WRk=; b=mkecgAbRiMfnOC2uPexnHAsmpffMi5SDp3Y4H2eU++uIFaHosvTdobuXEABoce0fhG xHsf6GIwVw1oTlxvqMg++l+u98rPIvFcHSRWZoAocDAerg2qAYWJ/T03dBefj98GclsC rnjJ/Kazv2VIXpsx0oRAmO/caeclvJP+z7h5tSr5bZ7XhYUMoKIk6wm+CBlpct5T3qYB N6kBiMQ62ZDnGdtivC2USkONqourXZeehHY25Wq6bxynZ03/Duph1lBiFRUPlzBjl7yt gNT66X4ONPZlvFPhYweMVvF44ySYlw63yY8yFuY1T6RtuwhmOZHjRb9JkFDo2stjmPlV /pqA== X-Gm-Message-State: ALQs6tDU0+IWsETNe3GkBONE3xbiX2/kfd0Ozc9NYZ7+z4pxq7emiwTc xhOqNRHY3Fpt7earci3EQow= X-Google-Smtp-Source: AIpwx4/875G0Flr+NwsDgLJRH+j5UjnjaJra1SOKv4ImxNl7m58bH3yZzczhs9TazTxsk4Vo70XSxw== X-Received: by 2002:a17:902:b212:: with SMTP id t18-v6mr4520236plr.137.1523162468224; Sat, 07 Apr 2018 21:41:08 -0700 (PDT) Received: from Asurada-CZ80.localdomain (c-73-231-2-134.hsd1.ca.comcast.net. [73.231.2.134]) by smtp.gmail.com with ESMTPSA id v8sm24091530pff.42.2018.04.07.21.41.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 07 Apr 2018 21:41:07 -0700 (PDT) From: Nicolin Chen To: broonie@kernel.org, mika.penttila@nextfour.com Date: Sat, 7 Apr 2018 21:40:21 -0700 Message-Id: <1523162421-26400-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, timur@tabi.org, linux-kernel@vger.kernel.org, tiwai@suse.com, lgirdwood@gmail.com, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH] ASoC: fsl_ssi: Fix mode setting when changing channel number 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This is a partial revert (in a cleaner way) of commit ebf08ae3bc90 ("ASoC: fsl_ssi: Keep ssi->i2s_net updated") to fix a regression at test cases when switching between mono and stereo audio. The problem is that ssi->i2s_net is initialized in set_dai_fmt() only, while this set_dai_fmt() is only called during the dai-link probe(). The original patch assumed set_dai_fmt() would be called during every playback instance, so it failed at the overriding use cases. This patch adds the local variable i2s_net back to let regular use cases still follow the mode settings from the set_dai_fmt(). Meanwhile, the original commit of keeping ssi->i2s_net updated was to make set_tdm_slot() clean by checking the ssi->i2s_net directly instead of reading SCR register. However, the change itself is not necessary (or even harmful) because the set_tdm_slot() might fail to check the slot number for Normal-Mode-None-Net settings while mono audio cases still need 2 slots. So this patch can also fix it. And it adds an extra line of comments to declare ssi->i2s_net does not reflect the register value but merely the initial setting from the set_dai_fmt(). Reported-by: Mika Penttilä Signed-off-by: Nicolin Chen Cc: Mika Penttilä Tested-by: Mika Penttilä --- sound/soc/fsl/fsl_ssi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 0823b08..89df2d9 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -217,6 +217,7 @@ struct fsl_ssi_soc_data { * @dai_fmt: DAI configuration this device is currently used with * @streams: Mask of current active streams: BIT(TX) and BIT(RX) * @i2s_net: I2S and Network mode configurations of SCR register + * (this is the initial settings based on the DAI format) * @synchronous: Use synchronous mode - both of TX and RX use STCK and SFCK * @use_dma: DMA is used or FIQ with stream filter * @use_dual_fifo: DMA with support for dual FIFO mode @@ -829,16 +830,23 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, } if (!fsl_ssi_is_ac97(ssi)) { + /* + * Keep the ssi->i2s_net intact while having a local variable + * to override settings for special use cases. Otherwise, the + * ssi->i2s_net will lose the settings for regular use cases. + */ + u8 i2s_net = ssi->i2s_net; + /* Normal + Network mode to send 16-bit data in 32-bit frames */ if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16) - ssi->i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET; + i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET; /* Use Normal mode to send mono data at 1st slot of 2 slots */ if (channels == 1) - ssi->i2s_net = SSI_SCR_I2S_MODE_NORMAL; + i2s_net = SSI_SCR_I2S_MODE_NORMAL; regmap_update_bits(regs, REG_SSI_SCR, - SSI_SCR_I2S_NET_MASK, ssi->i2s_net); + SSI_SCR_I2S_NET_MASK, i2s_net); } /* In synchronous mode, the SSI uses STCCR for capture */