16 Feb
2012
16 Feb
'12
10:36 a.m.
At Thu, 16 Feb 2012 11:41:10 +0800, joey.jiaojg wrote:
And now this code works: /* 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); snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1); } else { snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, 1); snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, 1); snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); }
}
The GPIO_MASK and GPIO_DIRECTION need to be set only once in the init verbs, both to 1. Then you just need to flip GPIO_DATA between 0 and 1 in the unsol event handler.
Takashi