Please check my reply below.
On 2012年02月15日 18:11, Takashi Iwai wrote:
At Wed, 15 Feb 2012 18:06:39 +0800, joey.jiaojg wrote:
OK, the situation is 0x01 is to control GPIO0:
- if I write (codec,0x01,0,AC_VERB_SET_GPIO_MASK,1) only; the result is
speaker not work.
- if I write (codec,0x01,0,AC_VERB_SET_GPIO_DIRECTION,1) only; the
result is speaker not work.
Sure, GPIO must be always set mask, direction and data all together. The question is, when you set GPIO mask/dir/data, the speaker starts playing, and if set to zero (e.g. only data), the speaker is muted?
JOEY: I tried set data to 0 or 1 doesn't influence. when I set mask & dir to 1, speaker starts to work and to 0 speaker muted while headphone works if headphone plugged in.
- If I write step 1& 2 together, speaker works when I reboot.
Then GPIO is likely an external amp control.
JOEY: YES.
- Then If I plugged in the headphone, the headphone doesn't work. It
only works when I write (codec,0x0F,0,AC_VERB_SET_PIN_WIDGET_CONTROL,PIN_HP).
This is normal.
JOEY: If I don't modify model=will. And headphone can play even without set AC_VERB_SET_PIN_WIDGET_CONTROL to PIN_HP. Of course, automute doesn't work as there is function implemented.
- From step 3& 4, it's similar for cases that I reboot with headphone
plugged in. That is, if I remove headphone, speaker doesn't work automatically. If I write (codec,0x0F,0,AC_VERB_SET_PIN_WIDGET_CONTROL,PIN_OUT), the auto-detection function works well can switch speaker/headphone automatically.
That's odd. If you don't change from PIN_HP, doesn't the unsolicited event work?
JOEY: the unsolicited works from the register I read also from the printk I previous added. But the audio path doesn't switch between speaker and headphone. I don't know why. It can works manually if I send any hda-verb command to codec, like hda-verb /dev/snd/hwC0D0 0x0F 0xF09 0x0; I think perhaps there needs to be some delay. But I wait seconds and it doesn't switch. Then if I run any hda-verb command, it will then switch. Then after I change from PIN_HP or from PIN_OUT, the automute (actually audio path switch) works.
Another question is, when you set PIN_WIDGET_CONTROL on the speaker pin (not sure which one is) to 0x00, does it mute the speaker, too?
JOEY: No, it doesn't mute the speaker. To mute the speaker, I just need to set 0 to dir or mask. Then audio path is to headphone.
Takashi
I don't know why it's this case, and from alsa document, it seems only enable GPIO0 will work but actually not.
On 2012年02月15日 17:58, Takashi Iwai wrote:
At Wed, 15 Feb 2012 17:45:37 +0800, joey.jiaojg wrote:
I have tried to enable each one of them separately, and the speaker doesn't work.
Sorry, it's not clear what you meant. Each of what separately? And what does GPIO do exactly?
I have to use these 3 write_cache to make switch and auto-detect work smoothly.
We need to know the reason why these must be needed.
Takashi
On 2012年02月15日 17:40, Takashi Iwai wrote:
At Wed, 15 Feb 2012 17:31:44 +0800, joey.jiaojg wrote:
Here is the diff file.
Thanks.
+/* toggle speaker-output according to the hp-jack state */ +static void alc260_b1900_automute(struct hda_codec *codec) +{
unsigned int present;
- present = snd_hda_jack_detect(codec, 0x0f);
- if (present) {
snd_hda_codec_write_cache(codec, 0x01, 0,
AC_VERB_SET_GPIO_MASK, 0);
snd_hda_codec_write_cache(codec, 0x01, 0,
AC_VERB_SET_GPIO_DIRECTION,
0);
What actually this GPIO bit does on your device? To mute/unmute the speaker?
If so, doesn't the speaker toggle work with just changing the pin-control of the corresponding pin?
Takashi