Received: by 10.213.65.68 with SMTP id h4csp1223611imn; Sat, 7 Apr 2018 21:45:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx484jeEIoFucXIrcADfL3Gy6aqU25Hl8i7VMdlQjLh/gcs+HbPCJenL7x1pfklhzpn98pAec X-Received: by 10.99.124.92 with SMTP id l28mr21603075pgn.51.1523162722703; Sat, 07 Apr 2018 21:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523162722; cv=none; d=google.com; s=arc-20160816; b=gGkDKa0xv3uACNjnMWIMpE7FCT/Cd1EUhzJ4kEys4RdvbMl4scjeYdwmSFPNpihR+z v9+TdWr9oHsIlt9sPofCHwZ9pex4+FR++VFlRpASYXKytHBAcpHKrY2S8rDjmCyGX6Wh uHm2wQ+cQHoT5dJ3pJ1Mc/A4ZAU1KClSe7iTrJqBYKZ24bkE5XeSlUIIbZFB80UYd7Uz ckPbXiQIuD4IC3Vzk7wEPpLuYf4X/j8F1EdA7LKlF6ZwIrfORbMzeq7zmPxaJYih8JIP 7buYd6v4PsnB5d3mclJZ5DAc7vIR4TRN7UxpaEk8P6YU0Mxkg23FB5CzWhLXys+646Xb gnwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=h9Ra3sCDlwGXw8Df4lls8K3mtMqvq/d3DufiqdA9WRk=; b=zu6Q/pdQa7x0+yhqD0ludBDVg5jk8pFazilQgIsgLj069KdM30GfMSBLsv6mqRLbfW txTaydz6DR1LdMyLV4Lc0MIqekKyomX82yseOIRMP6bS6zQIPVPapcawq0zSarzpSiKu lQwavXw89sXQcgnexk37as/Jb/aFvS930r3Mb2m1bbdcweAQb9ooIB4sQwZkacqIqhlp 0DQKNPEGfJez3+4IsVkqd2pO6dMYAa+507zmknfcG6MaRVKvg3SfQiP9cRQ2EStEZTbY S4VGoh1W75uG1v7uJyMt2Veqbk1oofj49KtXdoxWzLurQLvdnnFaFiUHpqWaXfpelb/v JSog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pYWbfdRo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4si562489pgs.571.2018.04.07.21.44.32; Sat, 07 Apr 2018 21:45:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pYWbfdRo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751309AbeDHElK (ORCPT + 99 others); Sun, 8 Apr 2018 00:41:10 -0400 Received: from mail-pl0-f49.google.com ([209.85.160.49]:37161 "EHLO mail-pl0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750760AbeDHElJ (ORCPT ); Sun, 8 Apr 2018 00:41:09 -0400 Received: by mail-pl0-f49.google.com with SMTP id v5-v6so3092533plo.4 for ; Sat, 07 Apr 2018 21:41:08 -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=KsWxmqcGSAEqKLvl5zcK/8B7CqeLAcOFVCZBAxDEZv7/K0OjrJxGi+jf2mJW5xE1IY 7ftf5ogzLVTVgqHGi0Sty/M7xxdCyeuQhZH555uk1gTRbaN+Ggqxjt/aj8HqfzLLQm+L dZk1EQbvaFgERaVHbKCJMxRxGd7bD5cqinnAZRl+2b0FX/DSSwiVr0fQcMn/feuTXGwQ +mOrBkCrPyS338pN36pEjUgOWb2E27AWvCjK0EuYaxAbW2AlzoDRBNUXyNba0Rj0dwn/ 3TrUoKsjyDr2x+ZIK3rK5lcubmxRLrEQ8CC78zkKHRLxvd1uRK2OGCC4EduM2XQSInis YOxA== X-Gm-Message-State: ALQs6tDxeVqMx1UnFzFA7rWqBCfMUPcSl/ivTgEulPkNy3hXnf+VuaFx 6i90UYCEPxwo0TyqjAoplhk= 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 Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, alsa-devel@alsa-project.org, tiwai@suse.com, perex@perex.cz, lgirdwood@gmail.com, fabio.estevam@nxp.com, timur@tabi.org Subject: [PATCH] ASoC: fsl_ssi: Fix mode setting when changing channel number 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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ä --- 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 */ -- 2.7.4