]> err.no Git - linux-2.6/blobdiff - sound/pci/hda/patch_sigmatel.c
Merge branch 'linus' into x86/cleanups
[linux-2.6] / sound / pci / hda / patch_sigmatel.c
index 47d3536a6576564d282862e20d0d445907b7b154..a4f44a00bae8eb548708a0dd8903cf0bf652bbb3 100644 (file)
@@ -52,6 +52,7 @@ enum {
        STAC_9200_DELL_M26,
        STAC_9200_DELL_M27,
        STAC_9200_GATEWAY,
+       STAC_9200_PANASONIC,
        STAC_9200_MODELS
 };
 
@@ -128,6 +129,7 @@ struct sigmatel_spec {
        unsigned int hp_detect: 1;
 
        /* gpio lines */
+       unsigned int eapd_mask;
        unsigned int gpio_mask;
        unsigned int gpio_dir;
        unsigned int gpio_data;
@@ -179,6 +181,7 @@ struct sigmatel_spec {
        /* i/o switches */
        unsigned int io_switch[2];
        unsigned int clfe_swap;
+       unsigned int hp_switch;
        unsigned int aloopback;
 
        struct hda_pcm pcm_rec[2];      /* PCM information */
@@ -534,6 +537,43 @@ static struct hda_verb stac92hd73xx_6ch_core_init[] = {
        {}
 };
 
+static struct hda_verb dell_eq_core_init[] = {
+       /* set master volume to max value without distortion
+        * and direct control */
+       { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
+       /* setup audio connections */
+       { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
+       { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
+       /* setup adcs to point to mixer */
+       { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
+       { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
+       /* setup import muxs */
+       { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {}
+};
+
+static struct hda_verb dell_m6_core_init[] = {
+       /* set master volume and direct control */
+       { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
+       /* setup audio connections */
+       { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
+       { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
+       /* setup adcs to point to mixer */
+       { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
+       { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
+       /* setup import muxs */
+       { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {}
+};
+
 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
        /* set master volume and direct control */
        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
@@ -800,7 +840,7 @@ static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
 static struct snd_kcontrol_new stac925x_mixer[] = {
        STAC_INPUT_SOURCE(1),
        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
-       HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
        { } /* end */
 };
@@ -1084,6 +1124,7 @@ static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
        [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
        [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
        [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
+       [STAC_9200_PANASONIC] = ref9200_pin_configs,
 };
 
 static const char *stac9200_models[STAC_9200_MODELS] = {
@@ -1100,6 +1141,7 @@ static const char *stac9200_models[STAC_9200_MODELS] = {
        [STAC_9200_DELL_M26] = "dell-m26",
        [STAC_9200_DELL_M27] = "dell-m27",
        [STAC_9200_GATEWAY] = "gateway",
+       [STAC_9200_PANASONIC] = "panasonic",
 };
 
 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
@@ -1166,7 +1208,7 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
                      "unknown Dell", STAC_9200_DELL_M26),
        /* Panasonic */
-       SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
+       SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
        /* Gateway machines needs EAPD to be set on resume */
        SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
        SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
@@ -1233,7 +1275,7 @@ static unsigned int ref92hd73xx_pin_configs[13] = {
 
 static unsigned int dell_m6_pin_configs[13] = {
        0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
-       0x03a11020, 0x03011050, 0x4f0000f0, 0x4f0000f0,
+       0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
        0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
        0x4f0000f0,
 };
@@ -1277,7 +1319,7 @@ static unsigned int ref92hd71bxx_pin_configs[10] = {
 
 static unsigned int dell_m4_1_pin_configs[13] = {
        0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
-       0x23a1902e, 0x23014250, 0x40f000f0, 0x4f0000f0,
+       0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
        0x40f000f0, 0x4f0000f0,
 };
 
@@ -1892,7 +1934,7 @@ static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
 {
        struct sigmatel_spec *spec = codec->spec;
 
-       snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
+       snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
        return 0;
 }
 
@@ -2011,6 +2053,34 @@ static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int
                                  AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
 }
 
+#define stac92xx_hp_switch_info                snd_ctl_boolean_mono_info
+
+static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
+                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+
+       ucontrol->value.integer.value[0] = spec->hp_switch;
+       return 0;
+}
+
+static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
+                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+
+       spec->hp_switch = ucontrol->value.integer.value[0];
+
+       /* check to be sure that the ports are upto date with
+        * switch changes
+        */
+       codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
+
+       return 1;
+}
+
 #define stac92xx_io_switch_info                snd_ctl_boolean_mono_info
 
 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
@@ -2082,6 +2152,15 @@ static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
        return 1;
 }
 
+#define STAC_CODEC_HP_SWITCH(xname) \
+       { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+         .name = xname, \
+         .index = 0, \
+         .info = stac92xx_hp_switch_info, \
+         .get = stac92xx_hp_switch_get, \
+         .put = stac92xx_hp_switch_put, \
+       }
+
 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
          .name = xname, \
@@ -2106,6 +2185,7 @@ enum {
        STAC_CTL_WIDGET_VOL,
        STAC_CTL_WIDGET_MUTE,
        STAC_CTL_WIDGET_MONO_MUX,
+       STAC_CTL_WIDGET_HP_SWITCH,
        STAC_CTL_WIDGET_IO_SWITCH,
        STAC_CTL_WIDGET_CLFE_SWITCH
 };
@@ -2114,6 +2194,7 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
        HDA_CODEC_VOLUME(NULL, 0, 0, 0),
        HDA_CODEC_MUTE(NULL, 0, 0, 0),
        STAC_MONO_MUX,
+       STAC_CODEC_HP_SWITCH(NULL),
        STAC_CODEC_IO_SWITCH(NULL, 0),
        STAC_CODEC_CLFE_SWITCH(NULL, 0),
 };
@@ -2345,7 +2426,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
        unsigned int wid_caps, pincap;
 
 
-       for (i = 0; i < cfg->line_outs; i++) {
+       for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
                if (!spec->multiout.dac_nids[i])
                        continue;
 
@@ -2378,6 +2459,14 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
                }
        }
 
+       if (cfg->hp_outs > 1) {
+               err = stac92xx_add_control(spec,
+                       STAC_CTL_WIDGET_HP_SWITCH,
+                       "Headphone as Line Out Switch", 0);
+               if (err < 0)
+                       return err;
+       }
+
        if (spec->line_switch) {
                nid = cfg->input_pins[AUTO_PIN_LINE];
                pincap = snd_hda_param_read(codec, nid,
@@ -2472,12 +2561,8 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
                        return err;
        }
        if (spec->multiout.hp_nid) {
-               const char *pfx;
-               if (old_num_dacs == spec->multiout.num_dacs)
-                       pfx = "Master";
-               else
-                       pfx = "Headphone";
-               err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
+               err = create_controls(spec, "Headphone",
+                                     spec->multiout.hp_nid, 3);
                if (err < 0)
                        return err;
        }
@@ -3016,12 +3101,16 @@ static int stac92xx_init(struct hda_codec *codec)
                                        ? STAC_HP_EVENT : STAC_PWR_EVENT;
                int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
                                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
+               int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
+                                       0, AC_VERB_GET_CONFIG_DEFAULT, 0);
                /* outputs are only ports capable of power management
                 * any attempts on powering down a input port cause the
                 * referenced VREF to act quirky.
                 */
                if (pinctl & AC_PINCTL_IN_EN)
                        continue;
+               if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED)
+                       continue;
                enable_pin_detect(codec, spec->pwr_nids[i], event | i);
                codec->patch_ops.unsol_event(codec, (event | i) << 26);
        }
@@ -3122,6 +3211,7 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
 {
        struct sigmatel_spec *spec = codec->spec;
        struct auto_pin_cfg *cfg = &spec->autocfg;
+       int nid = cfg->hp_pins[cfg->hp_outs - 1];
        int i, presence;
 
        presence = 0;
@@ -3132,26 +3222,42 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
        for (i = 0; i < cfg->hp_outs; i++) {
                if (presence)
                        break;
+               if (spec->hp_switch && cfg->hp_pins[i] == nid)
+                       break;
                presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
        }
 
        if (presence) {
                /* disable lineouts, enable hp */
+               if (spec->hp_switch)
+                       stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
                for (i = 0; i < cfg->line_outs; i++)
                        stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
                                                AC_PINCTL_OUT_EN);
                for (i = 0; i < cfg->speaker_outs; i++)
                        stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
                                                AC_PINCTL_OUT_EN);
+               if (spec->eapd_mask)
+                       stac_gpio_set(codec, spec->gpio_mask,
+                               spec->gpio_dir, spec->gpio_data &
+                               ~spec->eapd_mask);
        } else {
                /* enable lineouts, disable hp */
+               if (spec->hp_switch)
+                       stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
                for (i = 0; i < cfg->line_outs; i++)
                        stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
                                                AC_PINCTL_OUT_EN);
                for (i = 0; i < cfg->speaker_outs; i++)
                        stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
                                                AC_PINCTL_OUT_EN);
+               if (spec->eapd_mask)
+                       stac_gpio_set(codec, spec->gpio_mask,
+                               spec->gpio_dir, spec->gpio_data |
+                               spec->eapd_mask);
        }
+       if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
+               stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
 } 
 
 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
@@ -3265,6 +3371,11 @@ static int patch_stac9200(struct hda_codec *codec)
                spec->init = stac9200_core_init;
        spec->mixer = stac9200_mixer;
 
+       if (spec->board_config == STAC_9200_PANASONIC) {
+               spec->gpio_mask = spec->gpio_dir = 0x09;
+               spec->gpio_data = 0x00;
+       }
+
        err = stac9200_parse_auto_config(codec);
        if (err < 0) {
                stac92xx_free(codec);
@@ -3405,6 +3516,7 @@ again:
 
        switch (spec->multiout.num_dacs) {
        case 0x3: /* 6 Channel */
+               spec->multiout.hp_nid = 0x17;
                spec->mixer = stac92hd73xx_6ch_mixer;
                spec->init = stac92hd73xx_6ch_core_init;
                break;
@@ -3433,21 +3545,24 @@ again:
        spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
        spec->dinput_mux = &stac92hd73xx_dmux;
        /* GPIO0 High = Enable EAPD */
-       spec->gpio_mask = spec->gpio_dir = 0x1;
+       spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
        spec->gpio_data = 0x01;
 
        switch (spec->board_config) {
        case STAC_DELL_M6:
+               spec->init = dell_eq_core_init;
                switch (codec->subsystem_id) {
                case 0x1028025e: /* Analog Mics */
                case 0x1028025f:
                        stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
                        spec->num_dmics = 0;
                        break;
-               case 0x10280254: /* Digital Mics */
-               case 0x10280255:
-               case 0x10280271:
+               case 0x10280271: /* Digital Mics */
                case 0x10280272:
+                       spec->init = dell_m6_core_init;
+                       /* fall-through */
+               case 0x10280254:
+               case 0x10280255:
                        stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
                        spec->num_dmics = 1;
                        break;
@@ -3536,7 +3651,10 @@ again:
        spec->aloopback_shift = 0;
 
        /* GPIO0 High = EAPD */
-       spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1;
+       spec->gpio_mask = 0x01;
+       spec->gpio_dir = 0x01;
+       spec->gpio_mask = 0x01;
+       spec->gpio_data = 0x01;
 
        spec->mux_nids = stac92hd71bxx_mux_nids;
        spec->adc_nids = stac92hd71bxx_adc_nids;
@@ -3722,7 +3840,7 @@ static int patch_stac927x(struct hda_codec *codec)
        case STAC_D965_3ST:
        case STAC_D965_5ST:
                /* GPIO0 High = Enable EAPD */
-               spec->gpio_mask = spec->gpio_dir = 0x01;
+               spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
                spec->gpio_data = 0x01;
                spec->num_dmics = 0;
 
@@ -3730,6 +3848,13 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->mixer = stac927x_mixer;
                break;
        case STAC_DELL_BIOS:
+               switch (codec->subsystem_id) {
+               case 0x10280209:
+               case 0x1028022e:
+                       /* correct the device field to SPDIF out */
+                       stac92xx_set_config_reg(codec, 0x21, 0x01442070);
+                       break;
+               };
                /* configure the analog microphone on some laptops */
                stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
                /* correct the front output jack as a hp out */
@@ -3739,7 +3864,7 @@ static int patch_stac927x(struct hda_codec *codec)
                /* fallthru */
        case STAC_DELL_3ST:
                /* GPIO2 High = Enable EAPD */
-               spec->gpio_mask = spec->gpio_dir = 0x04;
+               spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
                spec->gpio_data = 0x04;
                spec->dmic_nids = stac927x_dmic_nids;
                spec->num_dmics = STAC927X_NUM_DMICS;
@@ -3751,7 +3876,7 @@ static int patch_stac927x(struct hda_codec *codec)
                break;
        default:
                /* GPIO0 High = Enable EAPD */
-               spec->gpio_mask = spec->gpio_dir = 0x1;
+               spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
                spec->gpio_data = 0x01;
                spec->num_dmics = 0;
 
@@ -3855,6 +3980,7 @@ static int patch_stac9205(struct hda_codec *codec)
                                          (AC_USRSP_EN | STAC_HP_EVENT));
 
                spec->gpio_dir = 0x0b;
+               spec->eapd_mask = 0x01;
                spec->gpio_mask = 0x1b;
                spec->gpio_mute = 0x10;
                /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
@@ -3864,7 +3990,7 @@ static int patch_stac9205(struct hda_codec *codec)
                break;
        default:
                /* GPIO0 High = EAPD */
-               spec->gpio_mask = spec->gpio_dir = 0x1;
+               spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
                spec->gpio_data = 0x01;
                break;
        }
@@ -4163,6 +4289,8 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
        { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
        { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
        { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
+       { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
+       { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
        /* The following does not take into account .id=0x83847661 when subsys =
         * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
         * currently not fully supported.