All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@zonque.org>
To: broonie@kernel.org, ryan.lee.analog@gmail.com
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	robh+dt@kernel.org, Daniel Mack <daniel@zonque.org>
Subject: [PATCH 6/8] ASoC: max98396: Fix register access for PCM format settings
Date: Fri, 24 Jun 2022 12:47:10 +0200	[thread overview]
Message-ID: <20220624104712.1934484-7-daniel@zonque.org> (raw)
In-Reply-To: <20220624104712.1934484-1-daniel@zonque.org>

max98396_dai_set_fmt() modifes register 2041 and touches bits in the mask
0x3a. Make sure to use the right mask for that operation.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 sound/soc/codecs/max98396.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/max98396.c b/sound/soc/codecs/max98396.c
index faa81b4bb709..0a1d98279a3e 100644
--- a/sound/soc/codecs/max98396.c
+++ b/sound/soc/codecs/max98396.c
@@ -349,12 +349,15 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 {
 	struct snd_soc_component *component = codec_dai->component;
 	struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component);
-	unsigned int format = 0;
+	unsigned int format_mask, format = 0;
 	unsigned int bclk_pol = 0;
 	int ret, status;
 	int reg;
 	bool update = false;
 
+	format_mask = MAX98396_PCM_MODE_CFG_FORMAT_MASK |
+		      MAX98396_PCM_MODE_CFG_LRCLKEDGE;
+
 	dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt);
 
 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -405,7 +408,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 		ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, &reg);
 		if (ret < 0)
 			return -EINVAL;
-		if (format != (reg & MAX98396_PCM_BCLKEDGE_BSEL_MASK)) {
+		if (format != (reg & format_mask)) {
 			update = true;
 		} else {
 			ret = regmap_read(max98396->regmap,
@@ -422,8 +425,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 
 	regmap_update_bits(max98396->regmap,
 			   MAX98396_R2041_PCM_MODE_CFG,
-			   MAX98396_PCM_BCLKEDGE_BSEL_MASK,
-			   format);
+			   format_mask, format);
 
 	regmap_update_bits(max98396->regmap,
 			   MAX98396_R2042_PCM_CLK_SETUP,
-- 
2.36.1


WARNING: multiple messages have this Message-ID (diff)
From: Daniel Mack <daniel@zonque.org>
To: broonie@kernel.org, ryan.lee.analog@gmail.com
Cc: robh+dt@kernel.org, alsa-devel@alsa-project.org,
	devicetree@vger.kernel.org, Daniel Mack <daniel@zonque.org>
Subject: [PATCH 6/8] ASoC: max98396: Fix register access for PCM format settings
Date: Fri, 24 Jun 2022 12:47:10 +0200	[thread overview]
Message-ID: <20220624104712.1934484-7-daniel@zonque.org> (raw)
In-Reply-To: <20220624104712.1934484-1-daniel@zonque.org>

max98396_dai_set_fmt() modifes register 2041 and touches bits in the mask
0x3a. Make sure to use the right mask for that operation.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 sound/soc/codecs/max98396.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/max98396.c b/sound/soc/codecs/max98396.c
index faa81b4bb709..0a1d98279a3e 100644
--- a/sound/soc/codecs/max98396.c
+++ b/sound/soc/codecs/max98396.c
@@ -349,12 +349,15 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 {
 	struct snd_soc_component *component = codec_dai->component;
 	struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component);
-	unsigned int format = 0;
+	unsigned int format_mask, format = 0;
 	unsigned int bclk_pol = 0;
 	int ret, status;
 	int reg;
 	bool update = false;
 
+	format_mask = MAX98396_PCM_MODE_CFG_FORMAT_MASK |
+		      MAX98396_PCM_MODE_CFG_LRCLKEDGE;
+
 	dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt);
 
 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -405,7 +408,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 		ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, &reg);
 		if (ret < 0)
 			return -EINVAL;
-		if (format != (reg & MAX98396_PCM_BCLKEDGE_BSEL_MASK)) {
+		if (format != (reg & format_mask)) {
 			update = true;
 		} else {
 			ret = regmap_read(max98396->regmap,
@@ -422,8 +425,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 
 	regmap_update_bits(max98396->regmap,
 			   MAX98396_R2041_PCM_MODE_CFG,
-			   MAX98396_PCM_BCLKEDGE_BSEL_MASK,
-			   format);
+			   format_mask, format);
 
 	regmap_update_bits(max98396->regmap,
 			   MAX98396_R2042_PCM_CLK_SETUP,
-- 
2.36.1


  parent reply	other threads:[~2022-06-24 10:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 10:47 [PATCH 0/8] ASoC: max98396: Some assorted fixes and additions Daniel Mack
2022-06-24 10:47 ` Daniel Mack
2022-06-24 10:47 ` [PATCH 1/8] ASoC: dt-bindings: max98396: add voltage supplies Daniel Mack
2022-06-24 10:47   ` Daniel Mack
2022-06-24 10:47 ` [PATCH 2/8] ASoC: dt-bindings: max98396: Add #sound-dai-cells Daniel Mack
2022-06-24 10:47   ` Daniel Mack
2022-06-24 17:26   ` Rob Herring
2022-06-24 17:26     ` Rob Herring
2022-06-24 10:47 ` [PATCH 3/8] ASoC: dt-bindings: max98396: Document adi,bypass-slot-no Daniel Mack
2022-06-24 10:47   ` Daniel Mack
2022-06-24 12:42   ` Mark Brown
2022-06-24 12:42     ` Mark Brown
2022-06-24 10:47 ` [PATCH 4/8] ASoC: max98396: add voltage regulators Daniel Mack
2022-06-24 10:47   ` Daniel Mack
2022-06-24 10:47 ` [PATCH 5/8] ASoC: max98396: Improve some error prints Daniel Mack
2022-06-24 10:47   ` Daniel Mack
2022-06-24 10:47 ` Daniel Mack [this message]
2022-06-24 10:47   ` [PATCH 6/8] ASoC: max98396: Fix register access for PCM format settings Daniel Mack
2022-06-24 12:52   ` Mark Brown
2022-06-24 12:52     ` Mark Brown
2022-06-24 10:47 ` [PATCH 7/8] ASoC: max98396: Implement DSP speaker monitor Daniel Mack
2022-06-24 10:47   ` Daniel Mack
2022-06-24 10:47 ` [PATCH 8/8] ASoC: max98396: Fix TDM mode BSEL settings Daniel Mack
2022-06-24 10:47   ` Daniel Mack
2022-06-24 11:34   ` Daniel Mack
2022-06-24 11:34     ` Daniel Mack
2022-06-24 12:54   ` Mark Brown
2022-06-24 12:54     ` Mark Brown
2022-06-27 20:19 ` (subset) [PATCH 0/8] ASoC: max98396: Some assorted fixes and additions Mark Brown
2022-06-27 20:19   ` Mark Brown
2022-06-27 20:26   ` Daniel Mack
2022-06-27 20:26     ` Daniel Mack
2022-06-27 22:23     ` Mark Brown
2022-06-27 22:23       ` 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=20220624104712.1934484-7-daniel@zonque.org \
    --to=daniel@zonque.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=ryan.lee.analog@gmail.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.