From patchwork Thu Feb 22 13:16:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 129242 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp587888lja; Thu, 22 Feb 2018 05:19:15 -0800 (PST) X-Google-Smtp-Source: AH8x225jy15dPnO9w7s8GMem5MlzIrwzEGaaucsVdQxx879CQPwe4ygcQpXIOxJEw5pSOl0FcE89 X-Received: by 10.223.209.18 with SMTP id a18mr6350418wri.141.1519305555182; Thu, 22 Feb 2018 05:19:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519305555; cv=none; d=google.com; s=arc-20160816; b=KEYRPGIhZQT5VgRN91kzVW1lEQtcCuqMFF09notbVcqz04rg1EkxCzKfAin6AA/1XZ 16WtJRzqjo0FpbE6jN6kI1k53hWcJ9szDUebrbpkmwdWCm+Av5oM4Fl5sICxL8ODCZ01 dn7gLJct8Ze7pRStw7X5fwv2Zw55i8FbLEsuS1iwF03bIYO3bUDMqf33IWvI3jGSaoSu wr8OvCT5WPQ+e2Nifb4PRH5Mpa6a0WEJ7/Od3c5kI1uPFqOxT45Kai1W6NbedCdEExMU py0S0JehgJOIx4hB+EpQ3dcfJAaa/DCtKo9M9sv8C04osxc163UHS7YfDbsmTWpdz9qM VzLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=VTfyF8+p4b0AdDzBZSWVoqe/nCuC+0mbfsqtBzTdbp4=; b=z2xQfHcR2cJsMC1FUDnbe0xt/WNWc7KbiXszxTA3PXBKQEF3537A937Mh4Oy4kWWSS LzbUSdiKQ/2p+EA7pKGueZoKZxipljLq2nkGw6q0M+POFtp9uqrSPa5H26BhHui/i0KI v4HY7KqwQFFfkcrf9e+Fs4FZoFhUPmhBP75JeTgpvjOOkZG260LGQI/+/4OQipBZgdH8 FHnvnqgyrnvNcEsguWcG1U93cB2aqhfbM+mEcRYTanYGvi7OeE8uxqqyEEptOgd15dhn bOgjlADgvXcaQDhPezw5rexj0gm2yHXVGY9YWI+TGNFWDUfO4+nrTFcbfO7nWiLc6O/M DNIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=q3isRVZC; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id y11si239401wmb.180.2018.02.22.05.19.14; Thu, 22 Feb 2018 05:19:15 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=q3isRVZC; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 11578267842; Thu, 22 Feb 2018 14:17:54 +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 6D1FA267835; Thu, 22 Feb 2018 14:17:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id 877AC26777C for ; Thu, 22 Feb 2018 14:17:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=rjSE2IG/Fj6yafFSF8Dz1iVjnbdev5NAPesmS1p2QS8=; b=q3isRVZC5oDE Ky0ECnwIWaP5+asBsh6dA30WskOD6KhINZ1kockOrkFbijSFewbOE+ZbHLI21S45oguGh51FqI0dh a15p5UCOT2nZpkfpm/x1lv+b761YqSTvnitMg4ITxpV/uvvGA+A/tbjEmJ9KRN+tqEHAkP17H10up a387w=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eoqk5-0002Va-B7; Thu, 22 Feb 2018 13:16:57 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1eoqk4-0006Pe-PP; Thu, 22 Feb 2018 13:16:56 +0000 From: Mark Brown To: Nicolin Chen In-Reply-To: <1515990087-11598-6-git-send-email-nicoleotsuka@gmail.com> Message-Id: Date: Thu, 22 Feb 2018 13:16:56 +0000 Cc: alsa-devel@alsa-project.org, arnaud.mouiche@invoxia.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, mail@maciej.szmigiero.name, caleb@crome.org, timur@tabi.org, broonie@kernel.org, kernel@pengutronix.de, lukma@denx.de, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] Applied "ASoC: fsl_ssi: Rename fsl_ssi_disable_val macro" to the asoc tree 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 The patch ASoC: fsl_ssi: Rename fsl_ssi_disable_val macro has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 06a994540505a9ce7028d9e801c52f967654b836 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:13 -0800 Subject: [PATCH] ASoC: fsl_ssi: Rename fsl_ssi_disable_val macro The define of fsl_ssi_disable_val is not so clear as it mixes two steps of calculations together. And those parameter names are also a bit long to read. Since it just tries to exclude the shared bits from the regvals of current stream while the opposite stream is active, it's better to use something like ssi_excl_shared_bits. This patch also bisects fsl_ssi_disable_val into two macros of two corresponding steps and then shortens its parameter names. It also updates callers in the fsl_ssi_config() accordingly. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 55 +++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) -- 2.16.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index b277a563ff48..0d8c800db0b3 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -421,24 +421,24 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) } /** - * 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. + * Exclude bits that are used by the opposite stream * - * Detailed calculation: - * These are the values that need to be active after disabling. For non-active - * second stream, this is 0: - * vals_stream * !!stream_active + * When both streams are active, disabling some bits for the current stream + * might break the other stream if these bits are used by it. * - * The following computes the overall differences between the setup for the - * to-disable stream and the active stream, a simple XOR: - * vals_disable ^ (vals_stream * !!(stream_active)) + * @vals : regvals of the current stream + * @avals: regvals of the opposite stream + * @aactive: active state of the opposite stream * - * The full expression adds a mask on all values we care about + * 1) XOR vals and avals to get the differences if the other stream is active; + * Otherwise, return current vals if the other stream is not active + * 2) AND the result of 1) with the current vals */ -#define fsl_ssi_disable_val(vals_disable, vals_stream, stream_active) \ - ((vals_disable) & \ - ((vals_disable) ^ ((vals_stream) * (u32)!!(stream_active)))) +#define _ssi_xor_shared_bits(vals, avals, aactive) \ + ((vals) ^ ((avals) * (aactive))) + +#define ssi_excl_shared_bits(vals, avals, aactive) \ + ((vals) & _ssi_xor_shared_bits(vals, avals, aactive)) /** * Enable or disable SSI configuration. @@ -446,19 +446,14 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, struct fsl_ssi_regvals *vals) { + int adir = (&ssi->regvals[TX] == vals) ? RX : TX; int dir = (&ssi->regvals[TX] == vals) ? TX : RX; struct regmap *regs = ssi->regs; struct fsl_ssi_regvals *avals; - int nr_active_streams; - int keep_active; - - nr_active_streams = !!(ssi->streams & BIT(TX)) + - !!(ssi->streams & BIT(RX)); + bool aactive; - if (nr_active_streams - 1 > 0) - keep_active = 1; - else - keep_active = 0; + /* Check if the opposite stream is active */ + aactive = ssi->streams & BIT(adir); /* Get the opposite direction to keep its values untouched */ if (&ssi->regvals[RX] == vals) @@ -471,8 +466,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, * To keep the other stream safe, exclude shared bits between * both streams, and get safe bits to disable current stream */ - u32 scr = fsl_ssi_disable_val(vals->scr, avals->scr, - keep_active); + u32 scr = ssi_excl_shared_bits(vals->scr, avals->scr, aactive); /* Safely disable SCR register for the stream */ regmap_update_bits(regs, REG_SSI_SCR, scr, 0); @@ -487,7 +481,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, * 2) Disable all remaining bits of both streams when last stream ends */ if (ssi->soc->offline_config) { - if ((enable && !nr_active_streams) || (!enable && !keep_active)) + if ((enable && !ssi->streams) || (!enable && !aactive)) fsl_ssi_rxtx_config(ssi, enable); goto config_done; @@ -509,12 +503,9 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, * To keep the other stream safe, exclude shared bits between * both streams, and get safe bits to disable current stream */ - sier = fsl_ssi_disable_val(vals->sier, avals->sier, - keep_active); - srcr = fsl_ssi_disable_val(vals->srcr, avals->srcr, - keep_active); - stcr = fsl_ssi_disable_val(vals->stcr, avals->stcr, - keep_active); + sier = ssi_excl_shared_bits(vals->sier, avals->sier, aactive); + srcr = ssi_excl_shared_bits(vals->srcr, avals->srcr, aactive); + stcr = ssi_excl_shared_bits(vals->stcr, avals->stcr, aactive); /* Safely disable other control registers for the stream */ regmap_update_bits(regs, REG_SSI_SRCR, srcr, 0);