[ALSA] hda: STAC9228 VT fixes
[powerpc.git] / sound / pci / hda / patch_sigmatel.c
index 4e71bba..a0af868 100644 (file)
@@ -24,7 +24,6 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
@@ -463,9 +462,6 @@ static struct hda_verb stac92hd73xx_6ch_core_init[] = {
        /* setup adcs to point to mixer */
        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
        { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
-       { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Front Mic */
-       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Mic */
-       { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Line In */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
        { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
@@ -490,9 +486,6 @@ static struct hda_verb stac92hd73xx_8ch_core_init[] = {
        /* setup adcs to point to mixer */
        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
        { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
-       { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Front Mic */
-       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Mic */
-       { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Line In */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
        { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
@@ -519,9 +512,6 @@ static struct hda_verb stac92hd73xx_10ch_core_init[] = {
        /* setup adcs to point to mixer */
        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
        { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
-       { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Front Mic */
-       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Mic */
-       { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Line In */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
        { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
@@ -543,8 +533,6 @@ static struct hda_verb stac92hd71bxx_core_init[] = {
        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
-       /* unmute mono out node */
-       { 0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
 };
 
 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
@@ -562,8 +550,6 @@ static struct hda_verb stac92hd71bxx_analog_core_init[] = {
        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
-       /* unmute mono out node */
-       { 0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        {}
 };
 
@@ -635,10 +621,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
 
-       /* hardware gain controls */
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x13, 0x0, HDA_INPUT),
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x14, 0x0, HDA_INPUT),
-
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
 
@@ -665,10 +647,6 @@ static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
 
-       /* hardware gain controls */
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x13, 0x0, HDA_INPUT),
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x14, 0x0, HDA_INPUT),
-
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
 
@@ -695,10 +673,6 @@ static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
 
-       /* hardware gain controls */
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x13, 0x0, HDA_INPUT),
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x14, 0x0, HDA_INPUT),
-
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
 
@@ -725,10 +699,6 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
        STAC_INPUT_SOURCE(2),
 
-       /* hardware gain controls */
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x18, 0x0, HDA_OUTPUT),
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x19, 0x0, HDA_OUTPUT),
-
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
@@ -739,6 +709,8 @@ static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
 
        HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
        HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
+
+       HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x14, 0x1, 0, HDA_INPUT),
        { } /* end */
 };
 
@@ -746,10 +718,6 @@ static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
        STAC_INPUT_SOURCE(2),
        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
 
-       /* hardware gain controls */
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x18, 0x0, HDA_OUTPUT),
-       HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x19, 0x0, HDA_OUTPUT),
-
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
@@ -757,6 +725,8 @@ static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
+
+       HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x14, 0x1, 0, HDA_INPUT),
        { } /* end */
 };
 
@@ -1458,13 +1428,13 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
        /* Dell 3 stack systems */
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f3, "Dell Inspiron 1420", STAC_DELL_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01ed, "Dell     ", STAC_DELL_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f4, "Dell     ", STAC_DELL_3ST),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0227, "Dell Vostro 1400  ", STAC_DELL_3ST),
        /* Dell 3 stack systems with verb table in BIOS */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0227, "Dell Vostro 1400  ", STAC_DELL_BIOS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x022f, "Dell     ", STAC_DELL_BIOS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x022e, "Dell     ", STAC_DELL_BIOS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0242, "Dell     ", STAC_DELL_BIOS),
@@ -2313,15 +2283,18 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
        struct sigmatel_spec *spec = codec->spec;
        struct hda_input_mux *dimux = &spec->private_dimux;
        hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
-       int i, j;
+       int err, i, j;
+       char name[32];
 
        dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
        dimux->items[dimux->num_items].index = 0;
        dimux->num_items++;
 
        for (i = 0; i < spec->num_dmics; i++) {
+               hda_nid_t nid;
                int index;
                int num_cons;
+               unsigned int wcaps;
                unsigned int def_conf;
 
                def_conf = snd_hda_codec_read(codec,
@@ -2332,17 +2305,32 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
                if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
                        continue;
 
+               nid = spec->dmic_nids[i];
                num_cons = snd_hda_get_connections(codec,
                                spec->dmux_nids[0],
                                con_lst,
                                HDA_MAX_NUM_INPUTS);
                for (j = 0; j < num_cons; j++)
-                       if (con_lst[j] == spec->dmic_nids[i]) {
+                       if (con_lst[j] == nid) {
                                index = j;
                                goto found;
                        }
                continue;
 found:
+               wcaps = get_wcaps(codec, nid);
+
+               if (wcaps & AC_WCAP_OUT_AMP) {
+                       sprintf(name, "%s Capture Volume",
+                               stac92xx_dmic_labels[dimux->num_items]);
+
+                       err = stac92xx_add_control(spec,
+                               STAC_CTL_WIDGET_VOL,
+                               name,
+                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               }
+
                dimux->items[dimux->num_items].label =
                        stac92xx_dmic_labels[dimux->num_items];
                dimux->items[dimux->num_items].index = index;
@@ -3344,6 +3332,8 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->mixer = stac927x_mixer;
                break;
        case STAC_DELL_BIOS:
+               /* correct the front output jack as a hp out */
+               stac92xx_set_config_reg(codec, 0x0f, 0x02270110);
                /* correct the front input jack as a mic */
                stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
                /* fallthru */