All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sameer Pujar <spujar@nvidia.com>
To: <broonie@kernel.org>, <robh+dt@kernel.org>, <krzk+dt@kernel.org>,
	<thierry.reding@gmail.com>, <lgirdwood@gmail.com>,
	<perex@perex.cz>, <tiwai@suse.com>
Cc: <jonathanh@nvidia.com>, <mkumard@nvidia.com>,
	<sheetal@nvidia.com>, <alsa-devel@alsa-project.org>,
	<devicetree@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: [PATCH 3/8] ASoC: tegra: Fix ADX byte map
Date: Thu, 22 Jun 2023 17:04:11 +0530	[thread overview]
Message-ID: <1687433656-7892-4-git-send-email-spujar@nvidia.com> (raw)
In-Reply-To: <1687433656-7892-1-git-send-email-spujar@nvidia.com>

From: Sheetal <sheetal@nvidia.com>

Byte mask for channel-1 of stream-1 is not getting enabled and this
causes failures during ADX use cases. The enable bit is not set during
put() callback of byte map mixer control.

This happens because the byte map value 0 matches the initial state
of byte map array and put() callback returns without doing anything.

Fix the put() callback by actually looking at the byte mask array
to identify if any change is needed and update the fields accordingly.
Also update get() callback to return 256 if the byte map is disabled.

Fixes: 3c97881b8c8a ("ASoC: tegra: Fix kcontrol put callback in ADX")
Cc: stable@vger.kernel.org
Signed-off-by: Sheetal <sheetal@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
---
 sound/soc/tegra/tegra210_adx.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/sound/soc/tegra/tegra210_adx.c b/sound/soc/tegra/tegra210_adx.c
index bd0b10c..6894b11 100644
--- a/sound/soc/tegra/tegra210_adx.c
+++ b/sound/soc/tegra/tegra210_adx.c
@@ -2,7 +2,7 @@
 //
 // tegra210_adx.c - Tegra210 ADX driver
 //
-// Copyright (c) 2021 NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2021-2023 NVIDIA CORPORATION.  All rights reserved.
 
 #include <linux/clk.h>
 #include <linux/device.h>
@@ -178,7 +178,7 @@ static int tegra210_adx_get_byte_map(struct snd_kcontrol *kcontrol,
 	if (enabled)
 		ucontrol->value.integer.value[0] = bytes_map[mc->reg];
 	else
-		ucontrol->value.integer.value[0] = 0;
+		ucontrol->value.integer.value[0] = 256;
 
 	return 0;
 }
@@ -192,19 +192,19 @@ static int tegra210_adx_put_byte_map(struct snd_kcontrol *kcontrol,
 	int value = ucontrol->value.integer.value[0];
 	struct soc_mixer_control *mc =
 		(struct soc_mixer_control *)kcontrol->private_value;
+	unsigned int mask_val = adx->byte_mask[mc->reg / 32];
 
-	if (value == bytes_map[mc->reg])
+	if (value >= 0 && value <= 255)
+		mask_val |= (1 << (mc->reg % 32));
+	else
+		mask_val &= ~(1 << (mc->reg % 32));
+
+	if (mask_val == adx->byte_mask[mc->reg / 32])
 		return 0;
 
-	if (value >= 0 && value <= 255) {
-		/* update byte map and enable slot */
-		bytes_map[mc->reg] = value;
-		adx->byte_mask[mc->reg / 32] |= (1 << (mc->reg % 32));
-	} else {
-		/* reset byte map and disable slot */
-		bytes_map[mc->reg] = 0;
-		adx->byte_mask[mc->reg / 32] &= ~(1 << (mc->reg % 32));
-	}
+	/* Update byte map and slot */
+	bytes_map[mc->reg] = value % 256;
+	adx->byte_mask[mc->reg / 32] = mask_val;
 
 	return 1;
 }
-- 
2.7.4


  parent reply	other threads:[~2023-06-22 11:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 11:34 [PATCH 0/8] Few audio fixes on Tegra platforms Sameer Pujar
2023-06-22 11:34 ` [PATCH 1/8] ASoC: tegra: Fix SFC conversion for few rates Sameer Pujar
2023-06-22 11:34 ` [PATCH 2/8] ASoC: tegra: Fix AMX byte map Sameer Pujar
2023-06-22 12:07   ` Mark Brown
2023-06-23  5:39     ` Sameer Pujar
2023-06-23 10:15       ` Mark Brown
2023-06-26  9:41         ` Sameer Pujar
2023-06-22 11:34 ` Sameer Pujar [this message]
2023-06-22 11:34 ` [PATCH 4/8] ASoC: rt5640: Fix sleep in atomic context Sameer Pujar
2023-06-22 12:12   ` Mark Brown
2023-06-23  4:54     ` Sameer Pujar
2023-06-22 11:34 ` [PATCH 5/8] ASoC: tegra: Use normal system sleep for ASRC Sameer Pujar
2023-06-22 11:34 ` [PATCH 6/8] ASoC: tegra: Remove stale comments in AHUB Sameer Pujar
2023-06-22 11:34 ` [PATCH 7/8] arm64: tegra: Update AHUB clock parent and rate on Tegra234 Sameer Pujar
2023-06-22 12:13   ` Mark Brown
2023-06-23  4:51     ` Sameer Pujar
2023-06-22 11:34 ` [PATCH 8/8] arm64: tegra: Update AHUB clock parent and rate Sameer Pujar
2023-06-22 22:33 ` (subset) [PATCH 0/8] Few audio fixes on Tegra platforms Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1687433656-7892-4-git-send-email-spujar@nvidia.com \
    --to=spujar@nvidia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mkumard@nvidia.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=sheetal@nvidia.com \
    --cc=stable@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.