]> Pileus Git - ~andy/linux/blobdiff - sound/pci/hda/patch_via.c
ALSA: hda - Cache the jack-detection value
[~andy/linux] / sound / pci / hda / patch_via.c
index 417d62ad3b96c89bd5f05f23e7c41e3edddb59c0..3467d0c23fe94395b0deb3b2382b0ae3cd8568a7 100644 (file)
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
+#include <linux/module.h>
 #include <sound/core.h>
 #include <sound/asoundef.h>
 #include "hda_codec.h"
 #include "hda_local.h"
+#include "hda_jack.h"
 
 /* Pin Widget NID */
 #define VT1708_HP_PIN_NID      0x20
@@ -1707,6 +1709,8 @@ static void via_gpio_control(struct hda_codec *codec)
 static void via_unsol_event(struct hda_codec *codec,
                                  unsigned int res)
 {
+       snd_hda_jack_set_dirty_all(codec); /* FIXME: to be more fine-grained */
+
        res >>= 26;
 
        if (res & VIA_JACK_EVENT)
@@ -2728,9 +2732,8 @@ static void via_auto_init_unsol_event(struct hda_codec *codec)
        int i;
 
        if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0]))
-               snd_hda_codec_write(codec, cfg->hp_pins[0], 0,
-                               AC_VERB_SET_UNSOLICITED_ENABLE,
-                               AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT);
+               snd_hda_jack_detect_enable(codec, cfg->hp_pins[0],
+                                          VIA_HP_EVENT | VIA_JACK_EVENT);
 
        if (cfg->speaker_pins[0])
                ev = VIA_LINE_EVENT;
@@ -2739,16 +2742,14 @@ static void via_auto_init_unsol_event(struct hda_codec *codec)
        for (i = 0; i < cfg->line_outs; i++) {
                if (cfg->line_out_pins[i] &&
                    is_jack_detectable(codec, cfg->line_out_pins[i]))
-                       snd_hda_codec_write(codec, cfg->line_out_pins[i], 0,
-                               AC_VERB_SET_UNSOLICITED_ENABLE,
-                               AC_USRSP_EN | ev | VIA_JACK_EVENT);
+                       snd_hda_jack_detect_enable(codec, cfg->line_out_pins[i],
+                                                  ev | VIA_JACK_EVENT);
        }
 
        for (i = 0; i < cfg->num_inputs; i++) {
                if (is_jack_detectable(codec, cfg->inputs[i].pin))
-                       snd_hda_codec_write(codec, cfg->inputs[i].pin, 0,
-                               AC_VERB_SET_UNSOLICITED_ENABLE,
-                               AC_USRSP_EN | VIA_JACK_EVENT);
+                       snd_hda_jack_detect_enable(codec, cfg->inputs[i].pin,
+                                                  VIA_JACK_EVENT);
        }
 }
 
@@ -2780,6 +2781,7 @@ static void vt1708_update_hp_jack_state(struct work_struct *work)
                                             vt1708_hp_work.work);
        if (spec->codec_type != VT1708)
                return;
+       snd_hda_jack_set_dirty_all(spec->codec);
        /* if jack state toggled */
        if (spec->vt1708_hp_present
            != snd_hda_jack_detect(spec->codec, spec->autocfg.hp_pins[0])) {
@@ -3700,13 +3702,8 @@ static const struct hda_verb vt1812_init_verbs[] = {
 static void set_widgets_power_state_vt1812(struct hda_codec *codec)
 {
        struct via_spec *spec = codec->spec;
-       int imux_is_smixer =
-       snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 3;
        unsigned int parm;
        unsigned int present;
-       /* MUX10 (1eh) = stereo mixer */
-       imux_is_smixer =
-       snd_hda_codec_read(codec, 0x1e, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 5;
        /* inputs */
        /* PW 5/6/7 (29h/2ah/2bh) */
        parm = AC_PWRST_D3;