Skip to contentSkip to conversation

ASoC: uda134x: add DATA011 register found in codecs family

PATCH In review Vladimir Zapolskiy 2 participants 11 messages Jun 24, 2010 – Jun 30, 2010

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

PATCH 1/2 ASoC: uda134x: add DATA011 register found in codecs family

In UDA1340, UDA1344 and UDA1345 codecs there is one more functional register in part of DATA0 tranfser. For UDA1341 this register coincides with EA register.

---
 sound/soc/codecs/uda134x.c |    3 ++-
 sound/soc/codecs/uda134x.h |    5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)
sound/soc/codecs/uda134x.c +2 -1
index b3039b1..e770029 100644
@@ -57,7 +57,7 @@ static const char uda134x_reg[UDA134X_REGS_NUM] = {
 	/* Extended address registers */
 	0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
 	/* Status, data regs */
-	0x00, 0x83, 0x00, 0x40, 0x80, 0x00,
+	0x00, 0x83, 0x00, 0x40, 0x80, 0xC0, 0x00,
 };
 
 /*
@@ -116,6 +116,7 @@ static int uda134x_write(struct snd_soc_codec *codec, unsigned int reg,
 	case UDA134X_DATA000:
 	case UDA134X_DATA001:
 	case UDA134X_DATA010:
+	case UDA134X_DATA011:
 		addr = UDA134X_DATA0_ADDR;
 		break;
 	case UDA134X_DATA1:
sound/soc/codecs/uda134x.h +3 -2
index 94f4404..205f03b 100644
@@ -23,9 +23,10 @@
 #define UDA134X_DATA000 10
 #define UDA134X_DATA001 11
 #define UDA134X_DATA010 12
-#define UDA134X_DATA1	13
+#define UDA134X_DATA011 13
+#define UDA134X_DATA1   14
 
-#define UDA134X_REGS_NUM 14
+#define UDA134X_REGS_NUM 15
 
 #define STATUS0_DAIFMT_MASK (~(7<<1))
 #define STATUS0_SYSCLK_MASK (~(3<<4))
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 2/2 ASoC: uda134x: fix bias level setup on initialization and runtime

For UDA1341 codec power control is managed in STATUS1 register, and for all other codecs in DATA011 register.

On initialization ADC/DAC are enabled only for UDA1341, that's why bias_level shall be set to off, otherwise dapm is misinformed about bias_level on startup.

---
 sound/soc/codecs/uda134x.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)
sound/soc/codecs/uda134x.c +22 -7
index e770029..0e9a945 100644
@@ -353,8 +353,13 @@ static int uda134x_set_bias_level(struct snd_soc_codec *codec,
 	switch (level) {
 	case SND_SOC_BIAS_ON:
 		/* ADC, DAC on */
-		reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-		uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+		if (pd->model == UDA134X_UDA1341) {
+			reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+			uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+		} else {
+			reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+			uda134x_write(codec, UDA134X_DATA011, reg | 0x03);
+		}
 		break;
 	case SND_SOC_BIAS_PREPARE:
 		/* power on */
@@ -367,8 +372,13 @@ static int uda134x_set_bias_level(struct snd_soc_codec *codec,
 		break;
 	case SND_SOC_BIAS_STANDBY:
 		/* ADC, DAC power off */
-		reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-		uda134x_write(codec, UDA134X_STATUS1, reg & ~(0x03));
+		if (pd->model == UDA134X_UDA1341) {
+			reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+			uda134x_write(codec, UDA134X_STATUS1, reg & ~(0x03));
+		} else {
+			reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+			uda134x_write(codec, UDA134X_DATA011, reg & ~(0x03));
+		}
 		break;
 	case SND_SOC_BIAS_OFF:
 		/* power off */
@@ -531,9 +541,7 @@ static int uda134x_soc_probe(struct platform_device *pdev)
 	codec->num_dai = 1;
 	codec->read = uda134x_read_reg_cache;
 	codec->write = uda134x_write;
-#ifdef POWER_OFF_ON_STANDBY
-	codec->set_bias_level = uda134x_set_bias_level;
-#endif
+
 	INIT_LIST_HEAD(&codec->dapm_widgets);
 	INIT_LIST_HEAD(&codec->dapm_paths);
 
@@ -544,6 +552,13 @@ static int uda134x_soc_probe(struct platform_device *pdev)
 
 	uda134x_reset(codec);
 
+#ifdef POWER_OFF_ON_STANDBY
+	codec->set_bias_level = uda134x_set_bias_level;
+	uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+#else
+	uda134x_set_bias_level(codec, SND_SOC_BIAS_ON);
+#endif
+
 	/* register pcms */
 	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
 	if (ret < 0) {
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH 2/2] ASoC: uda134x: fix bias level setup on initialization and runtime

sound/soc/codecs/uda134x.c static int uda134x_set_bias_level(struct snd_soc_codec *codec, · line 362

Quoted 10 lines · Vladimir Zapolskiy
		/* ADC, DAC on */
sound/soc/codecs/uda134x.c +7 -2
-		reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-		uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+		if (pd->model == UDA134X_UDA1341) {
+			reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+			uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+		} else {
+			reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+			uda134x_write(codec, UDA134X_DATA011, reg | 0x03);
+		}

I'd be more comfortable if these used switch statements. That way any further device specifics will slot in more easily.

Of course, this should really be using DAPM...

sound/soc/codecs/uda134x.c static int uda134x_soc_probe(struct platform_device *pdev) · line 544

Quoted 9 lines
sound/soc/codecs/uda134x.c +1 -3
@@ -531,9 +541,7 @@ static int uda134x_soc_probe(struct platform_device *pdev)
 	codec->num_dai = 1;
 	codec->read = uda134x_read_reg_cache;
 	codec->write = uda134x_write;
-#ifdef POWER_OFF_ON_STANDBY
-	codec->set_bias_level = uda134x_set_bias_level;
-#endif
+

These changes for the bias level configuration look to be unrelated to the addition of the new CODEC and should be split into a separate patch. It'd also be much better to remove this ifdefery, it should be handled via platform data or just done unconditionally.

#3 lore raw

Re: [PATCH 2/2] ASoC: uda134x: fix bias level setup on initialization and runtime

Hello,

Quoted 13 lines · Mark Brown
Quoted 10 lines · Vladimir Zapolskiy

              /* ADC, DAC on */
-             reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-             uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+             if (pd->model == UDA134X_UDA1341) {
+                     reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+                     uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+             } else {
+                     reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+                     uda134x_write(codec, UDA134X_DATA011, reg | 0x03);
+             }

Quoted 3 lines

I'd be more comfortable if these used switch statements. That way any further device specifics will slot in more easily.

Agree with the comment.

Quoted 17 lines

Of course, this should really be using DAPM...

sound/soc/codecs/uda134x.c static int uda134x_soc_probe(struct platform_device *pdev) · line 544

Quoted 9 lines
sound/soc/codecs/uda134x.c +1 -3
@@ -531,9 +541,7 @@ static int uda134x_soc_probe(struct platform_device *pdev)
       codec->num_dai = 1;
       codec->read = uda134x_read_reg_cache;
       codec->write = uda134x_write;
-#ifdef POWER_OFF_ON_STANDBY
-     codec->set_bias_level = uda134x_set_bias_level;
-#endif
+

These changes for the bias level configuration look to be unrelated to the addition of the new CODEC and should be split into a separate patch. It'd also be much better to remove this ifdefery, it should be handled via platform data or just done unconditionally.

I confirm that's actually unrelated, so it should be done in a separate patch.

I dislike the macro here too, I'll replace it with a platform data solution.

Best wishes,
Vladimir
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw

PATCH v2 2/2 ASoC: uda134x: correct bias level setup for codecs family

In reply to Vladimir Zapolskiy

For UDA1341 codec power control is managed in STATUS1 register, and for all other codecs in DATA011 register.

---
 sound/soc/codecs/uda134x.c |   36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)
sound/soc/codecs/uda134x.c +32 -4
index e770029..e8066b6 100644
@@ -353,8 +353,22 @@ static int uda134x_set_bias_level(struct snd_soc_codec *codec,
 	switch (level) {
 	case SND_SOC_BIAS_ON:
 		/* ADC, DAC on */
-		reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-		uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+		switch (pd->model) {
+		case UDA134X_UDA1340:
+		case UDA134X_UDA1344:
+		case UDA134X_UDA1345:
+			reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+			uda134x_write(codec, UDA134X_DATA011, reg | 0x03);
+			break;
+		case UDA134X_UDA1341:
+			reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+			uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+			break;
+		default:
+			printk(KERN_ERR "UDA134X SoC codec: "
+			       "unsupported model %d\n", pd->model);
+			return -EINVAL;
+		}
 		break;
 	case SND_SOC_BIAS_PREPARE:
 		/* power on */
@@ -367,8 +381,22 @@ static int uda134x_set_bias_level(struct snd_soc_codec *codec,
 		break;
 	case SND_SOC_BIAS_STANDBY:
 		/* ADC, DAC power off */
-		reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-		uda134x_write(codec, UDA134X_STATUS1, reg & ~(0x03));
+		switch (pd->model) {
+		case UDA134X_UDA1340:
+		case UDA134X_UDA1344:
+		case UDA134X_UDA1345:
+			reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+			uda134x_write(codec, UDA134X_DATA011, reg & ~(0x03));
+			break;
+		case UDA134X_UDA1341:
+			reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+			uda134x_write(codec, UDA134X_STATUS1, reg & ~(0x03));
+			break;
+		default:
+			printk(KERN_ERR "UDA134X SoC codec: "
+			       "unsupported model %d\n", pd->model);
+			return -EINVAL;
+		}
 		break;
 	case SND_SOC_BIAS_OFF:
 		/* power off */
Signature · 1 line
1.7.0.4
#5 lore raw

Re: [PATCH 2/2 v2] ASoC: uda134x: correct bias level setup for codecs family

Mark, Liam,

do you have more comments about this fix?

Quoted 56 lines · Vladimir Zapolskiy

For UDA1341 codec power control is managed in STATUS1 register, and for all other codecs in DATA011 register.

---
 sound/soc/codecs/uda134x.c |   36 ++++++++++++++++++++++++++++++++----

 1 files changed, 32 insertions(+), 4 deletions(-)
sound/soc/codecs/uda134x.c +0 -0
index e770029..e8066b6 100644
@@ -353,8 +353,22 @@ static int uda134x_set_bias_level(struct snd_soc_codec *codec,
        switch (level) {

       case SND_SOC_BIAS_ON:
               /* ADC, DAC on */
-               reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-               uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+               switch (pd->model) {
+               case UDA134X_UDA1340:
+               case UDA134X_UDA1344:
+               case UDA134X_UDA1345:
+                       reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+                       uda134x_write(codec, UDA134X_DATA011, reg | 0x03);
+                       break;
+               case UDA134X_UDA1341:
+                       reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+                       uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+                       break;
+               default:
+                       printk(KERN_ERR "UDA134X SoC codec: "
+                              "unsupported model %d\n", pd->model);
+                       return -EINVAL;
+               }
               break;
       case SND_SOC_BIAS_PREPARE:
               /* power on */

sound/soc/codecs/uda134x.c +0 -0
@@ -367,8 +381,22 @@ static int uda134x_set_bias_level(struct snd_soc_codec *codec,
                break;

       case SND_SOC_BIAS_STANDBY:
               /* ADC, DAC power off */
-               reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-               uda134x_write(codec, UDA134X_STATUS1, reg & ~(0x03));
+               switch (pd->model) {
+               case UDA134X_UDA1340:
+               case UDA134X_UDA1344:
+               case UDA134X_UDA1345:
+                       reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+                       uda134x_write(codec, UDA134X_DATA011, reg & ~(0x03));
+                       break;
+               case UDA134X_UDA1341:
+                       reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+                       uda134x_write(codec, UDA134X_STATUS1, reg & ~(0x03));
+                       break;
+               default:
+                       printk(KERN_ERR "UDA134X SoC codec: "

Quoted 10 lines

+                              "unsupported model %d\n", pd->model);
+                       return -EINVAL;
+               }
               break;
       case SND_SOC_BIAS_OFF:
               /* power off */
--
1.7.0.4

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#6 lore raw

Re: [PATCH 2/2 v2] ASoC: uda134x: correct bias level setup for codecs family

In reply to Vladimir Zapolskiy

Hi all,

would you like to review these two patches with fix for uda134{0,4,5} codecs core power control support?

Thanks in advance,
Vladimir

Quoted 56 lines · Vladimir Zapolskiy

For UDA1341 codec power control is managed in STATUS1 register, and for all other codecs in DATA011 register.

---
 sound/soc/codecs/uda134x.c |   36 ++++++++++++++++++++++++++++++++----

 1 files changed, 32 insertions(+), 4 deletions(-)
sound/soc/codecs/uda134x.c +0 -0
index e770029..e8066b6 100644
@@ -353,8 +353,22 @@ static int uda134x_set_bias_level(struct snd_soc_codec *codec,
        switch (level) {

       case SND_SOC_BIAS_ON:
               /* ADC, DAC on */
-               reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-               uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+               switch (pd->model) {
+               case UDA134X_UDA1340:
+               case UDA134X_UDA1344:
+               case UDA134X_UDA1345:
+                       reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+                       uda134x_write(codec, UDA134X_DATA011, reg | 0x03);
+                       break;
+               case UDA134X_UDA1341:
+                       reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+                       uda134x_write(codec, UDA134X_STATUS1, reg | 0x03);
+                       break;
+               default:
+                       printk(KERN_ERR "UDA134X SoC codec: "
+                              "unsupported model %d\n", pd->model);
+                       return -EINVAL;
+               }
               break;
       case SND_SOC_BIAS_PREPARE:
               /* power on */

sound/soc/codecs/uda134x.c +0 -0
@@ -367,8 +381,22 @@ static int uda134x_set_bias_level(struct snd_soc_codec *codec,
                break;

       case SND_SOC_BIAS_STANDBY:
               /* ADC, DAC power off */
-               reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
-               uda134x_write(codec, UDA134X_STATUS1, reg & ~(0x03));
+               switch (pd->model) {
+               case UDA134X_UDA1340:
+               case UDA134X_UDA1344:
+               case UDA134X_UDA1345:
+                       reg = uda134x_read_reg_cache(codec, UDA134X_DATA011);
+                       uda134x_write(codec, UDA134X_DATA011, reg & ~(0x03));
+                       break;
+               case UDA134X_UDA1341:
+                       reg = uda134x_read_reg_cache(codec, UDA134X_STATUS1);
+                       uda134x_write(codec, UDA134X_STATUS1, reg & ~(0x03));
+                       break;
+               default:
+                       printk(KERN_ERR "UDA134X SoC codec: "

Quoted 10 lines

+                              "unsupported model %d\n", pd->model);
+                       return -EINVAL;
+               }
               break;
       case SND_SOC_BIAS_OFF:
               /* power off */
--
1.7.0.4

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Applied
#7 lore raw

Re: [PATCH 2/2 v2] ASoC: uda134x: correct bias level setup for codecs family

Quoted 4 lines · Vladimir Zapolskiy

Hi all,

would you like to review these two patches with fix for uda134{0,4,5} codecs core power control support?

Applied both, sorry about the delay - it was due to Liam having poor net access unexpectedly and not being able to review stuff.

#8 lore raw

Re: [PATCH 2/2 v2] ASoC: uda134x: correct bias level setup for codecs family

Hi Mark,

Quoted 9 lines · Mark Brown
Quoted 4 lines · Vladimir Zapolskiy

Hi all,

would you like to review these two patches with fix for uda134{0,4,5} codecs core power control support?

Applied both, sorry about the delay - it was due to Liam having poor net access unexpectedly and not being able to review stuff.

no problem about delay.

Anyhow in broonie/sound-2.6 tree, branch `for-2.6.36' I can't find applied all 4 sent patches recently, e.g. 2 patchsets with 2 patches each, only the second patchset was applied 5 days ago.

Probably I look at invalid branch?

Thank you,
Vladimir

#9 lore raw

Re: [PATCH 2/2 v2] ASoC: uda134x: correct bias level setup for codecs family

Quoted 5 lines · Vladimir Zapolskiy

Anyhow in broonie/sound-2.6 tree, branch `for-2.6.36' I can't find applied all 4 sent patches recently, e.g. 2 patchsets with 2 patches each, only the second patchset was applied 5 days ago.

Probably I look at invalid branch?

You need to allow at least a few minutes for the kernel.org system to mirror out the commits after I push them, and I tend to send these mails as soon as I've applied locally rather than when I push stuff out.

#10 lore raw

Re: [PATCH 2/2 v2] ASoC: uda134x: correct bias level setup for codecs family

Quoted 6 lines · Mark Brown
Quoted 3 lines · Vladimir Zapolskiy

Anyhow in broonie/sound-2.6 tree, branch `for-2.6.36' I can't find applied all 4 sent patches recently, e.g. 2 patchsets with 2 patches each, only the second patchset was applied 5 days ago.

Quoted 6 lines
Quoted 1 line

Probably I look at invalid branch?

You need to allow at least a few minutes for the kernel.org system to mirror out the commits after I push them, and I tend to send these mails as soon as I've applied locally rather than when I push stuff out.

Clear for now, thank you a lot.

Vladimir