]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/hda/patch_sigmatel.c
[ALSA] hda-codec - Add proper model for HP xw series
[linux-2.6-omap-h63xx.git] / sound / pci / hda / patch_sigmatel.c
index 93ae9c2507677c4e75837c8357dafc32aa799cdf..addcb2a0ae667de899d9d4afb66658d2acd82aef 100644 (file)
@@ -51,6 +51,7 @@ enum {
        STAC_925x_REF,
        STAC_M2_2,
        STAC_MA6,
+       STAC_PA6,
        STAC_925x_MODELS
 };
 
@@ -58,11 +59,18 @@ enum {
        STAC_D945_REF,
        STAC_D945GTP3,
        STAC_D945GTP5,
+       STAC_INTEL_MAC_V1,
+       STAC_INTEL_MAC_V2,
+       STAC_INTEL_MAC_V3,
+       STAC_INTEL_MAC_V4,
+       STAC_INTEL_MAC_V5,
+       /* for backward compitability */
        STAC_MACMINI,
        STAC_MACBOOK,
        STAC_MACBOOK_PRO_V1,
        STAC_MACBOOK_PRO_V2,
        STAC_IMAC_INTEL,
+       STAC_IMAC_INTEL_20,
        STAC_922X_MODELS
 };
 
@@ -152,6 +160,10 @@ static hda_nid_t stac925x_dac_nids[1] = {
         0x02,
 };
 
+static hda_nid_t stac925x_dmic_nids[1] = {
+       0x15, 
+};
+
 static hda_nid_t stac922x_adc_nids[2] = {
         0x06, 0x07,
 };
@@ -467,6 +479,16 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
                      "Dell XPS M1710", STAC_REF),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
                      "Dell Precision M90", STAC_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
+                     "unknown Dell", STAC_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
+                     "Dell Inspiron 640m", STAC_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
+                     "Dell Inspiron 1501", STAC_REF),
+
+       /* Panasonic */
+       SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
+
        {} /* terminator */
 };
 
@@ -480,29 +502,38 @@ static unsigned int stac925x_MA6_pin_configs[8] = {
        0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
 };
 
+static unsigned int stac925x_PA6_pin_configs[8] = {
+       0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
+       0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
+};
+
 static unsigned int stac925xM2_2_pin_configs[8] = {
-       0x40c003f3, 0x424503f2, 0x041800f4, 0x02a19020,
-       0x50a103F0, 0x90100210, 0x400003f1, 0x9033032e,
+       0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
+       0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
 };
 
 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
        [STAC_REF] = ref925x_pin_configs,
        [STAC_M2_2] = stac925xM2_2_pin_configs,
        [STAC_MA6] = stac925x_MA6_pin_configs,
+       [STAC_PA6] = stac925x_PA6_pin_configs,
 };
 
 static const char *stac925x_models[STAC_925x_MODELS] = {
        [STAC_REF] = "ref",
        [STAC_M2_2] = "m2-2",
        [STAC_MA6] = "m6",
+       [STAC_PA6] = "pa6",
 };
 
 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
+       SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
        SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
        SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
        SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
+       SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
        SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
        {} /* terminator */
 };
@@ -525,21 +556,33 @@ static unsigned int d945gtp5_pin_configs[10] = {
        0x02a19320, 0x40000100,
 };
 
-static unsigned int macbook_pro_v1_pin_configs[10] = {
-       0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
-       0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
-       0x02a19320, 0x400000fb
+static unsigned int intel_mac_v1_pin_configs[10] = {
+       0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
+       0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
+       0x400000fc, 0x400000fb,
+};
+
+static unsigned int intel_mac_v2_pin_configs[10] = {
+       0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
+       0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
+       0x400000fc, 0x400000fb,
+};
+
+static unsigned int intel_mac_v3_pin_configs[10] = {
+       0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
+       0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
+       0x400000fc, 0x400000fb,
 };
 
-static unsigned int macbook_pro_v2_pin_configs[10] = {
-       0x0221401f, 0x90a70120, 0x01813024, 0x01014010,
-       0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e,
+static unsigned int intel_mac_v4_pin_configs[10] = {
+       0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
+       0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
        0x400000fc, 0x400000fb,
 };
 
-static unsigned int imac_intel_pin_configs[10] = {
-       0x0121e230, 0x90a70120, 0x9017e110, 0x400000fe,
-       0x400000fd, 0x0181e021, 0x1145e040, 0x400000fa,
+static unsigned int intel_mac_v5_pin_configs[10] = {
+       0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
+       0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
        0x400000fc, 0x400000fb,
 };
 
@@ -547,22 +590,36 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
        [STAC_D945_REF] = ref922x_pin_configs,
        [STAC_D945GTP3] = d945gtp3_pin_configs,
        [STAC_D945GTP5] = d945gtp5_pin_configs,
-       [STAC_MACMINI] = macbook_pro_v1_pin_configs,
-       [STAC_MACBOOK] = macbook_pro_v1_pin_configs,
-       [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
-       [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
-       [STAC_IMAC_INTEL] = imac_intel_pin_configs,
+       [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
+       [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
+       [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
+       [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
+       [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
+       /* for backward compitability */
+       [STAC_MACMINI] = intel_mac_v3_pin_configs,
+       [STAC_MACBOOK] = intel_mac_v5_pin_configs,
+       [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
+       [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
+       [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
+       [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
 };
 
 static const char *stac922x_models[STAC_922X_MODELS] = {
        [STAC_D945_REF] = "ref",
        [STAC_D945GTP5] = "5stack",
        [STAC_D945GTP3] = "3stack",
+       [STAC_INTEL_MAC_V1] = "intel-mac-v1",
+       [STAC_INTEL_MAC_V2] = "intel-mac-v2",
+       [STAC_INTEL_MAC_V3] = "intel-mac-v3",
+       [STAC_INTEL_MAC_V4] = "intel-mac-v4",
+       [STAC_INTEL_MAC_V5] = "intel-mac-v5",
+       /* for backward compitability */
        [STAC_MACMINI]  = "macmini",
        [STAC_MACBOOK]  = "macbook",
        [STAC_MACBOOK_PRO_V1]   = "macbook-pro-v1",
        [STAC_MACBOOK_PRO_V2]   = "macbook-pro",
        [STAC_IMAC_INTEL] = "imac-intel",
+       [STAC_IMAC_INTEL_20] = "imac-intel-20",
 };
 
 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
@@ -625,7 +682,7 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
        /* other systems  */
        /* Apple Mac Mini (early 2006) */
        SND_PCI_QUIRK(0x8384, 0x7680,
-                     "Mac Mini", STAC_MACMINI),
+                     "Mac Mini", STAC_INTEL_MAC_V3),
        {} /* terminator */
 };
 
@@ -1740,6 +1797,21 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
        unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
 
+       if (pin_ctl & AC_PINCTL_IN_EN) {
+               /*
+                * we need to check the current set-up direction of
+                * shared input pins since they can be switched via
+                * "xxx as Output" mixer switch
+                */
+               struct sigmatel_spec *spec = codec->spec;
+               struct auto_pin_cfg *cfg = &spec->autocfg;
+               if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
+                    spec->line_switch) ||
+                   (nid == cfg->input_pins[AUTO_PIN_MIC] &&
+                    spec->mic_switch))
+                       return;
+       }
+
        /* if setting pin direction bits, clear the current
           direction bits first */
        if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
@@ -1909,7 +1981,8 @@ static int patch_stac925x(struct hda_codec *codec)
                                                        stac925x_cfg_tbl);
  again:
        if (spec->board_config < 0) {
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x, using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," 
+                                     "using BIOS defaults\n");
                err = stac92xx_save_bios_config_regs(codec);
                if (err < 0) {
                        stac92xx_free(codec);
@@ -1927,7 +2000,18 @@ static int patch_stac925x(struct hda_codec *codec)
        spec->adc_nids = stac925x_adc_nids;
        spec->mux_nids = stac925x_mux_nids;
        spec->num_muxes = 1;
-       spec->num_dmics = 0;
+       switch (codec->vendor_id) {
+       case 0x83847632: /* STAC9202  */
+       case 0x83847633: /* STAC9202D */
+       case 0x83847636: /* STAC9251  */
+       case 0x83847637: /* STAC9251D */
+               spec->num_dmics = 1;
+               spec->dmic_nids = stac925x_dmic_nids;
+               break;
+       default:
+               spec->num_dmics = 0;
+               break;
+       }
 
        spec->init = stac925x_core_init;
        spec->mixer = stac925x_mixer;
@@ -1967,24 +2051,36 @@ static int patch_stac922x(struct hda_codec *codec)
        spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
                                                        stac922x_models,
                                                        stac922x_cfg_tbl);
-       if (spec->board_config == STAC_MACMINI) {
+       if (spec->board_config == STAC_INTEL_MAC_V3) {
                spec->gpio_mute = 1;
                /* Intel Macs have all same PCI SSID, so we need to check
                 * codec SSID to distinguish the exact models
                 */
                printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
                switch (codec->subsystem_id) {
-               case 0x106b0a00: /* MacBook First generatoin */
-                       spec->board_config = STAC_MACBOOK;
+
+               case 0x106b0800:
+                       spec->board_config = STAC_INTEL_MAC_V1;
                        break;
-               case 0x106b0200: /* MacBook Pro first generation */
-                       spec->board_config = STAC_MACBOOK_PRO_V1;
+               case 0x106b0600:
+               case 0x106b0700:
+                       spec->board_config = STAC_INTEL_MAC_V2;
                        break;
-               case 0x106b1e00: /* MacBook Pro second generation */
-                       spec->board_config = STAC_MACBOOK_PRO_V2;
+               case 0x106b0e00:
+               case 0x106b0f00:
+               case 0x106b1600:
+               case 0x106b1700:
+               case 0x106b0200:
+               case 0x106b1e00:
+                       spec->board_config = STAC_INTEL_MAC_V3;
                        break;
-               case 0x106b0700: /* Intel-based iMac */
-                       spec->board_config = STAC_IMAC_INTEL;
+               case 0x106b1a00:
+               case 0x00000100:
+                       spec->board_config = STAC_INTEL_MAC_V4;
+                       break;
+               case 0x106b0a00:
+               case 0x106b2200:
+                       spec->board_config = STAC_INTEL_MAC_V5;
                        break;
                }
        }
@@ -2031,6 +2127,13 @@ static int patch_stac922x(struct hda_codec *codec)
 
        codec->patch_ops = stac92xx_patch_ops;
 
+       /* Fix Mux capture level; max to 2 */
+       snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
+                                 (0 << AC_AMPCAP_OFFSET_SHIFT) |
+                                 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
+                                 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
+                                 (0 << AC_AMPCAP_MUTE_SHIFT));
+
        return 0;
 }
 
@@ -2108,6 +2211,13 @@ static int patch_stac927x(struct hda_codec *codec)
 
        codec->patch_ops = stac92xx_patch_ops;
 
+       /* Fix Mux capture level; max to 2 */
+       snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
+                                 (0 << AC_AMPCAP_OFFSET_SHIFT) |
+                                 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
+                                 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
+                                 (0 << AC_AMPCAP_MUTE_SHIFT));
+
        return 0;
 }