Skip to contentSkip to conversation

ASoC: codecs: pcm186x: fix wrong usage of DECLARE_TLV_DB_SCALE()

PATCH In review [email protected] 3 participants 8 messages Feb 19, 2019 – Feb 20, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 ASoC: codecs: pcm186x: fix wrong usage of DECLARE_TLV_DB_SCALE()

From: Codrin Ciubotariu <[email protected]>

According to DS, the gain is between -12 dB and 40 dB, with a 0.5 dB step. Tested on pcm1863.

---

Changes in v2:
- fixed title - added correct macro;
- revert the removal of a new line;

 sound/soc/codecs/pcm186x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/pcm186x.c +1 -1
index 809b7e9f03ca..c36a391fec8a 100644
@@ -42,7 +42,7 @@ struct pcm186x_priv {
 	bool is_master_mode;
 };
 
-static const DECLARE_TLV_DB_SCALE(pcm186x_pga_tlv, -1200, 4000, 50);
+static const DECLARE_TLV_DB_SCALE(pcm186x_pga_tlv, -1200, 50, 0);
 
 static const struct snd_kcontrol_new pcm1863_snd_controls[] = {
 	SOC_DOUBLE_R_S_TLV("ADC Capture Volume", PCM186X_PGA_VAL_CH1_L,
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 2/2 ASoC: codecs: pcm186x: Fix energysense SLEEP bit

From: Codrin Ciubotariu <[email protected]>

The ADCs are sleeping when the SLEEP bit is set and running when it's cleared, so the bit should be inverted.
Tested on pcm1863.

---

Changes in v2:
- none;

 sound/soc/codecs/pcm186x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/pcm186x.c +3 -3
index c36a391fec8a..c5fcc632f670 100644
@@ -158,7 +158,7 @@ static const struct snd_soc_dapm_widget pcm1863_dapm_widgets[] = {
 	 * Put the codec into SLEEP mode when not in use, allowing the
 	 * Energysense mechanism to operate.
 	 */
-	SND_SOC_DAPM_ADC("ADC", "HiFi Capture", PCM186X_POWER_CTRL, 1,  0),
+	SND_SOC_DAPM_ADC("ADC", "HiFi Capture", PCM186X_POWER_CTRL, 1,  1),
 };
 
 static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
@@ -184,8 +184,8 @@ static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
 	 * Put the codec into SLEEP mode when not in use, allowing the
 	 * Energysense mechanism to operate.
 	 */
-	SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1,  0),
-	SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1,  0),
+	SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1,  1),
+	SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1,  1),
 };
 
 static const struct snd_soc_dapm_route pcm1863_dapm_routes[] = {
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v2 2/2] ASoC: codecs: pcm186x: Fix energysense SLEEP bit

Quoted 3 lines · On Tue, Feb 19, 2019 at 04:29:28PM +0000, [email protected] wrote:

The ADCs are sleeping when the SLEEP bit is set and running when it's cleared, so the bit should be inverted.
Tested on pcm1863.

This definitely seems to be the case from the datasheet but...

sound/soc/codecs/pcm186x.c static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = { · line 189

Quoted 9 lines
sound/soc/codecs/pcm186x.c +2 -2
@@ -184,8 +184,8 @@ static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
 	 * Put the codec into SLEEP mode when not in use, allowing the
 	 * Energysense mechanism to operate.
 	 */
-	SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1,  0),
-	SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1,  0),
+	SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1,  1),
+	SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1,  1),
 };

...we still have a bug on pcm1865 as we've got the same register bit for both channels which isn't something that's supposed to happen. Looking at the register description this feels like it'd be better handled in set_bias_level() or as a DAPM supply widget. However that's already an issue without this patch. I am a bit curious how this ever worked for anyone though.

Acked-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] ASoC: codecs: pcm186x: Fix energysense SLEEP bit

In reply to [email protected]
Quoted 6 lines · On 2/19/19 10:29 AM, [email protected] wrote:

From: Codrin Ciubotariu <[email protected]>

The ADCs are sleeping when the SLEEP bit is set and running when it's cleared, so the bit should be inverted.
Tested on pcm1863.

Did this work for you before? Strange it would if reversed, I wonder if the SLEEP bit is really doing anything here. Can investigate later, for this patch:

Quoted 34 lines

---

Changes in v2:
- none;

 sound/soc/codecs/pcm186x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/pcm186x.c +3 -3
index c36a391fec8a..c5fcc632f670 100644
@@ -158,7 +158,7 @@ static const struct snd_soc_dapm_widget pcm1863_dapm_widgets[] = {
 	 * Put the codec into SLEEP mode when not in use, allowing the
 	 * Energysense mechanism to operate.
 	 */
-	SND_SOC_DAPM_ADC("ADC", "HiFi Capture", PCM186X_POWER_CTRL, 1,  0),
+	SND_SOC_DAPM_ADC("ADC", "HiFi Capture", PCM186X_POWER_CTRL, 1,  1),
 };
 
 static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
@@ -184,8 +184,8 @@ static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
 	 * Put the codec into SLEEP mode when not in use, allowing the
 	 * Energysense mechanism to operate.
 	 */
-	SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1,  0),
-	SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1,  0),
+	SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1,  1),
+	SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1,  1),
 };
 
 static const struct snd_soc_dapm_route pcm1863_dapm_routes[] = {
maintainer
#4 lore raw

Re: [PATCH v2 2/2] ASoC: codecs: pcm186x: Fix energysense SLEEP bit

Quoted 3 lines · Andrew F. Davis

Did this work for you before? Strange it would if reversed, I wonder if the SLEEP bit is really doing anything here. Can investigate later, for this patch:

Thinking about it some more I'm wondering if it gets overridden by something else (ie, the CODEC actually being asleep requires this being set and some other thing being turned off).

#5 lore raw

Re: [PATCH v2 2/2] ASoC: codecs: pcm186x: Fix energysense SLEEP bit

In reply to Andrew F. Davis
Quoted 11 lines · Andrew F. Davis
Quoted 6 lines · On 2/19/19 10:29 AM, [email protected] wrote:

From: Codrin Ciubotariu <[email protected]>

The ADCs are sleeping when the SLEEP bit is set and running when it's cleared, so the bit should be inverted.
Tested on pcm1863.

Did this work for you before? Strange it would if reversed, I wonder if the SLEEP bit is really doing anything here. Can investigate later, for this patch:

The SLEEP bit seems to work. At least STATE from register 114 says the IP is sleeping. Without this change, if pcm1863 is used as master, I can see BCK and LRCK generated while no sound is played. Once I start an audio stream, the clocks stop.

Thank you for your ACK. I would really appreciate if you could also test it on your side.

Best regards,
Codrin

Quoted 37 lines
Quoted 34 lines

---

Changes in v2:
- none;

  sound/soc/codecs/pcm186x.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/pcm186x.c +3 -3
index c36a391fec8a..c5fcc632f670 100644
@@ -158,7 +158,7 @@ static const struct snd_soc_dapm_widget pcm1863_dapm_widgets[] = {
  	 * Put the codec into SLEEP mode when not in use, allowing the
  	 * Energysense mechanism to operate.
  	 */
-	SND_SOC_DAPM_ADC("ADC", "HiFi Capture", PCM186X_POWER_CTRL, 1,  0),
+	SND_SOC_DAPM_ADC("ADC", "HiFi Capture", PCM186X_POWER_CTRL, 1,  1),
  };
 
  static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
@@ -184,8 +184,8 @@ static const struct snd_soc_dapm_widget pcm1865_dapm_widgets[] = {
  	 * Put the codec into SLEEP mode when not in use, allowing the
  	 * Energysense mechanism to operate.
  	 */
-	SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1,  0),
-	SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1,  0),
+	SND_SOC_DAPM_ADC("ADC1", "HiFi Capture 1", PCM186X_POWER_CTRL, 1,  1),
+	SND_SOC_DAPM_ADC("ADC2", "HiFi Capture 2", PCM186X_POWER_CTRL, 1,  1),
  };
 
  static const struct snd_soc_dapm_route pcm1863_dapm_routes[] = {
Acked-by on v2 1/2
#6 lore raw
In reply to [email protected]
Quoted 7 lines · On 2/19/19 10:29 AM, [email protected] wrote:

From: Codrin Ciubotariu <[email protected]>

According to DS, the gain is between -12 dB and 40 dB, with a 0.5 dB step. Tested on pcm1863.

---

Quoted 22 lines

Changes in v2:
- fixed title - added correct macro;
- revert the removal of a new line;

 sound/soc/codecs/pcm186x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/pcm186x.c +1 -1
index 809b7e9f03ca..c36a391fec8a 100644
@@ -42,7 +42,7 @@ struct pcm186x_priv {
 	bool is_master_mode;
 };
 
-static const DECLARE_TLV_DB_SCALE(pcm186x_pga_tlv, -1200, 4000, 50);
+static const DECLARE_TLV_DB_SCALE(pcm186x_pga_tlv, -1200, 50, 0);
 
 static const struct snd_kcontrol_new pcm1863_snd_controls[] = {
 	SOC_DOUBLE_R_S_TLV("ADC Capture Volume", PCM186X_PGA_VAL_CH1_L,
maintainer
#7 lore raw

Applied "ASoC: codecs: pcm186x: fix wrong usage of DECLARE_TLV_DB_SCALE()" to the asoc tree

In reply to [email protected]

The patch

ASoC: codecs: pcm186x: fix wrong usage of DECLARE_TLV_DB_SCALE()

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

Quoted 1 line

From fcf4daabf08079e6d09958a2992e7446ef8d0438 Mon Sep 17 00:00:00 2001

From: Codrin Ciubotariu <[email protected]>
Date: Tue, 19 Feb 2019 16:29:12 +0000
Subject: [PATCH] ASoC: codecs: pcm186x: fix wrong usage of
DECLARE_TLV_DB_SCALE()

According to DS, the gain is between -12 dB and 40 dB, with a 0.5 dB step. Tested on pcm1863.

---
 sound/soc/codecs/pcm186x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/pcm186x.c +1 -1
index 809b7e9f03ca..c36a391fec8a 100644
@@ -42,7 +42,7 @@ struct pcm186x_priv {
 	bool is_master_mode;
 };
 
-static const DECLARE_TLV_DB_SCALE(pcm186x_pga_tlv, -1200, 4000, 50);
+static const DECLARE_TLV_DB_SCALE(pcm186x_pga_tlv, -1200, 50, 0);
 
 static const struct snd_kcontrol_new pcm1863_snd_controls[] = {
 	SOC_DOUBLE_R_S_TLV("ADC Capture Volume", PCM186X_PGA_VAL_CH1_L,
Signature · 1 line
2.20.1