aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c591
1 files changed, 474 insertions, 117 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index e8cbe216e912..53538b0f9991 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -230,6 +230,7 @@ enum {
230 ALC888_ACER_ASPIRE_7730G, 230 ALC888_ACER_ASPIRE_7730G,
231 ALC883_MEDION, 231 ALC883_MEDION,
232 ALC883_MEDION_MD2, 232 ALC883_MEDION_MD2,
233 ALC883_MEDION_WIM2160,
233 ALC883_LAPTOP_EAPD, 234 ALC883_LAPTOP_EAPD,
234 ALC883_LENOVO_101E_2ch, 235 ALC883_LENOVO_101E_2ch,
235 ALC883_LENOVO_NB0763, 236 ALC883_LENOVO_NB0763,
@@ -275,6 +276,18 @@ struct alc_mic_route {
275 276
276#define MUX_IDX_UNDEF ((unsigned char)-1) 277#define MUX_IDX_UNDEF ((unsigned char)-1)
277 278
279struct alc_customize_define {
280 unsigned int sku_cfg;
281 unsigned char port_connectivity;
282 unsigned char check_sum;
283 unsigned char customization;
284 unsigned char external_amp;
285 unsigned int enable_pcbeep:1;
286 unsigned int platform_type:1;
287 unsigned int swap:1;
288 unsigned int override:1;
289};
290
278struct alc_spec { 291struct alc_spec {
279 /* codec parameterization */ 292 /* codec parameterization */
280 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 293 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
@@ -332,6 +345,7 @@ struct alc_spec {
332 345
333 /* dynamic controls, init_verbs and input_mux */ 346 /* dynamic controls, init_verbs and input_mux */
334 struct auto_pin_cfg autocfg; 347 struct auto_pin_cfg autocfg;
348 struct alc_customize_define cdefine;
335 struct snd_array kctls; 349 struct snd_array kctls;
336 struct hda_input_mux private_imux[3]; 350 struct hda_input_mux private_imux[3];
337 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 351 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
@@ -411,6 +425,8 @@ static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
411 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); 425 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
412 if (mux_idx >= spec->num_mux_defs) 426 if (mux_idx >= spec->num_mux_defs)
413 mux_idx = 0; 427 mux_idx = 0;
428 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
429 mux_idx = 0;
414 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); 430 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
415} 431}
416 432
@@ -439,6 +455,8 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
439 455
440 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 456 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
441 imux = &spec->input_mux[mux_idx]; 457 imux = &spec->input_mux[mux_idx];
458 if (!imux->num_items && mux_idx > 0)
459 imux = &spec->input_mux[0];
442 460
443 type = get_wcaps_type(get_wcaps(codec, nid)); 461 type = get_wcaps_type(get_wcaps(codec, nid));
444 if (type == AC_WID_AUD_MIX) { 462 if (type == AC_WID_AUD_MIX) {
@@ -1243,6 +1261,62 @@ static void alc_init_auto_mic(struct hda_codec *codec)
1243 spec->unsol_event = alc_sku_unsol_event; 1261 spec->unsol_event = alc_sku_unsol_event;
1244} 1262}
1245 1263
1264static int alc_auto_parse_customize_define(struct hda_codec *codec)
1265{
1266 unsigned int ass, tmp, i;
1267 unsigned nid = 0;
1268 struct alc_spec *spec = codec->spec;
1269
1270 ass = codec->subsystem_id & 0xffff;
1271 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1272 goto do_sku;
1273
1274 nid = 0x1d;
1275 if (codec->vendor_id == 0x10ec0260)
1276 nid = 0x17;
1277 ass = snd_hda_codec_get_pincfg(codec, nid);
1278
1279 if (!(ass & 1)) {
1280 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1281 codec->chip_name, ass);
1282 return -1;
1283 }
1284
1285 /* check sum */
1286 tmp = 0;
1287 for (i = 1; i < 16; i++) {
1288 if ((ass >> i) & 1)
1289 tmp++;
1290 }
1291 if (((ass >> 16) & 0xf) != tmp)
1292 return -1;
1293
1294 spec->cdefine.port_connectivity = ass >> 30;
1295 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1296 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1297 spec->cdefine.customization = ass >> 8;
1298do_sku:
1299 spec->cdefine.sku_cfg = ass;
1300 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1301 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1302 spec->cdefine.swap = (ass & 0x2) >> 1;
1303 spec->cdefine.override = ass & 0x1;
1304
1305 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1306 nid, spec->cdefine.sku_cfg);
1307 snd_printd("SKU: port_connectivity=0x%x\n",
1308 spec->cdefine.port_connectivity);
1309 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1310 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1311 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1312 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1313 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1314 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1315 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1316
1317 return 0;
1318}
1319
1246/* check subsystem ID and set up device-specific initialization; 1320/* check subsystem ID and set up device-specific initialization;
1247 * return 1 if initialized, 0 if invalid SSID 1321 * return 1 if initialized, 0 if invalid SSID
1248 */ 1322 */
@@ -1385,22 +1459,31 @@ struct alc_fixup {
1385 1459
1386static void alc_pick_fixup(struct hda_codec *codec, 1460static void alc_pick_fixup(struct hda_codec *codec,
1387 const struct snd_pci_quirk *quirk, 1461 const struct snd_pci_quirk *quirk,
1388 const struct alc_fixup *fix) 1462 const struct alc_fixup *fix,
1463 int pre_init)
1389{ 1464{
1390 const struct alc_pincfg *cfg; 1465 const struct alc_pincfg *cfg;
1391 1466
1392 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1467 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1393 if (!quirk) 1468 if (!quirk)
1394 return; 1469 return;
1395
1396 fix += quirk->value; 1470 fix += quirk->value;
1397 cfg = fix->pins; 1471 cfg = fix->pins;
1398 if (cfg) { 1472 if (pre_init && cfg) {
1473#ifdef CONFIG_SND_DEBUG_VERBOSE
1474 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1475 codec->chip_name, quirk->name);
1476#endif
1399 for (; cfg->nid; cfg++) 1477 for (; cfg->nid; cfg++)
1400 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); 1478 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1401 } 1479 }
1402 if (fix->verbs) 1480 if (!pre_init && fix->verbs) {
1481#ifdef CONFIG_SND_DEBUG_VERBOSE
1482 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1483 codec->chip_name, quirk->name);
1484#endif
1403 add_verb(codec->spec, fix->verbs); 1485 add_verb(codec->spec, fix->verbs);
1486 }
1404} 1487}
1405 1488
1406static int alc_read_coef_idx(struct hda_codec *codec, 1489static int alc_read_coef_idx(struct hda_codec *codec,
@@ -1617,6 +1700,11 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1617 */ 1700 */
1618 1701
1619static struct hda_verb alc888_acer_aspire_6530g_verbs[] = { 1702static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1703/* Route to built-in subwoofer as well as speakers */
1704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1707 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1620/* Bias voltage on for external mic port */ 1708/* Bias voltage on for external mic port */
1621 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80}, 1709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1622/* Front Mic: set to PIN_IN (empty by default) */ 1710/* Front Mic: set to PIN_IN (empty by default) */
@@ -1628,10 +1716,12 @@ static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1628/* Enable speaker output */ 1716/* Enable speaker output */
1629 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1630 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1719 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
1631/* Enable headphone output */ 1720/* Enable headphone output */
1632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP}, 1721 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 1723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1724 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
1635 { } 1725 { }
1636}; 1726};
1637 1727
@@ -2528,8 +2618,6 @@ static int alc_build_controls(struct hda_codec *codec)
2528 return err; 2618 return err;
2529 } 2619 }
2530 2620
2531 alc_free_kctls(codec); /* no longer needed */
2532
2533 /* assign Capture Source enums to NID */ 2621 /* assign Capture Source enums to NID */
2534 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); 2622 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2535 if (!kctl) 2623 if (!kctl)
@@ -2598,6 +2686,9 @@ static int alc_build_controls(struct hda_codec *codec)
2598 } 2686 }
2599 } 2687 }
2600 } 2688 }
2689
2690 alc_free_kctls(codec); /* no longer needed */
2691
2601 return 0; 2692 return 0;
2602} 2693}
2603 2694
@@ -3393,6 +3484,10 @@ static int alc_init(struct hda_codec *codec)
3393 if (spec->init_hook) 3484 if (spec->init_hook)
3394 spec->init_hook(codec); 3485 spec->init_hook(codec);
3395 3486
3487#ifdef CONFIG_SND_HDA_POWER_SAVE
3488 if (codec->patch_ops.check_power_status)
3489 codec->patch_ops.check_power_status(codec, 0x01);
3490#endif
3396 return 0; 3491 return 0;
3397} 3492}
3398 3493
@@ -3753,6 +3848,10 @@ static int alc_resume(struct hda_codec *codec)
3753 codec->patch_ops.init(codec); 3848 codec->patch_ops.init(codec);
3754 snd_hda_codec_resume_amp(codec); 3849 snd_hda_codec_resume_amp(codec);
3755 snd_hda_codec_resume_cache(codec); 3850 snd_hda_codec_resume_cache(codec);
3851#ifdef CONFIG_SND_HDA_POWER_SAVE
3852 if (codec->patch_ops.check_power_status)
3853 codec->patch_ops.check_power_status(codec, 0x01);
3854#endif
3756 return 0; 3855 return 0;
3757} 3856}
3758#endif 3857#endif
@@ -3775,6 +3874,17 @@ static struct hda_codec_ops alc_patch_ops = {
3775 .reboot_notify = alc_shutup, 3874 .reboot_notify = alc_shutup,
3776}; 3875};
3777 3876
3877/* replace the codec chip_name with the given string */
3878static int alc_codec_rename(struct hda_codec *codec, const char *name)
3879{
3880 kfree(codec->chip_name);
3881 codec->chip_name = kstrdup(name, GFP_KERNEL);
3882 if (!codec->chip_name) {
3883 alc_free(codec);
3884 return -ENOMEM;
3885 }
3886 return 0;
3887}
3778 3888
3779/* 3889/*
3780 * Test configuration for debugging 3890 * Test configuration for debugging
@@ -4121,7 +4231,7 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
4121 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), 4231 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
4122 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), 4232 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
4123 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), 4233 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
4124 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), 4234 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
4125 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), 4235 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
4126 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), 4236 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
4127 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), 4237 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
@@ -4796,6 +4906,25 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
4796 } 4906 }
4797} 4907}
4798 4908
4909static void alc880_auto_init_input_src(struct hda_codec *codec)
4910{
4911 struct alc_spec *spec = codec->spec;
4912 int c;
4913
4914 for (c = 0; c < spec->num_adc_nids; c++) {
4915 unsigned int mux_idx;
4916 const struct hda_input_mux *imux;
4917 mux_idx = c >= spec->num_mux_defs ? 0 : c;
4918 imux = &spec->input_mux[mux_idx];
4919 if (!imux->num_items && mux_idx > 0)
4920 imux = &spec->input_mux[0];
4921 if (imux)
4922 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
4923 AC_VERB_SET_CONNECT_SEL,
4924 imux->items[0].index);
4925 }
4926}
4927
4799/* parse the BIOS configuration and set up the alc_spec */ 4928/* parse the BIOS configuration and set up the alc_spec */
4800/* return 1 if successful, 0 if the proper config is not found, 4929/* return 1 if successful, 0 if the proper config is not found,
4801 * or a negative error code 4930 * or a negative error code
@@ -4874,6 +5003,7 @@ static void alc880_auto_init(struct hda_codec *codec)
4874 alc880_auto_init_multi_out(codec); 5003 alc880_auto_init_multi_out(codec);
4875 alc880_auto_init_extra_out(codec); 5004 alc880_auto_init_extra_out(codec);
4876 alc880_auto_init_analog_input(codec); 5005 alc880_auto_init_analog_input(codec);
5006 alc880_auto_init_input_src(codec);
4877 if (spec->unsol_event) 5007 if (spec->unsol_event)
4878 alc_inithook(codec); 5008 alc_inithook(codec);
4879} 5009}
@@ -4915,7 +5045,7 @@ static void fixup_automic_adc(struct hda_codec *codec)
4915static void fixup_single_adc(struct hda_codec *codec) 5045static void fixup_single_adc(struct hda_codec *codec)
4916{ 5046{
4917 struct alc_spec *spec = codec->spec; 5047 struct alc_spec *spec = codec->spec;
4918 hda_nid_t pin; 5048 hda_nid_t pin = 0;
4919 int i; 5049 int i;
4920 5050
4921 /* search for the input pin; there must be only one */ 5051 /* search for the input pin; there must be only one */
@@ -4979,6 +5109,70 @@ static void set_capture_mixer(struct hda_codec *codec)
4979 } 5109 }
4980} 5110}
4981 5111
5112/* fill adc_nids (and capsrc_nids) containing all active input pins */
5113static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5114 int num_nids)
5115{
5116 struct alc_spec *spec = codec->spec;
5117 int n;
5118 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5119
5120 for (n = 0; n < num_nids; n++) {
5121 hda_nid_t adc, cap;
5122 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5123 int nconns, i, j;
5124
5125 adc = nids[n];
5126 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5127 continue;
5128 cap = adc;
5129 nconns = snd_hda_get_connections(codec, cap, conn,
5130 ARRAY_SIZE(conn));
5131 if (nconns == 1) {
5132 cap = conn[0];
5133 nconns = snd_hda_get_connections(codec, cap, conn,
5134 ARRAY_SIZE(conn));
5135 }
5136 if (nconns <= 0)
5137 continue;
5138 if (!fallback_adc) {
5139 fallback_adc = adc;
5140 fallback_cap = cap;
5141 }
5142 for (i = 0; i < AUTO_PIN_LAST; i++) {
5143 hda_nid_t nid = spec->autocfg.input_pins[i];
5144 if (!nid)
5145 continue;
5146 for (j = 0; j < nconns; j++) {
5147 if (conn[j] == nid)
5148 break;
5149 }
5150 if (j >= nconns)
5151 break;
5152 }
5153 if (i >= AUTO_PIN_LAST) {
5154 int num_adcs = spec->num_adc_nids;
5155 spec->private_adc_nids[num_adcs] = adc;
5156 spec->private_capsrc_nids[num_adcs] = cap;
5157 spec->num_adc_nids++;
5158 spec->adc_nids = spec->private_adc_nids;
5159 if (adc != cap)
5160 spec->capsrc_nids = spec->private_capsrc_nids;
5161 }
5162 }
5163 if (!spec->num_adc_nids) {
5164 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
5165 " using fallback 0x%x\n",
5166 codec->chip_name, fallback_adc);
5167 spec->private_adc_nids[0] = fallback_adc;
5168 spec->adc_nids = spec->private_adc_nids;
5169 if (fallback_adc != fallback_cap) {
5170 spec->private_capsrc_nids[0] = fallback_cap;
5171 spec->capsrc_nids = spec->private_adc_nids;
5172 }
5173 }
5174}
5175
4982#ifdef CONFIG_SND_HDA_INPUT_BEEP 5176#ifdef CONFIG_SND_HDA_INPUT_BEEP
4983#define set_beep_amp(spec, nid, idx, dir) \ 5177#define set_beep_amp(spec, nid, idx, dir) \
4984 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) 5178 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
@@ -6321,6 +6515,8 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec)
6321 } 6515 }
6322} 6516}
6323 6517
6518#define alc260_auto_init_input_src alc880_auto_init_input_src
6519
6324/* 6520/*
6325 * generic initialization of ADC, input mixers and output mixers 6521 * generic initialization of ADC, input mixers and output mixers
6326 */ 6522 */
@@ -6407,6 +6603,7 @@ static void alc260_auto_init(struct hda_codec *codec)
6407 struct alc_spec *spec = codec->spec; 6603 struct alc_spec *spec = codec->spec;
6408 alc260_auto_init_multi_out(codec); 6604 alc260_auto_init_multi_out(codec);
6409 alc260_auto_init_analog_input(codec); 6605 alc260_auto_init_analog_input(codec);
6606 alc260_auto_init_input_src(codec);
6410 if (spec->unsol_event) 6607 if (spec->unsol_event)
6411 alc_inithook(codec); 6608 alc_inithook(codec);
6412} 6609}
@@ -6473,7 +6670,7 @@ static struct alc_config_preset alc260_presets[] = {
6473 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 6670 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6474 .dac_nids = alc260_dac_nids, 6671 .dac_nids = alc260_dac_nids,
6475 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), 6672 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6476 .adc_nids = alc260_adc_nids, 6673 .adc_nids = alc260_dual_adc_nids,
6477 .num_channel_mode = ARRAY_SIZE(alc260_modes), 6674 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6478 .channel_mode = alc260_modes, 6675 .channel_mode = alc260_modes,
6479 .input_mux = &alc260_capture_source, 6676 .input_mux = &alc260_capture_source,
@@ -8379,6 +8576,42 @@ static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8379 { } /* end */ 8576 { } /* end */
8380}; 8577};
8381 8578
8579static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8580 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8581 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8582 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8584 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8585 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8586 { } /* end */
8587};
8588
8589static struct hda_verb alc883_medion_wim2160_verbs[] = {
8590 /* Unmute front mixer */
8591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8593
8594 /* Set speaker pin to front mixer */
8595 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8596
8597 /* Init headphone pin */
8598 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8599 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8600 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8601 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8602
8603 { } /* end */
8604};
8605
8606/* toggle speaker-output according to the hp-jack state */
8607static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8608{
8609 struct alc_spec *spec = codec->spec;
8610
8611 spec->autocfg.hp_pins[0] = 0x1a;
8612 spec->autocfg.speaker_pins[0] = 0x15;
8613}
8614
8382static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { 8615static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
8383 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8616 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8384 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 8617 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -8393,9 +8626,7 @@ static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
8393 8626
8394static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = { 8627static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8395 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8628 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8396 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8397 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 8629 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8398 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8399 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 8630 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8400 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 8631 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8401 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
@@ -9090,6 +9321,7 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
9090 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g", 9321 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
9091 [ALC883_MEDION] = "medion", 9322 [ALC883_MEDION] = "medion",
9092 [ALC883_MEDION_MD2] = "medion-md2", 9323 [ALC883_MEDION_MD2] = "medion-md2",
9324 [ALC883_MEDION_WIM2160] = "medion-wim2160",
9093 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 9325 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
9094 [ALC883_LENOVO_101E_2ch] = "lenovo-101e", 9326 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
9095 [ALC883_LENOVO_NB0763] = "lenovo-nb0763", 9327 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
@@ -9191,6 +9423,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
9191 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), 9423 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9192 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), 9424 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9193 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 9425 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
9426 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
9194 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG), 9427 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
9195 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 9428 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9196 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 9429 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
@@ -9200,10 +9433,12 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
9200 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 9433 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
9201 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 9434 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
9202 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), 9435 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
9436 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
9203 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 9437 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
9204 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG), 9438 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
9205 9439
9206 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 9440 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
9441 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
9207 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), 9442 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9208 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), 9443 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
9209 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R), 9444 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
@@ -9231,7 +9466,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
9231 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL), 9466 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9232 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL), 9467 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9233 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL), 9468 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
9234 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 9469 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
9235 9470
9236 {} 9471 {}
9237}; 9472};
@@ -9742,6 +9977,21 @@ static struct alc_config_preset alc882_presets[] = {
9742 .setup = alc883_medion_md2_setup, 9977 .setup = alc883_medion_md2_setup,
9743 .init_hook = alc_automute_amp, 9978 .init_hook = alc_automute_amp,
9744 }, 9979 },
9980 [ALC883_MEDION_WIM2160] = {
9981 .mixers = { alc883_medion_wim2160_mixer },
9982 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
9983 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9984 .dac_nids = alc883_dac_nids,
9985 .dig_out_nid = ALC883_DIGOUT_NID,
9986 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9987 .adc_nids = alc883_adc_nids,
9988 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9989 .channel_mode = alc883_3ST_2ch_modes,
9990 .input_mux = &alc883_capture_source,
9991 .unsol_event = alc_automute_amp_unsol_event,
9992 .setup = alc883_medion_wim2160_setup,
9993 .init_hook = alc_automute_amp,
9994 },
9745 [ALC883_LAPTOP_EAPD] = { 9995 [ALC883_LAPTOP_EAPD] = {
9746 .mixers = { alc883_base_mixer }, 9996 .mixers = { alc883_base_mixer },
9747 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, 9997 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
@@ -10027,19 +10277,20 @@ static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10027 10277
10028static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, 10278static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
10029 hda_nid_t nid, int pin_type, 10279 hda_nid_t nid, int pin_type,
10030 int dac_idx) 10280 hda_nid_t dac)
10031{ 10281{
10032 /* set as output */
10033 struct alc_spec *spec = codec->spec;
10034 int idx; 10282 int idx;
10035 10283
10284 /* set as output */
10036 alc_set_pin_output(codec, nid, pin_type); 10285 alc_set_pin_output(codec, nid, pin_type);
10037 if (spec->multiout.dac_nids[dac_idx] == 0x25) 10286
10287 if (dac == 0x25)
10038 idx = 4; 10288 idx = 4;
10289 else if (dac >= 0x02 && dac <= 0x05)
10290 idx = dac - 2;
10039 else 10291 else
10040 idx = spec->multiout.dac_nids[dac_idx] - 2; 10292 return;
10041 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 10293 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10042
10043} 10294}
10044 10295
10045static void alc882_auto_init_multi_out(struct hda_codec *codec) 10296static void alc882_auto_init_multi_out(struct hda_codec *codec)
@@ -10052,22 +10303,29 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec)
10052 int pin_type = get_pin_type(spec->autocfg.line_out_type); 10303 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10053 if (nid) 10304 if (nid)
10054 alc882_auto_set_output_and_unmute(codec, nid, pin_type, 10305 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
10055 i); 10306 spec->multiout.dac_nids[i]);
10056 } 10307 }
10057} 10308}
10058 10309
10059static void alc882_auto_init_hp_out(struct hda_codec *codec) 10310static void alc882_auto_init_hp_out(struct hda_codec *codec)
10060{ 10311{
10061 struct alc_spec *spec = codec->spec; 10312 struct alc_spec *spec = codec->spec;
10062 hda_nid_t pin; 10313 hda_nid_t pin, dac;
10063 10314
10064 pin = spec->autocfg.hp_pins[0]; 10315 pin = spec->autocfg.hp_pins[0];
10065 if (pin) /* connect to front */ 10316 if (pin) {
10066 /* use dac 0 */ 10317 dac = spec->multiout.hp_nid;
10067 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 10318 if (!dac)
10319 dac = spec->multiout.dac_nids[0]; /* to front */
10320 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10321 }
10068 pin = spec->autocfg.speaker_pins[0]; 10322 pin = spec->autocfg.speaker_pins[0];
10069 if (pin) 10323 if (pin) {
10070 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 10324 dac = spec->multiout.extra_out_nid[0];
10325 if (!dac)
10326 dac = spec->multiout.dac_nids[0]; /* to front */
10327 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10328 }
10071} 10329}
10072 10330
10073static void alc882_auto_init_analog_input(struct hda_codec *codec) 10331static void alc882_auto_init_analog_input(struct hda_codec *codec)
@@ -10105,6 +10363,8 @@ static void alc882_auto_init_input_src(struct hda_codec *codec)
10105 continue; 10363 continue;
10106 mux_idx = c >= spec->num_mux_defs ? 0 : c; 10364 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10107 imux = &spec->input_mux[mux_idx]; 10365 imux = &spec->input_mux[mux_idx];
10366 if (!imux->num_items && mux_idx > 0)
10367 imux = &spec->input_mux[0];
10108 for (idx = 0; idx < conns; idx++) { 10368 for (idx = 0; idx < conns; idx++) {
10109 /* if the current connection is the selected one, 10369 /* if the current connection is the selected one,
10110 * unmute it as default - otherwise mute it 10370 * unmute it as default - otherwise mute it
@@ -10181,15 +10441,15 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
10181 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); 10441 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10182 if (err < 0) 10442 if (err < 0)
10183 return err; 10443 return err;
10444 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10445 "Headphone");
10446 if (err < 0)
10447 return err;
10184 err = alc880_auto_create_extra_out(spec, 10448 err = alc880_auto_create_extra_out(spec,
10185 spec->autocfg.speaker_pins[0], 10449 spec->autocfg.speaker_pins[0],
10186 "Speaker"); 10450 "Speaker");
10187 if (err < 0) 10451 if (err < 0)
10188 return err; 10452 return err;
10189 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10190 "Headphone");
10191 if (err < 0)
10192 return err;
10193 err = alc882_auto_create_input_ctls(codec, &spec->autocfg); 10453 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10194 if (err < 0) 10454 if (err < 0)
10195 return err; 10455 return err;
@@ -10259,6 +10519,8 @@ static int patch_alc882(struct hda_codec *codec)
10259 10519
10260 codec->spec = spec; 10520 codec->spec = spec;
10261 10521
10522 alc_auto_parse_customize_define(codec);
10523
10262 switch (codec->vendor_id) { 10524 switch (codec->vendor_id) {
10263 case 0x10ec0882: 10525 case 0x10ec0882:
10264 case 0x10ec0885: 10526 case 0x10ec0885:
@@ -10283,7 +10545,8 @@ static int patch_alc882(struct hda_codec *codec)
10283 board_config = ALC882_AUTO; 10545 board_config = ALC882_AUTO;
10284 } 10546 }
10285 10547
10286 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups); 10548 if (board_config == ALC882_AUTO)
10549 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
10287 10550
10288 if (board_config == ALC882_AUTO) { 10551 if (board_config == ALC882_AUTO) {
10289 /* automatic parse from the BIOS config */ 10552 /* automatic parse from the BIOS config */
@@ -10317,9 +10580,6 @@ static int patch_alc882(struct hda_codec *codec)
10317 spec->stream_digital_playback = &alc882_pcm_digital_playback; 10580 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10318 spec->stream_digital_capture = &alc882_pcm_digital_capture; 10581 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10319 10582
10320 if (codec->vendor_id == 0x10ec0888)
10321 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
10322
10323 if (!spec->adc_nids && spec->input_mux) { 10583 if (!spec->adc_nids && spec->input_mux) {
10324 int i, j; 10584 int i, j;
10325 spec->num_adc_nids = 0; 10585 spec->num_adc_nids = 0;
@@ -10354,7 +10614,12 @@ static int patch_alc882(struct hda_codec *codec)
10354 } 10614 }
10355 10615
10356 set_capture_mixer(codec); 10616 set_capture_mixer(codec);
10357 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 10617
10618 if (spec->cdefine.enable_pcbeep)
10619 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10620
10621 if (board_config == ALC882_AUTO)
10622 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10358 10623
10359 spec->vmaster_nid = 0x0c; 10624 spec->vmaster_nid = 0x0c;
10360 10625
@@ -12138,6 +12403,7 @@ static int patch_alc262(struct hda_codec *codec)
12138 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); 12403 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12139 } 12404 }
12140#endif 12405#endif
12406 alc_auto_parse_customize_define(codec);
12141 12407
12142 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 12408 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12143 12409
@@ -12216,7 +12482,7 @@ static int patch_alc262(struct hda_codec *codec)
12216 } 12482 }
12217 if (!spec->cap_mixer && !spec->no_analog) 12483 if (!spec->cap_mixer && !spec->no_analog)
12218 set_capture_mixer(codec); 12484 set_capture_mixer(codec);
12219 if (!spec->no_analog) 12485 if (!spec->no_analog && spec->cdefine.enable_pcbeep)
12220 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 12486 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
12221 12487
12222 spec->vmaster_nid = 0x0c; 12488 spec->vmaster_nid = 0x0c;
@@ -12447,11 +12713,11 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12447 unsigned char bits; 12713 unsigned char bits;
12448 12714
12449 present = snd_hda_jack_detect(codec, 0x15); 12715 present = snd_hda_jack_detect(codec, 0x15);
12450 bits = present ? AMP_IN_MUTE(0) : 0; 12716 bits = present ? HDA_AMP_MUTE : 0;
12451 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, 12717 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12452 AMP_IN_MUTE(0), bits); 12718 HDA_AMP_MUTE, bits);
12453 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1, 12719 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12454 AMP_IN_MUTE(0), bits); 12720 HDA_AMP_MUTE, bits);
12455} 12721}
12456 12722
12457static void alc268_acer_lc_unsol_event(struct hda_codec *codec, 12723static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
@@ -12736,6 +13002,7 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12736 dac = 0x02; 13002 dac = 0x02;
12737 break; 13003 break;
12738 case 0x15: 13004 case 0x15:
13005 case 0x21: /* ALC269vb has this pin, too */
12739 dac = 0x03; 13006 dac = 0x03;
12740 break; 13007 break;
12741 default: 13008 default:
@@ -13201,7 +13468,7 @@ static int patch_alc268(struct hda_codec *codec)
13201 13468
13202 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) 13469 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13203 board_config = snd_hda_check_board_codec_sid_config(codec, 13470 board_config = snd_hda_check_board_codec_sid_config(codec,
13204 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl); 13471 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
13205 13472
13206 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { 13473 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
13207 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 13474 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
@@ -13321,9 +13588,9 @@ static hda_nid_t alc269vb_capsrc_nids[1] = {
13321 0x22, 13588 0x22,
13322}; 13589};
13323 13590
13324/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), 13591static hda_nid_t alc269_adc_candidates[] = {
13325 * not a mux! 13592 0x08, 0x09, 0x07,
13326 */ 13593};
13327 13594
13328#define alc269_modes alc260_modes 13595#define alc269_modes alc260_modes
13329#define alc269_capture_source alc880_lg_lw_capture_source 13596#define alc269_capture_source alc880_lg_lw_capture_source
@@ -13470,11 +13737,11 @@ static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13470 unsigned char bits; 13737 unsigned char bits;
13471 13738
13472 present = snd_hda_jack_detect(codec, 0x15); 13739 present = snd_hda_jack_detect(codec, 0x15);
13473 bits = present ? AMP_IN_MUTE(0) : 0; 13740 bits = present ? HDA_AMP_MUTE : 0;
13474 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 13741 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13475 AMP_IN_MUTE(0), bits); 13742 HDA_AMP_MUTE, bits);
13476 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 13743 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13477 AMP_IN_MUTE(0), bits); 13744 HDA_AMP_MUTE, bits);
13478 13745
13479 snd_hda_codec_write(codec, 0x20, 0, 13746 snd_hda_codec_write(codec, 0x20, 0,
13480 AC_VERB_SET_COEF_INDEX, 0x0c); 13747 AC_VERB_SET_COEF_INDEX, 0x0c);
@@ -13499,11 +13766,11 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13499 /* Check port replicator headphone socket */ 13766 /* Check port replicator headphone socket */
13500 present |= snd_hda_jack_detect(codec, 0x1a); 13767 present |= snd_hda_jack_detect(codec, 0x1a);
13501 13768
13502 bits = present ? AMP_IN_MUTE(0) : 0; 13769 bits = present ? HDA_AMP_MUTE : 0;
13503 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 13770 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13504 AMP_IN_MUTE(0), bits); 13771 HDA_AMP_MUTE, bits);
13505 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 13772 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13506 AMP_IN_MUTE(0), bits); 13773 HDA_AMP_MUTE, bits);
13507 13774
13508 snd_hda_codec_write(codec, 0x20, 0, 13775 snd_hda_codec_write(codec, 0x20, 0,
13509 AC_VERB_SET_COEF_INDEX, 0x0c); 13776 AC_VERB_SET_COEF_INDEX, 0x0c);
@@ -13561,6 +13828,8 @@ static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13561static void alc269_quanta_fl1_setup(struct hda_codec *codec) 13828static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13562{ 13829{
13563 struct alc_spec *spec = codec->spec; 13830 struct alc_spec *spec = codec->spec;
13831 spec->autocfg.hp_pins[0] = 0x15;
13832 spec->autocfg.speaker_pins[0] = 0x14;
13564 spec->ext_mic.pin = 0x18; 13833 spec->ext_mic.pin = 0x18;
13565 spec->ext_mic.mux_idx = 0; 13834 spec->ext_mic.mux_idx = 0;
13566 spec->int_mic.pin = 0x19; 13835 spec->int_mic.pin = 0x19;
@@ -13632,11 +13901,11 @@ static void alc269_speaker_automute(struct hda_codec *codec)
13632 unsigned char bits; 13901 unsigned char bits;
13633 13902
13634 present = snd_hda_jack_detect(codec, nid); 13903 present = snd_hda_jack_detect(codec, nid);
13635 bits = present ? AMP_IN_MUTE(0) : 0; 13904 bits = present ? HDA_AMP_MUTE : 0;
13636 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 13905 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13637 AMP_IN_MUTE(0), bits); 13906 HDA_AMP_MUTE, bits);
13638 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 13907 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13639 AMP_IN_MUTE(0), bits); 13908 HDA_AMP_MUTE, bits);
13640} 13909}
13641 13910
13642/* unsolicited event for HP jack sensing */ 13911/* unsolicited event for HP jack sensing */
@@ -13653,29 +13922,35 @@ static void alc269_laptop_unsol_event(struct hda_codec *codec,
13653 } 13922 }
13654} 13923}
13655 13924
13656static void alc269_laptop_dmic_setup(struct hda_codec *codec) 13925static void alc269_laptop_amic_setup(struct hda_codec *codec)
13657{ 13926{
13658 struct alc_spec *spec = codec->spec; 13927 struct alc_spec *spec = codec->spec;
13928 spec->autocfg.hp_pins[0] = 0x15;
13929 spec->autocfg.speaker_pins[0] = 0x14;
13659 spec->ext_mic.pin = 0x18; 13930 spec->ext_mic.pin = 0x18;
13660 spec->ext_mic.mux_idx = 0; 13931 spec->ext_mic.mux_idx = 0;
13661 spec->int_mic.pin = 0x12; 13932 spec->int_mic.pin = 0x19;
13662 spec->int_mic.mux_idx = 5; 13933 spec->int_mic.mux_idx = 1;
13663 spec->auto_mic = 1; 13934 spec->auto_mic = 1;
13664} 13935}
13665 13936
13666static void alc269vb_laptop_dmic_setup(struct hda_codec *codec) 13937static void alc269_laptop_dmic_setup(struct hda_codec *codec)
13667{ 13938{
13668 struct alc_spec *spec = codec->spec; 13939 struct alc_spec *spec = codec->spec;
13940 spec->autocfg.hp_pins[0] = 0x15;
13941 spec->autocfg.speaker_pins[0] = 0x14;
13669 spec->ext_mic.pin = 0x18; 13942 spec->ext_mic.pin = 0x18;
13670 spec->ext_mic.mux_idx = 0; 13943 spec->ext_mic.mux_idx = 0;
13671 spec->int_mic.pin = 0x12; 13944 spec->int_mic.pin = 0x12;
13672 spec->int_mic.mux_idx = 6; 13945 spec->int_mic.mux_idx = 5;
13673 spec->auto_mic = 1; 13946 spec->auto_mic = 1;
13674} 13947}
13675 13948
13676static void alc269_laptop_amic_setup(struct hda_codec *codec) 13949static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
13677{ 13950{
13678 struct alc_spec *spec = codec->spec; 13951 struct alc_spec *spec = codec->spec;
13952 spec->autocfg.hp_pins[0] = 0x21;
13953 spec->autocfg.speaker_pins[0] = 0x14;
13679 spec->ext_mic.pin = 0x18; 13954 spec->ext_mic.pin = 0x18;
13680 spec->ext_mic.mux_idx = 0; 13955 spec->ext_mic.mux_idx = 0;
13681 spec->int_mic.pin = 0x19; 13956 spec->int_mic.pin = 0x19;
@@ -13683,6 +13958,18 @@ static void alc269_laptop_amic_setup(struct hda_codec *codec)
13683 spec->auto_mic = 1; 13958 spec->auto_mic = 1;
13684} 13959}
13685 13960
13961static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13962{
13963 struct alc_spec *spec = codec->spec;
13964 spec->autocfg.hp_pins[0] = 0x21;
13965 spec->autocfg.speaker_pins[0] = 0x14;
13966 spec->ext_mic.pin = 0x18;
13967 spec->ext_mic.mux_idx = 0;
13968 spec->int_mic.pin = 0x12;
13969 spec->int_mic.mux_idx = 6;
13970 spec->auto_mic = 1;
13971}
13972
13686static void alc269_laptop_inithook(struct hda_codec *codec) 13973static void alc269_laptop_inithook(struct hda_codec *codec)
13687{ 13974{
13688 alc269_speaker_automute(codec); 13975 alc269_speaker_automute(codec);
@@ -13814,6 +14101,35 @@ static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13814 /* NID is set in alc_build_pcms */ 14101 /* NID is set in alc_build_pcms */
13815}; 14102};
13816 14103
14104#ifdef CONFIG_SND_HDA_POWER_SAVE
14105static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14106{
14107 switch (codec->subsystem_id) {
14108 case 0x103c1586:
14109 return 1;
14110 }
14111 return 0;
14112}
14113
14114static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14115{
14116 /* update mute-LED according to the speaker mute state */
14117 if (nid == 0x01 || nid == 0x14) {
14118 int pinval;
14119 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14120 HDA_AMP_MUTE)
14121 pinval = 0x24;
14122 else
14123 pinval = 0x20;
14124 /* mic2 vref pin is used for mute LED control */
14125 snd_hda_codec_update_cache(codec, 0x19, 0,
14126 AC_VERB_SET_PIN_WIDGET_CONTROL,
14127 pinval);
14128 }
14129 return alc_check_power_status(codec, nid);
14130}
14131#endif /* CONFIG_SND_HDA_POWER_SAVE */
14132
13817/* 14133/*
13818 * BIOS auto configuration 14134 * BIOS auto configuration
13819 */ 14135 */
@@ -13822,7 +14138,6 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13822 struct alc_spec *spec = codec->spec; 14138 struct alc_spec *spec = codec->spec;
13823 int err; 14139 int err;
13824 static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; 14140 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13825 hda_nid_t real_capsrc_nids;
13826 14141
13827 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 14142 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13828 alc269_ignore); 14143 alc269_ignore);
@@ -13846,18 +14161,19 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13846 14161
13847 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) { 14162 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13848 add_verb(spec, alc269vb_init_verbs); 14163 add_verb(spec, alc269vb_init_verbs);
13849 real_capsrc_nids = alc269vb_capsrc_nids[0];
13850 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21); 14164 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
13851 } else { 14165 } else {
13852 add_verb(spec, alc269_init_verbs); 14166 add_verb(spec, alc269_init_verbs);
13853 real_capsrc_nids = alc269_capsrc_nids[0];
13854 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); 14167 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
13855 } 14168 }
13856 14169
13857 spec->num_mux_defs = 1; 14170 spec->num_mux_defs = 1;
13858 spec->input_mux = &spec->private_imux[0]; 14171 spec->input_mux = &spec->private_imux[0];
14172 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14173 sizeof(alc269_adc_candidates));
14174
13859 /* set default input source */ 14175 /* set default input source */
13860 snd_hda_codec_write_cache(codec, real_capsrc_nids, 14176 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
13861 0, AC_VERB_SET_CONNECT_SEL, 14177 0, AC_VERB_SET_CONNECT_SEL,
13862 spec->input_mux->items[0].index); 14178 spec->input_mux->items[0].index);
13863 14179
@@ -13887,6 +14203,27 @@ static void alc269_auto_init(struct hda_codec *codec)
13887 alc_inithook(codec); 14203 alc_inithook(codec);
13888} 14204}
13889 14205
14206enum {
14207 ALC269_FIXUP_SONY_VAIO,
14208};
14209
14210static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = {
14211 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14212 {}
14213};
14214
14215static const struct alc_fixup alc269_fixups[] = {
14216 [ALC269_FIXUP_SONY_VAIO] = {
14217 .verbs = alc269_sony_vaio_fixup_verbs
14218 },
14219};
14220
14221static struct snd_pci_quirk alc269_fixup_tbl[] = {
14222 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
14223 {}
14224};
14225
14226
13890/* 14227/*
13891 * configuration and preset 14228 * configuration and preset
13892 */ 14229 */
@@ -13946,7 +14283,7 @@ static struct snd_pci_quirk alc269_cfg_tbl[] = {
13946 ALC269_DMIC), 14283 ALC269_DMIC),
13947 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC), 14284 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
13948 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC), 14285 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
13949 SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC), 14286 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
13950 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), 14287 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
13951 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC), 14288 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
13952 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), 14289 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
@@ -14020,7 +14357,7 @@ static struct alc_config_preset alc269_presets[] = {
14020 .num_channel_mode = ARRAY_SIZE(alc269_modes), 14357 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14021 .channel_mode = alc269_modes, 14358 .channel_mode = alc269_modes,
14022 .unsol_event = alc269_laptop_unsol_event, 14359 .unsol_event = alc269_laptop_unsol_event,
14023 .setup = alc269_laptop_amic_setup, 14360 .setup = alc269vb_laptop_amic_setup,
14024 .init_hook = alc269_laptop_inithook, 14361 .init_hook = alc269_laptop_inithook,
14025 }, 14362 },
14026 [ALC269VB_DMIC] = { 14363 [ALC269VB_DMIC] = {
@@ -14078,17 +14415,17 @@ static int patch_alc269(struct hda_codec *codec)
14078 14415
14079 codec->spec = spec; 14416 codec->spec = spec;
14080 14417
14081 alc_fix_pll_init(codec, 0x20, 0x04, 15); 14418 alc_auto_parse_customize_define(codec);
14082 14419
14083 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){ 14420 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14084 kfree(codec->chip_name); 14421 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14085 codec->chip_name = kstrdup("ALC259", GFP_KERNEL); 14422 spec->cdefine.platform_type == 1)
14086 if (!codec->chip_name) { 14423 alc_codec_rename(codec, "ALC271X");
14087 alc_free(codec); 14424 else
14088 return -ENOMEM; 14425 alc_codec_rename(codec, "ALC259");
14089 }
14090 is_alc269vb = 1; 14426 is_alc269vb = 1;
14091 } 14427 } else
14428 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14092 14429
14093 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, 14430 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14094 alc269_models, 14431 alc269_models,
@@ -14100,6 +14437,9 @@ static int patch_alc269(struct hda_codec *codec)
14100 board_config = ALC269_AUTO; 14437 board_config = ALC269_AUTO;
14101 } 14438 }
14102 14439
14440 if (board_config == ALC269_AUTO)
14441 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14442
14103 if (board_config == ALC269_AUTO) { 14443 if (board_config == ALC269_AUTO) {
14104 /* automatic parse from the BIOS config */ 14444 /* automatic parse from the BIOS config */
14105 err = alc269_parse_auto_config(codec); 14445 err = alc269_parse_auto_config(codec);
@@ -14136,19 +14476,25 @@ static int patch_alc269(struct hda_codec *codec)
14136 spec->stream_digital_playback = &alc269_pcm_digital_playback; 14476 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14137 spec->stream_digital_capture = &alc269_pcm_digital_capture; 14477 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14138 14478
14139 if (!is_alc269vb) { 14479 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14140 spec->adc_nids = alc269_adc_nids; 14480 if (!is_alc269vb) {
14141 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 14481 spec->adc_nids = alc269_adc_nids;
14142 spec->capsrc_nids = alc269_capsrc_nids; 14482 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14143 } else { 14483 spec->capsrc_nids = alc269_capsrc_nids;
14144 spec->adc_nids = alc269vb_adc_nids; 14484 } else {
14145 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids); 14485 spec->adc_nids = alc269vb_adc_nids;
14146 spec->capsrc_nids = alc269vb_capsrc_nids; 14486 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14487 spec->capsrc_nids = alc269vb_capsrc_nids;
14488 }
14147 } 14489 }
14148 14490
14149 if (!spec->cap_mixer) 14491 if (!spec->cap_mixer)
14150 set_capture_mixer(codec); 14492 set_capture_mixer(codec);
14151 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 14493 if (spec->cdefine.enable_pcbeep)
14494 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
14495
14496 if (board_config == ALC269_AUTO)
14497 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14152 14498
14153 spec->vmaster_nid = 0x02; 14499 spec->vmaster_nid = 0x02;
14154 14500
@@ -14158,6 +14504,8 @@ static int patch_alc269(struct hda_codec *codec)
14158#ifdef CONFIG_SND_HDA_POWER_SAVE 14504#ifdef CONFIG_SND_HDA_POWER_SAVE
14159 if (!spec->loopback.amplist) 14505 if (!spec->loopback.amplist)
14160 spec->loopback.amplist = alc269_loopbacks; 14506 spec->loopback.amplist = alc269_loopbacks;
14507 if (alc269_mic2_for_mute_led(codec))
14508 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
14161#endif 14509#endif
14162 14510
14163 return 0; 14511 return 0;
@@ -15238,7 +15586,8 @@ static int patch_alc861(struct hda_codec *codec)
15238 board_config = ALC861_AUTO; 15586 board_config = ALC861_AUTO;
15239 } 15587 }
15240 15588
15241 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups); 15589 if (board_config == ALC861_AUTO)
15590 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
15242 15591
15243 if (board_config == ALC861_AUTO) { 15592 if (board_config == ALC861_AUTO) {
15244 /* automatic parse from the BIOS config */ 15593 /* automatic parse from the BIOS config */
@@ -15275,6 +15624,9 @@ static int patch_alc861(struct hda_codec *codec)
15275 15624
15276 spec->vmaster_nid = 0x03; 15625 spec->vmaster_nid = 0x03;
15277 15626
15627 if (board_config == ALC861_AUTO)
15628 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15629
15278 codec->patch_ops = alc_patch_ops; 15630 codec->patch_ops = alc_patch_ops;
15279 if (board_config == ALC861_AUTO) { 15631 if (board_config == ALC861_AUTO) {
15280 spec->init_hook = alc861_auto_init; 15632 spec->init_hook = alc861_auto_init;
@@ -16209,7 +16561,8 @@ static int patch_alc861vd(struct hda_codec *codec)
16209 board_config = ALC861VD_AUTO; 16561 board_config = ALC861VD_AUTO;
16210 } 16562 }
16211 16563
16212 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups); 16564 if (board_config == ALC861VD_AUTO)
16565 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
16213 16566
16214 if (board_config == ALC861VD_AUTO) { 16567 if (board_config == ALC861VD_AUTO) {
16215 /* automatic parse from the BIOS config */ 16568 /* automatic parse from the BIOS config */
@@ -16257,6 +16610,9 @@ static int patch_alc861vd(struct hda_codec *codec)
16257 16610
16258 spec->vmaster_nid = 0x02; 16611 spec->vmaster_nid = 0x02;
16259 16612
16613 if (board_config == ALC861VD_AUTO)
16614 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16615
16260 codec->patch_ops = alc_patch_ops; 16616 codec->patch_ops = alc_patch_ops;
16261 16617
16262 if (board_config == ALC861VD_AUTO) 16618 if (board_config == ALC861VD_AUTO)
@@ -17095,9 +17451,9 @@ static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17095 present = snd_hda_jack_detect(codec, 0x21); 17451 present = snd_hda_jack_detect(codec, 0x21);
17096 bits = present ? HDA_AMP_MUTE : 0; 17452 bits = present ? HDA_AMP_MUTE : 0;
17097 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 17453 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17098 AMP_IN_MUTE(0), bits); 17454 HDA_AMP_MUTE, bits);
17099 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 17455 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17100 AMP_IN_MUTE(0), bits); 17456 HDA_AMP_MUTE, bits);
17101} 17457}
17102 17458
17103static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) 17459static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
@@ -17108,13 +17464,13 @@ static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17108 present = snd_hda_jack_detect(codec, 0x21); 17464 present = snd_hda_jack_detect(codec, 0x21);
17109 bits = present ? HDA_AMP_MUTE : 0; 17465 bits = present ? HDA_AMP_MUTE : 0;
17110 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 17466 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17111 AMP_IN_MUTE(0), bits); 17467 HDA_AMP_MUTE, bits);
17112 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 17468 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17113 AMP_IN_MUTE(0), bits); 17469 HDA_AMP_MUTE, bits);
17114 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, 17470 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17115 AMP_IN_MUTE(0), bits); 17471 HDA_AMP_MUTE, bits);
17116 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, 17472 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17117 AMP_IN_MUTE(0), bits); 17473 HDA_AMP_MUTE, bits);
17118} 17474}
17119 17475
17120static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) 17476static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
@@ -17125,13 +17481,13 @@ static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17125 present = snd_hda_jack_detect(codec, 0x15); 17481 present = snd_hda_jack_detect(codec, 0x15);
17126 bits = present ? HDA_AMP_MUTE : 0; 17482 bits = present ? HDA_AMP_MUTE : 0;
17127 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 17483 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17128 AMP_IN_MUTE(0), bits); 17484 HDA_AMP_MUTE, bits);
17129 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 17485 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17130 AMP_IN_MUTE(0), bits); 17486 HDA_AMP_MUTE, bits);
17131 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, 17487 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17132 AMP_IN_MUTE(0), bits); 17488 HDA_AMP_MUTE, bits);
17133 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, 17489 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17134 AMP_IN_MUTE(0), bits); 17490 HDA_AMP_MUTE, bits);
17135} 17491}
17136 17492
17137static void alc662_f5z_speaker_automute(struct hda_codec *codec) 17493static void alc662_f5z_speaker_automute(struct hda_codec *codec)
@@ -17170,14 +17526,14 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17170 17526
17171 if (present1 || present2) { 17527 if (present1 || present2) {
17172 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 17528 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17173 AMP_IN_MUTE(0), AMP_IN_MUTE(0)); 17529 HDA_AMP_MUTE, HDA_AMP_MUTE);
17174 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 17530 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17175 AMP_IN_MUTE(0), AMP_IN_MUTE(0)); 17531 HDA_AMP_MUTE, HDA_AMP_MUTE);
17176 } else { 17532 } else {
17177 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 17533 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17178 AMP_IN_MUTE(0), 0); 17534 HDA_AMP_MUTE, 0);
17179 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 17535 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17180 AMP_IN_MUTE(0), 0); 17536 HDA_AMP_MUTE, 0);
17181 } 17537 }
17182} 17538}
17183 17539
@@ -17643,7 +17999,6 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
17643 ALC662_3ST_6ch_DIG), 17999 ALC662_3ST_6ch_DIG),
17644 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x", 18000 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17645 ALC663_ASUS_H13), 18001 ALC663_ASUS_H13),
17646 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
17647 {} 18002 {}
17648}; 18003};
17649 18004
@@ -18298,16 +18653,16 @@ static int patch_alc662(struct hda_codec *codec)
18298 18653
18299 codec->spec = spec; 18654 codec->spec = spec;
18300 18655
18656 alc_auto_parse_customize_define(codec);
18657
18301 alc_fix_pll_init(codec, 0x20, 0x04, 15); 18658 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18302 18659
18303 if (alc_read_coef_idx(codec, 0)==0x8020){ 18660 if (alc_read_coef_idx(codec, 0) == 0x8020)
18304 kfree(codec->chip_name); 18661 alc_codec_rename(codec, "ALC661");
18305 codec->chip_name = kstrdup("ALC661", GFP_KERNEL); 18662 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18306 if (!codec->chip_name) { 18663 codec->bus->pci->subsystem_vendor == 0x1025 &&
18307 alc_free(codec); 18664 spec->cdefine.platform_type == 1)
18308 return -ENOMEM; 18665 alc_codec_rename(codec, "ALC272X");
18309 }
18310 }
18311 18666
18312 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, 18667 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18313 alc662_models, 18668 alc662_models,
@@ -18357,18 +18712,20 @@ static int patch_alc662(struct hda_codec *codec)
18357 if (!spec->cap_mixer) 18712 if (!spec->cap_mixer)
18358 set_capture_mixer(codec); 18713 set_capture_mixer(codec);
18359 18714
18360 switch (codec->vendor_id) { 18715 if (spec->cdefine.enable_pcbeep) {
18361 case 0x10ec0662: 18716 switch (codec->vendor_id) {
18362 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 18717 case 0x10ec0662:
18363 break; 18718 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18364 case 0x10ec0272: 18719 break;
18365 case 0x10ec0663: 18720 case 0x10ec0272:
18366 case 0x10ec0665: 18721 case 0x10ec0663:
18367 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 18722 case 0x10ec0665:
18368 break; 18723 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18369 case 0x10ec0273: 18724 break;
18370 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); 18725 case 0x10ec0273:
18371 break; 18726 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18727 break;
18728 }
18372 } 18729 }
18373 spec->vmaster_nid = 0x02; 18730 spec->vmaster_nid = 0x02;
18374 18731