Skip to contentSkip to conversation

Question about WM8904 regcache

DISCUSSION Bo Shen 2 participants 4 messages Jul 12, 2013

lore
Share & tools
lore

Bo Shen

author
#0 lore raw

Hi Mark,
I am sorry to disturb you. On our EK board, it use wm8904 codec. When
I enable the audio, and use alsa utils aplay to test, I meet the following issue.
The audio can not playback, it show the following error.
---8>---
#aplay 44.1k_16bit_stereo.wav
Playing WAVE '44.1k_16bit_stereo.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
aplay: pcm_write:1737: write error: Input/output error
---<8---

After check the register, they are not be configured correctly. When
read from debug file system, found the cache_dirty always Y before playback and also failed playback.
I try to add the following two line in wm8904_set_bias_level into
"case SND_SOC_BIAS_ON", it doesn't work.
---8>---
@@ -1832,9 +1834,12 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec,

        switch (level) {
        case SND_SOC_BIAS_ON:
+               regcache_cache_only(wm8904->regmap, false);
+               regcache_sync(wm8904->regmap);
                break;

---<8---

However, If I comment the regcache_cache_only(wm8904->regmap, true)
as following, then it play OK.
---8>---
@@ -2232,7 +2239,7 @@ static int wm8904_i2c_probe(struct i2c_client *i2c,

                            WM8904_POBCTRL, 0);

        /* Can leave the device powered off until we need it */

- regcache_cache_only(wm8904->regmap, true);
+ // regcache_cache_only(wm8904->regmap, true);
---<8---

So, any clue for this issue?

Thanks.

Best Regards,
Bo Shen

#1 lore raw

Review static int wm8904_set_bias_level(struct · line 1837

Quoted 12 lines · Bo Shen

I try to add the following two line in wm8904_set_bias_level into
"case SND_SOC_BIAS_ON", it doesn't work.
---8>---

(quoted diff) +2 -1
@@ -1832,9 +1834,12 @@ static int wm8904_set_bias_level(struct
 snd_soc_codec *codec,
 
        switch (level) {
        case SND_SOC_BIAS_ON:
+               regcache_cache_only(wm8904->regmap, false);
+               regcache_sync(wm8904->regmap);
                break;
---<8---

That's far too late to be doing that, the device is already supposed to be powered and running - you can see the device is doing this already in the transition from _OFF to _STANDBY which is where it should happen.

Review static int wm8904_i2c_probe(struct i2c_client *i2c, · line 2244

Quoted 12 lines
(quoted diff) +0 -0
  However, If I comment the regcache_cache_only(wm8904->regmap,

true) as following, then it play OK.
---8>---

(quoted diff) +1 -2
@@ -2232,7 +2239,7 @@ static int wm8904_i2c_probe(struct i2c_client *i2c,
                            WM8904_POBCTRL, 0);
 
        /* Can leave the device powered off until we need it */
-       regcache_cache_only(wm8904->regmap, true);
+       // regcache_cache_only(wm8904->regmap, true);
---<8---
 
  So, any clue for this issue?

The device is supposed to be idle_bias_off so sitting in _BIAS_OFF when not in use, this should mean a transition to _STANDBY as part of the power up sequence which should reenable interaction with the device. Check to see why that is not happening - _OFF should be the default bias level as well.

author
#2 lore raw

Hi Mark,

Quoted 30 lines · Mark Brown

Review static int wm8904_set_bias_level(struct · line 1837

Quoted 12 lines · Bo Shen

I try to add the following two line in wm8904_set_bias_level into
"case SND_SOC_BIAS_ON", it doesn't work.
---8>---

(quoted diff) +2 -1
@@ -1832,9 +1834,12 @@ static int wm8904_set_bias_level(struct
 snd_soc_codec *codec,
 
         switch (level) {
         case SND_SOC_BIAS_ON:
+               regcache_cache_only(wm8904->regmap, false);
+               regcache_sync(wm8904->regmap);
                 break;
---<8---

That's far too late to be doing that, the device is already supposed to be powered and running - you can see the device is doing this already in the transition from _OFF to _STANDBY which is where it should happen.

Quoted 10 lines
(quoted diff) +0 -0
   However, If I comment the regcache_cache_only(wm8904->regmap,

true) as following, then it play OK.
---8>---

(quoted diff) +1 -2
@@ -2232,7 +2239,7 @@ static int wm8904_i2c_probe(struct i2c_client *i2c,
                             WM8904_POBCTRL, 0);
 
         /* Can leave the device powered off until we need it */
-       regcache_cache_only(wm8904->regmap, true);
+       // regcache_cache_only(wm8904->regmap, true);
---<8---
Quoted 8 lines

Review static int wm8904_i2c_probe(struct i2c_client *i2c, · line 2243

Quoted 1 line
(quoted diff) +0 -0
   So, any clue for this issue?

The device is supposed to be idle_bias_off so sitting in _BIAS_OFF when not in use, this should mean a transition to _STANDBY as part of the power up sequence which should reenable interaction with the device. Check to see why that is not happening - _OFF should be the default bias level as well.

Do you mean the system boot up the device should be in _BIAS_OFF state?

I add debug info to set_bias_level function, and don't see this is called when system boot up. When I run aplay command, it call from _STANDBY to _ON, not _OFF, after show the error message, it call from _PREPARE to _OFF.

---8>---

# aplay 44.1k_16bit_stereo.wav
Playing WAVE '44.1k_16bit_stereo.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

leve is: 1
leve is: 2
leve is: 3

aplay: pcm_write:1737: write error: Input/output error # >>>>>> leve is: 2

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

leve is: 1
leve is: 0

---<8---

Best Regards,
Bo Shen

#3 lore raw
Quoted 1 line · Bo Shen

Do you mean the system boot up the device should be in _BIAS_OFF state?

Yes.

Quoted 4 lines

I add debug info to set_bias_level function, and don't see this is called when system boot up. When I run aplay command, it call from _STANDBY to _ON, not _OFF, after show the error message, it call from _PREPARE to _OFF.

It's not called on boot, it's just the default state - the probe() function is intended to leave things in _OFF. What you describe sounds like it's sitting in _STANDBY, you need to debug why this is happening. I can't see anything in current code - snd_soc_register_codec() sets the bias level to _OFF by default.