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.c3468
1 files changed, 1673 insertions, 1795 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fea976793ae..efb92c83c7a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -208,12 +208,6 @@ enum {
208 ALC885_MBP3, 208 ALC885_MBP3,
209 ALC885_MB5, 209 ALC885_MB5,
210 ALC885_IMAC24, 210 ALC885_IMAC24,
211 ALC882_AUTO,
212 ALC882_MODEL_LAST,
213};
214
215/* ALC883 models */
216enum {
217 ALC883_3ST_2ch_DIG, 211 ALC883_3ST_2ch_DIG,
218 ALC883_3ST_6ch_DIG, 212 ALC883_3ST_6ch_DIG,
219 ALC883_3ST_6ch, 213 ALC883_3ST_6ch,
@@ -241,13 +235,15 @@ enum {
241 ALC883_FUJITSU_PI2515, 235 ALC883_FUJITSU_PI2515,
242 ALC888_FUJITSU_XA3530, 236 ALC888_FUJITSU_XA3530,
243 ALC883_3ST_6ch_INTEL, 237 ALC883_3ST_6ch_INTEL,
238 ALC889A_INTEL,
239 ALC889_INTEL,
244 ALC888_ASUS_M90V, 240 ALC888_ASUS_M90V,
245 ALC888_ASUS_EEE1601, 241 ALC888_ASUS_EEE1601,
246 ALC889A_MB31, 242 ALC889A_MB31,
247 ALC1200_ASUS_P5Q, 243 ALC1200_ASUS_P5Q,
248 ALC883_SONY_VAIO_TT, 244 ALC883_SONY_VAIO_TT,
249 ALC883_AUTO, 245 ALC882_AUTO,
250 ALC883_MODEL_LAST, 246 ALC882_MODEL_LAST,
251}; 247};
252 248
253/* for GPIO Poll */ 249/* for GPIO Poll */
@@ -262,6 +258,14 @@ enum {
262 ALC_INIT_GPIO3, 258 ALC_INIT_GPIO3,
263}; 259};
264 260
261struct alc_mic_route {
262 hda_nid_t pin;
263 unsigned char mux_idx;
264 unsigned char amix_idx;
265};
266
267#define MUX_IDX_UNDEF ((unsigned char)-1)
268
265struct alc_spec { 269struct alc_spec {
266 /* codec parameterization */ 270 /* codec parameterization */
267 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 271 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
@@ -304,6 +308,8 @@ struct alc_spec {
304 unsigned int num_mux_defs; 308 unsigned int num_mux_defs;
305 const struct hda_input_mux *input_mux; 309 const struct hda_input_mux *input_mux;
306 unsigned int cur_mux[3]; 310 unsigned int cur_mux[3];
311 struct alc_mic_route ext_mic;
312 struct alc_mic_route int_mic;
307 313
308 /* channel model */ 314 /* channel model */
309 const struct hda_channel_mode *channel_mode; 315 const struct hda_channel_mode *channel_mode;
@@ -320,6 +326,8 @@ struct alc_spec {
320 struct snd_array kctls; 326 struct snd_array kctls;
321 struct hda_input_mux private_imux[3]; 327 struct hda_input_mux private_imux[3];
322 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 328 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
329 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
330 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
323 331
324 /* hooks */ 332 /* hooks */
325 void (*init_hook)(struct hda_codec *codec); 333 void (*init_hook)(struct hda_codec *codec);
@@ -329,6 +337,7 @@ struct alc_spec {
329 unsigned int sense_updated: 1; 337 unsigned int sense_updated: 1;
330 unsigned int jack_present: 1; 338 unsigned int jack_present: 1;
331 unsigned int master_sw: 1; 339 unsigned int master_sw: 1;
340 unsigned int auto_mic:1;
332 341
333 /* other flags */ 342 /* other flags */
334 unsigned int no_analog :1; /* digital I/O only */ 343 unsigned int no_analog :1; /* digital I/O only */
@@ -370,6 +379,7 @@ struct alc_config_preset {
370 unsigned int num_mux_defs; 379 unsigned int num_mux_defs;
371 const struct hda_input_mux *input_mux; 380 const struct hda_input_mux *input_mux;
372 void (*unsol_event)(struct hda_codec *, unsigned int); 381 void (*unsol_event)(struct hda_codec *, unsigned int);
382 void (*setup)(struct hda_codec *);
373 void (*init_hook)(struct hda_codec *); 383 void (*init_hook)(struct hda_codec *);
374#ifdef CONFIG_SND_HDA_POWER_SAVE 384#ifdef CONFIG_SND_HDA_POWER_SAVE
375 struct hda_amp_list *loopbacks; 385 struct hda_amp_list *loopbacks;
@@ -417,7 +427,7 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
417 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 427 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
418 imux = &spec->input_mux[mux_idx]; 428 imux = &spec->input_mux[mux_idx];
419 429
420 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 430 type = get_wcaps_type(get_wcaps(codec, nid));
421 if (type == AC_WID_AUD_MIX) { 431 if (type == AC_WID_AUD_MIX) {
422 /* Matrix-mixer style (e.g. ALC882) */ 432 /* Matrix-mixer style (e.g. ALC882) */
423 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 433 unsigned int *cur_val = &spec->cur_mux[adc_idx];
@@ -842,9 +852,10 @@ static void print_realtek_coef(struct snd_info_buffer *buffer,
842/* 852/*
843 * set up from the preset table 853 * set up from the preset table
844 */ 854 */
845static void setup_preset(struct alc_spec *spec, 855static void setup_preset(struct hda_codec *codec,
846 const struct alc_config_preset *preset) 856 const struct alc_config_preset *preset)
847{ 857{
858 struct alc_spec *spec = codec->spec;
848 int i; 859 int i;
849 860
850 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) 861 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
@@ -886,6 +897,9 @@ static void setup_preset(struct alc_spec *spec,
886#ifdef CONFIG_SND_HDA_POWER_SAVE 897#ifdef CONFIG_SND_HDA_POWER_SAVE
887 spec->loopback.amplist = preset->loopbacks; 898 spec->loopback.amplist = preset->loopbacks;
888#endif 899#endif
900
901 if (preset->setup)
902 preset->setup(codec);
889} 903}
890 904
891/* Enable GPIO mask and set output */ 905/* Enable GPIO mask and set output */
@@ -965,30 +979,64 @@ static void alc_automute_pin(struct hda_codec *codec)
965 } 979 }
966} 980}
967 981
968#if 0 /* it's broken in some cases -- temporarily disabled */ 982static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
983 hda_nid_t nid)
984{
985 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
986 int i, nums;
987
988 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
989 for (i = 0; i < nums; i++)
990 if (conn[i] == nid)
991 return i;
992 return -1;
993}
994
969static void alc_mic_automute(struct hda_codec *codec) 995static void alc_mic_automute(struct hda_codec *codec)
970{ 996{
971 struct alc_spec *spec = codec->spec; 997 struct alc_spec *spec = codec->spec;
972 unsigned int present; 998 struct alc_mic_route *dead, *alive;
973 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; 999 unsigned int present, type;
974 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; 1000 hda_nid_t cap_nid;
975 unsigned int mix_nid = spec->capsrc_nids[0]; 1001
976 unsigned int capsrc_idx_mic, capsrc_idx_fmic; 1002 if (!spec->auto_mic)
977 1003 return;
978 capsrc_idx_mic = mic_nid - 0x18; 1004 if (!spec->int_mic.pin || !spec->ext_mic.pin)
979 capsrc_idx_fmic = fmic_nid - 0x18; 1005 return;
980 present = snd_hda_codec_read(codec, mic_nid, 0, 1006 if (snd_BUG_ON(!spec->adc_nids))
981 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1007 return;
982 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1008
983 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); 1009 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
984 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1010
985 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); 1011 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
986 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, 1012 AC_VERB_GET_PIN_SENSE, 0);
987 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 1013 present &= AC_PINSENSE_PRESENCE;
1014 if (present) {
1015 alive = &spec->ext_mic;
1016 dead = &spec->int_mic;
1017 } else {
1018 alive = &spec->int_mic;
1019 dead = &spec->ext_mic;
1020 }
1021
1022 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1023 if (type == AC_WID_AUD_MIX) {
1024 /* Matrix-mixer style (e.g. ALC882) */
1025 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1026 alive->mux_idx,
1027 HDA_AMP_MUTE, 0);
1028 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1029 dead->mux_idx,
1030 HDA_AMP_MUTE, HDA_AMP_MUTE);
1031 } else {
1032 /* MUX style (e.g. ALC880) */
1033 snd_hda_codec_write_cache(codec, cap_nid, 0,
1034 AC_VERB_SET_CONNECT_SEL,
1035 alive->mux_idx);
1036 }
1037
1038 /* FIXME: analog mixer */
988} 1039}
989#else
990#define alc_mic_automute(codec) do {} while(0) /* NOP */
991#endif /* disabled */
992 1040
993/* unsolicited event for HP jack sensing */ 1041/* unsolicited event for HP jack sensing */
994static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 1042static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1031,6 +1079,16 @@ static void alc888_coef_init(struct hda_codec *codec)
1031 AC_VERB_SET_PROC_COEF, 0x3030); 1079 AC_VERB_SET_PROC_COEF, 0x3030);
1032} 1080}
1033 1081
1082static void alc889_coef_init(struct hda_codec *codec)
1083{
1084 unsigned int tmp;
1085
1086 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1087 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1089 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1090}
1091
1034static void alc_auto_init_amp(struct hda_codec *codec, int type) 1092static void alc_auto_init_amp(struct hda_codec *codec, int type)
1035{ 1093{
1036 unsigned int tmp; 1094 unsigned int tmp;
@@ -1088,15 +1146,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
1088 case 0x10ec0885: 1146 case 0x10ec0885:
1089 case 0x10ec0887: 1147 case 0x10ec0887:
1090 case 0x10ec0889: 1148 case 0x10ec0889:
1091 snd_hda_codec_write(codec, 0x20, 0, 1149 alc889_coef_init(codec);
1092 AC_VERB_SET_COEF_INDEX, 7);
1093 tmp = snd_hda_codec_read(codec, 0x20, 0,
1094 AC_VERB_GET_PROC_COEF, 0);
1095 snd_hda_codec_write(codec, 0x20, 0,
1096 AC_VERB_SET_COEF_INDEX, 7);
1097 snd_hda_codec_write(codec, 0x20, 0,
1098 AC_VERB_SET_PROC_COEF,
1099 tmp | 0x2010);
1100 break; 1150 break;
1101 case 0x10ec0888: 1151 case 0x10ec0888:
1102 alc888_coef_init(codec); 1152 alc888_coef_init(codec);
@@ -1142,6 +1192,55 @@ static void alc_init_auto_hp(struct hda_codec *codec)
1142 spec->unsol_event = alc_sku_unsol_event; 1192 spec->unsol_event = alc_sku_unsol_event;
1143} 1193}
1144 1194
1195static void alc_init_auto_mic(struct hda_codec *codec)
1196{
1197 struct alc_spec *spec = codec->spec;
1198 struct auto_pin_cfg *cfg = &spec->autocfg;
1199 hda_nid_t fixed, ext;
1200 int i;
1201
1202 /* there must be only two mic inputs exclusively */
1203 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1204 if (cfg->input_pins[i])
1205 return;
1206
1207 fixed = ext = 0;
1208 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1209 hda_nid_t nid = cfg->input_pins[i];
1210 unsigned int defcfg;
1211 if (!nid)
1212 return;
1213 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1214 switch (get_defcfg_connect(defcfg)) {
1215 case AC_JACK_PORT_FIXED:
1216 if (fixed)
1217 return; /* already occupied */
1218 fixed = nid;
1219 break;
1220 case AC_JACK_PORT_COMPLEX:
1221 if (ext)
1222 return; /* already occupied */
1223 ext = nid;
1224 break;
1225 default:
1226 return; /* invalid entry */
1227 }
1228 }
1229 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1230 return; /* no unsol support */
1231 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1232 ext, fixed);
1233 spec->ext_mic.pin = ext;
1234 spec->int_mic.pin = fixed;
1235 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1236 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1237 spec->auto_mic = 1;
1238 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1239 AC_VERB_SET_UNSOLICITED_ENABLE,
1240 AC_USRSP_EN | ALC880_MIC_EVENT);
1241 spec->unsol_event = alc_sku_unsol_event;
1242}
1243
1145/* check subsystem ID and set up device-specific initialization; 1244/* check subsystem ID and set up device-specific initialization;
1146 * return 1 if initialized, 0 if invalid SSID 1245 * return 1 if initialized, 0 if invalid SSID
1147 */ 1246 */
@@ -1243,6 +1342,7 @@ do_sku:
1243 } 1342 }
1244 1343
1245 alc_init_auto_hp(codec); 1344 alc_init_auto_hp(codec);
1345 alc_init_auto_mic(codec);
1246 return 1; 1346 return 1;
1247} 1347}
1248 1348
@@ -1255,6 +1355,7 @@ static void alc_ssid_check(struct hda_codec *codec,
1255 "Enable default setup for auto mode as fallback\n"); 1355 "Enable default setup for auto mode as fallback\n");
1256 spec->init_amp = ALC_INIT_DEFAULT; 1356 spec->init_amp = ALC_INIT_DEFAULT;
1257 alc_init_auto_hp(codec); 1357 alc_init_auto_hp(codec);
1358 alc_init_auto_mic(codec);
1258 } 1359 }
1259} 1360}
1260 1361
@@ -1436,7 +1537,25 @@ static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1436 alc_automute_amp(codec); 1537 alc_automute_amp(codec);
1437} 1538}
1438 1539
1439static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec) 1540static void alc889_automute_setup(struct hda_codec *codec)
1541{
1542 struct alc_spec *spec = codec->spec;
1543
1544 spec->autocfg.hp_pins[0] = 0x15;
1545 spec->autocfg.speaker_pins[0] = 0x14;
1546 spec->autocfg.speaker_pins[1] = 0x16;
1547 spec->autocfg.speaker_pins[2] = 0x17;
1548 spec->autocfg.speaker_pins[3] = 0x19;
1549 spec->autocfg.speaker_pins[4] = 0x1a;
1550}
1551
1552static void alc889_intel_init_hook(struct hda_codec *codec)
1553{
1554 alc889_coef_init(codec);
1555 alc_automute_amp(codec);
1556}
1557
1558static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1440{ 1559{
1441 struct alc_spec *spec = codec->spec; 1560 struct alc_spec *spec = codec->spec;
1442 1561
@@ -1444,7 +1563,6 @@ static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1444 spec->autocfg.hp_pins[1] = 0x1b; /* hp */ 1563 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1445 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ 1564 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1446 spec->autocfg.speaker_pins[1] = 0x15; /* bass */ 1565 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1447 alc_automute_amp(codec);
1448} 1566}
1449 1567
1450/* 1568/*
@@ -1643,16 +1761,15 @@ static struct snd_kcontrol_new alc888_base_mixer[] = {
1643 { } /* end */ 1761 { } /* end */
1644}; 1762};
1645 1763
1646static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec) 1764static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
1647{ 1765{
1648 struct alc_spec *spec = codec->spec; 1766 struct alc_spec *spec = codec->spec;
1649 1767
1650 spec->autocfg.hp_pins[0] = 0x15; 1768 spec->autocfg.hp_pins[0] = 0x15;
1651 spec->autocfg.speaker_pins[0] = 0x14; 1769 spec->autocfg.speaker_pins[0] = 0x14;
1652 alc_automute_amp(codec);
1653} 1770}
1654 1771
1655static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec) 1772static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
1656{ 1773{
1657 struct alc_spec *spec = codec->spec; 1774 struct alc_spec *spec = codec->spec;
1658 1775
@@ -1660,10 +1777,9 @@ static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1660 spec->autocfg.speaker_pins[0] = 0x14; 1777 spec->autocfg.speaker_pins[0] = 0x14;
1661 spec->autocfg.speaker_pins[1] = 0x16; 1778 spec->autocfg.speaker_pins[1] = 0x16;
1662 spec->autocfg.speaker_pins[2] = 0x17; 1779 spec->autocfg.speaker_pins[2] = 0x17;
1663 alc_automute_amp(codec);
1664} 1780}
1665 1781
1666static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) 1782static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
1667{ 1783{
1668 struct alc_spec *spec = codec->spec; 1784 struct alc_spec *spec = codec->spec;
1669 1785
@@ -1671,7 +1787,6 @@ static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
1671 spec->autocfg.speaker_pins[0] = 0x14; 1787 spec->autocfg.speaker_pins[0] = 0x14;
1672 spec->autocfg.speaker_pins[1] = 0x16; 1788 spec->autocfg.speaker_pins[1] = 0x16;
1673 spec->autocfg.speaker_pins[2] = 0x1b; 1789 spec->autocfg.speaker_pins[2] = 0x1b;
1674 alc_automute_amp(codec);
1675} 1790}
1676 1791
1677/* 1792/*
@@ -2651,13 +2766,17 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2651 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); 2766 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2652} 2767}
2653 2768
2654static void alc880_uniwill_init_hook(struct hda_codec *codec) 2769static void alc880_uniwill_setup(struct hda_codec *codec)
2655{ 2770{
2656 struct alc_spec *spec = codec->spec; 2771 struct alc_spec *spec = codec->spec;
2657 2772
2658 spec->autocfg.hp_pins[0] = 0x14; 2773 spec->autocfg.hp_pins[0] = 0x14;
2659 spec->autocfg.speaker_pins[0] = 0x15; 2774 spec->autocfg.speaker_pins[0] = 0x15;
2660 spec->autocfg.speaker_pins[0] = 0x16; 2775 spec->autocfg.speaker_pins[0] = 0x16;
2776}
2777
2778static void alc880_uniwill_init_hook(struct hda_codec *codec)
2779{
2661 alc_automute_amp(codec); 2780 alc_automute_amp(codec);
2662 alc880_uniwill_mic_automute(codec); 2781 alc880_uniwill_mic_automute(codec);
2663} 2782}
@@ -2678,13 +2797,12 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2678 } 2797 }
2679} 2798}
2680 2799
2681static void alc880_uniwill_p53_init_hook(struct hda_codec *codec) 2800static void alc880_uniwill_p53_setup(struct hda_codec *codec)
2682{ 2801{
2683 struct alc_spec *spec = codec->spec; 2802 struct alc_spec *spec = codec->spec;
2684 2803
2685 spec->autocfg.hp_pins[0] = 0x14; 2804 spec->autocfg.hp_pins[0] = 0x14;
2686 spec->autocfg.speaker_pins[0] = 0x15; 2805 spec->autocfg.speaker_pins[0] = 0x15;
2687 alc_automute_amp(codec);
2688} 2806}
2689 2807
2690static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 2808static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -2947,13 +3065,12 @@ static struct hda_verb alc880_lg_init_verbs[] = {
2947}; 3065};
2948 3066
2949/* toggle speaker-output according to the hp-jack state */ 3067/* toggle speaker-output according to the hp-jack state */
2950static void alc880_lg_init_hook(struct hda_codec *codec) 3068static void alc880_lg_setup(struct hda_codec *codec)
2951{ 3069{
2952 struct alc_spec *spec = codec->spec; 3070 struct alc_spec *spec = codec->spec;
2953 3071
2954 spec->autocfg.hp_pins[0] = 0x1b; 3072 spec->autocfg.hp_pins[0] = 0x1b;
2955 spec->autocfg.speaker_pins[0] = 0x17; 3073 spec->autocfg.speaker_pins[0] = 0x17;
2956 alc_automute_amp(codec);
2957} 3074}
2958 3075
2959/* 3076/*
@@ -3032,13 +3149,12 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
3032}; 3149};
3033 3150
3034/* toggle speaker-output according to the hp-jack state */ 3151/* toggle speaker-output according to the hp-jack state */
3035static void alc880_lg_lw_init_hook(struct hda_codec *codec) 3152static void alc880_lg_lw_setup(struct hda_codec *codec)
3036{ 3153{
3037 struct alc_spec *spec = codec->spec; 3154 struct alc_spec *spec = codec->spec;
3038 3155
3039 spec->autocfg.hp_pins[0] = 0x1b; 3156 spec->autocfg.hp_pins[0] = 0x1b;
3040 spec->autocfg.speaker_pins[0] = 0x14; 3157 spec->autocfg.speaker_pins[0] = 0x14;
3041 alc_automute_amp(codec);
3042} 3158}
3043 3159
3044static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { 3160static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
@@ -3104,13 +3220,12 @@ static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3104 alc880_medion_rim_automute(codec); 3220 alc880_medion_rim_automute(codec);
3105} 3221}
3106 3222
3107static void alc880_medion_rim_init_hook(struct hda_codec *codec) 3223static void alc880_medion_rim_setup(struct hda_codec *codec)
3108{ 3224{
3109 struct alc_spec *spec = codec->spec; 3225 struct alc_spec *spec = codec->spec;
3110 3226
3111 spec->autocfg.hp_pins[0] = 0x14; 3227 spec->autocfg.hp_pins[0] = 0x14;
3112 spec->autocfg.speaker_pins[0] = 0x1b; 3228 spec->autocfg.speaker_pins[0] = 0x1b;
3113 alc880_medion_rim_automute(codec);
3114} 3229}
3115 3230
3116#ifdef CONFIG_SND_HDA_POWER_SAVE 3231#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -3977,7 +4092,8 @@ static struct alc_config_preset alc880_presets[] = {
3977 .channel_mode = alc880_2_jack_modes, 4092 .channel_mode = alc880_2_jack_modes,
3978 .input_mux = &alc880_f1734_capture_source, 4093 .input_mux = &alc880_f1734_capture_source,
3979 .unsol_event = alc880_uniwill_p53_unsol_event, 4094 .unsol_event = alc880_uniwill_p53_unsol_event,
3980 .init_hook = alc880_uniwill_p53_init_hook, 4095 .setup = alc880_uniwill_p53_setup,
4096 .init_hook = alc_automute_amp,
3981 }, 4097 },
3982 [ALC880_ASUS] = { 4098 [ALC880_ASUS] = {
3983 .mixers = { alc880_asus_mixer }, 4099 .mixers = { alc880_asus_mixer },
@@ -4054,6 +4170,7 @@ static struct alc_config_preset alc880_presets[] = {
4054 .need_dac_fix = 1, 4170 .need_dac_fix = 1,
4055 .input_mux = &alc880_capture_source, 4171 .input_mux = &alc880_capture_source,
4056 .unsol_event = alc880_uniwill_unsol_event, 4172 .unsol_event = alc880_uniwill_unsol_event,
4173 .setup = alc880_uniwill_setup,
4057 .init_hook = alc880_uniwill_init_hook, 4174 .init_hook = alc880_uniwill_init_hook,
4058 }, 4175 },
4059 [ALC880_UNIWILL_P53] = { 4176 [ALC880_UNIWILL_P53] = {
@@ -4066,7 +4183,8 @@ static struct alc_config_preset alc880_presets[] = {
4066 .channel_mode = alc880_threestack_modes, 4183 .channel_mode = alc880_threestack_modes,
4067 .input_mux = &alc880_capture_source, 4184 .input_mux = &alc880_capture_source,
4068 .unsol_event = alc880_uniwill_p53_unsol_event, 4185 .unsol_event = alc880_uniwill_p53_unsol_event,
4069 .init_hook = alc880_uniwill_p53_init_hook, 4186 .setup = alc880_uniwill_p53_setup,
4187 .init_hook = alc_automute_amp,
4070 }, 4188 },
4071 [ALC880_FUJITSU] = { 4189 [ALC880_FUJITSU] = {
4072 .mixers = { alc880_fujitsu_mixer }, 4190 .mixers = { alc880_fujitsu_mixer },
@@ -4080,7 +4198,8 @@ static struct alc_config_preset alc880_presets[] = {
4080 .channel_mode = alc880_2_jack_modes, 4198 .channel_mode = alc880_2_jack_modes,
4081 .input_mux = &alc880_capture_source, 4199 .input_mux = &alc880_capture_source,
4082 .unsol_event = alc880_uniwill_p53_unsol_event, 4200 .unsol_event = alc880_uniwill_p53_unsol_event,
4083 .init_hook = alc880_uniwill_p53_init_hook, 4201 .setup = alc880_uniwill_p53_setup,
4202 .init_hook = alc_automute_amp,
4084 }, 4203 },
4085 [ALC880_CLEVO] = { 4204 [ALC880_CLEVO] = {
4086 .mixers = { alc880_three_stack_mixer }, 4205 .mixers = { alc880_three_stack_mixer },
@@ -4106,7 +4225,8 @@ static struct alc_config_preset alc880_presets[] = {
4106 .need_dac_fix = 1, 4225 .need_dac_fix = 1,
4107 .input_mux = &alc880_lg_capture_source, 4226 .input_mux = &alc880_lg_capture_source,
4108 .unsol_event = alc_automute_amp_unsol_event, 4227 .unsol_event = alc_automute_amp_unsol_event,
4109 .init_hook = alc880_lg_init_hook, 4228 .setup = alc880_lg_setup,
4229 .init_hook = alc_automute_amp,
4110#ifdef CONFIG_SND_HDA_POWER_SAVE 4230#ifdef CONFIG_SND_HDA_POWER_SAVE
4111 .loopbacks = alc880_lg_loopbacks, 4231 .loopbacks = alc880_lg_loopbacks,
4112#endif 4232#endif
@@ -4122,7 +4242,8 @@ static struct alc_config_preset alc880_presets[] = {
4122 .channel_mode = alc880_lg_lw_modes, 4242 .channel_mode = alc880_lg_lw_modes,
4123 .input_mux = &alc880_lg_lw_capture_source, 4243 .input_mux = &alc880_lg_lw_capture_source,
4124 .unsol_event = alc_automute_amp_unsol_event, 4244 .unsol_event = alc_automute_amp_unsol_event,
4125 .init_hook = alc880_lg_lw_init_hook, 4245 .setup = alc880_lg_lw_setup,
4246 .init_hook = alc_automute_amp,
4126 }, 4247 },
4127 [ALC880_MEDION_RIM] = { 4248 [ALC880_MEDION_RIM] = {
4128 .mixers = { alc880_medion_rim_mixer }, 4249 .mixers = { alc880_medion_rim_mixer },
@@ -4136,7 +4257,8 @@ static struct alc_config_preset alc880_presets[] = {
4136 .channel_mode = alc880_2_jack_modes, 4257 .channel_mode = alc880_2_jack_modes,
4137 .input_mux = &alc880_medion_rim_capture_source, 4258 .input_mux = &alc880_medion_rim_capture_source,
4138 .unsol_event = alc880_medion_rim_unsol_event, 4259 .unsol_event = alc880_medion_rim_unsol_event,
4139 .init_hook = alc880_medion_rim_init_hook, 4260 .setup = alc880_medion_rim_setup,
4261 .init_hook = alc880_medion_rim_automute,
4140 }, 4262 },
4141#ifdef CONFIG_SND_DEBUG 4263#ifdef CONFIG_SND_DEBUG
4142 [ALC880_TEST] = { 4264 [ALC880_TEST] = {
@@ -4505,12 +4627,6 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4505 &dig_nid, 1); 4627 &dig_nid, 1);
4506 if (err < 0) 4628 if (err < 0)
4507 continue; 4629 continue;
4508 if (dig_nid > 0x7f) {
4509 printk(KERN_ERR "alc880_auto: invalid dig_nid "
4510 "connection 0x%x for NID 0x%x\n", dig_nid,
4511 spec->autocfg.dig_out_pins[i]);
4512 continue;
4513 }
4514 if (!i) 4630 if (!i)
4515 spec->multiout.dig_out_nid = dig_nid; 4631 spec->multiout.dig_out_nid = dig_nid;
4516 else { 4632 else {
@@ -4547,8 +4663,42 @@ static void alc880_auto_init(struct hda_codec *codec)
4547 alc_inithook(codec); 4663 alc_inithook(codec);
4548} 4664}
4549 4665
4550static void set_capture_mixer(struct alc_spec *spec) 4666/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4667 * one of two digital mic pins, e.g. on ALC272
4668 */
4669static void fixup_automic_adc(struct hda_codec *codec)
4670{
4671 struct alc_spec *spec = codec->spec;
4672 int i;
4673
4674 for (i = 0; i < spec->num_adc_nids; i++) {
4675 hda_nid_t cap = spec->capsrc_nids ?
4676 spec->capsrc_nids[i] : spec->adc_nids[i];
4677 int iidx, eidx;
4678
4679 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4680 if (iidx < 0)
4681 continue;
4682 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4683 if (eidx < 0)
4684 continue;
4685 spec->int_mic.mux_idx = iidx;
4686 spec->ext_mic.mux_idx = eidx;
4687 if (spec->capsrc_nids)
4688 spec->capsrc_nids += i;
4689 spec->adc_nids += i;
4690 spec->num_adc_nids = 1;
4691 return;
4692 }
4693 snd_printd(KERN_INFO "hda_codec: %s: "
4694 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4695 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4696 spec->auto_mic = 0; /* disable auto-mic to be sure */
4697}
4698
4699static void set_capture_mixer(struct hda_codec *codec)
4551{ 4700{
4701 struct alc_spec *spec = codec->spec;
4552 static struct snd_kcontrol_new *caps[2][3] = { 4702 static struct snd_kcontrol_new *caps[2][3] = {
4553 { alc_capture_mixer_nosrc1, 4703 { alc_capture_mixer_nosrc1,
4554 alc_capture_mixer_nosrc2, 4704 alc_capture_mixer_nosrc2,
@@ -4559,7 +4709,10 @@ static void set_capture_mixer(struct alc_spec *spec)
4559 }; 4709 };
4560 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { 4710 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4561 int mux; 4711 int mux;
4562 if (spec->input_mux && spec->input_mux->num_items > 1) 4712 if (spec->auto_mic) {
4713 mux = 0;
4714 fixup_automic_adc(codec);
4715 } else if (spec->input_mux && spec->input_mux->num_items > 1)
4563 mux = 1; 4716 mux = 1;
4564 else 4717 else
4565 mux = 0; 4718 mux = 0;
@@ -4590,8 +4743,8 @@ static int patch_alc880(struct hda_codec *codec)
4590 alc880_models, 4743 alc880_models,
4591 alc880_cfg_tbl); 4744 alc880_cfg_tbl);
4592 if (board_config < 0) { 4745 if (board_config < 0) {
4593 printk(KERN_INFO "hda_codec: Unknown model for %s, " 4746 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4594 "trying auto-probe from BIOS...\n", codec->chip_name); 4747 codec->chip_name);
4595 board_config = ALC880_AUTO; 4748 board_config = ALC880_AUTO;
4596 } 4749 }
4597 4750
@@ -4616,7 +4769,7 @@ static int patch_alc880(struct hda_codec *codec)
4616 } 4769 }
4617 4770
4618 if (board_config != ALC880_AUTO) 4771 if (board_config != ALC880_AUTO)
4619 setup_preset(spec, &alc880_presets[board_config]); 4772 setup_preset(codec, &alc880_presets[board_config]);
4620 4773
4621 spec->stream_analog_playback = &alc880_pcm_analog_playback; 4774 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4622 spec->stream_analog_capture = &alc880_pcm_analog_capture; 4775 spec->stream_analog_capture = &alc880_pcm_analog_capture;
@@ -4629,7 +4782,7 @@ static int patch_alc880(struct hda_codec *codec)
4629 /* check whether NID 0x07 is valid */ 4782 /* check whether NID 0x07 is valid */
4630 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 4783 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
4631 /* get type */ 4784 /* get type */
4632 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 4785 wcap = get_wcaps_type(wcap);
4633 if (wcap != AC_WID_AUD_IN) { 4786 if (wcap != AC_WID_AUD_IN) {
4634 spec->adc_nids = alc880_adc_nids_alt; 4787 spec->adc_nids = alc880_adc_nids_alt;
4635 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 4788 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
@@ -4638,7 +4791,7 @@ static int patch_alc880(struct hda_codec *codec)
4638 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); 4791 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
4639 } 4792 }
4640 } 4793 }
4641 set_capture_mixer(spec); 4794 set_capture_mixer(codec);
4642 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4795 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4643 4796
4644 spec->vmaster_nid = 0x0c; 4797 spec->vmaster_nid = 0x0c;
@@ -6234,8 +6387,7 @@ static int patch_alc260(struct hda_codec *codec)
6234 alc260_models, 6387 alc260_models,
6235 alc260_cfg_tbl); 6388 alc260_cfg_tbl);
6236 if (board_config < 0) { 6389 if (board_config < 0) {
6237 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, " 6390 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6238 "trying auto-probe from BIOS...\n",
6239 codec->chip_name); 6391 codec->chip_name);
6240 board_config = ALC260_AUTO; 6392 board_config = ALC260_AUTO;
6241 } 6393 }
@@ -6261,7 +6413,7 @@ static int patch_alc260(struct hda_codec *codec)
6261 } 6413 }
6262 6414
6263 if (board_config != ALC260_AUTO) 6415 if (board_config != ALC260_AUTO)
6264 setup_preset(spec, &alc260_presets[board_config]); 6416 setup_preset(codec, &alc260_presets[board_config]);
6265 6417
6266 spec->stream_analog_playback = &alc260_pcm_analog_playback; 6418 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6267 spec->stream_analog_capture = &alc260_pcm_analog_capture; 6419 spec->stream_analog_capture = &alc260_pcm_analog_capture;
@@ -6272,7 +6424,7 @@ static int patch_alc260(struct hda_codec *codec)
6272 if (!spec->adc_nids && spec->input_mux) { 6424 if (!spec->adc_nids && spec->input_mux) {
6273 /* check whether NID 0x04 is valid */ 6425 /* check whether NID 0x04 is valid */
6274 unsigned int wcap = get_wcaps(codec, 0x04); 6426 unsigned int wcap = get_wcaps(codec, 0x04);
6275 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 6427 wcap = get_wcaps_type(wcap);
6276 /* get type */ 6428 /* get type */
6277 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 6429 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6278 spec->adc_nids = alc260_adc_nids_alt; 6430 spec->adc_nids = alc260_adc_nids_alt;
@@ -6282,7 +6434,7 @@ static int patch_alc260(struct hda_codec *codec)
6282 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 6434 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6283 } 6435 }
6284 } 6436 }
6285 set_capture_mixer(spec); 6437 set_capture_mixer(codec);
6286 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); 6438 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
6287 6439
6288 spec->vmaster_nid = 0x08; 6440 spec->vmaster_nid = 0x08;
@@ -6301,7 +6453,7 @@ static int patch_alc260(struct hda_codec *codec)
6301 6453
6302 6454
6303/* 6455/*
6304 * ALC882 support 6456 * ALC882/883/885/888/889 support
6305 * 6457 *
6306 * ALC882 is almost identical with ALC880 but has cleaner and more flexible 6458 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6307 * configuration. Each pin widget can choose any input DACs and a mixer. 6459 * configuration. Each pin widget can choose any input DACs and a mixer.
@@ -6313,22 +6465,35 @@ static int patch_alc260(struct hda_codec *codec)
6313 */ 6465 */
6314#define ALC882_DIGOUT_NID 0x06 6466#define ALC882_DIGOUT_NID 0x06
6315#define ALC882_DIGIN_NID 0x0a 6467#define ALC882_DIGIN_NID 0x0a
6468#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6469#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6470#define ALC1200_DIGOUT_NID 0x10
6471
6316 6472
6317static struct hda_channel_mode alc882_ch_modes[1] = { 6473static struct hda_channel_mode alc882_ch_modes[1] = {
6318 { 8, NULL } 6474 { 8, NULL }
6319}; 6475};
6320 6476
6477/* DACs */
6321static hda_nid_t alc882_dac_nids[4] = { 6478static hda_nid_t alc882_dac_nids[4] = {
6322 /* front, rear, clfe, rear_surr */ 6479 /* front, rear, clfe, rear_surr */
6323 0x02, 0x03, 0x04, 0x05 6480 0x02, 0x03, 0x04, 0x05
6324}; 6481};
6482#define alc883_dac_nids alc882_dac_nids
6325 6483
6326/* identical with ALC880 */ 6484/* ADCs */
6327#define alc882_adc_nids alc880_adc_nids 6485#define alc882_adc_nids alc880_adc_nids
6328#define alc882_adc_nids_alt alc880_adc_nids_alt 6486#define alc882_adc_nids_alt alc880_adc_nids_alt
6487#define alc883_adc_nids alc882_adc_nids_alt
6488static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6489static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6490#define alc889_adc_nids alc880_adc_nids
6329 6491
6330static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; 6492static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6331static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; 6493static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6494#define alc883_capsrc_nids alc882_capsrc_nids_alt
6495static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6496#define alc889_capsrc_nids alc882_capsrc_nids
6332 6497
6333/* input MUX */ 6498/* input MUX */
6334/* FIXME: should be a matrix-type input source selection */ 6499/* FIXME: should be a matrix-type input source selection */
@@ -6343,6 +6508,17 @@ static struct hda_input_mux alc882_capture_source = {
6343 }, 6508 },
6344}; 6509};
6345 6510
6511#define alc883_capture_source alc882_capture_source
6512
6513static struct hda_input_mux alc889_capture_source = {
6514 .num_items = 3,
6515 .items = {
6516 { "Front Mic", 0x0 },
6517 { "Mic", 0x3 },
6518 { "Line", 0x2 },
6519 },
6520};
6521
6346static struct hda_input_mux mb5_capture_source = { 6522static struct hda_input_mux mb5_capture_source = {
6347 .num_items = 3, 6523 .num_items = 3,
6348 .items = { 6524 .items = {
@@ -6352,6 +6528,77 @@ static struct hda_input_mux mb5_capture_source = {
6352 }, 6528 },
6353}; 6529};
6354 6530
6531static struct hda_input_mux alc883_3stack_6ch_intel = {
6532 .num_items = 4,
6533 .items = {
6534 { "Mic", 0x1 },
6535 { "Front Mic", 0x0 },
6536 { "Line", 0x2 },
6537 { "CD", 0x4 },
6538 },
6539};
6540
6541static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6542 .num_items = 2,
6543 .items = {
6544 { "Mic", 0x1 },
6545 { "Line", 0x2 },
6546 },
6547};
6548
6549static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6550 .num_items = 4,
6551 .items = {
6552 { "Mic", 0x0 },
6553 { "iMic", 0x1 },
6554 { "Line", 0x2 },
6555 { "CD", 0x4 },
6556 },
6557};
6558
6559static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6560 .num_items = 2,
6561 .items = {
6562 { "Mic", 0x0 },
6563 { "Int Mic", 0x1 },
6564 },
6565};
6566
6567static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6568 .num_items = 3,
6569 .items = {
6570 { "Mic", 0x0 },
6571 { "Front Mic", 0x1 },
6572 { "Line", 0x4 },
6573 },
6574};
6575
6576static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6577 .num_items = 2,
6578 .items = {
6579 { "Mic", 0x0 },
6580 { "Line", 0x2 },
6581 },
6582};
6583
6584static struct hda_input_mux alc889A_mb31_capture_source = {
6585 .num_items = 2,
6586 .items = {
6587 { "Mic", 0x0 },
6588 /* Front Mic (0x01) unused */
6589 { "Line", 0x2 },
6590 /* Line 2 (0x03) unused */
6591 /* CD (0x04) unsused? */
6592 },
6593};
6594
6595/*
6596 * 2ch mode
6597 */
6598static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6599 { 2, NULL }
6600};
6601
6355/* 6602/*
6356 * 2ch mode 6603 * 2ch mode
6357 */ 6604 */
@@ -6364,6 +6611,18 @@ static struct hda_verb alc882_3ST_ch2_init[] = {
6364}; 6611};
6365 6612
6366/* 6613/*
6614 * 4ch mode
6615 */
6616static struct hda_verb alc882_3ST_ch4_init[] = {
6617 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6618 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6619 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6620 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6621 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6622 { } /* end */
6623};
6624
6625/*
6367 * 6ch mode 6626 * 6ch mode
6368 */ 6627 */
6369static struct hda_verb alc882_3ST_ch6_init[] = { 6628static struct hda_verb alc882_3ST_ch6_init[] = {
@@ -6376,11 +6635,14 @@ static struct hda_verb alc882_3ST_ch6_init[] = {
6376 { } /* end */ 6635 { } /* end */
6377}; 6636};
6378 6637
6379static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { 6638static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
6380 { 2, alc882_3ST_ch2_init }, 6639 { 2, alc882_3ST_ch2_init },
6640 { 4, alc882_3ST_ch4_init },
6381 { 6, alc882_3ST_ch6_init }, 6641 { 6, alc882_3ST_ch6_init },
6382}; 6642};
6383 6643
6644#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6645
6384/* 6646/*
6385 * 6ch mode 6647 * 6ch mode
6386 */ 6648 */
@@ -6468,6 +6730,189 @@ static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6468 { 6, alc885_mb5_ch6_init }, 6730 { 6, alc885_mb5_ch6_init },
6469}; 6731};
6470 6732
6733
6734/*
6735 * 2ch mode
6736 */
6737static struct hda_verb alc883_4ST_ch2_init[] = {
6738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6740 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6741 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6744 { } /* end */
6745};
6746
6747/*
6748 * 4ch mode
6749 */
6750static struct hda_verb alc883_4ST_ch4_init[] = {
6751 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6752 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6753 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6754 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6755 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6756 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6757 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6758 { } /* end */
6759};
6760
6761/*
6762 * 6ch mode
6763 */
6764static struct hda_verb alc883_4ST_ch6_init[] = {
6765 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6766 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6767 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6768 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6769 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6770 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6771 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6772 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6773 { } /* end */
6774};
6775
6776/*
6777 * 8ch mode
6778 */
6779static struct hda_verb alc883_4ST_ch8_init[] = {
6780 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6781 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6782 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6783 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6784 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6785 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6786 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6787 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6788 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6789 { } /* end */
6790};
6791
6792static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6793 { 2, alc883_4ST_ch2_init },
6794 { 4, alc883_4ST_ch4_init },
6795 { 6, alc883_4ST_ch6_init },
6796 { 8, alc883_4ST_ch8_init },
6797};
6798
6799
6800/*
6801 * 2ch mode
6802 */
6803static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6804 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6805 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6806 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6807 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6808 { } /* end */
6809};
6810
6811/*
6812 * 4ch mode
6813 */
6814static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6815 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6816 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6817 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6818 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6819 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6820 { } /* end */
6821};
6822
6823/*
6824 * 6ch mode
6825 */
6826static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6827 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6828 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6829 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6830 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6831 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6832 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6833 { } /* end */
6834};
6835
6836static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6837 { 2, alc883_3ST_ch2_intel_init },
6838 { 4, alc883_3ST_ch4_intel_init },
6839 { 6, alc883_3ST_ch6_intel_init },
6840};
6841
6842/*
6843 * 2ch mode
6844 */
6845static struct hda_verb alc889_ch2_intel_init[] = {
6846 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6847 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6848 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6849 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6850 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6851 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6852 { } /* end */
6853};
6854
6855/*
6856 * 6ch mode
6857 */
6858static struct hda_verb alc889_ch6_intel_init[] = {
6859 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6860 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6861 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6862 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6865 { } /* end */
6866};
6867
6868/*
6869 * 8ch mode
6870 */
6871static struct hda_verb alc889_ch8_intel_init[] = {
6872 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6873 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6874 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6875 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6876 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
6877 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6878 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6879 { } /* end */
6880};
6881
6882static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6883 { 2, alc889_ch2_intel_init },
6884 { 6, alc889_ch6_intel_init },
6885 { 8, alc889_ch8_intel_init },
6886};
6887
6888/*
6889 * 6ch mode
6890 */
6891static struct hda_verb alc883_sixstack_ch6_init[] = {
6892 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6893 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6894 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6895 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6896 { } /* end */
6897};
6898
6899/*
6900 * 8ch mode
6901 */
6902static struct hda_verb alc883_sixstack_ch8_init[] = {
6903 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6904 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6905 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6906 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6907 { } /* end */
6908};
6909
6910static struct hda_channel_mode alc883_sixstack_modes[2] = {
6911 { 6, alc883_sixstack_ch6_init },
6912 { 8, alc883_sixstack_ch8_init },
6913};
6914
6915
6471/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 6916/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6472 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 6917 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6473 */ 6918 */
@@ -6603,7 +7048,7 @@ static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6603 { } /* end */ 7048 { } /* end */
6604}; 7049};
6605 7050
6606static struct hda_verb alc882_init_verbs[] = { 7051static struct hda_verb alc882_base_init_verbs[] = {
6607 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 7052 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
@@ -6621,6 +7066,13 @@ static struct hda_verb alc882_init_verbs[] = {
6621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7066 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7067 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6623 7068
7069 /* mute analog input loopbacks */
7070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7075
6624 /* Front Pin: output 0 (0x0c) */ 7076 /* Front Pin: output 0 (0x0c) */
6625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7077 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7078 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -6655,11 +7107,6 @@ static struct hda_verb alc882_init_verbs[] = {
6655 7107
6656 /* FIXME: use matrix-type input source selection */ 7108 /* FIXME: use matrix-type input source selection */
6657 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 7109 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6658 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6663 /* Input mixer2 */ 7110 /* Input mixer2 */
6664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
@@ -6670,9 +7117,6 @@ static struct hda_verb alc882_init_verbs[] = {
6670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 7119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6673 /* ADC1: mute amp left and right */
6674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6675 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6676 /* ADC2: mute amp left and right */ 7120 /* ADC2: mute amp left and right */
6677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6678 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7122 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -6683,6 +7127,18 @@ static struct hda_verb alc882_init_verbs[] = {
6683 { } 7127 { }
6684}; 7128};
6685 7129
7130static struct hda_verb alc882_adc1_init_verbs[] = {
7131 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7135 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7136 /* ADC1: mute amp left and right */
7137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7138 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7139 { }
7140};
7141
6686static struct hda_verb alc882_eapd_verbs[] = { 7142static struct hda_verb alc882_eapd_verbs[] = {
6687 /* change to EAPD mode */ 7143 /* change to EAPD mode */
6688 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 7144 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
@@ -6690,6 +7146,110 @@ static struct hda_verb alc882_eapd_verbs[] = {
6690 { } 7146 { }
6691}; 7147};
6692 7148
7149static struct hda_verb alc889_eapd_verbs[] = {
7150 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7151 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7152 { }
7153};
7154
7155static struct hda_verb alc_hp15_unsol_verbs[] = {
7156 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7158 {}
7159};
7160
7161static struct hda_verb alc885_init_verbs[] = {
7162 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7166 /* Rear mixer */
7167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7169 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7170 /* CLFE mixer */
7171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7174 /* Side mixer */
7175 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7177 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7178
7179 /* mute analog input loopbacks */
7180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7181 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7183
7184 /* Front HP Pin: output 0 (0x0c) */
7185 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7188 /* Front Pin: output 0 (0x0c) */
7189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7191 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7192 /* Rear Pin: output 1 (0x0d) */
7193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7194 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7195 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7196 /* CLFE Pin: output 2 (0x0e) */
7197 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7198 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7199 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7200 /* Side Pin: output 3 (0x0f) */
7201 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7202 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7203 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7204 /* Mic (rear) pin: input vref at 80% */
7205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7206 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7207 /* Front Mic pin: input vref at 80% */
7208 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7209 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7210 /* Line In pin: input */
7211 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7212 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7213
7214 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7215 /* Input mixer1 */
7216 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7218 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7219 /* Input mixer2 */
7220 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7221 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7223 /* Input mixer3 */
7224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7225 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7227 /* ADC2: mute amp left and right */
7228 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7229 /* ADC3: mute amp left and right */
7230 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7231
7232 { }
7233};
7234
7235static struct hda_verb alc885_init_input_verbs[] = {
7236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7239 { }
7240};
7241
7242
7243/* Unmute Selector 24h and set the default input to front mic */
7244static struct hda_verb alc889_init_input_verbs[] = {
7245 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7247 { }
7248};
7249
7250
7251#define alc883_init_verbs alc882_base_init_verbs
7252
6693/* Mac Pro test */ 7253/* Mac Pro test */
6694static struct snd_kcontrol_new alc882_macpro_mixer[] = { 7254static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6695 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7255 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -6893,23 +7453,21 @@ static struct hda_verb alc885_imac24_init_verbs[] = {
6893}; 7453};
6894 7454
6895/* Toggle speaker-output according to the hp-jack state */ 7455/* Toggle speaker-output according to the hp-jack state */
6896static void alc885_imac24_automute_init_hook(struct hda_codec *codec) 7456static void alc885_imac24_setup(struct hda_codec *codec)
6897{ 7457{
6898 struct alc_spec *spec = codec->spec; 7458 struct alc_spec *spec = codec->spec;
6899 7459
6900 spec->autocfg.hp_pins[0] = 0x14; 7460 spec->autocfg.hp_pins[0] = 0x14;
6901 spec->autocfg.speaker_pins[0] = 0x18; 7461 spec->autocfg.speaker_pins[0] = 0x18;
6902 spec->autocfg.speaker_pins[1] = 0x1a; 7462 spec->autocfg.speaker_pins[1] = 0x1a;
6903 alc_automute_amp(codec);
6904} 7463}
6905 7464
6906static void alc885_mbp3_init_hook(struct hda_codec *codec) 7465static void alc885_mbp3_setup(struct hda_codec *codec)
6907{ 7466{
6908 struct alc_spec *spec = codec->spec; 7467 struct alc_spec *spec = codec->spec;
6909 7468
6910 spec->autocfg.hp_pins[0] = 0x15; 7469 spec->autocfg.hp_pins[0] = 0x15;
6911 spec->autocfg.speaker_pins[0] = 0x14; 7470 spec->autocfg.speaker_pins[0] = 0x14;
6912 alc_automute_amp(codec);
6913} 7471}
6914 7472
6915 7473
@@ -6937,13 +7495,12 @@ static void alc882_targa_automute(struct hda_codec *codec)
6937 spec->jack_present ? 1 : 3); 7495 spec->jack_present ? 1 : 3);
6938} 7496}
6939 7497
6940static void alc882_targa_init_hook(struct hda_codec *codec) 7498static void alc882_targa_setup(struct hda_codec *codec)
6941{ 7499{
6942 struct alc_spec *spec = codec->spec; 7500 struct alc_spec *spec = codec->spec;
6943 7501
6944 spec->autocfg.hp_pins[0] = 0x14; 7502 spec->autocfg.hp_pins[0] = 0x14;
6945 spec->autocfg.speaker_pins[0] = 0x1b; 7503 spec->autocfg.speaker_pins[0] = 0x1b;
6946 alc882_targa_automute(codec);
6947} 7504}
6948 7505
6949static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) 7506static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -7031,18 +7588,16 @@ static void alc885_macpro_init_hook(struct hda_codec *codec)
7031static void alc885_imac24_init_hook(struct hda_codec *codec) 7588static void alc885_imac24_init_hook(struct hda_codec *codec)
7032{ 7589{
7033 alc885_macpro_init_hook(codec); 7590 alc885_macpro_init_hook(codec);
7034 alc885_imac24_automute_init_hook(codec); 7591 alc_automute_amp(codec);
7035} 7592}
7036 7593
7037/* 7594/*
7038 * generic initialization of ADC, input mixers and output mixers 7595 * generic initialization of ADC, input mixers and output mixers
7039 */ 7596 */
7040static struct hda_verb alc882_auto_init_verbs[] = { 7597static struct hda_verb alc883_auto_init_verbs[] = {
7041 /* 7598 /*
7042 * Unmute ADC0-2 and set the default input to mic-in 7599 * Unmute ADC0-2 and set the default input to mic-in
7043 */ 7600 */
7044 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7046 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7601 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7047 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7602 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7048 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 7603 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -7083,11 +7638,6 @@ static struct hda_verb alc882_auto_init_verbs[] = {
7083 7638
7084 /* FIXME: use matrix-type input source selection */ 7639 /* FIXME: use matrix-type input source selection */
7085 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 7640 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7086 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7091 /* Input mixer2 */ 7641 /* Input mixer2 */
7092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 7642 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 7643 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
@@ -7102,820 +7652,6 @@ static struct hda_verb alc882_auto_init_verbs[] = {
7102 { } 7652 { }
7103}; 7653};
7104 7654
7105#ifdef CONFIG_SND_HDA_POWER_SAVE
7106#define alc882_loopbacks alc880_loopbacks
7107#endif
7108
7109/* pcm configuration: identical with ALC880 */
7110#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7111#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7112#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7113#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7114
7115/*
7116 * configuration and preset
7117 */
7118static const char *alc882_models[ALC882_MODEL_LAST] = {
7119 [ALC882_3ST_DIG] = "3stack-dig",
7120 [ALC882_6ST_DIG] = "6stack-dig",
7121 [ALC882_ARIMA] = "arima",
7122 [ALC882_W2JC] = "w2jc",
7123 [ALC882_TARGA] = "targa",
7124 [ALC882_ASUS_A7J] = "asus-a7j",
7125 [ALC882_ASUS_A7M] = "asus-a7m",
7126 [ALC885_MACPRO] = "macpro",
7127 [ALC885_MB5] = "mb5",
7128 [ALC885_MBP3] = "mbp3",
7129 [ALC885_IMAC24] = "imac24",
7130 [ALC882_AUTO] = "auto",
7131};
7132
7133static struct snd_pci_quirk alc882_cfg_tbl[] = {
7134 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
7135 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
7136 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
7137 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
7138 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
7139 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
7140 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
7141 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
7142 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
7143 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7144 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7145 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
7146 {}
7147};
7148
7149static struct alc_config_preset alc882_presets[] = {
7150 [ALC882_3ST_DIG] = {
7151 .mixers = { alc882_base_mixer },
7152 .init_verbs = { alc882_init_verbs },
7153 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7154 .dac_nids = alc882_dac_nids,
7155 .dig_out_nid = ALC882_DIGOUT_NID,
7156 .dig_in_nid = ALC882_DIGIN_NID,
7157 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7158 .channel_mode = alc882_ch_modes,
7159 .need_dac_fix = 1,
7160 .input_mux = &alc882_capture_source,
7161 },
7162 [ALC882_6ST_DIG] = {
7163 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7164 .init_verbs = { alc882_init_verbs },
7165 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7166 .dac_nids = alc882_dac_nids,
7167 .dig_out_nid = ALC882_DIGOUT_NID,
7168 .dig_in_nid = ALC882_DIGIN_NID,
7169 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7170 .channel_mode = alc882_sixstack_modes,
7171 .input_mux = &alc882_capture_source,
7172 },
7173 [ALC882_ARIMA] = {
7174 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7175 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7176 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7177 .dac_nids = alc882_dac_nids,
7178 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7179 .channel_mode = alc882_sixstack_modes,
7180 .input_mux = &alc882_capture_source,
7181 },
7182 [ALC882_W2JC] = {
7183 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7184 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7185 alc880_gpio1_init_verbs },
7186 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7187 .dac_nids = alc882_dac_nids,
7188 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7189 .channel_mode = alc880_threestack_modes,
7190 .need_dac_fix = 1,
7191 .input_mux = &alc882_capture_source,
7192 .dig_out_nid = ALC882_DIGOUT_NID,
7193 },
7194 [ALC885_MBP3] = {
7195 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7196 .init_verbs = { alc885_mbp3_init_verbs,
7197 alc880_gpio1_init_verbs },
7198 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7199 .dac_nids = alc882_dac_nids,
7200 .channel_mode = alc885_mbp_6ch_modes,
7201 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7202 .input_mux = &alc882_capture_source,
7203 .dig_out_nid = ALC882_DIGOUT_NID,
7204 .dig_in_nid = ALC882_DIGIN_NID,
7205 .unsol_event = alc_automute_amp_unsol_event,
7206 .init_hook = alc885_mbp3_init_hook,
7207 },
7208 [ALC885_MB5] = {
7209 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
7210 .init_verbs = { alc885_mb5_init_verbs,
7211 alc880_gpio1_init_verbs },
7212 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7213 .dac_nids = alc882_dac_nids,
7214 .channel_mode = alc885_mb5_6ch_modes,
7215 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
7216 .input_mux = &mb5_capture_source,
7217 .dig_out_nid = ALC882_DIGOUT_NID,
7218 .dig_in_nid = ALC882_DIGIN_NID,
7219 },
7220 [ALC885_MACPRO] = {
7221 .mixers = { alc882_macpro_mixer },
7222 .init_verbs = { alc882_macpro_init_verbs },
7223 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7224 .dac_nids = alc882_dac_nids,
7225 .dig_out_nid = ALC882_DIGOUT_NID,
7226 .dig_in_nid = ALC882_DIGIN_NID,
7227 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7228 .channel_mode = alc882_ch_modes,
7229 .input_mux = &alc882_capture_source,
7230 .init_hook = alc885_macpro_init_hook,
7231 },
7232 [ALC885_IMAC24] = {
7233 .mixers = { alc885_imac24_mixer },
7234 .init_verbs = { alc885_imac24_init_verbs },
7235 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7236 .dac_nids = alc882_dac_nids,
7237 .dig_out_nid = ALC882_DIGOUT_NID,
7238 .dig_in_nid = ALC882_DIGIN_NID,
7239 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7240 .channel_mode = alc882_ch_modes,
7241 .input_mux = &alc882_capture_source,
7242 .unsol_event = alc_automute_amp_unsol_event,
7243 .init_hook = alc885_imac24_init_hook,
7244 },
7245 [ALC882_TARGA] = {
7246 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
7247 .init_verbs = { alc882_init_verbs, alc880_gpio3_init_verbs,
7248 alc882_targa_verbs},
7249 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7250 .dac_nids = alc882_dac_nids,
7251 .dig_out_nid = ALC882_DIGOUT_NID,
7252 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7253 .adc_nids = alc882_adc_nids,
7254 .capsrc_nids = alc882_capsrc_nids,
7255 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7256 .channel_mode = alc882_3ST_6ch_modes,
7257 .need_dac_fix = 1,
7258 .input_mux = &alc882_capture_source,
7259 .unsol_event = alc882_targa_unsol_event,
7260 .init_hook = alc882_targa_init_hook,
7261 },
7262 [ALC882_ASUS_A7J] = {
7263 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
7264 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7265 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7266 .dac_nids = alc882_dac_nids,
7267 .dig_out_nid = ALC882_DIGOUT_NID,
7268 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7269 .adc_nids = alc882_adc_nids,
7270 .capsrc_nids = alc882_capsrc_nids,
7271 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7272 .channel_mode = alc882_3ST_6ch_modes,
7273 .need_dac_fix = 1,
7274 .input_mux = &alc882_capture_source,
7275 },
7276 [ALC882_ASUS_A7M] = {
7277 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7278 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7279 alc880_gpio1_init_verbs,
7280 alc882_asus_a7m_verbs },
7281 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7282 .dac_nids = alc882_dac_nids,
7283 .dig_out_nid = ALC882_DIGOUT_NID,
7284 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7285 .channel_mode = alc880_threestack_modes,
7286 .need_dac_fix = 1,
7287 .input_mux = &alc882_capture_source,
7288 },
7289};
7290
7291
7292/*
7293 * Pin config fixes
7294 */
7295enum {
7296 PINFIX_ABIT_AW9D_MAX
7297};
7298
7299static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7300 { 0x15, 0x01080104 }, /* side */
7301 { 0x16, 0x01011012 }, /* rear */
7302 { 0x17, 0x01016011 }, /* clfe */
7303 { }
7304};
7305
7306static const struct alc_pincfg *alc882_pin_fixes[] = {
7307 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7308};
7309
7310static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7311 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7312 {}
7313};
7314
7315/*
7316 * BIOS auto configuration
7317 */
7318static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7319 hda_nid_t nid, int pin_type,
7320 int dac_idx)
7321{
7322 /* set as output */
7323 struct alc_spec *spec = codec->spec;
7324 int idx;
7325
7326 alc_set_pin_output(codec, nid, pin_type);
7327 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7328 idx = 4;
7329 else
7330 idx = spec->multiout.dac_nids[dac_idx] - 2;
7331 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7332
7333}
7334
7335static void alc882_auto_init_multi_out(struct hda_codec *codec)
7336{
7337 struct alc_spec *spec = codec->spec;
7338 int i;
7339
7340 for (i = 0; i <= HDA_SIDE; i++) {
7341 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7342 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7343 if (nid)
7344 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
7345 i);
7346 }
7347}
7348
7349static void alc882_auto_init_hp_out(struct hda_codec *codec)
7350{
7351 struct alc_spec *spec = codec->spec;
7352 hda_nid_t pin;
7353
7354 pin = spec->autocfg.hp_pins[0];
7355 if (pin) /* connect to front */
7356 /* use dac 0 */
7357 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7358 pin = spec->autocfg.speaker_pins[0];
7359 if (pin)
7360 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
7361}
7362
7363#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7364#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7365
7366static void alc882_auto_init_analog_input(struct hda_codec *codec)
7367{
7368 struct alc_spec *spec = codec->spec;
7369 int i;
7370
7371 for (i = 0; i < AUTO_PIN_LAST; i++) {
7372 hda_nid_t nid = spec->autocfg.input_pins[i];
7373 if (!nid)
7374 continue;
7375 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
7376 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7377 snd_hda_codec_write(codec, nid, 0,
7378 AC_VERB_SET_AMP_GAIN_MUTE,
7379 AMP_OUT_MUTE);
7380 }
7381}
7382
7383static void alc882_auto_init_input_src(struct hda_codec *codec)
7384{
7385 struct alc_spec *spec = codec->spec;
7386 int c;
7387
7388 for (c = 0; c < spec->num_adc_nids; c++) {
7389 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7390 hda_nid_t nid = spec->capsrc_nids[c];
7391 unsigned int mux_idx;
7392 const struct hda_input_mux *imux;
7393 int conns, mute, idx, item;
7394
7395 conns = snd_hda_get_connections(codec, nid, conn_list,
7396 ARRAY_SIZE(conn_list));
7397 if (conns < 0)
7398 continue;
7399 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7400 imux = &spec->input_mux[mux_idx];
7401 for (idx = 0; idx < conns; idx++) {
7402 /* if the current connection is the selected one,
7403 * unmute it as default - otherwise mute it
7404 */
7405 mute = AMP_IN_MUTE(idx);
7406 for (item = 0; item < imux->num_items; item++) {
7407 if (imux->items[item].index == idx) {
7408 if (spec->cur_mux[c] == item)
7409 mute = AMP_IN_UNMUTE(idx);
7410 break;
7411 }
7412 }
7413 /* check if we have a selector or mixer
7414 * we could check for the widget type instead, but
7415 * just check for Amp-In presence (in case of mixer
7416 * without amp-in there is something wrong, this
7417 * function shouldn't be used or capsrc nid is wrong)
7418 */
7419 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7420 snd_hda_codec_write(codec, nid, 0,
7421 AC_VERB_SET_AMP_GAIN_MUTE,
7422 mute);
7423 else if (mute != AMP_IN_MUTE(idx))
7424 snd_hda_codec_write(codec, nid, 0,
7425 AC_VERB_SET_CONNECT_SEL,
7426 idx);
7427 }
7428 }
7429}
7430
7431/* add mic boosts if needed */
7432static int alc_auto_add_mic_boost(struct hda_codec *codec)
7433{
7434 struct alc_spec *spec = codec->spec;
7435 int err;
7436 hda_nid_t nid;
7437
7438 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
7439 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
7440 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7441 "Mic Boost",
7442 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7443 if (err < 0)
7444 return err;
7445 }
7446 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
7447 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
7448 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7449 "Front Mic Boost",
7450 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7451 if (err < 0)
7452 return err;
7453 }
7454 return 0;
7455}
7456
7457/* almost identical with ALC880 parser... */
7458static int alc882_parse_auto_config(struct hda_codec *codec)
7459{
7460 struct alc_spec *spec = codec->spec;
7461 int err = alc880_parse_auto_config(codec);
7462
7463 if (err < 0)
7464 return err;
7465 else if (!err)
7466 return 0; /* no config found */
7467
7468 err = alc_auto_add_mic_boost(codec);
7469 if (err < 0)
7470 return err;
7471
7472 /* hack - override the init verbs */
7473 spec->init_verbs[0] = alc882_auto_init_verbs;
7474
7475 return 1; /* config found */
7476}
7477
7478/* additional initialization for auto-configuration model */
7479static void alc882_auto_init(struct hda_codec *codec)
7480{
7481 struct alc_spec *spec = codec->spec;
7482 alc882_auto_init_multi_out(codec);
7483 alc882_auto_init_hp_out(codec);
7484 alc882_auto_init_analog_input(codec);
7485 alc882_auto_init_input_src(codec);
7486 if (spec->unsol_event)
7487 alc_inithook(codec);
7488}
7489
7490static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7491
7492static int patch_alc882(struct hda_codec *codec)
7493{
7494 struct alc_spec *spec;
7495 int err, board_config;
7496
7497 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7498 if (spec == NULL)
7499 return -ENOMEM;
7500
7501 codec->spec = spec;
7502
7503 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7504 alc882_models,
7505 alc882_cfg_tbl);
7506
7507 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
7508 /* Pick up systems that don't supply PCI SSID */
7509 switch (codec->subsystem_id) {
7510 case 0x106b0c00: /* Mac Pro */
7511 board_config = ALC885_MACPRO;
7512 break;
7513 case 0x106b1000: /* iMac 24 */
7514 case 0x106b2800: /* AppleTV */
7515 case 0x106b3e00: /* iMac 24 Aluminium */
7516 board_config = ALC885_IMAC24;
7517 break;
7518 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
7519 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
7520 case 0x106b00a4: /* MacbookPro4,1 */
7521 case 0x106b2c00: /* Macbook Pro rev3 */
7522 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
7523 case 0x106b3800: /* MacbookPro4,1 - latter revision */
7524 board_config = ALC885_MBP3;
7525 break;
7526 case 0x106b3f00: /* Macbook 5,1 */
7527 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7528 * seems not working, so apparently
7529 * no perfect solution yet
7530 */
7531 board_config = ALC885_MB5;
7532 break;
7533 default:
7534 /* ALC889A is handled better as ALC888-compatible */
7535 if (codec->revision_id == 0x100101 ||
7536 codec->revision_id == 0x100103) {
7537 alc_free(codec);
7538 return patch_alc883(codec);
7539 }
7540 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7541 "trying auto-probe from BIOS...\n",
7542 codec->chip_name);
7543 board_config = ALC882_AUTO;
7544 }
7545 }
7546
7547 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7548
7549 if (board_config == ALC882_AUTO) {
7550 /* automatic parse from the BIOS config */
7551 err = alc882_parse_auto_config(codec);
7552 if (err < 0) {
7553 alc_free(codec);
7554 return err;
7555 } else if (!err) {
7556 printk(KERN_INFO
7557 "hda_codec: Cannot set up configuration "
7558 "from BIOS. Using base mode...\n");
7559 board_config = ALC882_3ST_DIG;
7560 }
7561 }
7562
7563 err = snd_hda_attach_beep_device(codec, 0x1);
7564 if (err < 0) {
7565 alc_free(codec);
7566 return err;
7567 }
7568
7569 if (board_config != ALC882_AUTO)
7570 setup_preset(spec, &alc882_presets[board_config]);
7571
7572 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7573 spec->stream_analog_capture = &alc882_pcm_analog_capture;
7574 /* FIXME: setup DAC5 */
7575 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7576 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
7577
7578 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7579 spec->stream_digital_capture = &alc882_pcm_digital_capture;
7580
7581 if (!spec->adc_nids && spec->input_mux) {
7582 /* check whether NID 0x07 is valid */
7583 unsigned int wcap = get_wcaps(codec, 0x07);
7584 /* get type */
7585 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
7586 if (wcap != AC_WID_AUD_IN) {
7587 spec->adc_nids = alc882_adc_nids_alt;
7588 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
7589 spec->capsrc_nids = alc882_capsrc_nids_alt;
7590 } else {
7591 spec->adc_nids = alc882_adc_nids;
7592 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
7593 spec->capsrc_nids = alc882_capsrc_nids;
7594 }
7595 }
7596 set_capture_mixer(spec);
7597 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
7598
7599 spec->vmaster_nid = 0x0c;
7600
7601 codec->patch_ops = alc_patch_ops;
7602 if (board_config == ALC882_AUTO)
7603 spec->init_hook = alc882_auto_init;
7604#ifdef CONFIG_SND_HDA_POWER_SAVE
7605 if (!spec->loopback.amplist)
7606 spec->loopback.amplist = alc882_loopbacks;
7607#endif
7608 codec->proc_widget_hook = print_realtek_coef;
7609
7610 return 0;
7611}
7612
7613/*
7614 * ALC883 support
7615 *
7616 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7617 * configuration. Each pin widget can choose any input DACs and a mixer.
7618 * Each ADC is connected from a mixer of all inputs. This makes possible
7619 * 6-channel independent captures.
7620 *
7621 * In addition, an independent DAC for the multi-playback (not used in this
7622 * driver yet).
7623 */
7624#define ALC883_DIGOUT_NID 0x06
7625#define ALC883_DIGIN_NID 0x0a
7626
7627#define ALC1200_DIGOUT_NID 0x10
7628
7629static hda_nid_t alc883_dac_nids[4] = {
7630 /* front, rear, clfe, rear_surr */
7631 0x02, 0x03, 0x04, 0x05
7632};
7633
7634static hda_nid_t alc883_adc_nids[2] = {
7635 /* ADC1-2 */
7636 0x08, 0x09,
7637};
7638
7639static hda_nid_t alc883_adc_nids_alt[1] = {
7640 /* ADC1 */
7641 0x08,
7642};
7643
7644static hda_nid_t alc883_adc_nids_rev[2] = {
7645 /* ADC2-1 */
7646 0x09, 0x08
7647};
7648
7649#define alc889_adc_nids alc880_adc_nids
7650
7651static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7652
7653static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7654
7655#define alc889_capsrc_nids alc882_capsrc_nids
7656
7657/* input MUX */
7658/* FIXME: should be a matrix-type input source selection */
7659
7660static struct hda_input_mux alc883_capture_source = {
7661 .num_items = 4,
7662 .items = {
7663 { "Mic", 0x0 },
7664 { "Front Mic", 0x1 },
7665 { "Line", 0x2 },
7666 { "CD", 0x4 },
7667 },
7668};
7669
7670static struct hda_input_mux alc883_3stack_6ch_intel = {
7671 .num_items = 4,
7672 .items = {
7673 { "Mic", 0x1 },
7674 { "Front Mic", 0x0 },
7675 { "Line", 0x2 },
7676 { "CD", 0x4 },
7677 },
7678};
7679
7680static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7681 .num_items = 2,
7682 .items = {
7683 { "Mic", 0x1 },
7684 { "Line", 0x2 },
7685 },
7686};
7687
7688static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7689 .num_items = 4,
7690 .items = {
7691 { "Mic", 0x0 },
7692 { "iMic", 0x1 },
7693 { "Line", 0x2 },
7694 { "CD", 0x4 },
7695 },
7696};
7697
7698static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7699 .num_items = 2,
7700 .items = {
7701 { "Mic", 0x0 },
7702 { "Int Mic", 0x1 },
7703 },
7704};
7705
7706static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7707 .num_items = 3,
7708 .items = {
7709 { "Mic", 0x0 },
7710 { "Front Mic", 0x1 },
7711 { "Line", 0x4 },
7712 },
7713};
7714
7715static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7716 .num_items = 2,
7717 .items = {
7718 { "Mic", 0x0 },
7719 { "Line", 0x2 },
7720 },
7721};
7722
7723static struct hda_input_mux alc889A_mb31_capture_source = {
7724 .num_items = 2,
7725 .items = {
7726 { "Mic", 0x0 },
7727 /* Front Mic (0x01) unused */
7728 { "Line", 0x2 },
7729 /* Line 2 (0x03) unused */
7730 /* CD (0x04) unsused? */
7731 },
7732};
7733
7734/*
7735 * 2ch mode
7736 */
7737static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7738 { 2, NULL }
7739};
7740
7741/*
7742 * 2ch mode
7743 */
7744static struct hda_verb alc883_3ST_ch2_init[] = {
7745 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7746 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7747 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7748 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7749 { } /* end */
7750};
7751
7752/*
7753 * 4ch mode
7754 */
7755static struct hda_verb alc883_3ST_ch4_init[] = {
7756 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7757 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7759 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7760 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7761 { } /* end */
7762};
7763
7764/*
7765 * 6ch mode
7766 */
7767static struct hda_verb alc883_3ST_ch6_init[] = {
7768 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7769 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7770 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7771 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7772 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7773 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7774 { } /* end */
7775};
7776
7777static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
7778 { 2, alc883_3ST_ch2_init },
7779 { 4, alc883_3ST_ch4_init },
7780 { 6, alc883_3ST_ch6_init },
7781};
7782
7783
7784/*
7785 * 2ch mode
7786 */
7787static struct hda_verb alc883_4ST_ch2_init[] = {
7788 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7789 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7790 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7791 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7792 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7793 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7794 { } /* end */
7795};
7796
7797/*
7798 * 4ch mode
7799 */
7800static struct hda_verb alc883_4ST_ch4_init[] = {
7801 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7802 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7803 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7804 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7805 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7806 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7807 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7808 { } /* end */
7809};
7810
7811/*
7812 * 6ch mode
7813 */
7814static struct hda_verb alc883_4ST_ch6_init[] = {
7815 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7816 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7819 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7820 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7821 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7822 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7823 { } /* end */
7824};
7825
7826/*
7827 * 8ch mode
7828 */
7829static struct hda_verb alc883_4ST_ch8_init[] = {
7830 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7831 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7832 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7833 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7834 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7835 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7836 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7837 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7838 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7839 { } /* end */
7840};
7841
7842static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7843 { 2, alc883_4ST_ch2_init },
7844 { 4, alc883_4ST_ch4_init },
7845 { 6, alc883_4ST_ch6_init },
7846 { 8, alc883_4ST_ch8_init },
7847};
7848
7849
7850/*
7851 * 2ch mode
7852 */
7853static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7854 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7855 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7856 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7857 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7858 { } /* end */
7859};
7860
7861/*
7862 * 4ch mode
7863 */
7864static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7865 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7866 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7867 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7868 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7869 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7870 { } /* end */
7871};
7872
7873/*
7874 * 6ch mode
7875 */
7876static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7877 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7878 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7879 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7880 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7881 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7882 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7883 { } /* end */
7884};
7885
7886static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7887 { 2, alc883_3ST_ch2_intel_init },
7888 { 4, alc883_3ST_ch4_intel_init },
7889 { 6, alc883_3ST_ch6_intel_init },
7890};
7891
7892/*
7893 * 6ch mode
7894 */
7895static struct hda_verb alc883_sixstack_ch6_init[] = {
7896 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7897 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7898 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7899 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7900 { } /* end */
7901};
7902
7903/*
7904 * 8ch mode
7905 */
7906static struct hda_verb alc883_sixstack_ch8_init[] = {
7907 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7908 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7909 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7910 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7911 { } /* end */
7912};
7913
7914static struct hda_channel_mode alc883_sixstack_modes[2] = {
7915 { 6, alc883_sixstack_ch6_init },
7916 { 8, alc883_sixstack_ch8_init },
7917};
7918
7919/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */ 7655/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7920static struct hda_verb alc889A_mb31_ch2_init[] = { 7656static struct hda_verb alc889A_mb31_ch2_init[] = {
7921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ 7657 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
@@ -7966,34 +7702,7 @@ static struct hda_verb alc883_medion_eapd_verbs[] = {
7966 { } 7702 { }
7967}; 7703};
7968 7704
7969/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 7705#define alc883_base_mixer alc882_base_mixer
7970 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7971 */
7972
7973static struct snd_kcontrol_new alc883_base_mixer[] = {
7974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7975 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7977 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7978 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7980 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7981 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7982 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7983 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7984 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7994 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7995 { } /* end */
7996};
7997 7706
7998static struct snd_kcontrol_new alc883_mitac_mixer[] = { 7707static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7999 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7708 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -8104,6 +7813,30 @@ static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8104 { } /* end */ 7813 { } /* end */
8105}; 7814};
8106 7815
7816static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7817 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7818 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7819 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7820 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7821 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7822 HDA_OUTPUT),
7823 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7824 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7825 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7826 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7827 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7834 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7835 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7836 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7837 { } /* end */
7838};
7839
8107static struct snd_kcontrol_new alc883_fivestack_mixer[] = { 7840static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
8108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7841 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8109 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7842 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -8344,93 +8077,14 @@ static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8344 { } /* end */ 8077 { } /* end */
8345}; 8078};
8346 8079
8347static struct hda_verb alc883_init_verbs[] = {
8348 /* ADC1: mute amp left and right */
8349 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8350 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8351 /* ADC2: mute amp left and right */
8352 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8353 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8354 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8358 /* Rear mixer */
8359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8362 /* CLFE mixer */
8363 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8366 /* Side mixer */
8367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8368 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8369 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8370
8371 /* mute analog input loopbacks */
8372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8377
8378 /* Front Pin: output 0 (0x0c) */
8379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8380 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8381 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8382 /* Rear Pin: output 1 (0x0d) */
8383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8385 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8386 /* CLFE Pin: output 2 (0x0e) */
8387 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8388 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8389 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8390 /* Side Pin: output 3 (0x0f) */
8391 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8392 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8393 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8394 /* Mic (rear) pin: input vref at 80% */
8395 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8396 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8397 /* Front Mic pin: input vref at 80% */
8398 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8400 /* Line In pin: input */
8401 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8402 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8403 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8405 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8406 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8407 /* CD pin widget for input */
8408 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8409
8410 /* FIXME: use matrix-type input source selection */
8411 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8412 /* Input mixer2 */
8413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8417 /* Input mixer3 */
8418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8422 { }
8423};
8424
8425/* toggle speaker-output according to the hp-jack state */ 8080/* toggle speaker-output according to the hp-jack state */
8426static void alc883_mitac_init_hook(struct hda_codec *codec) 8081static void alc883_mitac_setup(struct hda_codec *codec)
8427{ 8082{
8428 struct alc_spec *spec = codec->spec; 8083 struct alc_spec *spec = codec->spec;
8429 8084
8430 spec->autocfg.hp_pins[0] = 0x15; 8085 spec->autocfg.hp_pins[0] = 0x15;
8431 spec->autocfg.speaker_pins[0] = 0x14; 8086 spec->autocfg.speaker_pins[0] = 0x14;
8432 spec->autocfg.speaker_pins[1] = 0x17; 8087 spec->autocfg.speaker_pins[1] = 0x17;
8433 alc_automute_amp(codec);
8434} 8088}
8435 8089
8436/* auto-toggle front mic */ 8090/* auto-toggle front mic */
@@ -8585,7 +8239,7 @@ static struct hda_verb alc883_vaiott_verbs[] = {
8585 { } /* end */ 8239 { } /* end */
8586}; 8240};
8587 8241
8588static void alc888_3st_hp_init_hook(struct hda_codec *codec) 8242static void alc888_3st_hp_setup(struct hda_codec *codec)
8589{ 8243{
8590 struct alc_spec *spec = codec->spec; 8244 struct alc_spec *spec = codec->spec;
8591 8245
@@ -8593,7 +8247,6 @@ static void alc888_3st_hp_init_hook(struct hda_codec *codec)
8593 spec->autocfg.speaker_pins[0] = 0x14; 8247 spec->autocfg.speaker_pins[0] = 0x14;
8594 spec->autocfg.speaker_pins[1] = 0x16; 8248 spec->autocfg.speaker_pins[1] = 0x16;
8595 spec->autocfg.speaker_pins[2] = 0x18; 8249 spec->autocfg.speaker_pins[2] = 0x18;
8596 alc_automute_amp(codec);
8597} 8250}
8598 8251
8599static struct hda_verb alc888_3st_hp_verbs[] = { 8252static struct hda_verb alc888_3st_hp_verbs[] = {
@@ -8690,13 +8343,12 @@ static struct hda_verb alc883_medion_md2_verbs[] = {
8690}; 8343};
8691 8344
8692/* toggle speaker-output according to the hp-jack state */ 8345/* toggle speaker-output according to the hp-jack state */
8693static void alc883_medion_md2_init_hook(struct hda_codec *codec) 8346static void alc883_medion_md2_setup(struct hda_codec *codec)
8694{ 8347{
8695 struct alc_spec *spec = codec->spec; 8348 struct alc_spec *spec = codec->spec;
8696 8349
8697 spec->autocfg.hp_pins[0] = 0x14; 8350 spec->autocfg.hp_pins[0] = 0x14;
8698 spec->autocfg.speaker_pins[0] = 0x15; 8351 spec->autocfg.speaker_pins[0] = 0x15;
8699 alc_automute_amp(codec);
8700} 8352}
8701 8353
8702/* toggle speaker-output according to the hp-jack state */ 8354/* toggle speaker-output according to the hp-jack state */
@@ -8713,12 +8365,16 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8713 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8365 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8714} 8366}
8715 8367
8716static void alc883_clevo_m720_init_hook(struct hda_codec *codec) 8368static void alc883_clevo_m720_setup(struct hda_codec *codec)
8717{ 8369{
8718 struct alc_spec *spec = codec->spec; 8370 struct alc_spec *spec = codec->spec;
8719 8371
8720 spec->autocfg.hp_pins[0] = 0x15; 8372 spec->autocfg.hp_pins[0] = 0x15;
8721 spec->autocfg.speaker_pins[0] = 0x14; 8373 spec->autocfg.speaker_pins[0] = 0x14;
8374}
8375
8376static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8377{
8722 alc_automute_amp(codec); 8378 alc_automute_amp(codec);
8723 alc883_clevo_m720_mic_automute(codec); 8379 alc883_clevo_m720_mic_automute(codec);
8724} 8380}
@@ -8737,22 +8393,20 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8737} 8393}
8738 8394
8739/* toggle speaker-output according to the hp-jack state */ 8395/* toggle speaker-output according to the hp-jack state */
8740static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec) 8396static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
8741{ 8397{
8742 struct alc_spec *spec = codec->spec; 8398 struct alc_spec *spec = codec->spec;
8743 8399
8744 spec->autocfg.hp_pins[0] = 0x14; 8400 spec->autocfg.hp_pins[0] = 0x14;
8745 spec->autocfg.speaker_pins[0] = 0x15; 8401 spec->autocfg.speaker_pins[0] = 0x15;
8746 alc_automute_amp(codec);
8747} 8402}
8748 8403
8749static void alc883_haier_w66_init_hook(struct hda_codec *codec) 8404static void alc883_haier_w66_setup(struct hda_codec *codec)
8750{ 8405{
8751 struct alc_spec *spec = codec->spec; 8406 struct alc_spec *spec = codec->spec;
8752 8407
8753 spec->autocfg.hp_pins[0] = 0x1b; 8408 spec->autocfg.hp_pins[0] = 0x1b;
8754 spec->autocfg.speaker_pins[0] = 0x14; 8409 spec->autocfg.speaker_pins[0] = 0x14;
8755 alc_automute_amp(codec);
8756} 8410}
8757 8411
8758static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 8412static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
@@ -8791,14 +8445,13 @@ static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8791} 8445}
8792 8446
8793/* toggle speaker-output according to the hp-jack state */ 8447/* toggle speaker-output according to the hp-jack state */
8794static void alc883_acer_aspire_init_hook(struct hda_codec *codec) 8448static void alc883_acer_aspire_setup(struct hda_codec *codec)
8795{ 8449{
8796 struct alc_spec *spec = codec->spec; 8450 struct alc_spec *spec = codec->spec;
8797 8451
8798 spec->autocfg.hp_pins[0] = 0x14; 8452 spec->autocfg.hp_pins[0] = 0x14;
8799 spec->autocfg.speaker_pins[0] = 0x15; 8453 spec->autocfg.speaker_pins[0] = 0x15;
8800 spec->autocfg.speaker_pins[1] = 0x16; 8454 spec->autocfg.speaker_pins[1] = 0x16;
8801 alc_automute_amp(codec);
8802} 8455}
8803 8456
8804static struct hda_verb alc883_acer_eapd_verbs[] = { 8457static struct hda_verb alc883_acer_eapd_verbs[] = {
@@ -8819,7 +8472,7 @@ static struct hda_verb alc883_acer_eapd_verbs[] = {
8819 { } 8472 { }
8820}; 8473};
8821 8474
8822static void alc888_6st_dell_init_hook(struct hda_codec *codec) 8475static void alc888_6st_dell_setup(struct hda_codec *codec)
8823{ 8476{
8824 struct alc_spec *spec = codec->spec; 8477 struct alc_spec *spec = codec->spec;
8825 8478
@@ -8828,10 +8481,9 @@ static void alc888_6st_dell_init_hook(struct hda_codec *codec)
8828 spec->autocfg.speaker_pins[1] = 0x15; 8481 spec->autocfg.speaker_pins[1] = 0x15;
8829 spec->autocfg.speaker_pins[2] = 0x16; 8482 spec->autocfg.speaker_pins[2] = 0x16;
8830 spec->autocfg.speaker_pins[3] = 0x17; 8483 spec->autocfg.speaker_pins[3] = 0x17;
8831 alc_automute_amp(codec);
8832} 8484}
8833 8485
8834static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) 8486static void alc888_lenovo_sky_setup(struct hda_codec *codec)
8835{ 8487{
8836 struct alc_spec *spec = codec->spec; 8488 struct alc_spec *spec = codec->spec;
8837 8489
@@ -8841,82 +8493,17 @@ static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
8841 spec->autocfg.speaker_pins[2] = 0x16; 8493 spec->autocfg.speaker_pins[2] = 0x16;
8842 spec->autocfg.speaker_pins[3] = 0x17; 8494 spec->autocfg.speaker_pins[3] = 0x17;
8843 spec->autocfg.speaker_pins[4] = 0x1a; 8495 spec->autocfg.speaker_pins[4] = 0x1a;
8844 alc_automute_amp(codec);
8845} 8496}
8846 8497
8847static void alc883_vaiott_init_hook(struct hda_codec *codec) 8498static void alc883_vaiott_setup(struct hda_codec *codec)
8848{ 8499{
8849 struct alc_spec *spec = codec->spec; 8500 struct alc_spec *spec = codec->spec;
8850 8501
8851 spec->autocfg.hp_pins[0] = 0x15; 8502 spec->autocfg.hp_pins[0] = 0x15;
8852 spec->autocfg.speaker_pins[0] = 0x14; 8503 spec->autocfg.speaker_pins[0] = 0x14;
8853 spec->autocfg.speaker_pins[1] = 0x17; 8504 spec->autocfg.speaker_pins[1] = 0x17;
8854 alc_automute_amp(codec);
8855} 8505}
8856 8506
8857/*
8858 * generic initialization of ADC, input mixers and output mixers
8859 */
8860static struct hda_verb alc883_auto_init_verbs[] = {
8861 /*
8862 * Unmute ADC0-2 and set the default input to mic-in
8863 */
8864 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8866 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8867 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8868
8869 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8870 * mixer widget
8871 * Note: PASD motherboards uses the Line In 2 as the input for
8872 * front panel mic (mic 2)
8873 */
8874 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8880
8881 /*
8882 * Set up output mixers (0x0c - 0x0f)
8883 */
8884 /* set vol=0 to output mixers */
8885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8886 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8887 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8888 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8889 /* set up input amps for analog loopback */
8890 /* Amp Indices: DAC = 0, mixer = 1 */
8891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8895 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8897 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8898 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8899 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8900 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8901
8902 /* FIXME: use matrix-type input source selection */
8903 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8904 /* Input mixer1 */
8905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8908 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
8909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8910 /* Input mixer2 */
8911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8914 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
8915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8916
8917 { }
8918};
8919
8920static struct hda_verb alc888_asus_m90v_verbs[] = { 8507static struct hda_verb alc888_asus_m90v_verbs[] = {
8921 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8922 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
@@ -8927,19 +8514,7 @@ static struct hda_verb alc888_asus_m90v_verbs[] = {
8927 { } /* end */ 8514 { } /* end */
8928}; 8515};
8929 8516
8930static void alc883_nb_mic_automute(struct hda_codec *codec) 8517static void alc883_mode2_setup(struct hda_codec *codec)
8931{
8932 unsigned int present;
8933
8934 present = snd_hda_codec_read(codec, 0x18, 0,
8935 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8936 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8937 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8938 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8939 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8940}
8941
8942static void alc883_M90V_init_hook(struct hda_codec *codec)
8943{ 8518{
8944 struct alc_spec *spec = codec->spec; 8519 struct alc_spec *spec = codec->spec;
8945 8520
@@ -8947,26 +8522,11 @@ static void alc883_M90V_init_hook(struct hda_codec *codec)
8947 spec->autocfg.speaker_pins[0] = 0x14; 8522 spec->autocfg.speaker_pins[0] = 0x14;
8948 spec->autocfg.speaker_pins[1] = 0x15; 8523 spec->autocfg.speaker_pins[1] = 0x15;
8949 spec->autocfg.speaker_pins[2] = 0x16; 8524 spec->autocfg.speaker_pins[2] = 0x16;
8950 alc_automute_pin(codec); 8525 spec->ext_mic.pin = 0x18;
8951} 8526 spec->int_mic.pin = 0x19;
8952 8527 spec->ext_mic.mux_idx = 0;
8953static void alc883_mode2_unsol_event(struct hda_codec *codec, 8528 spec->int_mic.mux_idx = 1;
8954 unsigned int res) 8529 spec->auto_mic = 1;
8955{
8956 switch (res >> 26) {
8957 case ALC880_MIC_EVENT:
8958 alc883_nb_mic_automute(codec);
8959 break;
8960 default:
8961 alc_sku_unsol_event(codec, res);
8962 break;
8963 }
8964}
8965
8966static void alc883_mode2_inithook(struct hda_codec *codec)
8967{
8968 alc883_M90V_init_hook(codec);
8969 alc883_nb_mic_automute(codec);
8970} 8530}
8971 8531
8972static struct hda_verb alc888_asus_eee1601_verbs[] = { 8532static struct hda_verb alc888_asus_eee1601_verbs[] = {
@@ -9027,25 +8587,44 @@ static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9027 alc889A_mb31_automute(codec); 8587 alc889A_mb31_automute(codec);
9028} 8588}
9029 8589
8590
9030#ifdef CONFIG_SND_HDA_POWER_SAVE 8591#ifdef CONFIG_SND_HDA_POWER_SAVE
9031#define alc883_loopbacks alc880_loopbacks 8592#define alc882_loopbacks alc880_loopbacks
9032#endif 8593#endif
9033 8594
9034/* pcm configuration: identical with ALC880 */ 8595/* pcm configuration: identical with ALC880 */
9035#define alc883_pcm_analog_playback alc880_pcm_analog_playback 8596#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9036#define alc883_pcm_analog_capture alc880_pcm_analog_capture 8597#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9037#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture 8598#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9038#define alc883_pcm_digital_playback alc880_pcm_digital_playback 8599#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9039#define alc883_pcm_digital_capture alc880_pcm_digital_capture 8600
8601static hda_nid_t alc883_slave_dig_outs[] = {
8602 ALC1200_DIGOUT_NID, 0,
8603};
8604
8605static hda_nid_t alc1200_slave_dig_outs[] = {
8606 ALC883_DIGOUT_NID, 0,
8607};
9040 8608
9041/* 8609/*
9042 * configuration and preset 8610 * configuration and preset
9043 */ 8611 */
9044static const char *alc883_models[ALC883_MODEL_LAST] = { 8612static const char *alc882_models[ALC882_MODEL_LAST] = {
9045 [ALC883_3ST_2ch_DIG] = "3stack-dig", 8613 [ALC882_3ST_DIG] = "3stack-dig",
8614 [ALC882_6ST_DIG] = "6stack-dig",
8615 [ALC882_ARIMA] = "arima",
8616 [ALC882_W2JC] = "w2jc",
8617 [ALC882_TARGA] = "targa",
8618 [ALC882_ASUS_A7J] = "asus-a7j",
8619 [ALC882_ASUS_A7M] = "asus-a7m",
8620 [ALC885_MACPRO] = "macpro",
8621 [ALC885_MB5] = "mb5",
8622 [ALC885_MBP3] = "mbp3",
8623 [ALC885_IMAC24] = "imac24",
8624 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
9046 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", 8625 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9047 [ALC883_3ST_6ch] = "3stack-6ch", 8626 [ALC883_3ST_6ch] = "3stack-6ch",
9048 [ALC883_6ST_DIG] = "6stack-dig", 8627 [ALC883_6ST_DIG] = "alc883-6stack-dig",
9049 [ALC883_TARGA_DIG] = "targa-dig", 8628 [ALC883_TARGA_DIG] = "targa-dig",
9050 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 8629 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
9051 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig", 8630 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
@@ -9069,14 +8648,17 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
9069 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", 8648 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
9070 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", 8649 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
9071 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", 8650 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8651 [ALC889A_INTEL] = "intel-alc889a",
8652 [ALC889_INTEL] = "intel-x58",
9072 [ALC1200_ASUS_P5Q] = "asus-p5q", 8653 [ALC1200_ASUS_P5Q] = "asus-p5q",
9073 [ALC889A_MB31] = "mb31", 8654 [ALC889A_MB31] = "mb31",
9074 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt", 8655 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
9075 [ALC883_AUTO] = "auto", 8656 [ALC882_AUTO] = "auto",
9076}; 8657};
9077 8658
9078static struct snd_pci_quirk alc883_cfg_tbl[] = { 8659static struct snd_pci_quirk alc882_cfg_tbl[] = {
9079 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 8660 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8661
9080 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 8662 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
9081 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), 8663 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
9082 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE), 8664 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
@@ -9091,8 +8673,8 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9091 ALC888_ACER_ASPIRE_8930G), 8673 ALC888_ACER_ASPIRE_8930G),
9092 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", 8674 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9093 ALC888_ACER_ASPIRE_8930G), 8675 ALC888_ACER_ASPIRE_8930G),
9094 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), 8676 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9095 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), 8677 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
9096 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 8678 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
9097 ALC888_ACER_ASPIRE_6530G), 8679 ALC888_ACER_ASPIRE_6530G),
9098 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", 8680 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
@@ -9101,30 +8683,44 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9101 * model=auto should work fine now 8683 * model=auto should work fine now
9102 */ 8684 */
9103 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */ 8685 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
8686
9104 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 8687 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8688
9105 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 8689 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
9106 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8690 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9107 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8691 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
9108 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8692 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
9109 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), 8693 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
9110 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP), 8694 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8695
8696 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8697 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8698 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
9111 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8699 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8700 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8701 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8702 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
9112 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8703 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
9113 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), 8704 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
9114 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), 8705 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
9115 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8706 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8707
8708 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
9116 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8709 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
9117 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 8710 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
9118 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), 8711 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
9119 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), 8712 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9120 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 8713 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
9121 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), 8714 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
9122 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 8715 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
9123 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), 8716 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8717
9124 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 8718 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9125 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), 8719 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9126 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 8720 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
8721 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
9127 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), 8722 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
8723 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
9128 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), 8724 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
9129 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), 8725 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
9130 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 8726 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
@@ -9133,6 +8729,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9133 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), 8729 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9134 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), 8730 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9135 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), 8731 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8732 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
9136 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), 8733 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9137 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), 8734 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9138 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 8735 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
@@ -9146,11 +8743,14 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9146 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 8743 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
9147 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), 8744 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
9148 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 8745 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
8746 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
8747
9149 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 8748 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
9150 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), 8749 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9151 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), 8750 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
9152 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), 8751 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
9153 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 8752 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8753 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
9154 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 8754 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
9155 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", 8755 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
9156 ALC883_FUJITSU_PI2515), 8756 ALC883_FUJITSU_PI2515),
@@ -9165,24 +8765,185 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9165 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), 8765 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
9166 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), 8766 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
9167 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 8767 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8768
9168 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), 8769 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9169 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), 8770 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
9170 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), 8771 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
9171 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), 8772 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8773 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8774 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
9172 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 8775 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
9173 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
9174 {}
9175};
9176 8776
9177static hda_nid_t alc883_slave_dig_outs[] = { 8777 {}
9178 ALC1200_DIGOUT_NID, 0,
9179}; 8778};
9180 8779
9181static hda_nid_t alc1200_slave_dig_outs[] = { 8780/* codec SSID table for Intel Mac */
9182 ALC883_DIGOUT_NID, 0, 8781static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8782 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8783 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8784 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8785 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8786 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8787 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8788 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8789 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8790 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8791 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8792 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8793 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8794 * no perfect solution yet
8795 */
8796 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8797 {} /* terminator */
9183}; 8798};
9184 8799
9185static struct alc_config_preset alc883_presets[] = { 8800static struct alc_config_preset alc882_presets[] = {
8801 [ALC882_3ST_DIG] = {
8802 .mixers = { alc882_base_mixer },
8803 .init_verbs = { alc882_base_init_verbs,
8804 alc882_adc1_init_verbs },
8805 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8806 .dac_nids = alc882_dac_nids,
8807 .dig_out_nid = ALC882_DIGOUT_NID,
8808 .dig_in_nid = ALC882_DIGIN_NID,
8809 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8810 .channel_mode = alc882_ch_modes,
8811 .need_dac_fix = 1,
8812 .input_mux = &alc882_capture_source,
8813 },
8814 [ALC882_6ST_DIG] = {
8815 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8816 .init_verbs = { alc882_base_init_verbs,
8817 alc882_adc1_init_verbs },
8818 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8819 .dac_nids = alc882_dac_nids,
8820 .dig_out_nid = ALC882_DIGOUT_NID,
8821 .dig_in_nid = ALC882_DIGIN_NID,
8822 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8823 .channel_mode = alc882_sixstack_modes,
8824 .input_mux = &alc882_capture_source,
8825 },
8826 [ALC882_ARIMA] = {
8827 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8828 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8829 alc882_eapd_verbs },
8830 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8831 .dac_nids = alc882_dac_nids,
8832 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8833 .channel_mode = alc882_sixstack_modes,
8834 .input_mux = &alc882_capture_source,
8835 },
8836 [ALC882_W2JC] = {
8837 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
8838 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8839 alc882_eapd_verbs, alc880_gpio1_init_verbs },
8840 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8841 .dac_nids = alc882_dac_nids,
8842 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8843 .channel_mode = alc880_threestack_modes,
8844 .need_dac_fix = 1,
8845 .input_mux = &alc882_capture_source,
8846 .dig_out_nid = ALC882_DIGOUT_NID,
8847 },
8848 [ALC885_MBP3] = {
8849 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8850 .init_verbs = { alc885_mbp3_init_verbs,
8851 alc880_gpio1_init_verbs },
8852 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8853 .dac_nids = alc882_dac_nids,
8854 .channel_mode = alc885_mbp_6ch_modes,
8855 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8856 .input_mux = &alc882_capture_source,
8857 .dig_out_nid = ALC882_DIGOUT_NID,
8858 .dig_in_nid = ALC882_DIGIN_NID,
8859 .unsol_event = alc_automute_amp_unsol_event,
8860 .setup = alc885_mbp3_setup,
8861 .init_hook = alc_automute_amp,
8862 },
8863 [ALC885_MB5] = {
8864 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8865 .init_verbs = { alc885_mb5_init_verbs,
8866 alc880_gpio1_init_verbs },
8867 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8868 .dac_nids = alc882_dac_nids,
8869 .channel_mode = alc885_mb5_6ch_modes,
8870 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8871 .input_mux = &mb5_capture_source,
8872 .dig_out_nid = ALC882_DIGOUT_NID,
8873 .dig_in_nid = ALC882_DIGIN_NID,
8874 },
8875 [ALC885_MACPRO] = {
8876 .mixers = { alc882_macpro_mixer },
8877 .init_verbs = { alc882_macpro_init_verbs },
8878 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8879 .dac_nids = alc882_dac_nids,
8880 .dig_out_nid = ALC882_DIGOUT_NID,
8881 .dig_in_nid = ALC882_DIGIN_NID,
8882 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8883 .channel_mode = alc882_ch_modes,
8884 .input_mux = &alc882_capture_source,
8885 .init_hook = alc885_macpro_init_hook,
8886 },
8887 [ALC885_IMAC24] = {
8888 .mixers = { alc885_imac24_mixer },
8889 .init_verbs = { alc885_imac24_init_verbs },
8890 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8891 .dac_nids = alc882_dac_nids,
8892 .dig_out_nid = ALC882_DIGOUT_NID,
8893 .dig_in_nid = ALC882_DIGIN_NID,
8894 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8895 .channel_mode = alc882_ch_modes,
8896 .input_mux = &alc882_capture_source,
8897 .unsol_event = alc_automute_amp_unsol_event,
8898 .setup = alc885_imac24_setup,
8899 .init_hook = alc885_imac24_init_hook,
8900 },
8901 [ALC882_TARGA] = {
8902 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
8903 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8904 alc880_gpio3_init_verbs, alc882_targa_verbs},
8905 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8906 .dac_nids = alc882_dac_nids,
8907 .dig_out_nid = ALC882_DIGOUT_NID,
8908 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8909 .adc_nids = alc882_adc_nids,
8910 .capsrc_nids = alc882_capsrc_nids,
8911 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8912 .channel_mode = alc882_3ST_6ch_modes,
8913 .need_dac_fix = 1,
8914 .input_mux = &alc882_capture_source,
8915 .unsol_event = alc882_targa_unsol_event,
8916 .setup = alc882_targa_setup,
8917 .init_hook = alc882_targa_automute,
8918 },
8919 [ALC882_ASUS_A7J] = {
8920 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
8921 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8922 alc882_asus_a7j_verbs},
8923 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8924 .dac_nids = alc882_dac_nids,
8925 .dig_out_nid = ALC882_DIGOUT_NID,
8926 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8927 .adc_nids = alc882_adc_nids,
8928 .capsrc_nids = alc882_capsrc_nids,
8929 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8930 .channel_mode = alc882_3ST_6ch_modes,
8931 .need_dac_fix = 1,
8932 .input_mux = &alc882_capture_source,
8933 },
8934 [ALC882_ASUS_A7M] = {
8935 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
8936 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8937 alc882_eapd_verbs, alc880_gpio1_init_verbs,
8938 alc882_asus_a7m_verbs },
8939 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8940 .dac_nids = alc882_dac_nids,
8941 .dig_out_nid = ALC882_DIGOUT_NID,
8942 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8943 .channel_mode = alc880_threestack_modes,
8944 .need_dac_fix = 1,
8945 .input_mux = &alc882_capture_source,
8946 },
9186 [ALC883_3ST_2ch_DIG] = { 8947 [ALC883_3ST_2ch_DIG] = {
9187 .mixers = { alc883_3ST_2ch_mixer }, 8948 .mixers = { alc883_3ST_2ch_mixer },
9188 .init_verbs = { alc883_init_verbs }, 8949 .init_verbs = { alc883_init_verbs },
@@ -9229,6 +8990,46 @@ static struct alc_config_preset alc883_presets[] = {
9229 .need_dac_fix = 1, 8990 .need_dac_fix = 1,
9230 .input_mux = &alc883_3stack_6ch_intel, 8991 .input_mux = &alc883_3stack_6ch_intel,
9231 }, 8992 },
8993 [ALC889A_INTEL] = {
8994 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
8995 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
8996 alc_hp15_unsol_verbs },
8997 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8998 .dac_nids = alc883_dac_nids,
8999 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9000 .adc_nids = alc889_adc_nids,
9001 .dig_out_nid = ALC883_DIGOUT_NID,
9002 .dig_in_nid = ALC883_DIGIN_NID,
9003 .slave_dig_outs = alc883_slave_dig_outs,
9004 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9005 .channel_mode = alc889_8ch_intel_modes,
9006 .capsrc_nids = alc889_capsrc_nids,
9007 .input_mux = &alc889_capture_source,
9008 .setup = alc889_automute_setup,
9009 .init_hook = alc_automute_amp,
9010 .unsol_event = alc_automute_amp_unsol_event,
9011 .need_dac_fix = 1,
9012 },
9013 [ALC889_INTEL] = {
9014 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9015 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
9016 alc889_eapd_verbs, alc_hp15_unsol_verbs},
9017 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9018 .dac_nids = alc883_dac_nids,
9019 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9020 .adc_nids = alc889_adc_nids,
9021 .dig_out_nid = ALC883_DIGOUT_NID,
9022 .dig_in_nid = ALC883_DIGIN_NID,
9023 .slave_dig_outs = alc883_slave_dig_outs,
9024 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9025 .channel_mode = alc889_8ch_intel_modes,
9026 .capsrc_nids = alc889_capsrc_nids,
9027 .input_mux = &alc889_capture_source,
9028 .setup = alc889_automute_setup,
9029 .init_hook = alc889_intel_init_hook,
9030 .unsol_event = alc_automute_amp_unsol_event,
9031 .need_dac_fix = 1,
9032 },
9232 [ALC883_6ST_DIG] = { 9033 [ALC883_6ST_DIG] = {
9233 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9034 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9234 .init_verbs = { alc883_init_verbs }, 9035 .init_verbs = { alc883_init_verbs },
@@ -9252,7 +9053,8 @@ static struct alc_config_preset alc883_presets[] = {
9252 .need_dac_fix = 1, 9053 .need_dac_fix = 1,
9253 .input_mux = &alc883_capture_source, 9054 .input_mux = &alc883_capture_source,
9254 .unsol_event = alc883_targa_unsol_event, 9055 .unsol_event = alc883_targa_unsol_event,
9255 .init_hook = alc883_targa_init_hook, 9056 .setup = alc882_targa_setup,
9057 .init_hook = alc882_targa_automute,
9256 }, 9058 },
9257 [ALC883_TARGA_2ch_DIG] = { 9059 [ALC883_TARGA_2ch_DIG] = {
9258 .mixers = { alc883_targa_2ch_mixer}, 9060 .mixers = { alc883_targa_2ch_mixer},
@@ -9267,7 +9069,8 @@ static struct alc_config_preset alc883_presets[] = {
9267 .channel_mode = alc883_3ST_2ch_modes, 9069 .channel_mode = alc883_3ST_2ch_modes,
9268 .input_mux = &alc883_capture_source, 9070 .input_mux = &alc883_capture_source,
9269 .unsol_event = alc883_targa_unsol_event, 9071 .unsol_event = alc883_targa_unsol_event,
9270 .init_hook = alc883_targa_init_hook, 9072 .setup = alc882_targa_setup,
9073 .init_hook = alc882_targa_automute,
9271 }, 9074 },
9272 [ALC883_TARGA_8ch_DIG] = { 9075 [ALC883_TARGA_8ch_DIG] = {
9273 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9076 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
@@ -9285,7 +9088,8 @@ static struct alc_config_preset alc883_presets[] = {
9285 .need_dac_fix = 1, 9088 .need_dac_fix = 1,
9286 .input_mux = &alc883_capture_source, 9089 .input_mux = &alc883_capture_source,
9287 .unsol_event = alc883_targa_unsol_event, 9090 .unsol_event = alc883_targa_unsol_event,
9288 .init_hook = alc883_targa_init_hook, 9091 .setup = alc882_targa_setup,
9092 .init_hook = alc882_targa_automute,
9289 }, 9093 },
9290 [ALC883_ACER] = { 9094 [ALC883_ACER] = {
9291 .mixers = { alc883_base_mixer }, 9095 .mixers = { alc883_base_mixer },
@@ -9311,7 +9115,8 @@ static struct alc_config_preset alc883_presets[] = {
9311 .channel_mode = alc883_3ST_2ch_modes, 9115 .channel_mode = alc883_3ST_2ch_modes,
9312 .input_mux = &alc883_capture_source, 9116 .input_mux = &alc883_capture_source,
9313 .unsol_event = alc_automute_amp_unsol_event, 9117 .unsol_event = alc_automute_amp_unsol_event,
9314 .init_hook = alc883_acer_aspire_init_hook, 9118 .setup = alc883_acer_aspire_setup,
9119 .init_hook = alc_automute_amp,
9315 }, 9120 },
9316 [ALC888_ACER_ASPIRE_4930G] = { 9121 [ALC888_ACER_ASPIRE_4930G] = {
9317 .mixers = { alc888_base_mixer, 9122 .mixers = { alc888_base_mixer,
@@ -9331,7 +9136,8 @@ static struct alc_config_preset alc883_presets[] = {
9331 ARRAY_SIZE(alc888_2_capture_sources), 9136 ARRAY_SIZE(alc888_2_capture_sources),
9332 .input_mux = alc888_2_capture_sources, 9137 .input_mux = alc888_2_capture_sources,
9333 .unsol_event = alc_automute_amp_unsol_event, 9138 .unsol_event = alc_automute_amp_unsol_event,
9334 .init_hook = alc888_acer_aspire_4930g_init_hook, 9139 .setup = alc888_acer_aspire_4930g_setup,
9140 .init_hook = alc_automute_amp,
9335 }, 9141 },
9336 [ALC888_ACER_ASPIRE_6530G] = { 9142 [ALC888_ACER_ASPIRE_6530G] = {
9337 .mixers = { alc888_acer_aspire_6530_mixer }, 9143 .mixers = { alc888_acer_aspire_6530_mixer },
@@ -9349,7 +9155,8 @@ static struct alc_config_preset alc883_presets[] = {
9349 ARRAY_SIZE(alc888_2_capture_sources), 9155 ARRAY_SIZE(alc888_2_capture_sources),
9350 .input_mux = alc888_acer_aspire_6530_sources, 9156 .input_mux = alc888_acer_aspire_6530_sources,
9351 .unsol_event = alc_automute_amp_unsol_event, 9157 .unsol_event = alc_automute_amp_unsol_event,
9352 .init_hook = alc888_acer_aspire_6530g_init_hook, 9158 .setup = alc888_acer_aspire_6530g_setup,
9159 .init_hook = alc_automute_amp,
9353 }, 9160 },
9354 [ALC888_ACER_ASPIRE_8930G] = { 9161 [ALC888_ACER_ASPIRE_8930G] = {
9355 .mixers = { alc888_base_mixer, 9162 .mixers = { alc888_base_mixer,
@@ -9370,7 +9177,8 @@ static struct alc_config_preset alc883_presets[] = {
9370 ARRAY_SIZE(alc889_capture_sources), 9177 ARRAY_SIZE(alc889_capture_sources),
9371 .input_mux = alc889_capture_sources, 9178 .input_mux = alc889_capture_sources,
9372 .unsol_event = alc_automute_amp_unsol_event, 9179 .unsol_event = alc_automute_amp_unsol_event,
9373 .init_hook = alc889_acer_aspire_8930g_init_hook, 9180 .setup = alc889_acer_aspire_8930g_setup,
9181 .init_hook = alc_automute_amp,
9374 }, 9182 },
9375 [ALC883_MEDION] = { 9183 [ALC883_MEDION] = {
9376 .mixers = { alc883_fivestack_mixer, 9184 .mixers = { alc883_fivestack_mixer,
@@ -9395,7 +9203,8 @@ static struct alc_config_preset alc883_presets[] = {
9395 .channel_mode = alc883_3ST_2ch_modes, 9203 .channel_mode = alc883_3ST_2ch_modes,
9396 .input_mux = &alc883_capture_source, 9204 .input_mux = &alc883_capture_source,
9397 .unsol_event = alc_automute_amp_unsol_event, 9205 .unsol_event = alc_automute_amp_unsol_event,
9398 .init_hook = alc883_medion_md2_init_hook, 9206 .setup = alc883_medion_md2_setup,
9207 .init_hook = alc_automute_amp,
9399 }, 9208 },
9400 [ALC883_LAPTOP_EAPD] = { 9209 [ALC883_LAPTOP_EAPD] = {
9401 .mixers = { alc883_base_mixer }, 9210 .mixers = { alc883_base_mixer },
@@ -9416,6 +9225,7 @@ static struct alc_config_preset alc883_presets[] = {
9416 .channel_mode = alc883_3ST_2ch_modes, 9225 .channel_mode = alc883_3ST_2ch_modes,
9417 .input_mux = &alc883_capture_source, 9226 .input_mux = &alc883_capture_source,
9418 .unsol_event = alc883_clevo_m720_unsol_event, 9227 .unsol_event = alc883_clevo_m720_unsol_event,
9228 .setup = alc883_clevo_m720_setup,
9419 .init_hook = alc883_clevo_m720_init_hook, 9229 .init_hook = alc883_clevo_m720_init_hook,
9420 }, 9230 },
9421 [ALC883_LENOVO_101E_2ch] = { 9231 [ALC883_LENOVO_101E_2ch] = {
@@ -9441,7 +9251,8 @@ static struct alc_config_preset alc883_presets[] = {
9441 .need_dac_fix = 1, 9251 .need_dac_fix = 1,
9442 .input_mux = &alc883_lenovo_nb0763_capture_source, 9252 .input_mux = &alc883_lenovo_nb0763_capture_source,
9443 .unsol_event = alc_automute_amp_unsol_event, 9253 .unsol_event = alc_automute_amp_unsol_event,
9444 .init_hook = alc883_medion_md2_init_hook, 9254 .setup = alc883_medion_md2_setup,
9255 .init_hook = alc_automute_amp,
9445 }, 9256 },
9446 [ALC888_LENOVO_MS7195_DIG] = { 9257 [ALC888_LENOVO_MS7195_DIG] = {
9447 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9258 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9466,7 +9277,8 @@ static struct alc_config_preset alc883_presets[] = {
9466 .channel_mode = alc883_3ST_2ch_modes, 9277 .channel_mode = alc883_3ST_2ch_modes,
9467 .input_mux = &alc883_capture_source, 9278 .input_mux = &alc883_capture_source,
9468 .unsol_event = alc_automute_amp_unsol_event, 9279 .unsol_event = alc_automute_amp_unsol_event,
9469 .init_hook = alc883_haier_w66_init_hook, 9280 .setup = alc883_haier_w66_setup,
9281 .init_hook = alc_automute_amp,
9470 }, 9282 },
9471 [ALC888_3ST_HP] = { 9283 [ALC888_3ST_HP] = {
9472 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9284 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9478,7 +9290,8 @@ static struct alc_config_preset alc883_presets[] = {
9478 .need_dac_fix = 1, 9290 .need_dac_fix = 1,
9479 .input_mux = &alc883_capture_source, 9291 .input_mux = &alc883_capture_source,
9480 .unsol_event = alc_automute_amp_unsol_event, 9292 .unsol_event = alc_automute_amp_unsol_event,
9481 .init_hook = alc888_3st_hp_init_hook, 9293 .setup = alc888_3st_hp_setup,
9294 .init_hook = alc_automute_amp,
9482 }, 9295 },
9483 [ALC888_6ST_DELL] = { 9296 [ALC888_6ST_DELL] = {
9484 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9297 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
@@ -9491,7 +9304,8 @@ static struct alc_config_preset alc883_presets[] = {
9491 .channel_mode = alc883_sixstack_modes, 9304 .channel_mode = alc883_sixstack_modes,
9492 .input_mux = &alc883_capture_source, 9305 .input_mux = &alc883_capture_source,
9493 .unsol_event = alc_automute_amp_unsol_event, 9306 .unsol_event = alc_automute_amp_unsol_event,
9494 .init_hook = alc888_6st_dell_init_hook, 9307 .setup = alc888_6st_dell_setup,
9308 .init_hook = alc_automute_amp,
9495 }, 9309 },
9496 [ALC883_MITAC] = { 9310 [ALC883_MITAC] = {
9497 .mixers = { alc883_mitac_mixer }, 9311 .mixers = { alc883_mitac_mixer },
@@ -9502,7 +9316,8 @@ static struct alc_config_preset alc883_presets[] = {
9502 .channel_mode = alc883_3ST_2ch_modes, 9316 .channel_mode = alc883_3ST_2ch_modes,
9503 .input_mux = &alc883_capture_source, 9317 .input_mux = &alc883_capture_source,
9504 .unsol_event = alc_automute_amp_unsol_event, 9318 .unsol_event = alc_automute_amp_unsol_event,
9505 .init_hook = alc883_mitac_init_hook, 9319 .setup = alc883_mitac_setup,
9320 .init_hook = alc_automute_amp,
9506 }, 9321 },
9507 [ALC883_FUJITSU_PI2515] = { 9322 [ALC883_FUJITSU_PI2515] = {
9508 .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, 9323 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
@@ -9515,7 +9330,8 @@ static struct alc_config_preset alc883_presets[] = {
9515 .channel_mode = alc883_3ST_2ch_modes, 9330 .channel_mode = alc883_3ST_2ch_modes,
9516 .input_mux = &alc883_fujitsu_pi2515_capture_source, 9331 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9517 .unsol_event = alc_automute_amp_unsol_event, 9332 .unsol_event = alc_automute_amp_unsol_event,
9518 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook, 9333 .setup = alc883_2ch_fujitsu_pi2515_setup,
9334 .init_hook = alc_automute_amp,
9519 }, 9335 },
9520 [ALC888_FUJITSU_XA3530] = { 9336 [ALC888_FUJITSU_XA3530] = {
9521 .mixers = { alc888_base_mixer, alc883_chmode_mixer }, 9337 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
@@ -9533,7 +9349,8 @@ static struct alc_config_preset alc883_presets[] = {
9533 ARRAY_SIZE(alc888_2_capture_sources), 9349 ARRAY_SIZE(alc888_2_capture_sources),
9534 .input_mux = alc888_2_capture_sources, 9350 .input_mux = alc888_2_capture_sources,
9535 .unsol_event = alc_automute_amp_unsol_event, 9351 .unsol_event = alc_automute_amp_unsol_event,
9536 .init_hook = alc888_fujitsu_xa3530_init_hook, 9352 .setup = alc888_fujitsu_xa3530_setup,
9353 .init_hook = alc_automute_amp,
9537 }, 9354 },
9538 [ALC888_LENOVO_SKY] = { 9355 [ALC888_LENOVO_SKY] = {
9539 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, 9356 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
@@ -9546,7 +9363,8 @@ static struct alc_config_preset alc883_presets[] = {
9546 .need_dac_fix = 1, 9363 .need_dac_fix = 1,
9547 .input_mux = &alc883_lenovo_sky_capture_source, 9364 .input_mux = &alc883_lenovo_sky_capture_source,
9548 .unsol_event = alc_automute_amp_unsol_event, 9365 .unsol_event = alc_automute_amp_unsol_event,
9549 .init_hook = alc888_lenovo_sky_init_hook, 9366 .setup = alc888_lenovo_sky_setup,
9367 .init_hook = alc_automute_amp,
9550 }, 9368 },
9551 [ALC888_ASUS_M90V] = { 9369 [ALC888_ASUS_M90V] = {
9552 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9370 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9559,8 +9377,9 @@ static struct alc_config_preset alc883_presets[] = {
9559 .channel_mode = alc883_3ST_6ch_modes, 9377 .channel_mode = alc883_3ST_6ch_modes,
9560 .need_dac_fix = 1, 9378 .need_dac_fix = 1,
9561 .input_mux = &alc883_fujitsu_pi2515_capture_source, 9379 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9562 .unsol_event = alc883_mode2_unsol_event, 9380 .unsol_event = alc_sku_unsol_event,
9563 .init_hook = alc883_mode2_inithook, 9381 .setup = alc883_mode2_setup,
9382 .init_hook = alc_inithook,
9564 }, 9383 },
9565 [ALC888_ASUS_EEE1601] = { 9384 [ALC888_ASUS_EEE1601] = {
9566 .mixers = { alc883_asus_eee1601_mixer }, 9385 .mixers = { alc883_asus_eee1601_mixer },
@@ -9613,15 +9432,39 @@ static struct alc_config_preset alc883_presets[] = {
9613 .channel_mode = alc883_3ST_2ch_modes, 9432 .channel_mode = alc883_3ST_2ch_modes,
9614 .input_mux = &alc883_capture_source, 9433 .input_mux = &alc883_capture_source,
9615 .unsol_event = alc_automute_amp_unsol_event, 9434 .unsol_event = alc_automute_amp_unsol_event,
9616 .init_hook = alc883_vaiott_init_hook, 9435 .setup = alc883_vaiott_setup,
9436 .init_hook = alc_automute_amp,
9617 }, 9437 },
9618}; 9438};
9619 9439
9620 9440
9621/* 9441/*
9442 * Pin config fixes
9443 */
9444enum {
9445 PINFIX_ABIT_AW9D_MAX
9446};
9447
9448static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9449 { 0x15, 0x01080104 }, /* side */
9450 { 0x16, 0x01011012 }, /* rear */
9451 { 0x17, 0x01016011 }, /* clfe */
9452 { }
9453};
9454
9455static const struct alc_pincfg *alc882_pin_fixes[] = {
9456 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9457};
9458
9459static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9460 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9461 {}
9462};
9463
9464/*
9622 * BIOS auto configuration 9465 * BIOS auto configuration
9623 */ 9466 */
9624static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, 9467static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
9625 hda_nid_t nid, int pin_type, 9468 hda_nid_t nid, int pin_type,
9626 int dac_idx) 9469 int dac_idx)
9627{ 9470{
@@ -9638,7 +9481,7 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9638 9481
9639} 9482}
9640 9483
9641static void alc883_auto_init_multi_out(struct hda_codec *codec) 9484static void alc882_auto_init_multi_out(struct hda_codec *codec)
9642{ 9485{
9643 struct alc_spec *spec = codec->spec; 9486 struct alc_spec *spec = codec->spec;
9644 int i; 9487 int i;
@@ -9647,12 +9490,12 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
9647 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 9490 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9648 int pin_type = get_pin_type(spec->autocfg.line_out_type); 9491 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9649 if (nid) 9492 if (nid)
9650 alc883_auto_set_output_and_unmute(codec, nid, pin_type, 9493 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
9651 i); 9494 i);
9652 } 9495 }
9653} 9496}
9654 9497
9655static void alc883_auto_init_hp_out(struct hda_codec *codec) 9498static void alc882_auto_init_hp_out(struct hda_codec *codec)
9656{ 9499{
9657 struct alc_spec *spec = codec->spec; 9500 struct alc_spec *spec = codec->spec;
9658 hda_nid_t pin; 9501 hda_nid_t pin;
@@ -9660,42 +9503,111 @@ static void alc883_auto_init_hp_out(struct hda_codec *codec)
9660 pin = spec->autocfg.hp_pins[0]; 9503 pin = spec->autocfg.hp_pins[0];
9661 if (pin) /* connect to front */ 9504 if (pin) /* connect to front */
9662 /* use dac 0 */ 9505 /* use dac 0 */
9663 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 9506 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9664 pin = spec->autocfg.speaker_pins[0]; 9507 pin = spec->autocfg.speaker_pins[0];
9665 if (pin) 9508 if (pin)
9666 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 9509 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9667} 9510}
9668 9511
9669#define alc883_is_input_pin(nid) alc880_is_input_pin(nid) 9512static void alc882_auto_init_analog_input(struct hda_codec *codec)
9670#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9671
9672static void alc883_auto_init_analog_input(struct hda_codec *codec)
9673{ 9513{
9674 struct alc_spec *spec = codec->spec; 9514 struct alc_spec *spec = codec->spec;
9675 int i; 9515 int i;
9676 9516
9677 for (i = 0; i < AUTO_PIN_LAST; i++) { 9517 for (i = 0; i < AUTO_PIN_LAST; i++) {
9678 hda_nid_t nid = spec->autocfg.input_pins[i]; 9518 hda_nid_t nid = spec->autocfg.input_pins[i];
9679 if (alc883_is_input_pin(nid)) { 9519 if (!nid)
9680 alc_set_input_pin(codec, nid, i); 9520 continue;
9681 if (nid != ALC883_PIN_CD_NID && 9521 alc_set_input_pin(codec, nid, i);
9682 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 9522 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9523 snd_hda_codec_write(codec, nid, 0,
9524 AC_VERB_SET_AMP_GAIN_MUTE,
9525 AMP_OUT_MUTE);
9526 }
9527}
9528
9529static void alc882_auto_init_input_src(struct hda_codec *codec)
9530{
9531 struct alc_spec *spec = codec->spec;
9532 int c;
9533
9534 for (c = 0; c < spec->num_adc_nids; c++) {
9535 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9536 hda_nid_t nid = spec->capsrc_nids[c];
9537 unsigned int mux_idx;
9538 const struct hda_input_mux *imux;
9539 int conns, mute, idx, item;
9540
9541 conns = snd_hda_get_connections(codec, nid, conn_list,
9542 ARRAY_SIZE(conn_list));
9543 if (conns < 0)
9544 continue;
9545 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9546 imux = &spec->input_mux[mux_idx];
9547 for (idx = 0; idx < conns; idx++) {
9548 /* if the current connection is the selected one,
9549 * unmute it as default - otherwise mute it
9550 */
9551 mute = AMP_IN_MUTE(idx);
9552 for (item = 0; item < imux->num_items; item++) {
9553 if (imux->items[item].index == idx) {
9554 if (spec->cur_mux[c] == item)
9555 mute = AMP_IN_UNMUTE(idx);
9556 break;
9557 }
9558 }
9559 /* check if we have a selector or mixer
9560 * we could check for the widget type instead, but
9561 * just check for Amp-In presence (in case of mixer
9562 * without amp-in there is something wrong, this
9563 * function shouldn't be used or capsrc nid is wrong)
9564 */
9565 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
9683 snd_hda_codec_write(codec, nid, 0, 9566 snd_hda_codec_write(codec, nid, 0,
9684 AC_VERB_SET_AMP_GAIN_MUTE, 9567 AC_VERB_SET_AMP_GAIN_MUTE,
9685 AMP_OUT_MUTE); 9568 mute);
9569 else if (mute != AMP_IN_MUTE(idx))
9570 snd_hda_codec_write(codec, nid, 0,
9571 AC_VERB_SET_CONNECT_SEL,
9572 idx);
9686 } 9573 }
9687 } 9574 }
9688} 9575}
9689 9576
9690#define alc883_auto_init_input_src alc882_auto_init_input_src 9577/* add mic boosts if needed */
9578static int alc_auto_add_mic_boost(struct hda_codec *codec)
9579{
9580 struct alc_spec *spec = codec->spec;
9581 int err;
9582 hda_nid_t nid;
9583
9584 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9585 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9586 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9587 "Mic Boost",
9588 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9589 if (err < 0)
9590 return err;
9591 }
9592 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9593 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9594 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9595 "Front Mic Boost",
9596 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9597 if (err < 0)
9598 return err;
9599 }
9600 return 0;
9601}
9691 9602
9692/* almost identical with ALC880 parser... */ 9603/* almost identical with ALC880 parser... */
9693static int alc883_parse_auto_config(struct hda_codec *codec) 9604static int alc882_parse_auto_config(struct hda_codec *codec)
9694{ 9605{
9695 struct alc_spec *spec = codec->spec; 9606 struct alc_spec *spec = codec->spec;
9696 int err = alc880_parse_auto_config(codec); 9607 struct auto_pin_cfg *autocfg = &spec->autocfg;
9697 struct auto_pin_cfg *cfg = &spec->autocfg; 9608 unsigned int wcap;
9698 int i; 9609 int i;
9610 int err = alc880_parse_auto_config(codec);
9699 9611
9700 if (err < 0) 9612 if (err < 0)
9701 return err; 9613 return err;
@@ -9708,43 +9620,45 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
9708 9620
9709 /* hack - override the init verbs */ 9621 /* hack - override the init verbs */
9710 spec->init_verbs[0] = alc883_auto_init_verbs; 9622 spec->init_verbs[0] = alc883_auto_init_verbs;
9623 /* if ADC 0x07 is available, initialize it, too */
9624 wcap = get_wcaps(codec, 0x07);
9625 wcap = get_wcaps_type(wcap);
9626 if (wcap == AC_WID_AUD_IN)
9627 add_verb(spec, alc882_adc1_init_verbs);
9711 9628
9712 /* setup input_mux for ALC889 */ 9629 /* digital-mic input pin is excluded in alc880_auto_create..()
9713 if (codec->vendor_id == 0x10ec0889) { 9630 * because it's under 0x18
9714 /* digital-mic input pin is excluded in alc880_auto_create..() 9631 */
9715 * because it's under 0x18 9632 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9716 */ 9633 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9717 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || 9634 struct hda_input_mux *imux = &spec->private_imux[0];
9718 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { 9635 for (i = 1; i < 3; i++)
9719 struct hda_input_mux *imux = &spec->private_imux[0]; 9636 memcpy(&spec->private_imux[i],
9720 for (i = 1; i < 3; i++) 9637 &spec->private_imux[0],
9721 memcpy(&spec->private_imux[i], 9638 sizeof(spec->private_imux[0]));
9722 &spec->private_imux[0], 9639 imux->items[imux->num_items].label = "Int DMic";
9723 sizeof(spec->private_imux[0])); 9640 imux->items[imux->num_items].index = 0x0b;
9724 imux->items[imux->num_items].label = "Int DMic"; 9641 imux->num_items++;
9725 imux->items[imux->num_items].index = 0x0b; 9642 spec->num_mux_defs = 3;
9726 imux->num_items++; 9643 spec->input_mux = spec->private_imux;
9727 spec->num_mux_defs = 3;
9728 spec->input_mux = spec->private_imux;
9729 }
9730 } 9644 }
9731 9645
9732 return 1; /* config found */ 9646 return 1; /* config found */
9733} 9647}
9734 9648
9735/* additional initialization for auto-configuration model */ 9649/* additional initialization for auto-configuration model */
9736static void alc883_auto_init(struct hda_codec *codec) 9650static void alc882_auto_init(struct hda_codec *codec)
9737{ 9651{
9738 struct alc_spec *spec = codec->spec; 9652 struct alc_spec *spec = codec->spec;
9739 alc883_auto_init_multi_out(codec); 9653 alc882_auto_init_multi_out(codec);
9740 alc883_auto_init_hp_out(codec); 9654 alc882_auto_init_hp_out(codec);
9741 alc883_auto_init_analog_input(codec); 9655 alc882_auto_init_analog_input(codec);
9742 alc883_auto_init_input_src(codec); 9656 alc882_auto_init_input_src(codec);
9743 if (spec->unsol_event) 9657 if (spec->unsol_event)
9744 alc_inithook(codec); 9658 alc_inithook(codec);
9745} 9659}
9746 9660
9747static int patch_alc883(struct hda_codec *codec) 9661static int patch_alc882(struct hda_codec *codec)
9748{ 9662{
9749 struct alc_spec *spec; 9663 struct alc_spec *spec;
9750 int err, board_config; 9664 int err, board_config;
@@ -9755,28 +9669,35 @@ static int patch_alc883(struct hda_codec *codec)
9755 9669
9756 codec->spec = spec; 9670 codec->spec = spec;
9757 9671
9758 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 9672 switch (codec->vendor_id) {
9673 case 0x10ec0882:
9674 case 0x10ec0885:
9675 break;
9676 default:
9677 /* ALC883 and variants */
9678 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9679 break;
9680 }
9759 9681
9760 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, 9682 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9761 alc883_models, 9683 alc882_models,
9762 alc883_cfg_tbl); 9684 alc882_cfg_tbl);
9763 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) { 9685
9764 /* Pick up systems that don't supply PCI SSID */ 9686 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9765 switch (codec->subsystem_id) { 9687 board_config = snd_hda_check_board_codec_sid_config(codec,
9766 case 0x106b3600: /* Macbook 3.1 */ 9688 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9767 board_config = ALC889A_MB31; 9689
9768 break; 9690 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
9769 default: 9691 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
9770 printk(KERN_INFO 9692 codec->chip_name);
9771 "hda_codec: Unknown model for %s, trying " 9693 board_config = ALC882_AUTO;
9772 "auto-probe from BIOS...\n", codec->chip_name);
9773 board_config = ALC883_AUTO;
9774 }
9775 } 9694 }
9776 9695
9777 if (board_config == ALC883_AUTO) { 9696 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9697
9698 if (board_config == ALC882_AUTO) {
9778 /* automatic parse from the BIOS config */ 9699 /* automatic parse from the BIOS config */
9779 err = alc883_parse_auto_config(codec); 9700 err = alc882_parse_auto_config(codec);
9780 if (err < 0) { 9701 if (err < 0) {
9781 alc_free(codec); 9702 alc_free(codec);
9782 return err; 9703 return err;
@@ -9784,7 +9705,7 @@ static int patch_alc883(struct hda_codec *codec)
9784 printk(KERN_INFO 9705 printk(KERN_INFO
9785 "hda_codec: Cannot set up configuration " 9706 "hda_codec: Cannot set up configuration "
9786 "from BIOS. Using base mode...\n"); 9707 "from BIOS. Using base mode...\n");
9787 board_config = ALC883_3ST_2ch_DIG; 9708 board_config = ALC882_3ST_DIG;
9788 } 9709 }
9789 } 9710 }
9790 9711
@@ -9794,63 +9715,61 @@ static int patch_alc883(struct hda_codec *codec)
9794 return err; 9715 return err;
9795 } 9716 }
9796 9717
9797 if (board_config != ALC883_AUTO) 9718 if (board_config != ALC882_AUTO)
9798 setup_preset(spec, &alc883_presets[board_config]); 9719 setup_preset(codec, &alc882_presets[board_config]);
9799 9720
9800 switch (codec->vendor_id) { 9721 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9801 case 0x10ec0888: 9722 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9802 if (!spec->num_adc_nids) { 9723 /* FIXME: setup DAC5 */
9803 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9724 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9804 spec->adc_nids = alc883_adc_nids; 9725 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9805 } 9726
9806 if (!spec->capsrc_nids) 9727 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9807 spec->capsrc_nids = alc883_capsrc_nids; 9728 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9729
9730 if (codec->vendor_id == 0x10ec0888)
9808 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ 9731 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
9809 break; 9732
9810 case 0x10ec0889: 9733 if (!spec->adc_nids && spec->input_mux) {
9811 if (!spec->num_adc_nids) { 9734 int i;
9812 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); 9735 spec->num_adc_nids = 0;
9813 spec->adc_nids = alc889_adc_nids; 9736 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9814 } 9737 hda_nid_t cap;
9815 if (!spec->capsrc_nids) 9738 hda_nid_t nid = alc882_adc_nids[i];
9816 spec->capsrc_nids = alc889_capsrc_nids; 9739 unsigned int wcap = get_wcaps(codec, nid);
9817 break; 9740 /* get type */
9818 default: 9741 wcap = get_wcaps_type(wcap);
9819 if (!spec->num_adc_nids) { 9742 if (wcap != AC_WID_AUD_IN)
9820 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9743 continue;
9821 spec->adc_nids = alc883_adc_nids; 9744 spec->private_adc_nids[spec->num_adc_nids] = nid;
9745 err = snd_hda_get_connections(codec, nid, &cap, 1);
9746 if (err < 0)
9747 continue;
9748 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9749 spec->num_adc_nids++;
9822 } 9750 }
9823 if (!spec->capsrc_nids) 9751 spec->adc_nids = spec->private_adc_nids;
9824 spec->capsrc_nids = alc883_capsrc_nids; 9752 spec->capsrc_nids = spec->private_capsrc_nids;
9825 break;
9826 } 9753 }
9827 9754
9828 spec->stream_analog_playback = &alc883_pcm_analog_playback; 9755 set_capture_mixer(codec);
9829 spec->stream_analog_capture = &alc883_pcm_analog_capture;
9830 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
9831
9832 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9833 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9834
9835 if (!spec->cap_mixer)
9836 set_capture_mixer(spec);
9837 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 9756 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9838 9757
9839 spec->vmaster_nid = 0x0c; 9758 spec->vmaster_nid = 0x0c;
9840 9759
9841 codec->patch_ops = alc_patch_ops; 9760 codec->patch_ops = alc_patch_ops;
9842 if (board_config == ALC883_AUTO) 9761 if (board_config == ALC882_AUTO)
9843 spec->init_hook = alc883_auto_init; 9762 spec->init_hook = alc882_auto_init;
9844
9845#ifdef CONFIG_SND_HDA_POWER_SAVE 9763#ifdef CONFIG_SND_HDA_POWER_SAVE
9846 if (!spec->loopback.amplist) 9764 if (!spec->loopback.amplist)
9847 spec->loopback.amplist = alc883_loopbacks; 9765 spec->loopback.amplist = alc882_loopbacks;
9848#endif 9766#endif
9849 codec->proc_widget_hook = print_realtek_coef; 9767 codec->proc_widget_hook = print_realtek_coef;
9850 9768
9851 return 0; 9769 return 0;
9852} 9770}
9853 9771
9772
9854/* 9773/*
9855 * ALC262 support 9774 * ALC262 support
9856 */ 9775 */
@@ -10026,13 +9945,12 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10026}; 9945};
10027 9946
10028/* mute/unmute internal speaker according to the hp jack and mute state */ 9947/* mute/unmute internal speaker according to the hp jack and mute state */
10029static void alc262_hp_t5735_init_hook(struct hda_codec *codec) 9948static void alc262_hp_t5735_setup(struct hda_codec *codec)
10030{ 9949{
10031 struct alc_spec *spec = codec->spec; 9950 struct alc_spec *spec = codec->spec;
10032 9951
10033 spec->autocfg.hp_pins[0] = 0x15; 9952 spec->autocfg.hp_pins[0] = 0x15;
10034 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ 9953 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10035 alc_automute_amp(codec);
10036} 9954}
10037 9955
10038static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { 9956static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
@@ -10189,22 +10107,20 @@ static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10189 alc262_hippo_automute(codec); 10107 alc262_hippo_automute(codec);
10190} 10108}
10191 10109
10192static void alc262_hippo_init_hook(struct hda_codec *codec) 10110static void alc262_hippo_setup(struct hda_codec *codec)
10193{ 10111{
10194 struct alc_spec *spec = codec->spec; 10112 struct alc_spec *spec = codec->spec;
10195 10113
10196 spec->autocfg.hp_pins[0] = 0x15; 10114 spec->autocfg.hp_pins[0] = 0x15;
10197 spec->autocfg.speaker_pins[0] = 0x14; 10115 spec->autocfg.speaker_pins[0] = 0x14;
10198 alc262_hippo_automute(codec);
10199} 10116}
10200 10117
10201static void alc262_hippo1_init_hook(struct hda_codec *codec) 10118static void alc262_hippo1_setup(struct hda_codec *codec)
10202{ 10119{
10203 struct alc_spec *spec = codec->spec; 10120 struct alc_spec *spec = codec->spec;
10204 10121
10205 spec->autocfg.hp_pins[0] = 0x1b; 10122 spec->autocfg.hp_pins[0] = 0x1b;
10206 spec->autocfg.speaker_pins[0] = 0x14; 10123 spec->autocfg.speaker_pins[0] = 0x14;
10207 alc262_hippo_automute(codec);
10208} 10124}
10209 10125
10210 10126
@@ -10261,13 +10177,12 @@ static struct hda_verb alc262_tyan_verbs[] = {
10261}; 10177};
10262 10178
10263/* unsolicited event for HP jack sensing */ 10179/* unsolicited event for HP jack sensing */
10264static void alc262_tyan_init_hook(struct hda_codec *codec) 10180static void alc262_tyan_setup(struct hda_codec *codec)
10265{ 10181{
10266 struct alc_spec *spec = codec->spec; 10182 struct alc_spec *spec = codec->spec;
10267 10183
10268 spec->autocfg.hp_pins[0] = 0x1b; 10184 spec->autocfg.hp_pins[0] = 0x1b;
10269 spec->autocfg.speaker_pins[0] = 0x15; 10185 spec->autocfg.speaker_pins[0] = 0x15;
10270 alc_automute_amp(codec);
10271} 10186}
10272 10187
10273 10188
@@ -10359,12 +10274,6 @@ static struct hda_verb alc262_eapd_verbs[] = {
10359 { } 10274 { }
10360}; 10275};
10361 10276
10362static struct hda_verb alc262_hippo_unsol_verbs[] = {
10363 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10365 {}
10366};
10367
10368static struct hda_verb alc262_hippo1_unsol_verbs[] = { 10277static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 10278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10370 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 10279 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -10385,14 +10294,6 @@ static struct hda_verb alc262_sony_unsol_verbs[] = {
10385 {} 10294 {}
10386}; 10295};
10387 10296
10388static struct hda_input_mux alc262_dmic_capture_source = {
10389 .num_items = 2,
10390 .items = {
10391 { "Int DMic", 0x9 },
10392 { "Mic", 0x0 },
10393 },
10394};
10395
10396static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { 10297static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10397 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 10298 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10398 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10299 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
@@ -10414,35 +10315,17 @@ static struct hda_verb alc262_toshiba_s06_verbs[] = {
10414 {} 10315 {}
10415}; 10316};
10416 10317
10417static void alc262_dmic_automute(struct hda_codec *codec) 10318static void alc262_toshiba_s06_setup(struct hda_codec *codec)
10418{
10419 unsigned int present;
10420
10421 present = snd_hda_codec_read(codec, 0x18, 0,
10422 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10423 snd_hda_codec_write(codec, 0x22, 0,
10424 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10425}
10426
10427
10428/* unsolicited event for HP jack sensing */
10429static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10430 unsigned int res)
10431{
10432 if ((res >> 26) == ALC880_MIC_EVENT)
10433 alc262_dmic_automute(codec);
10434 else
10435 alc_sku_unsol_event(codec, res);
10436}
10437
10438static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10439{ 10319{
10440 struct alc_spec *spec = codec->spec; 10320 struct alc_spec *spec = codec->spec;
10441 10321
10442 spec->autocfg.hp_pins[0] = 0x15; 10322 spec->autocfg.hp_pins[0] = 0x15;
10443 spec->autocfg.speaker_pins[0] = 0x14; 10323 spec->autocfg.speaker_pins[0] = 0x14;
10444 alc_automute_pin(codec); 10324 spec->ext_mic.pin = 0x18;
10445 alc262_dmic_automute(codec); 10325 spec->ext_mic.mux_idx = 0;
10326 spec->int_mic.pin = 0x12;
10327 spec->int_mic.mux_idx = 9;
10328 spec->auto_mic = 1;
10446} 10329}
10447 10330
10448/* 10331/*
@@ -11406,7 +11289,7 @@ static struct alc_config_preset alc262_presets[] = {
11406 }, 11289 },
11407 [ALC262_HIPPO] = { 11290 [ALC262_HIPPO] = {
11408 .mixers = { alc262_hippo_mixer }, 11291 .mixers = { alc262_hippo_mixer },
11409 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, 11292 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
11410 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 11293 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11411 .dac_nids = alc262_dac_nids, 11294 .dac_nids = alc262_dac_nids,
11412 .hp_nid = 0x03, 11295 .hp_nid = 0x03,
@@ -11415,7 +11298,8 @@ static struct alc_config_preset alc262_presets[] = {
11415 .channel_mode = alc262_modes, 11298 .channel_mode = alc262_modes,
11416 .input_mux = &alc262_capture_source, 11299 .input_mux = &alc262_capture_source,
11417 .unsol_event = alc262_hippo_unsol_event, 11300 .unsol_event = alc262_hippo_unsol_event,
11418 .init_hook = alc262_hippo_init_hook, 11301 .setup = alc262_hippo_setup,
11302 .init_hook = alc262_hippo_automute,
11419 }, 11303 },
11420 [ALC262_HIPPO_1] = { 11304 [ALC262_HIPPO_1] = {
11421 .mixers = { alc262_hippo1_mixer }, 11305 .mixers = { alc262_hippo1_mixer },
@@ -11428,7 +11312,8 @@ static struct alc_config_preset alc262_presets[] = {
11428 .channel_mode = alc262_modes, 11312 .channel_mode = alc262_modes,
11429 .input_mux = &alc262_capture_source, 11313 .input_mux = &alc262_capture_source,
11430 .unsol_event = alc262_hippo_unsol_event, 11314 .unsol_event = alc262_hippo_unsol_event,
11431 .init_hook = alc262_hippo1_init_hook, 11315 .setup = alc262_hippo1_setup,
11316 .init_hook = alc262_hippo_automute,
11432 }, 11317 },
11433 [ALC262_FUJITSU] = { 11318 [ALC262_FUJITSU] = {
11434 .mixers = { alc262_fujitsu_mixer }, 11319 .mixers = { alc262_fujitsu_mixer },
@@ -11491,7 +11376,8 @@ static struct alc_config_preset alc262_presets[] = {
11491 .channel_mode = alc262_modes, 11376 .channel_mode = alc262_modes,
11492 .input_mux = &alc262_capture_source, 11377 .input_mux = &alc262_capture_source,
11493 .unsol_event = alc_automute_amp_unsol_event, 11378 .unsol_event = alc_automute_amp_unsol_event,
11494 .init_hook = alc262_hp_t5735_init_hook, 11379 .setup = alc262_hp_t5735_setup,
11380 .init_hook = alc_automute_amp,
11495 }, 11381 },
11496 [ALC262_HP_RP5700] = { 11382 [ALC262_HP_RP5700] = {
11497 .mixers = { alc262_hp_rp5700_mixer }, 11383 .mixers = { alc262_hp_rp5700_mixer },
@@ -11522,11 +11408,13 @@ static struct alc_config_preset alc262_presets[] = {
11522 .channel_mode = alc262_modes, 11408 .channel_mode = alc262_modes,
11523 .input_mux = &alc262_capture_source, 11409 .input_mux = &alc262_capture_source,
11524 .unsol_event = alc262_hippo_unsol_event, 11410 .unsol_event = alc262_hippo_unsol_event,
11525 .init_hook = alc262_hippo_init_hook, 11411 .setup = alc262_hippo_setup,
11412 .init_hook = alc262_hippo_automute,
11526 }, 11413 },
11527 [ALC262_BENQ_T31] = { 11414 [ALC262_BENQ_T31] = {
11528 .mixers = { alc262_benq_t31_mixer }, 11415 .mixers = { alc262_benq_t31_mixer },
11529 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, 11416 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11417 alc_hp15_unsol_verbs },
11530 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 11418 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11531 .dac_nids = alc262_dac_nids, 11419 .dac_nids = alc262_dac_nids,
11532 .hp_nid = 0x03, 11420 .hp_nid = 0x03,
@@ -11534,7 +11422,8 @@ static struct alc_config_preset alc262_presets[] = {
11534 .channel_mode = alc262_modes, 11422 .channel_mode = alc262_modes,
11535 .input_mux = &alc262_capture_source, 11423 .input_mux = &alc262_capture_source,
11536 .unsol_event = alc262_hippo_unsol_event, 11424 .unsol_event = alc262_hippo_unsol_event,
11537 .init_hook = alc262_hippo_init_hook, 11425 .setup = alc262_hippo_setup,
11426 .init_hook = alc262_hippo_automute,
11538 }, 11427 },
11539 [ALC262_ULTRA] = { 11428 [ALC262_ULTRA] = {
11540 .mixers = { alc262_ultra_mixer }, 11429 .mixers = { alc262_ultra_mixer },
@@ -11586,9 +11475,9 @@ static struct alc_config_preset alc262_presets[] = {
11586 .dig_out_nid = ALC262_DIGOUT_NID, 11475 .dig_out_nid = ALC262_DIGOUT_NID,
11587 .num_channel_mode = ARRAY_SIZE(alc262_modes), 11476 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11588 .channel_mode = alc262_modes, 11477 .channel_mode = alc262_modes,
11589 .input_mux = &alc262_dmic_capture_source, 11478 .unsol_event = alc_sku_unsol_event,
11590 .unsol_event = alc262_toshiba_s06_unsol_event, 11479 .setup = alc262_toshiba_s06_setup,
11591 .init_hook = alc262_toshiba_s06_init_hook, 11480 .init_hook = alc_inithook,
11592 }, 11481 },
11593 [ALC262_TOSHIBA_RX1] = { 11482 [ALC262_TOSHIBA_RX1] = {
11594 .mixers = { alc262_toshiba_rx1_mixer }, 11483 .mixers = { alc262_toshiba_rx1_mixer },
@@ -11600,7 +11489,8 @@ static struct alc_config_preset alc262_presets[] = {
11600 .channel_mode = alc262_modes, 11489 .channel_mode = alc262_modes,
11601 .input_mux = &alc262_capture_source, 11490 .input_mux = &alc262_capture_source,
11602 .unsol_event = alc262_hippo_unsol_event, 11491 .unsol_event = alc262_hippo_unsol_event,
11603 .init_hook = alc262_hippo_init_hook, 11492 .setup = alc262_hippo_setup,
11493 .init_hook = alc262_hippo_automute,
11604 }, 11494 },
11605 [ALC262_TYAN] = { 11495 [ALC262_TYAN] = {
11606 .mixers = { alc262_tyan_mixer }, 11496 .mixers = { alc262_tyan_mixer },
@@ -11613,7 +11503,8 @@ static struct alc_config_preset alc262_presets[] = {
11613 .channel_mode = alc262_modes, 11503 .channel_mode = alc262_modes,
11614 .input_mux = &alc262_capture_source, 11504 .input_mux = &alc262_capture_source,
11615 .unsol_event = alc_automute_amp_unsol_event, 11505 .unsol_event = alc_automute_amp_unsol_event,
11616 .init_hook = alc262_tyan_init_hook, 11506 .setup = alc262_tyan_setup,
11507 .init_hook = alc_automute_amp,
11617 }, 11508 },
11618}; 11509};
11619 11510
@@ -11648,8 +11539,8 @@ static int patch_alc262(struct hda_codec *codec)
11648 alc262_cfg_tbl); 11539 alc262_cfg_tbl);
11649 11540
11650 if (board_config < 0) { 11541 if (board_config < 0) {
11651 printk(KERN_INFO "hda_codec: Unknown model for %s, " 11542 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11652 "trying auto-probe from BIOS...\n", codec->chip_name); 11543 codec->chip_name);
11653 board_config = ALC262_AUTO; 11544 board_config = ALC262_AUTO;
11654 } 11545 }
11655 11546
@@ -11676,7 +11567,7 @@ static int patch_alc262(struct hda_codec *codec)
11676 } 11567 }
11677 11568
11678 if (board_config != ALC262_AUTO) 11569 if (board_config != ALC262_AUTO)
11679 setup_preset(spec, &alc262_presets[board_config]); 11570 setup_preset(codec, &alc262_presets[board_config]);
11680 11571
11681 spec->stream_analog_playback = &alc262_pcm_analog_playback; 11572 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11682 spec->stream_analog_capture = &alc262_pcm_analog_capture; 11573 spec->stream_analog_capture = &alc262_pcm_analog_capture;
@@ -11702,7 +11593,7 @@ static int patch_alc262(struct hda_codec *codec)
11702 unsigned int wcap = get_wcaps(codec, 0x07); 11593 unsigned int wcap = get_wcaps(codec, 0x07);
11703 11594
11704 /* get type */ 11595 /* get type */
11705 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 11596 wcap = get_wcaps_type(wcap);
11706 if (wcap != AC_WID_AUD_IN) { 11597 if (wcap != AC_WID_AUD_IN) {
11707 spec->adc_nids = alc262_adc_nids_alt; 11598 spec->adc_nids = alc262_adc_nids_alt;
11708 spec->num_adc_nids = 11599 spec->num_adc_nids =
@@ -11717,7 +11608,7 @@ static int patch_alc262(struct hda_codec *codec)
11717 } 11608 }
11718 } 11609 }
11719 if (!spec->cap_mixer && !spec->no_analog) 11610 if (!spec->cap_mixer && !spec->no_analog)
11720 set_capture_mixer(spec); 11611 set_capture_mixer(codec);
11721 if (!spec->no_analog) 11612 if (!spec->no_analog)
11722 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 11613 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11723 11614
@@ -11809,14 +11700,6 @@ static struct hda_verb alc268_toshiba_verbs[] = {
11809 { } /* end */ 11700 { } /* end */
11810}; 11701};
11811 11702
11812static struct hda_input_mux alc268_acer_lc_capture_source = {
11813 .num_items = 2,
11814 .items = {
11815 { "i-Mic", 0x6 },
11816 { "E-Mic", 0x0 },
11817 },
11818};
11819
11820/* Acer specific */ 11703/* Acer specific */
11821/* bind volumes of both NID 0x02 and 0x03 */ 11704/* bind volumes of both NID 0x02 and 0x03 */
11822static struct hda_bind_ctls alc268_acer_bind_master_vol = { 11705static struct hda_bind_ctls alc268_acer_bind_master_vol = {
@@ -11935,7 +11818,8 @@ static struct hda_verb alc268_acer_verbs[] = {
11935 11818
11936/* unsolicited event for HP jack sensing */ 11819/* unsolicited event for HP jack sensing */
11937#define alc268_toshiba_unsol_event alc262_hippo_unsol_event 11820#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11938#define alc268_toshiba_init_hook alc262_hippo_init_hook 11821#define alc268_toshiba_setup alc262_hippo_setup
11822#define alc268_toshiba_automute alc262_hippo_automute
11939 11823
11940static void alc268_acer_unsol_event(struct hda_codec *codec, 11824static void alc268_acer_unsol_event(struct hda_codec *codec,
11941 unsigned int res) 11825 unsigned int res)
@@ -11965,30 +11849,33 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11965 AMP_IN_MUTE(0), bits); 11849 AMP_IN_MUTE(0), bits);
11966} 11850}
11967 11851
11968
11969static void alc268_acer_mic_automute(struct hda_codec *codec)
11970{
11971 unsigned int present;
11972
11973 present = snd_hda_codec_read(codec, 0x18, 0,
11974 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11975 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11976 present ? 0x0 : 0x6);
11977}
11978
11979static void alc268_acer_lc_unsol_event(struct hda_codec *codec, 11852static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11980 unsigned int res) 11853 unsigned int res)
11981{ 11854{
11982 if ((res >> 26) == ALC880_HP_EVENT) 11855 switch (res >> 26) {
11856 case ALC880_HP_EVENT:
11983 alc268_aspire_one_speaker_automute(codec); 11857 alc268_aspire_one_speaker_automute(codec);
11984 if ((res >> 26) == ALC880_MIC_EVENT) 11858 break;
11985 alc268_acer_mic_automute(codec); 11859 case ALC880_MIC_EVENT:
11860 alc_mic_automute(codec);
11861 break;
11862 }
11863}
11864
11865static void alc268_acer_lc_setup(struct hda_codec *codec)
11866{
11867 struct alc_spec *spec = codec->spec;
11868 spec->ext_mic.pin = 0x18;
11869 spec->ext_mic.mux_idx = 0;
11870 spec->int_mic.pin = 0x12;
11871 spec->int_mic.mux_idx = 6;
11872 spec->auto_mic = 1;
11986} 11873}
11987 11874
11988static void alc268_acer_lc_init_hook(struct hda_codec *codec) 11875static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11989{ 11876{
11990 alc268_aspire_one_speaker_automute(codec); 11877 alc268_aspire_one_speaker_automute(codec);
11991 alc268_acer_mic_automute(codec); 11878 alc_mic_automute(codec);
11992} 11879}
11993 11880
11994static struct snd_kcontrol_new alc268_dell_mixer[] = { 11881static struct snd_kcontrol_new alc268_dell_mixer[] = {
@@ -12006,17 +11893,22 @@ static struct hda_verb alc268_dell_verbs[] = {
12006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 11893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 11894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 11895 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11896 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12009 { } 11897 { }
12010}; 11898};
12011 11899
12012/* mute/unmute internal speaker according to the hp jack and mute state */ 11900/* mute/unmute internal speaker according to the hp jack and mute state */
12013static void alc268_dell_init_hook(struct hda_codec *codec) 11901static void alc268_dell_setup(struct hda_codec *codec)
12014{ 11902{
12015 struct alc_spec *spec = codec->spec; 11903 struct alc_spec *spec = codec->spec;
12016 11904
12017 spec->autocfg.hp_pins[0] = 0x15; 11905 spec->autocfg.hp_pins[0] = 0x15;
12018 spec->autocfg.speaker_pins[0] = 0x14; 11906 spec->autocfg.speaker_pins[0] = 0x14;
12019 alc_automute_pin(codec); 11907 spec->ext_mic.pin = 0x18;
11908 spec->ext_mic.mux_idx = 0;
11909 spec->int_mic.pin = 0x19;
11910 spec->int_mic.mux_idx = 1;
11911 spec->auto_mic = 1;
12020} 11912}
12021 11913
12022static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { 11914static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
@@ -12037,38 +11929,16 @@ static struct hda_verb alc267_quanta_il1_verbs[] = {
12037 { } 11929 { }
12038}; 11930};
12039 11931
12040static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) 11932static void alc267_quanta_il1_setup(struct hda_codec *codec)
12041{
12042 unsigned int present;
12043
12044 present = snd_hda_codec_read(codec, 0x18, 0,
12045 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12046 snd_hda_codec_write(codec, 0x23, 0,
12047 AC_VERB_SET_CONNECT_SEL,
12048 present ? 0x00 : 0x01);
12049}
12050
12051static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
12052{ 11933{
12053 struct alc_spec *spec = codec->spec; 11934 struct alc_spec *spec = codec->spec;
12054
12055 spec->autocfg.hp_pins[0] = 0x15; 11935 spec->autocfg.hp_pins[0] = 0x15;
12056 spec->autocfg.speaker_pins[0] = 0x14; 11936 spec->autocfg.speaker_pins[0] = 0x14;
12057 alc_automute_pin(codec); 11937 spec->ext_mic.pin = 0x18;
12058 alc267_quanta_il1_mic_automute(codec); 11938 spec->ext_mic.mux_idx = 0;
12059} 11939 spec->int_mic.pin = 0x19;
12060 11940 spec->int_mic.mux_idx = 1;
12061static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, 11941 spec->auto_mic = 1;
12062 unsigned int res)
12063{
12064 switch (res >> 26) {
12065 case ALC880_MIC_EVENT:
12066 alc267_quanta_il1_mic_automute(codec);
12067 break;
12068 default:
12069 alc_sku_unsol_event(codec, res);
12070 break;
12071 }
12072} 11942}
12073 11943
12074/* 11944/*
@@ -12148,21 +12018,16 @@ static struct hda_verb alc268_volume_init_verbs[] = {
12148 { } 12018 { }
12149}; 12019};
12150 12020
12021static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12022 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12023 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12024 { } /* end */
12025};
12026
12151static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 12027static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12152 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 12028 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12153 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 12029 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12154 { 12030 _DEFINE_CAPSRC(1),
12155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12156 /* The multiple "Capture Source" controls confuse alsamixer
12157 * So call somewhat different..
12158 */
12159 /* .name = "Capture Source", */
12160 .name = "Input Source",
12161 .count = 1,
12162 .info = alc_mux_enum_info,
12163 .get = alc_mux_enum_get,
12164 .put = alc_mux_enum_put,
12165 },
12166 { } /* end */ 12031 { } /* end */
12167}; 12032};
12168 12033
@@ -12171,18 +12036,7 @@ static struct snd_kcontrol_new alc268_capture_mixer[] = {
12171 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 12036 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12172 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), 12037 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12173 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), 12038 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12174 { 12039 _DEFINE_CAPSRC(2),
12175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12176 /* The multiple "Capture Source" controls confuse alsamixer
12177 * So call somewhat different..
12178 */
12179 /* .name = "Capture Source", */
12180 .name = "Input Source",
12181 .count = 2,
12182 .info = alc_mux_enum_info,
12183 .get = alc_mux_enum_get,
12184 .put = alc_mux_enum_put,
12185 },
12186 { } /* end */ 12040 { } /* end */
12187}; 12041};
12188 12042
@@ -12269,26 +12123,38 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12269 const char *ctlname, int idx) 12123 const char *ctlname, int idx)
12270{ 12124{
12271 char name[32]; 12125 char name[32];
12126 hda_nid_t dac;
12272 int err; 12127 int err;
12273 12128
12274 sprintf(name, "%s Playback Volume", ctlname); 12129 sprintf(name, "%s Playback Volume", ctlname);
12275 if (nid == 0x14) { 12130 switch (nid) {
12276 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 12131 case 0x14:
12277 HDA_COMPOSE_AMP_VAL(0x02, 3, idx, 12132 case 0x16:
12278 HDA_OUTPUT)); 12133 dac = 0x02;
12279 if (err < 0) 12134 break;
12280 return err; 12135 case 0x15:
12281 } else if (nid == 0x15) { 12136 dac = 0x03;
12137 break;
12138 default:
12139 return 0;
12140 }
12141 if (spec->multiout.dac_nids[0] != dac &&
12142 spec->multiout.dac_nids[1] != dac) {
12282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 12143 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12283 HDA_COMPOSE_AMP_VAL(0x03, 3, idx, 12144 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
12284 HDA_OUTPUT)); 12145 HDA_OUTPUT));
12285 if (err < 0) 12146 if (err < 0)
12286 return err; 12147 return err;
12287 } else 12148 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12288 return -1; 12149 }
12150
12289 sprintf(name, "%s Playback Switch", ctlname); 12151 sprintf(name, "%s Playback Switch", ctlname);
12290 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 12152 if (nid != 0x16)
12153 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12291 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); 12154 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12155 else /* mono */
12156 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12157 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
12292 if (err < 0) 12158 if (err < 0)
12293 return err; 12159 return err;
12294 return 0; 12160 return 0;
@@ -12301,14 +12167,19 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12301 hda_nid_t nid; 12167 hda_nid_t nid;
12302 int err; 12168 int err;
12303 12169
12304 spec->multiout.num_dacs = 2; /* only use one dac */
12305 spec->multiout.dac_nids = spec->private_dac_nids; 12170 spec->multiout.dac_nids = spec->private_dac_nids;
12306 spec->multiout.dac_nids[0] = 2;
12307 spec->multiout.dac_nids[1] = 3;
12308 12171
12309 nid = cfg->line_out_pins[0]; 12172 nid = cfg->line_out_pins[0];
12310 if (nid) 12173 if (nid) {
12311 alc268_new_analog_output(spec, nid, "Front", 0); 12174 const char *name;
12175 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12176 name = "Speaker";
12177 else
12178 name = "Front";
12179 err = alc268_new_analog_output(spec, nid, name, 0);
12180 if (err < 0)
12181 return err;
12182 }
12312 12183
12313 nid = cfg->speaker_pins[0]; 12184 nid = cfg->speaker_pins[0];
12314 if (nid == 0x1d) { 12185 if (nid == 0x1d) {
@@ -12317,16 +12188,23 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12317 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 12188 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12318 if (err < 0) 12189 if (err < 0)
12319 return err; 12190 return err;
12191 } else {
12192 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12193 if (err < 0)
12194 return err;
12320 } 12195 }
12321 nid = cfg->hp_pins[0]; 12196 nid = cfg->hp_pins[0];
12322 if (nid) 12197 if (nid) {
12323 alc268_new_analog_output(spec, nid, "Headphone", 0); 12198 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12199 if (err < 0)
12200 return err;
12201 }
12324 12202
12325 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; 12203 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12326 if (nid == 0x16) { 12204 if (nid == 0x16) {
12327 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12205 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12328 "Mono Playback Switch", 12206 "Mono Playback Switch",
12329 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); 12207 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
12330 if (err < 0) 12208 if (err < 0)
12331 return err; 12209 return err;
12332 } 12210 }
@@ -12338,32 +12216,40 @@ static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12338 const struct auto_pin_cfg *cfg) 12216 const struct auto_pin_cfg *cfg)
12339{ 12217{
12340 struct hda_input_mux *imux = &spec->private_imux[0]; 12218 struct hda_input_mux *imux = &spec->private_imux[0];
12341 int i, idx1; 12219 int i, idx1, dmic_nid;
12342 12220
12343 for (i = 0; i < AUTO_PIN_LAST; i++) { 12221 dmic_nid = 0x12;
12344 switch(cfg->input_pins[i]) { 12222 while (dmic_nid <= 0x13) {
12345 case 0x18: 12223 for (i = 0; i < AUTO_PIN_LAST; i++) {
12346 idx1 = 0; /* Mic 1 */ 12224 switch (cfg->input_pins[i]) {
12347 break; 12225 case 0x18:
12348 case 0x19: 12226 idx1 = 0; /* Mic 1 */
12349 idx1 = 1; /* Mic 2 */ 12227 break;
12350 break; 12228 case 0x19:
12351 case 0x1a: 12229 idx1 = 1; /* Mic 2 */
12352 idx1 = 2; /* Line In */ 12230 break;
12353 break; 12231 case 0x1a:
12354 case 0x1c: 12232 idx1 = 2; /* Line In */
12355 idx1 = 3; /* CD */ 12233 break;
12356 break; 12234 case 0x1c:
12357 case 0x12: 12235 idx1 = 3; /* CD */
12358 case 0x13: 12236 break;
12359 idx1 = 6; /* digital mics */ 12237 case 0x12:
12360 break; 12238 case 0x13:
12361 default: 12239 if (cfg->input_pins[i] != dmic_nid)
12362 continue; 12240 continue;
12241 idx1 = 6; /* digital mics */
12242 break;
12243 default:
12244 continue;
12245 }
12246 imux->items[imux->num_items].label =
12247 auto_pin_cfg_labels[i];
12248 imux->items[imux->num_items].index = idx1;
12249 imux->num_items++;
12363 } 12250 }
12364 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 12251 imux++;
12365 imux->items[imux->num_items].index = idx1; 12252 dmic_nid++;
12366 imux->num_items++;
12367 } 12253 }
12368 return 0; 12254 return 0;
12369} 12255}
@@ -12461,7 +12347,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
12461 add_mixer(spec, alc268_beep_mixer); 12347 add_mixer(spec, alc268_beep_mixer);
12462 12348
12463 add_verb(spec, alc268_volume_init_verbs); 12349 add_verb(spec, alc268_volume_init_verbs);
12464 spec->num_mux_defs = 1; 12350 spec->num_mux_defs = 2;
12465 spec->input_mux = &spec->private_imux[0]; 12351 spec->input_mux = &spec->private_imux[0];
12466 12352
12467 err = alc_auto_add_mic_boost(codec); 12353 err = alc_auto_add_mic_boost(codec);
@@ -12532,7 +12418,8 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
12532 12418
12533static struct alc_config_preset alc268_presets[] = { 12419static struct alc_config_preset alc268_presets[] = {
12534 [ALC267_QUANTA_IL1] = { 12420 [ALC267_QUANTA_IL1] = {
12535 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer }, 12421 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12422 alc268_capture_nosrc_mixer },
12536 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12423 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12537 alc267_quanta_il1_verbs }, 12424 alc267_quanta_il1_verbs },
12538 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12425 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -12542,9 +12429,9 @@ static struct alc_config_preset alc268_presets[] = {
12542 .hp_nid = 0x03, 12429 .hp_nid = 0x03,
12543 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12430 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12544 .channel_mode = alc268_modes, 12431 .channel_mode = alc268_modes,
12545 .input_mux = &alc268_capture_source, 12432 .unsol_event = alc_sku_unsol_event,
12546 .unsol_event = alc267_quanta_il1_unsol_event, 12433 .setup = alc267_quanta_il1_setup,
12547 .init_hook = alc267_quanta_il1_init_hook, 12434 .init_hook = alc_inithook,
12548 }, 12435 },
12549 [ALC268_3ST] = { 12436 [ALC268_3ST] = {
12550 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 12437 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
@@ -12576,10 +12463,11 @@ static struct alc_config_preset alc268_presets[] = {
12576 .channel_mode = alc268_modes, 12463 .channel_mode = alc268_modes,
12577 .input_mux = &alc268_capture_source, 12464 .input_mux = &alc268_capture_source,
12578 .unsol_event = alc268_toshiba_unsol_event, 12465 .unsol_event = alc268_toshiba_unsol_event,
12579 .init_hook = alc268_toshiba_init_hook, 12466 .setup = alc268_toshiba_setup,
12467 .init_hook = alc268_toshiba_automute,
12580 }, 12468 },
12581 [ALC268_ACER] = { 12469 [ALC268_ACER] = {
12582 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, 12470 .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer,
12583 alc268_beep_mixer }, 12471 alc268_beep_mixer },
12584 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12472 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12585 alc268_acer_verbs }, 12473 alc268_acer_verbs },
@@ -12615,7 +12503,7 @@ static struct alc_config_preset alc268_presets[] = {
12615 [ALC268_ACER_ASPIRE_ONE] = { 12503 [ALC268_ACER_ASPIRE_ONE] = {
12616 .mixers = { alc268_acer_aspire_one_mixer, 12504 .mixers = { alc268_acer_aspire_one_mixer,
12617 alc268_beep_mixer, 12505 alc268_beep_mixer,
12618 alc268_capture_alt_mixer }, 12506 alc268_capture_nosrc_mixer },
12619 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12507 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12620 alc268_acer_aspire_one_verbs }, 12508 alc268_acer_aspire_one_verbs },
12621 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12509 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -12626,22 +12514,26 @@ static struct alc_config_preset alc268_presets[] = {
12626 .hp_nid = 0x03, 12514 .hp_nid = 0x03,
12627 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12515 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12628 .channel_mode = alc268_modes, 12516 .channel_mode = alc268_modes,
12629 .input_mux = &alc268_acer_lc_capture_source,
12630 .unsol_event = alc268_acer_lc_unsol_event, 12517 .unsol_event = alc268_acer_lc_unsol_event,
12518 .setup = alc268_acer_lc_setup,
12631 .init_hook = alc268_acer_lc_init_hook, 12519 .init_hook = alc268_acer_lc_init_hook,
12632 }, 12520 },
12633 [ALC268_DELL] = { 12521 [ALC268_DELL] = {
12634 .mixers = { alc268_dell_mixer, alc268_beep_mixer }, 12522 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12523 alc268_capture_nosrc_mixer },
12635 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12524 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12636 alc268_dell_verbs }, 12525 alc268_dell_verbs },
12637 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12526 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12638 .dac_nids = alc268_dac_nids, 12527 .dac_nids = alc268_dac_nids,
12528 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12529 .adc_nids = alc268_adc_nids_alt,
12530 .capsrc_nids = alc268_capsrc_nids,
12639 .hp_nid = 0x02, 12531 .hp_nid = 0x02,
12640 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12532 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12641 .channel_mode = alc268_modes, 12533 .channel_mode = alc268_modes,
12642 .unsol_event = alc_sku_unsol_event, 12534 .unsol_event = alc_sku_unsol_event,
12643 .init_hook = alc268_dell_init_hook, 12535 .setup = alc268_dell_setup,
12644 .input_mux = &alc268_capture_source, 12536 .init_hook = alc_inithook,
12645 }, 12537 },
12646 [ALC268_ZEPTO] = { 12538 [ALC268_ZEPTO] = {
12647 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 12539 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
@@ -12658,8 +12550,8 @@ static struct alc_config_preset alc268_presets[] = {
12658 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12550 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12659 .channel_mode = alc268_modes, 12551 .channel_mode = alc268_modes,
12660 .input_mux = &alc268_capture_source, 12552 .input_mux = &alc268_capture_source,
12661 .unsol_event = alc268_toshiba_unsol_event, 12553 .setup = alc268_toshiba_setup,
12662 .init_hook = alc268_toshiba_init_hook 12554 .init_hook = alc268_toshiba_automute,
12663 }, 12555 },
12664#ifdef CONFIG_SND_DEBUG 12556#ifdef CONFIG_SND_DEBUG
12665 [ALC268_TEST] = { 12557 [ALC268_TEST] = {
@@ -12697,8 +12589,8 @@ static int patch_alc268(struct hda_codec *codec)
12697 alc268_cfg_tbl); 12589 alc268_cfg_tbl);
12698 12590
12699 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { 12591 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12700 printk(KERN_INFO "hda_codec: Unknown model for %s, " 12592 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12701 "trying auto-probe from BIOS...\n", codec->chip_name); 12593 codec->chip_name);
12702 board_config = ALC268_AUTO; 12594 board_config = ALC268_AUTO;
12703 } 12595 }
12704 12596
@@ -12717,7 +12609,7 @@ static int patch_alc268(struct hda_codec *codec)
12717 } 12609 }
12718 12610
12719 if (board_config != ALC268_AUTO) 12611 if (board_config != ALC268_AUTO)
12720 setup_preset(spec, &alc268_presets[board_config]); 12612 setup_preset(codec, &alc268_presets[board_config]);
12721 12613
12722 spec->stream_analog_playback = &alc268_pcm_analog_playback; 12614 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12723 spec->stream_analog_capture = &alc268_pcm_analog_capture; 12615 spec->stream_analog_capture = &alc268_pcm_analog_capture;
@@ -12754,11 +12646,15 @@ static int patch_alc268(struct hda_codec *codec)
12754 int i; 12646 int i;
12755 12647
12756 /* get type */ 12648 /* get type */
12757 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 12649 wcap = get_wcaps_type(wcap);
12758 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 12650 if (spec->auto_mic ||
12651 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
12759 spec->adc_nids = alc268_adc_nids_alt; 12652 spec->adc_nids = alc268_adc_nids_alt;
12760 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); 12653 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
12761 add_mixer(spec, alc268_capture_alt_mixer); 12654 if (spec->auto_mic || spec->input_mux->num_items == 1)
12655 add_mixer(spec, alc268_capture_nosrc_mixer);
12656 else
12657 add_mixer(spec, alc268_capture_alt_mixer);
12762 } else { 12658 } else {
12763 spec->adc_nids = alc268_adc_nids; 12659 spec->adc_nids = alc268_adc_nids;
12764 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); 12660 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
@@ -12769,6 +12665,8 @@ static int patch_alc268(struct hda_codec *codec)
12769 for (i = 0; i < spec->num_adc_nids; i++) 12665 for (i = 0; i < spec->num_adc_nids; i++)
12770 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], 12666 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12771 0, AC_VERB_SET_CONNECT_SEL, 12667 0, AC_VERB_SET_CONNECT_SEL,
12668 i < spec->num_mux_defs ?
12669 spec->input_mux[i].items[0].index :
12772 spec->input_mux->items[0].index); 12670 spec->input_mux->items[0].index);
12773 } 12671 }
12774 12672
@@ -12803,22 +12701,6 @@ static hda_nid_t alc269_capsrc_nids[1] = {
12803 * not a mux! 12701 * not a mux!
12804 */ 12702 */
12805 12703
12806static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12807 .num_items = 2,
12808 .items = {
12809 { "i-Mic", 0x5 },
12810 { "e-Mic", 0x0 },
12811 },
12812};
12813
12814static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12815 .num_items = 2,
12816 .items = {
12817 { "i-Mic", 0x1 },
12818 { "e-Mic", 0x0 },
12819 },
12820};
12821
12822#define alc269_modes alc260_modes 12704#define alc269_modes alc260_modes
12823#define alc269_capture_source alc880_lg_lw_capture_source 12705#define alc269_capture_source alc880_lg_lw_capture_source
12824 12706
@@ -12980,16 +12862,6 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12980 AC_VERB_SET_PROC_COEF, 0x480); 12862 AC_VERB_SET_PROC_COEF, 0x480);
12981} 12863}
12982 12864
12983static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12984{
12985 unsigned int present;
12986
12987 present = snd_hda_codec_read(codec, 0x18, 0,
12988 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12989 snd_hda_codec_write(codec, 0x23, 0,
12990 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12991}
12992
12993static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) 12865static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12994{ 12866{
12995 unsigned int present_laptop; 12867 unsigned int present_laptop;
@@ -13016,10 +12888,14 @@ static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13016static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, 12888static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13017 unsigned int res) 12889 unsigned int res)
13018{ 12890{
13019 if ((res >> 26) == ALC880_HP_EVENT) 12891 switch (res >> 26) {
12892 case ALC880_HP_EVENT:
13020 alc269_quanta_fl1_speaker_automute(codec); 12893 alc269_quanta_fl1_speaker_automute(codec);
13021 if ((res >> 26) == ALC880_MIC_EVENT) 12894 break;
13022 alc269_quanta_fl1_mic_automute(codec); 12895 case ALC880_MIC_EVENT:
12896 alc_mic_automute(codec);
12897 break;
12898 }
13023} 12899}
13024 12900
13025static void alc269_lifebook_unsol_event(struct hda_codec *codec, 12901static void alc269_lifebook_unsol_event(struct hda_codec *codec,
@@ -13031,10 +12907,20 @@ static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13031 alc269_lifebook_mic_autoswitch(codec); 12907 alc269_lifebook_mic_autoswitch(codec);
13032} 12908}
13033 12909
12910static void alc269_quanta_fl1_setup(struct hda_codec *codec)
12911{
12912 struct alc_spec *spec = codec->spec;
12913 spec->ext_mic.pin = 0x18;
12914 spec->ext_mic.mux_idx = 0;
12915 spec->int_mic.pin = 0x19;
12916 spec->int_mic.mux_idx = 1;
12917 spec->auto_mic = 1;
12918}
12919
13034static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) 12920static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13035{ 12921{
13036 alc269_quanta_fl1_speaker_automute(codec); 12922 alc269_quanta_fl1_speaker_automute(codec);
13037 alc269_quanta_fl1_mic_automute(codec); 12923 alc_mic_automute(codec);
13038} 12924}
13039 12925
13040static void alc269_lifebook_init_hook(struct hda_codec *codec) 12926static void alc269_lifebook_init_hook(struct hda_codec *codec)
@@ -13079,60 +12965,44 @@ static void alc269_speaker_automute(struct hda_codec *codec)
13079 AMP_IN_MUTE(0), bits); 12965 AMP_IN_MUTE(0), bits);
13080} 12966}
13081 12967
13082static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13083{
13084 unsigned int present;
13085
13086 present = snd_hda_codec_read(codec, 0x18, 0,
13087 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13088 snd_hda_codec_write(codec, 0x23, 0,
13089 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13090}
13091
13092static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13093{
13094 unsigned int present;
13095
13096 present = snd_hda_codec_read(codec, 0x18, 0,
13097 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13098 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13099 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13100 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13101 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13102}
13103
13104/* unsolicited event for HP jack sensing */ 12968/* unsolicited event for HP jack sensing */
13105static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, 12969static void alc269_eeepc_unsol_event(struct hda_codec *codec,
13106 unsigned int res) 12970 unsigned int res)
13107{ 12971{
13108 if ((res >> 26) == ALC880_HP_EVENT) 12972 switch (res >> 26) {
12973 case ALC880_HP_EVENT:
13109 alc269_speaker_automute(codec); 12974 alc269_speaker_automute(codec);
13110 12975 break;
13111 if ((res >> 26) == ALC880_MIC_EVENT) 12976 case ALC880_MIC_EVENT:
13112 alc269_eeepc_dmic_automute(codec); 12977 alc_mic_automute(codec);
12978 break;
12979 }
13113} 12980}
13114 12981
13115static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) 12982static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13116{ 12983{
13117 alc269_speaker_automute(codec); 12984 struct alc_spec *spec = codec->spec;
13118 alc269_eeepc_dmic_automute(codec); 12985 spec->ext_mic.pin = 0x18;
12986 spec->ext_mic.mux_idx = 0;
12987 spec->int_mic.pin = 0x12;
12988 spec->int_mic.mux_idx = 5;
12989 spec->auto_mic = 1;
13119} 12990}
13120 12991
13121/* unsolicited event for HP jack sensing */ 12992static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13122static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13123 unsigned int res)
13124{ 12993{
13125 if ((res >> 26) == ALC880_HP_EVENT) 12994 struct alc_spec *spec = codec->spec;
13126 alc269_speaker_automute(codec); 12995 spec->ext_mic.pin = 0x18;
13127 12996 spec->ext_mic.mux_idx = 0;
13128 if ((res >> 26) == ALC880_MIC_EVENT) 12997 spec->int_mic.pin = 0x19;
13129 alc269_eeepc_amic_automute(codec); 12998 spec->int_mic.mux_idx = 1;
12999 spec->auto_mic = 1;
13130} 13000}
13131 13001
13132static void alc269_eeepc_amic_inithook(struct hda_codec *codec) 13002static void alc269_eeepc_inithook(struct hda_codec *codec)
13133{ 13003{
13134 alc269_speaker_automute(codec); 13004 alc269_speaker_automute(codec);
13135 alc269_eeepc_amic_automute(codec); 13005 alc_mic_automute(codec);
13136} 13006}
13137 13007
13138/* 13008/*
@@ -13362,7 +13232,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13362 return err; 13232 return err;
13363 13233
13364 if (!spec->cap_mixer && !spec->no_analog) 13234 if (!spec->cap_mixer && !spec->no_analog)
13365 set_capture_mixer(spec); 13235 set_capture_mixer(codec);
13366 13236
13367 alc_ssid_check(codec, 0x15, 0x1b, 0x14); 13237 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13368 13238
@@ -13438,6 +13308,7 @@ static struct alc_config_preset alc269_presets[] = {
13438 .channel_mode = alc269_modes, 13308 .channel_mode = alc269_modes,
13439 .input_mux = &alc269_capture_source, 13309 .input_mux = &alc269_capture_source,
13440 .unsol_event = alc269_quanta_fl1_unsol_event, 13310 .unsol_event = alc269_quanta_fl1_unsol_event,
13311 .setup = alc269_quanta_fl1_setup,
13441 .init_hook = alc269_quanta_fl1_init_hook, 13312 .init_hook = alc269_quanta_fl1_init_hook,
13442 }, 13313 },
13443 [ALC269_ASUS_EEEPC_P703] = { 13314 [ALC269_ASUS_EEEPC_P703] = {
@@ -13450,9 +13321,9 @@ static struct alc_config_preset alc269_presets[] = {
13450 .hp_nid = 0x03, 13321 .hp_nid = 0x03,
13451 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13322 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13452 .channel_mode = alc269_modes, 13323 .channel_mode = alc269_modes,
13453 .input_mux = &alc269_eeepc_amic_capture_source, 13324 .unsol_event = alc269_eeepc_unsol_event,
13454 .unsol_event = alc269_eeepc_amic_unsol_event, 13325 .setup = alc269_eeepc_amic_setup,
13455 .init_hook = alc269_eeepc_amic_inithook, 13326 .init_hook = alc269_eeepc_inithook,
13456 }, 13327 },
13457 [ALC269_ASUS_EEEPC_P901] = { 13328 [ALC269_ASUS_EEEPC_P901] = {
13458 .mixers = { alc269_eeepc_mixer }, 13329 .mixers = { alc269_eeepc_mixer },
@@ -13464,9 +13335,9 @@ static struct alc_config_preset alc269_presets[] = {
13464 .hp_nid = 0x03, 13335 .hp_nid = 0x03,
13465 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13336 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13466 .channel_mode = alc269_modes, 13337 .channel_mode = alc269_modes,
13467 .input_mux = &alc269_eeepc_dmic_capture_source, 13338 .unsol_event = alc269_eeepc_unsol_event,
13468 .unsol_event = alc269_eeepc_dmic_unsol_event, 13339 .setup = alc269_eeepc_dmic_setup,
13469 .init_hook = alc269_eeepc_dmic_inithook, 13340 .init_hook = alc269_eeepc_inithook,
13470 }, 13341 },
13471 [ALC269_FUJITSU] = { 13342 [ALC269_FUJITSU] = {
13472 .mixers = { alc269_fujitsu_mixer }, 13343 .mixers = { alc269_fujitsu_mixer },
@@ -13478,9 +13349,9 @@ static struct alc_config_preset alc269_presets[] = {
13478 .hp_nid = 0x03, 13349 .hp_nid = 0x03,
13479 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13350 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13480 .channel_mode = alc269_modes, 13351 .channel_mode = alc269_modes,
13481 .input_mux = &alc269_eeepc_dmic_capture_source, 13352 .unsol_event = alc269_eeepc_unsol_event,
13482 .unsol_event = alc269_eeepc_dmic_unsol_event, 13353 .setup = alc269_eeepc_dmic_setup,
13483 .init_hook = alc269_eeepc_dmic_inithook, 13354 .init_hook = alc269_eeepc_inithook,
13484 }, 13355 },
13485 [ALC269_LIFEBOOK] = { 13356 [ALC269_LIFEBOOK] = {
13486 .mixers = { alc269_lifebook_mixer }, 13357 .mixers = { alc269_lifebook_mixer },
@@ -13515,8 +13386,8 @@ static int patch_alc269(struct hda_codec *codec)
13515 alc269_cfg_tbl); 13386 alc269_cfg_tbl);
13516 13387
13517 if (board_config < 0) { 13388 if (board_config < 0) {
13518 printk(KERN_INFO "hda_codec: Unknown model for %s, " 13389 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13519 "trying auto-probe from BIOS...\n", codec->chip_name); 13390 codec->chip_name);
13520 board_config = ALC269_AUTO; 13391 board_config = ALC269_AUTO;
13521 } 13392 }
13522 13393
@@ -13541,7 +13412,7 @@ static int patch_alc269(struct hda_codec *codec)
13541 } 13412 }
13542 13413
13543 if (board_config != ALC269_AUTO) 13414 if (board_config != ALC269_AUTO)
13544 setup_preset(spec, &alc269_presets[board_config]); 13415 setup_preset(codec, &alc269_presets[board_config]);
13545 13416
13546 if (codec->subsystem_id == 0x17aa3bf8) { 13417 if (codec->subsystem_id == 0x17aa3bf8) {
13547 /* Due to a hardware problem on Lenovo Ideadpad, we need to 13418 /* Due to a hardware problem on Lenovo Ideadpad, we need to
@@ -13560,7 +13431,7 @@ static int patch_alc269(struct hda_codec *codec)
13560 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 13431 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
13561 spec->capsrc_nids = alc269_capsrc_nids; 13432 spec->capsrc_nids = alc269_capsrc_nids;
13562 if (!spec->cap_mixer) 13433 if (!spec->cap_mixer)
13563 set_capture_mixer(spec); 13434 set_capture_mixer(codec);
13564 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 13435 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
13565 13436
13566 spec->vmaster_nid = 0x02; 13437 spec->vmaster_nid = 0x02;
@@ -14110,23 +13981,23 @@ static struct hda_verb alc861_auto_init_verbs[] = {
14110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, 13982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14112 13983
14113 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13984 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14114 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13985 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14115 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13986 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14116 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14117 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13988 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14118 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14119 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13990 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14120 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14121 13992
14122 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13993 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14123 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13994 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14124 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13995 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 13996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14126 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13997 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14127 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14128 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13999 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14129 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 14000 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14130 14001
14131 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ 14002 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
14132 14003
@@ -14198,64 +14069,96 @@ static struct hda_input_mux alc861_capture_source = {
14198 }, 14069 },
14199}; 14070};
14200 14071
14072static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14073{
14074 struct alc_spec *spec = codec->spec;
14075 hda_nid_t mix, srcs[5];
14076 int i, j, num;
14077
14078 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14079 return 0;
14080 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14081 if (num < 0)
14082 return 0;
14083 for (i = 0; i < num; i++) {
14084 unsigned int type;
14085 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
14086 if (type != AC_WID_AUD_OUT)
14087 continue;
14088 for (j = 0; j < spec->multiout.num_dacs; j++)
14089 if (spec->multiout.dac_nids[j] == srcs[i])
14090 break;
14091 if (j >= spec->multiout.num_dacs)
14092 return srcs[i];
14093 }
14094 return 0;
14095}
14096
14201/* fill in the dac_nids table from the parsed pin configuration */ 14097/* fill in the dac_nids table from the parsed pin configuration */
14202static int alc861_auto_fill_dac_nids(struct alc_spec *spec, 14098static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
14203 const struct auto_pin_cfg *cfg) 14099 const struct auto_pin_cfg *cfg)
14204{ 14100{
14101 struct alc_spec *spec = codec->spec;
14205 int i; 14102 int i;
14206 hda_nid_t nid; 14103 hda_nid_t nid, dac;
14207 14104
14208 spec->multiout.dac_nids = spec->private_dac_nids; 14105 spec->multiout.dac_nids = spec->private_dac_nids;
14209 for (i = 0; i < cfg->line_outs; i++) { 14106 for (i = 0; i < cfg->line_outs; i++) {
14210 nid = cfg->line_out_pins[i]; 14107 nid = cfg->line_out_pins[i];
14211 if (nid) { 14108 dac = alc861_look_for_dac(codec, nid);
14212 if (i >= ARRAY_SIZE(alc861_dac_nids)) 14109 if (!dac)
14213 continue; 14110 continue;
14214 spec->multiout.dac_nids[i] = alc861_dac_nids[i]; 14111 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
14215 }
14216 } 14112 }
14217 spec->multiout.num_dacs = cfg->line_outs;
14218 return 0; 14113 return 0;
14219} 14114}
14220 14115
14116static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14117 hda_nid_t nid, unsigned int chs)
14118{
14119 char name[32];
14120 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14121 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14122 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14123}
14124
14221/* add playback controls from the parsed DAC table */ 14125/* add playback controls from the parsed DAC table */
14222static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, 14126static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14223 const struct auto_pin_cfg *cfg) 14127 const struct auto_pin_cfg *cfg)
14224{ 14128{
14225 char name[32]; 14129 struct alc_spec *spec = codec->spec;
14226 static const char *chname[4] = { 14130 static const char *chname[4] = {
14227 "Front", "Surround", NULL /*CLFE*/, "Side" 14131 "Front", "Surround", NULL /*CLFE*/, "Side"
14228 }; 14132 };
14229 hda_nid_t nid; 14133 hda_nid_t nid;
14230 int i, idx, err; 14134 int i, err;
14135
14136 if (cfg->line_outs == 1) {
14137 const char *pfx = NULL;
14138 if (!cfg->hp_outs)
14139 pfx = "Master";
14140 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14141 pfx = "Speaker";
14142 if (pfx) {
14143 nid = spec->multiout.dac_nids[0];
14144 return alc861_create_out_sw(codec, pfx, nid, 3);
14145 }
14146 }
14231 14147
14232 for (i = 0; i < cfg->line_outs; i++) { 14148 for (i = 0; i < cfg->line_outs; i++) {
14233 nid = spec->multiout.dac_nids[i]; 14149 nid = spec->multiout.dac_nids[i];
14234 if (!nid) 14150 if (!nid)
14235 continue; 14151 continue;
14236 if (nid == 0x05) { 14152 if (i == 2) {
14237 /* Center/LFE */ 14153 /* Center/LFE */
14238 err = add_control(spec, ALC_CTL_BIND_MUTE, 14154 err = alc861_create_out_sw(codec, "Center", nid, 1);
14239 "Center Playback Switch",
14240 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14241 HDA_OUTPUT));
14242 if (err < 0) 14155 if (err < 0)
14243 return err; 14156 return err;
14244 err = add_control(spec, ALC_CTL_BIND_MUTE, 14157 err = alc861_create_out_sw(codec, "LFE", nid, 2);
14245 "LFE Playback Switch",
14246 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14247 HDA_OUTPUT));
14248 if (err < 0) 14158 if (err < 0)
14249 return err; 14159 return err;
14250 } else { 14160 } else {
14251 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; 14161 err = alc861_create_out_sw(codec, chname[i], nid, 3);
14252 idx++)
14253 if (nid == alc861_dac_nids[idx])
14254 break;
14255 sprintf(name, "%s Playback Switch", chname[idx]);
14256 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14257 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14258 HDA_OUTPUT));
14259 if (err < 0) 14162 if (err < 0)
14260 return err; 14163 return err;
14261 } 14164 }
@@ -14263,8 +14166,9 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14263 return 0; 14166 return 0;
14264} 14167}
14265 14168
14266static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) 14169static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
14267{ 14170{
14171 struct alc_spec *spec = codec->spec;
14268 int err; 14172 int err;
14269 hda_nid_t nid; 14173 hda_nid_t nid;
14270 14174
@@ -14272,21 +14176,22 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14272 return 0; 14176 return 0;
14273 14177
14274 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 14178 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14275 nid = 0x03; 14179 nid = alc861_look_for_dac(codec, pin);
14276 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 14180 if (nid) {
14277 "Headphone Playback Switch", 14181 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14278 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 14182 if (err < 0)
14279 if (err < 0) 14183 return err;
14280 return err; 14184 spec->multiout.hp_nid = nid;
14281 spec->multiout.hp_nid = nid; 14185 }
14282 } 14186 }
14283 return 0; 14187 return 0;
14284} 14188}
14285 14189
14286/* create playback/capture controls for input pins */ 14190/* create playback/capture controls for input pins */
14287static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, 14191static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
14288 const struct auto_pin_cfg *cfg) 14192 const struct auto_pin_cfg *cfg)
14289{ 14193{
14194 struct alc_spec *spec = codec->spec;
14290 struct hda_input_mux *imux = &spec->private_imux[0]; 14195 struct hda_input_mux *imux = &spec->private_imux[0];
14291 int i, err, idx, idx1; 14196 int i, err, idx, idx1;
14292 14197
@@ -14330,12 +14235,29 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
14330 14235
14331static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, 14236static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14332 hda_nid_t nid, 14237 hda_nid_t nid,
14333 int pin_type, int dac_idx) 14238 int pin_type, hda_nid_t dac)
14334{ 14239{
14240 hda_nid_t mix, srcs[5];
14241 int i, num;
14242
14335 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 14243 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14336 pin_type); 14244 pin_type);
14337 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, 14245 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14338 AMP_OUT_UNMUTE); 14246 AMP_OUT_UNMUTE);
14247 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14248 return;
14249 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14250 if (num < 0)
14251 return;
14252 for (i = 0; i < num; i++) {
14253 unsigned int mute;
14254 if (srcs[i] == dac || srcs[i] == 0x15)
14255 mute = AMP_IN_UNMUTE(i);
14256 else
14257 mute = AMP_IN_MUTE(i);
14258 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14259 mute);
14260 }
14339} 14261}
14340 14262
14341static void alc861_auto_init_multi_out(struct hda_codec *codec) 14263static void alc861_auto_init_multi_out(struct hda_codec *codec)
@@ -14358,12 +14280,13 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
14358 hda_nid_t pin; 14280 hda_nid_t pin;
14359 14281
14360 pin = spec->autocfg.hp_pins[0]; 14282 pin = spec->autocfg.hp_pins[0];
14361 if (pin) /* connect to front */ 14283 if (pin)
14362 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, 14284 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14363 spec->multiout.dac_nids[0]); 14285 spec->multiout.hp_nid);
14364 pin = spec->autocfg.speaker_pins[0]; 14286 pin = spec->autocfg.speaker_pins[0];
14365 if (pin) 14287 if (pin)
14366 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 14288 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14289 spec->multiout.dac_nids[0]);
14367} 14290}
14368 14291
14369static void alc861_auto_init_analog_input(struct hda_codec *codec) 14292static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -14395,16 +14318,16 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
14395 if (!spec->autocfg.line_outs) 14318 if (!spec->autocfg.line_outs)
14396 return 0; /* can't find valid BIOS pin config */ 14319 return 0; /* can't find valid BIOS pin config */
14397 14320
14398 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); 14321 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
14399 if (err < 0) 14322 if (err < 0)
14400 return err; 14323 return err;
14401 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); 14324 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
14402 if (err < 0) 14325 if (err < 0)
14403 return err; 14326 return err;
14404 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 14327 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
14405 if (err < 0) 14328 if (err < 0)
14406 return err; 14329 return err;
14407 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); 14330 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg);
14408 if (err < 0) 14331 if (err < 0)
14409 return err; 14332 return err;
14410 14333
@@ -14423,7 +14346,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
14423 14346
14424 spec->adc_nids = alc861_adc_nids; 14347 spec->adc_nids = alc861_adc_nids;
14425 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 14348 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
14426 set_capture_mixer(spec); 14349 set_capture_mixer(codec);
14427 14350
14428 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); 14351 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14429 14352
@@ -14616,8 +14539,8 @@ static int patch_alc861(struct hda_codec *codec)
14616 alc861_cfg_tbl); 14539 alc861_cfg_tbl);
14617 14540
14618 if (board_config < 0) { 14541 if (board_config < 0) {
14619 printk(KERN_INFO "hda_codec: Unknown model for %s, " 14542 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14620 "trying auto-probe from BIOS...\n", codec->chip_name); 14543 codec->chip_name);
14621 board_config = ALC861_AUTO; 14544 board_config = ALC861_AUTO;
14622 } 14545 }
14623 14546
@@ -14642,7 +14565,7 @@ static int patch_alc861(struct hda_codec *codec)
14642 } 14565 }
14643 14566
14644 if (board_config != ALC861_AUTO) 14567 if (board_config != ALC861_AUTO)
14645 setup_preset(spec, &alc861_presets[board_config]); 14568 setup_preset(codec, &alc861_presets[board_config]);
14646 14569
14647 spec->stream_analog_playback = &alc861_pcm_analog_playback; 14570 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14648 spec->stream_analog_capture = &alc861_pcm_analog_capture; 14571 spec->stream_analog_capture = &alc861_pcm_analog_capture;
@@ -15045,12 +14968,15 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15045 HDA_AMP_MUTE, bits); 14968 HDA_AMP_MUTE, bits);
15046} 14969}
15047 14970
15048static void alc861vd_lenovo_init_hook(struct hda_codec *codec) 14971static void alc861vd_lenovo_setup(struct hda_codec *codec)
15049{ 14972{
15050 struct alc_spec *spec = codec->spec; 14973 struct alc_spec *spec = codec->spec;
15051
15052 spec->autocfg.hp_pins[0] = 0x1b; 14974 spec->autocfg.hp_pins[0] = 0x1b;
15053 spec->autocfg.speaker_pins[0] = 0x14; 14975 spec->autocfg.speaker_pins[0] = 0x14;
14976}
14977
14978static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
14979{
15054 alc_automute_amp(codec); 14980 alc_automute_amp(codec);
15055 alc861vd_lenovo_mic_automute(codec); 14981 alc861vd_lenovo_mic_automute(codec);
15056} 14982}
@@ -15114,13 +15040,12 @@ static struct hda_verb alc861vd_dallas_verbs[] = {
15114}; 15040};
15115 15041
15116/* toggle speaker-output according to the hp-jack state */ 15042/* toggle speaker-output according to the hp-jack state */
15117static void alc861vd_dallas_init_hook(struct hda_codec *codec) 15043static void alc861vd_dallas_setup(struct hda_codec *codec)
15118{ 15044{
15119 struct alc_spec *spec = codec->spec; 15045 struct alc_spec *spec = codec->spec;
15120 15046
15121 spec->autocfg.hp_pins[0] = 0x15; 15047 spec->autocfg.hp_pins[0] = 0x15;
15122 spec->autocfg.speaker_pins[0] = 0x14; 15048 spec->autocfg.speaker_pins[0] = 0x14;
15123 alc_automute_amp(codec);
15124} 15049}
15125 15050
15126#ifdef CONFIG_SND_HDA_POWER_SAVE 15051#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -15234,6 +15159,7 @@ static struct alc_config_preset alc861vd_presets[] = {
15234 .channel_mode = alc861vd_3stack_2ch_modes, 15159 .channel_mode = alc861vd_3stack_2ch_modes,
15235 .input_mux = &alc861vd_capture_source, 15160 .input_mux = &alc861vd_capture_source,
15236 .unsol_event = alc861vd_lenovo_unsol_event, 15161 .unsol_event = alc861vd_lenovo_unsol_event,
15162 .setup = alc861vd_lenovo_setup,
15237 .init_hook = alc861vd_lenovo_init_hook, 15163 .init_hook = alc861vd_lenovo_init_hook,
15238 }, 15164 },
15239 [ALC861VD_DALLAS] = { 15165 [ALC861VD_DALLAS] = {
@@ -15245,7 +15171,8 @@ static struct alc_config_preset alc861vd_presets[] = {
15245 .channel_mode = alc861vd_3stack_2ch_modes, 15171 .channel_mode = alc861vd_3stack_2ch_modes,
15246 .input_mux = &alc861vd_dallas_capture_source, 15172 .input_mux = &alc861vd_dallas_capture_source,
15247 .unsol_event = alc_automute_amp_unsol_event, 15173 .unsol_event = alc_automute_amp_unsol_event,
15248 .init_hook = alc861vd_dallas_init_hook, 15174 .setup = alc861vd_dallas_setup,
15175 .init_hook = alc_automute_amp,
15249 }, 15176 },
15250 [ALC861VD_HP] = { 15177 [ALC861VD_HP] = {
15251 .mixers = { alc861vd_hp_mixer }, 15178 .mixers = { alc861vd_hp_mixer },
@@ -15257,7 +15184,8 @@ static struct alc_config_preset alc861vd_presets[] = {
15257 .channel_mode = alc861vd_3stack_2ch_modes, 15184 .channel_mode = alc861vd_3stack_2ch_modes,
15258 .input_mux = &alc861vd_hp_capture_source, 15185 .input_mux = &alc861vd_hp_capture_source,
15259 .unsol_event = alc_automute_amp_unsol_event, 15186 .unsol_event = alc_automute_amp_unsol_event,
15260 .init_hook = alc861vd_dallas_init_hook, 15187 .setup = alc861vd_dallas_setup,
15188 .init_hook = alc_automute_amp,
15261 }, 15189 },
15262 [ALC660VD_ASUS_V1S] = { 15190 [ALC660VD_ASUS_V1S] = {
15263 .mixers = { alc861vd_lenovo_mixer }, 15191 .mixers = { alc861vd_lenovo_mixer },
@@ -15272,6 +15200,7 @@ static struct alc_config_preset alc861vd_presets[] = {
15272 .channel_mode = alc861vd_3stack_2ch_modes, 15200 .channel_mode = alc861vd_3stack_2ch_modes,
15273 .input_mux = &alc861vd_capture_source, 15201 .input_mux = &alc861vd_capture_source,
15274 .unsol_event = alc861vd_lenovo_unsol_event, 15202 .unsol_event = alc861vd_lenovo_unsol_event,
15203 .setup = alc861vd_lenovo_setup,
15275 .init_hook = alc861vd_lenovo_init_hook, 15204 .init_hook = alc861vd_lenovo_init_hook,
15276 }, 15205 },
15277}; 15206};
@@ -15540,8 +15469,8 @@ static int patch_alc861vd(struct hda_codec *codec)
15540 alc861vd_cfg_tbl); 15469 alc861vd_cfg_tbl);
15541 15470
15542 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { 15471 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15543 printk(KERN_INFO "hda_codec: Unknown model for %s, " 15472 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15544 "trying auto-probe from BIOS...\n", codec->chip_name); 15473 codec->chip_name);
15545 board_config = ALC861VD_AUTO; 15474 board_config = ALC861VD_AUTO;
15546 } 15475 }
15547 15476
@@ -15566,7 +15495,7 @@ static int patch_alc861vd(struct hda_codec *codec)
15566 } 15495 }
15567 15496
15568 if (board_config != ALC861VD_AUTO) 15497 if (board_config != ALC861VD_AUTO)
15569 setup_preset(spec, &alc861vd_presets[board_config]); 15498 setup_preset(codec, &alc861vd_presets[board_config]);
15570 15499
15571 if (codec->vendor_id == 0x10ec0660) { 15500 if (codec->vendor_id == 0x10ec0660) {
15572 /* always turn on EAPD */ 15501 /* always turn on EAPD */
@@ -15586,7 +15515,7 @@ static int patch_alc861vd(struct hda_codec *codec)
15586 if (!spec->capsrc_nids) 15515 if (!spec->capsrc_nids)
15587 spec->capsrc_nids = alc861vd_capsrc_nids; 15516 spec->capsrc_nids = alc861vd_capsrc_nids;
15588 15517
15589 set_capture_mixer(spec); 15518 set_capture_mixer(codec);
15590 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 15519 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
15591 15520
15592 spec->vmaster_nid = 0x02; 15521 spec->vmaster_nid = 0x02;
@@ -15627,9 +15556,9 @@ static hda_nid_t alc272_dac_nids[2] = {
15627 0x02, 0x03 15556 0x02, 0x03
15628}; 15557};
15629 15558
15630static hda_nid_t alc662_adc_nids[1] = { 15559static hda_nid_t alc662_adc_nids[2] = {
15631 /* ADC1-2 */ 15560 /* ADC1-2 */
15632 0x09, 15561 0x09, 0x08
15633}; 15562};
15634 15563
15635static hda_nid_t alc272_adc_nids[1] = { 15564static hda_nid_t alc272_adc_nids[1] = {
@@ -15637,7 +15566,7 @@ static hda_nid_t alc272_adc_nids[1] = {
15637 0x08, 15566 0x08,
15638}; 15567};
15639 15568
15640static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; 15569static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
15641static hda_nid_t alc272_capsrc_nids[1] = { 0x23 }; 15570static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15642 15571
15643 15572
@@ -15661,14 +15590,6 @@ static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15661 }, 15590 },
15662}; 15591};
15663 15592
15664static struct hda_input_mux alc662_eeepc_capture_source = {
15665 .num_items = 2,
15666 .items = {
15667 { "i-Mic", 0x1 },
15668 { "e-Mic", 0x0 },
15669 },
15670};
15671
15672static struct hda_input_mux alc663_capture_source = { 15593static struct hda_input_mux alc663_capture_source = {
15673 .num_items = 3, 15594 .num_items = 3,
15674 .items = { 15595 .items = {
@@ -15678,23 +15599,7 @@ static struct hda_input_mux alc663_capture_source = {
15678 }, 15599 },
15679}; 15600};
15680 15601
15681static struct hda_input_mux alc663_m51va_capture_source = { 15602#if 0 /* set to 1 for testing other input sources below */
15682 .num_items = 2,
15683 .items = {
15684 { "Ext-Mic", 0x0 },
15685 { "D-Mic", 0x9 },
15686 },
15687};
15688
15689#if 1 /* set to 0 for testing other input sources below */
15690static struct hda_input_mux alc272_nc10_capture_source = {
15691 .num_items = 2,
15692 .items = {
15693 { "Autoselect Mic", 0x0 },
15694 { "Internal Mic", 0x1 },
15695 },
15696};
15697#else
15698static struct hda_input_mux alc272_nc10_capture_source = { 15603static struct hda_input_mux alc272_nc10_capture_source = {
15699 .num_items = 16, 15604 .num_items = 16,
15700 .items = { 15605 .items = {
@@ -16363,47 +16268,44 @@ static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16363 alc662_lenovo_101e_ispeaker_automute(codec); 16268 alc662_lenovo_101e_ispeaker_automute(codec);
16364} 16269}
16365 16270
16366static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16367{
16368 unsigned int present;
16369
16370 present = snd_hda_codec_read(codec, 0x18, 0,
16371 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16372 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16373 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16374 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16375 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16376 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16377 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16378 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16379 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16380}
16381
16382/* unsolicited event for HP jack sensing */ 16271/* unsolicited event for HP jack sensing */
16383static void alc662_eeepc_unsol_event(struct hda_codec *codec, 16272static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16384 unsigned int res) 16273 unsigned int res)
16385{ 16274{
16386 if ((res >> 26) == ALC880_MIC_EVENT) 16275 if ((res >> 26) == ALC880_MIC_EVENT)
16387 alc662_eeepc_mic_automute(codec); 16276 alc_mic_automute(codec);
16388 else 16277 else
16389 alc262_hippo_unsol_event(codec, res); 16278 alc262_hippo_unsol_event(codec, res);
16390} 16279}
16391 16280
16281static void alc662_eeepc_setup(struct hda_codec *codec)
16282{
16283 struct alc_spec *spec = codec->spec;
16284
16285 alc262_hippo1_setup(codec);
16286 spec->ext_mic.pin = 0x18;
16287 spec->ext_mic.mux_idx = 0;
16288 spec->int_mic.pin = 0x19;
16289 spec->int_mic.mux_idx = 1;
16290 spec->auto_mic = 1;
16291}
16292
16392static void alc662_eeepc_inithook(struct hda_codec *codec) 16293static void alc662_eeepc_inithook(struct hda_codec *codec)
16393{ 16294{
16394 alc262_hippo1_init_hook(codec); 16295 alc262_hippo_automute(codec);
16395 alc662_eeepc_mic_automute(codec); 16296 alc_mic_automute(codec);
16396} 16297}
16397 16298
16398static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) 16299static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
16399{ 16300{
16400 struct alc_spec *spec = codec->spec; 16301 struct alc_spec *spec = codec->spec;
16401 16302
16402 spec->autocfg.hp_pins[0] = 0x14; 16303 spec->autocfg.hp_pins[0] = 0x14;
16403 spec->autocfg.speaker_pins[0] = 0x1b; 16304 spec->autocfg.speaker_pins[0] = 0x1b;
16404 alc262_hippo_master_update(codec);
16405} 16305}
16406 16306
16307#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16308
16407static void alc663_m51va_speaker_automute(struct hda_codec *codec) 16309static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16408{ 16310{
16409 unsigned int present; 16311 unsigned int present;
@@ -16514,23 +16416,6 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16514 } 16416 }
16515} 16417}
16516 16418
16517static void alc663_m51va_mic_automute(struct hda_codec *codec)
16518{
16519 unsigned int present;
16520
16521 present = snd_hda_codec_read(codec, 0x18, 0,
16522 AC_VERB_GET_PIN_SENSE, 0)
16523 & AC_PINSENSE_PRESENCE;
16524 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16525 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16526 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16527 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16528 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16529 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
16530 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16531 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
16532}
16533
16534static void alc663_m51va_unsol_event(struct hda_codec *codec, 16419static void alc663_m51va_unsol_event(struct hda_codec *codec,
16535 unsigned int res) 16420 unsigned int res)
16536{ 16421{
@@ -16539,36 +16424,32 @@ static void alc663_m51va_unsol_event(struct hda_codec *codec,
16539 alc663_m51va_speaker_automute(codec); 16424 alc663_m51va_speaker_automute(codec);
16540 break; 16425 break;
16541 case ALC880_MIC_EVENT: 16426 case ALC880_MIC_EVENT:
16542 alc663_m51va_mic_automute(codec); 16427 alc_mic_automute(codec);
16543 break; 16428 break;
16544 } 16429 }
16545} 16430}
16546 16431
16432static void alc663_m51va_setup(struct hda_codec *codec)
16433{
16434 struct alc_spec *spec = codec->spec;
16435 spec->ext_mic.pin = 0x18;
16436 spec->ext_mic.mux_idx = 0;
16437 spec->int_mic.pin = 0x12;
16438 spec->int_mic.mux_idx = 1;
16439 spec->auto_mic = 1;
16440}
16441
16547static void alc663_m51va_inithook(struct hda_codec *codec) 16442static void alc663_m51va_inithook(struct hda_codec *codec)
16548{ 16443{
16549 alc663_m51va_speaker_automute(codec); 16444 alc663_m51va_speaker_automute(codec);
16550 alc663_m51va_mic_automute(codec); 16445 alc_mic_automute(codec);
16551} 16446}
16552 16447
16553/* ***************** Mode1 ******************************/ 16448/* ***************** Mode1 ******************************/
16554static void alc663_mode1_unsol_event(struct hda_codec *codec, 16449#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16555 unsigned int res) 16450#define alc663_mode1_setup alc663_m51va_setup
16556{ 16451#define alc663_mode1_inithook alc663_m51va_inithook
16557 switch (res >> 26) {
16558 case ALC880_HP_EVENT:
16559 alc663_m51va_speaker_automute(codec);
16560 break;
16561 case ALC880_MIC_EVENT:
16562 alc662_eeepc_mic_automute(codec);
16563 break;
16564 }
16565}
16566 16452
16567static void alc663_mode1_inithook(struct hda_codec *codec)
16568{
16569 alc663_m51va_speaker_automute(codec);
16570 alc662_eeepc_mic_automute(codec);
16571}
16572/* ***************** Mode2 ******************************/ 16453/* ***************** Mode2 ******************************/
16573static void alc662_mode2_unsol_event(struct hda_codec *codec, 16454static void alc662_mode2_unsol_event(struct hda_codec *codec,
16574 unsigned int res) 16455 unsigned int res)
@@ -16578,15 +16459,17 @@ static void alc662_mode2_unsol_event(struct hda_codec *codec,
16578 alc662_f5z_speaker_automute(codec); 16459 alc662_f5z_speaker_automute(codec);
16579 break; 16460 break;
16580 case ALC880_MIC_EVENT: 16461 case ALC880_MIC_EVENT:
16581 alc662_eeepc_mic_automute(codec); 16462 alc_mic_automute(codec);
16582 break; 16463 break;
16583 } 16464 }
16584} 16465}
16585 16466
16467#define alc662_mode2_setup alc663_m51va_setup
16468
16586static void alc662_mode2_inithook(struct hda_codec *codec) 16469static void alc662_mode2_inithook(struct hda_codec *codec)
16587{ 16470{
16588 alc662_f5z_speaker_automute(codec); 16471 alc662_f5z_speaker_automute(codec);
16589 alc662_eeepc_mic_automute(codec); 16472 alc_mic_automute(codec);
16590} 16473}
16591/* ***************** Mode3 ******************************/ 16474/* ***************** Mode3 ******************************/
16592static void alc663_mode3_unsol_event(struct hda_codec *codec, 16475static void alc663_mode3_unsol_event(struct hda_codec *codec,
@@ -16597,15 +16480,17 @@ static void alc663_mode3_unsol_event(struct hda_codec *codec,
16597 alc663_two_hp_m1_speaker_automute(codec); 16480 alc663_two_hp_m1_speaker_automute(codec);
16598 break; 16481 break;
16599 case ALC880_MIC_EVENT: 16482 case ALC880_MIC_EVENT:
16600 alc662_eeepc_mic_automute(codec); 16483 alc_mic_automute(codec);
16601 break; 16484 break;
16602 } 16485 }
16603} 16486}
16604 16487
16488#define alc663_mode3_setup alc663_m51va_setup
16489
16605static void alc663_mode3_inithook(struct hda_codec *codec) 16490static void alc663_mode3_inithook(struct hda_codec *codec)
16606{ 16491{
16607 alc663_two_hp_m1_speaker_automute(codec); 16492 alc663_two_hp_m1_speaker_automute(codec);
16608 alc662_eeepc_mic_automute(codec); 16493 alc_mic_automute(codec);
16609} 16494}
16610/* ***************** Mode4 ******************************/ 16495/* ***************** Mode4 ******************************/
16611static void alc663_mode4_unsol_event(struct hda_codec *codec, 16496static void alc663_mode4_unsol_event(struct hda_codec *codec,
@@ -16616,15 +16501,17 @@ static void alc663_mode4_unsol_event(struct hda_codec *codec,
16616 alc663_21jd_two_speaker_automute(codec); 16501 alc663_21jd_two_speaker_automute(codec);
16617 break; 16502 break;
16618 case ALC880_MIC_EVENT: 16503 case ALC880_MIC_EVENT:
16619 alc662_eeepc_mic_automute(codec); 16504 alc_mic_automute(codec);
16620 break; 16505 break;
16621 } 16506 }
16622} 16507}
16623 16508
16509#define alc663_mode4_setup alc663_m51va_setup
16510
16624static void alc663_mode4_inithook(struct hda_codec *codec) 16511static void alc663_mode4_inithook(struct hda_codec *codec)
16625{ 16512{
16626 alc663_21jd_two_speaker_automute(codec); 16513 alc663_21jd_two_speaker_automute(codec);
16627 alc662_eeepc_mic_automute(codec); 16514 alc_mic_automute(codec);
16628} 16515}
16629/* ***************** Mode5 ******************************/ 16516/* ***************** Mode5 ******************************/
16630static void alc663_mode5_unsol_event(struct hda_codec *codec, 16517static void alc663_mode5_unsol_event(struct hda_codec *codec,
@@ -16635,15 +16522,17 @@ static void alc663_mode5_unsol_event(struct hda_codec *codec,
16635 alc663_15jd_two_speaker_automute(codec); 16522 alc663_15jd_two_speaker_automute(codec);
16636 break; 16523 break;
16637 case ALC880_MIC_EVENT: 16524 case ALC880_MIC_EVENT:
16638 alc662_eeepc_mic_automute(codec); 16525 alc_mic_automute(codec);
16639 break; 16526 break;
16640 } 16527 }
16641} 16528}
16642 16529
16530#define alc663_mode5_setup alc663_m51va_setup
16531
16643static void alc663_mode5_inithook(struct hda_codec *codec) 16532static void alc663_mode5_inithook(struct hda_codec *codec)
16644{ 16533{
16645 alc663_15jd_two_speaker_automute(codec); 16534 alc663_15jd_two_speaker_automute(codec);
16646 alc662_eeepc_mic_automute(codec); 16535 alc_mic_automute(codec);
16647} 16536}
16648/* ***************** Mode6 ******************************/ 16537/* ***************** Mode6 ******************************/
16649static void alc663_mode6_unsol_event(struct hda_codec *codec, 16538static void alc663_mode6_unsol_event(struct hda_codec *codec,
@@ -16654,15 +16543,17 @@ static void alc663_mode6_unsol_event(struct hda_codec *codec,
16654 alc663_two_hp_m2_speaker_automute(codec); 16543 alc663_two_hp_m2_speaker_automute(codec);
16655 break; 16544 break;
16656 case ALC880_MIC_EVENT: 16545 case ALC880_MIC_EVENT:
16657 alc662_eeepc_mic_automute(codec); 16546 alc_mic_automute(codec);
16658 break; 16547 break;
16659 } 16548 }
16660} 16549}
16661 16550
16551#define alc663_mode6_setup alc663_m51va_setup
16552
16662static void alc663_mode6_inithook(struct hda_codec *codec) 16553static void alc663_mode6_inithook(struct hda_codec *codec)
16663{ 16554{
16664 alc663_two_hp_m2_speaker_automute(codec); 16555 alc663_two_hp_m2_speaker_automute(codec);
16665 alc662_eeepc_mic_automute(codec); 16556 alc_mic_automute(codec);
16666} 16557}
16667 16558
16668static void alc663_g71v_hp_automute(struct hda_codec *codec) 16559static void alc663_g71v_hp_automute(struct hda_codec *codec)
@@ -16704,16 +16595,18 @@ static void alc663_g71v_unsol_event(struct hda_codec *codec,
16704 alc663_g71v_front_automute(codec); 16595 alc663_g71v_front_automute(codec);
16705 break; 16596 break;
16706 case ALC880_MIC_EVENT: 16597 case ALC880_MIC_EVENT:
16707 alc662_eeepc_mic_automute(codec); 16598 alc_mic_automute(codec);
16708 break; 16599 break;
16709 } 16600 }
16710} 16601}
16711 16602
16603#define alc663_g71v_setup alc663_m51va_setup
16604
16712static void alc663_g71v_inithook(struct hda_codec *codec) 16605static void alc663_g71v_inithook(struct hda_codec *codec)
16713{ 16606{
16714 alc663_g71v_front_automute(codec); 16607 alc663_g71v_front_automute(codec);
16715 alc663_g71v_hp_automute(codec); 16608 alc663_g71v_hp_automute(codec);
16716 alc662_eeepc_mic_automute(codec); 16609 alc_mic_automute(codec);
16717} 16610}
16718 16611
16719static void alc663_g50v_unsol_event(struct hda_codec *codec, 16612static void alc663_g50v_unsol_event(struct hda_codec *codec,
@@ -16724,15 +16617,17 @@ static void alc663_g50v_unsol_event(struct hda_codec *codec,
16724 alc663_m51va_speaker_automute(codec); 16617 alc663_m51va_speaker_automute(codec);
16725 break; 16618 break;
16726 case ALC880_MIC_EVENT: 16619 case ALC880_MIC_EVENT:
16727 alc662_eeepc_mic_automute(codec); 16620 alc_mic_automute(codec);
16728 break; 16621 break;
16729 } 16622 }
16730} 16623}
16731 16624
16625#define alc663_g50v_setup alc663_m51va_setup
16626
16732static void alc663_g50v_inithook(struct hda_codec *codec) 16627static void alc663_g50v_inithook(struct hda_codec *codec)
16733{ 16628{
16734 alc663_m51va_speaker_automute(codec); 16629 alc663_m51va_speaker_automute(codec);
16735 alc662_eeepc_mic_automute(codec); 16630 alc_mic_automute(codec);
16736} 16631}
16737 16632
16738static struct snd_kcontrol_new alc662_ecs_mixer[] = { 16633static struct snd_kcontrol_new alc662_ecs_mixer[] = {
@@ -16936,8 +16831,8 @@ static struct alc_config_preset alc662_presets[] = {
16936 .dac_nids = alc662_dac_nids, 16831 .dac_nids = alc662_dac_nids,
16937 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16832 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16938 .channel_mode = alc662_3ST_2ch_modes, 16833 .channel_mode = alc662_3ST_2ch_modes,
16939 .input_mux = &alc662_eeepc_capture_source,
16940 .unsol_event = alc662_eeepc_unsol_event, 16834 .unsol_event = alc662_eeepc_unsol_event,
16835 .setup = alc662_eeepc_setup,
16941 .init_hook = alc662_eeepc_inithook, 16836 .init_hook = alc662_eeepc_inithook,
16942 }, 16837 },
16943 [ALC662_ASUS_EEEPC_EP20] = { 16838 [ALC662_ASUS_EEEPC_EP20] = {
@@ -16951,6 +16846,7 @@ static struct alc_config_preset alc662_presets[] = {
16951 .channel_mode = alc662_3ST_6ch_modes, 16846 .channel_mode = alc662_3ST_6ch_modes,
16952 .input_mux = &alc662_lenovo_101e_capture_source, 16847 .input_mux = &alc662_lenovo_101e_capture_source,
16953 .unsol_event = alc662_eeepc_unsol_event, 16848 .unsol_event = alc662_eeepc_unsol_event,
16849 .setup = alc662_eeepc_ep20_setup,
16954 .init_hook = alc662_eeepc_ep20_inithook, 16850 .init_hook = alc662_eeepc_ep20_inithook,
16955 }, 16851 },
16956 [ALC662_ECS] = { 16852 [ALC662_ECS] = {
@@ -16961,8 +16857,8 @@ static struct alc_config_preset alc662_presets[] = {
16961 .dac_nids = alc662_dac_nids, 16857 .dac_nids = alc662_dac_nids,
16962 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16858 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16963 .channel_mode = alc662_3ST_2ch_modes, 16859 .channel_mode = alc662_3ST_2ch_modes,
16964 .input_mux = &alc662_eeepc_capture_source,
16965 .unsol_event = alc662_eeepc_unsol_event, 16860 .unsol_event = alc662_eeepc_unsol_event,
16861 .setup = alc662_eeepc_setup,
16966 .init_hook = alc662_eeepc_inithook, 16862 .init_hook = alc662_eeepc_inithook,
16967 }, 16863 },
16968 [ALC663_ASUS_M51VA] = { 16864 [ALC663_ASUS_M51VA] = {
@@ -16973,8 +16869,8 @@ static struct alc_config_preset alc662_presets[] = {
16973 .dig_out_nid = ALC662_DIGOUT_NID, 16869 .dig_out_nid = ALC662_DIGOUT_NID,
16974 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16870 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16975 .channel_mode = alc662_3ST_2ch_modes, 16871 .channel_mode = alc662_3ST_2ch_modes,
16976 .input_mux = &alc663_m51va_capture_source,
16977 .unsol_event = alc663_m51va_unsol_event, 16872 .unsol_event = alc663_m51va_unsol_event,
16873 .setup = alc663_m51va_setup,
16978 .init_hook = alc663_m51va_inithook, 16874 .init_hook = alc663_m51va_inithook,
16979 }, 16875 },
16980 [ALC663_ASUS_G71V] = { 16876 [ALC663_ASUS_G71V] = {
@@ -16985,8 +16881,8 @@ static struct alc_config_preset alc662_presets[] = {
16985 .dig_out_nid = ALC662_DIGOUT_NID, 16881 .dig_out_nid = ALC662_DIGOUT_NID,
16986 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16882 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16987 .channel_mode = alc662_3ST_2ch_modes, 16883 .channel_mode = alc662_3ST_2ch_modes,
16988 .input_mux = &alc662_eeepc_capture_source,
16989 .unsol_event = alc663_g71v_unsol_event, 16884 .unsol_event = alc663_g71v_unsol_event,
16885 .setup = alc663_g71v_setup,
16990 .init_hook = alc663_g71v_inithook, 16886 .init_hook = alc663_g71v_inithook,
16991 }, 16887 },
16992 [ALC663_ASUS_H13] = { 16888 [ALC663_ASUS_H13] = {
@@ -16996,7 +16892,6 @@ static struct alc_config_preset alc662_presets[] = {
16996 .dac_nids = alc662_dac_nids, 16892 .dac_nids = alc662_dac_nids,
16997 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16893 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16998 .channel_mode = alc662_3ST_2ch_modes, 16894 .channel_mode = alc662_3ST_2ch_modes,
16999 .input_mux = &alc663_m51va_capture_source,
17000 .unsol_event = alc663_m51va_unsol_event, 16895 .unsol_event = alc663_m51va_unsol_event,
17001 .init_hook = alc663_m51va_inithook, 16896 .init_hook = alc663_m51va_inithook,
17002 }, 16897 },
@@ -17010,6 +16905,7 @@ static struct alc_config_preset alc662_presets[] = {
17010 .channel_mode = alc662_3ST_6ch_modes, 16905 .channel_mode = alc662_3ST_6ch_modes,
17011 .input_mux = &alc663_capture_source, 16906 .input_mux = &alc663_capture_source,
17012 .unsol_event = alc663_g50v_unsol_event, 16907 .unsol_event = alc663_g50v_unsol_event,
16908 .setup = alc663_g50v_setup,
17013 .init_hook = alc663_g50v_inithook, 16909 .init_hook = alc663_g50v_inithook,
17014 }, 16910 },
17015 [ALC663_ASUS_MODE1] = { 16911 [ALC663_ASUS_MODE1] = {
@@ -17023,8 +16919,8 @@ static struct alc_config_preset alc662_presets[] = {
17023 .dig_out_nid = ALC662_DIGOUT_NID, 16919 .dig_out_nid = ALC662_DIGOUT_NID,
17024 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16920 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17025 .channel_mode = alc662_3ST_2ch_modes, 16921 .channel_mode = alc662_3ST_2ch_modes,
17026 .input_mux = &alc662_eeepc_capture_source,
17027 .unsol_event = alc663_mode1_unsol_event, 16922 .unsol_event = alc663_mode1_unsol_event,
16923 .setup = alc663_mode1_setup,
17028 .init_hook = alc663_mode1_inithook, 16924 .init_hook = alc663_mode1_inithook,
17029 }, 16925 },
17030 [ALC662_ASUS_MODE2] = { 16926 [ALC662_ASUS_MODE2] = {
@@ -17037,8 +16933,8 @@ static struct alc_config_preset alc662_presets[] = {
17037 .dig_out_nid = ALC662_DIGOUT_NID, 16933 .dig_out_nid = ALC662_DIGOUT_NID,
17038 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16934 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17039 .channel_mode = alc662_3ST_2ch_modes, 16935 .channel_mode = alc662_3ST_2ch_modes,
17040 .input_mux = &alc662_eeepc_capture_source,
17041 .unsol_event = alc662_mode2_unsol_event, 16936 .unsol_event = alc662_mode2_unsol_event,
16937 .setup = alc662_mode2_setup,
17042 .init_hook = alc662_mode2_inithook, 16938 .init_hook = alc662_mode2_inithook,
17043 }, 16939 },
17044 [ALC663_ASUS_MODE3] = { 16940 [ALC663_ASUS_MODE3] = {
@@ -17052,8 +16948,8 @@ static struct alc_config_preset alc662_presets[] = {
17052 .dig_out_nid = ALC662_DIGOUT_NID, 16948 .dig_out_nid = ALC662_DIGOUT_NID,
17053 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16949 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17054 .channel_mode = alc662_3ST_2ch_modes, 16950 .channel_mode = alc662_3ST_2ch_modes,
17055 .input_mux = &alc662_eeepc_capture_source,
17056 .unsol_event = alc663_mode3_unsol_event, 16951 .unsol_event = alc663_mode3_unsol_event,
16952 .setup = alc663_mode3_setup,
17057 .init_hook = alc663_mode3_inithook, 16953 .init_hook = alc663_mode3_inithook,
17058 }, 16954 },
17059 [ALC663_ASUS_MODE4] = { 16955 [ALC663_ASUS_MODE4] = {
@@ -17067,8 +16963,8 @@ static struct alc_config_preset alc662_presets[] = {
17067 .dig_out_nid = ALC662_DIGOUT_NID, 16963 .dig_out_nid = ALC662_DIGOUT_NID,
17068 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16964 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17069 .channel_mode = alc662_3ST_2ch_modes, 16965 .channel_mode = alc662_3ST_2ch_modes,
17070 .input_mux = &alc662_eeepc_capture_source,
17071 .unsol_event = alc663_mode4_unsol_event, 16966 .unsol_event = alc663_mode4_unsol_event,
16967 .setup = alc663_mode4_setup,
17072 .init_hook = alc663_mode4_inithook, 16968 .init_hook = alc663_mode4_inithook,
17073 }, 16969 },
17074 [ALC663_ASUS_MODE5] = { 16970 [ALC663_ASUS_MODE5] = {
@@ -17082,8 +16978,8 @@ static struct alc_config_preset alc662_presets[] = {
17082 .dig_out_nid = ALC662_DIGOUT_NID, 16978 .dig_out_nid = ALC662_DIGOUT_NID,
17083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16979 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17084 .channel_mode = alc662_3ST_2ch_modes, 16980 .channel_mode = alc662_3ST_2ch_modes,
17085 .input_mux = &alc662_eeepc_capture_source,
17086 .unsol_event = alc663_mode5_unsol_event, 16981 .unsol_event = alc663_mode5_unsol_event,
16982 .setup = alc663_mode5_setup,
17087 .init_hook = alc663_mode5_inithook, 16983 .init_hook = alc663_mode5_inithook,
17088 }, 16984 },
17089 [ALC663_ASUS_MODE6] = { 16985 [ALC663_ASUS_MODE6] = {
@@ -17097,8 +16993,8 @@ static struct alc_config_preset alc662_presets[] = {
17097 .dig_out_nid = ALC662_DIGOUT_NID, 16993 .dig_out_nid = ALC662_DIGOUT_NID,
17098 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16994 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17099 .channel_mode = alc662_3ST_2ch_modes, 16995 .channel_mode = alc662_3ST_2ch_modes,
17100 .input_mux = &alc662_eeepc_capture_source,
17101 .unsol_event = alc663_mode6_unsol_event, 16996 .unsol_event = alc663_mode6_unsol_event,
16997 .setup = alc663_mode6_setup,
17102 .init_hook = alc663_mode6_inithook, 16998 .init_hook = alc663_mode6_inithook,
17103 }, 16999 },
17104 [ALC272_DELL] = { 17000 [ALC272_DELL] = {
@@ -17112,8 +17008,8 @@ static struct alc_config_preset alc662_presets[] = {
17112 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids), 17008 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17113 .capsrc_nids = alc272_capsrc_nids, 17009 .capsrc_nids = alc272_capsrc_nids,
17114 .channel_mode = alc662_3ST_2ch_modes, 17010 .channel_mode = alc662_3ST_2ch_modes,
17115 .input_mux = &alc663_m51va_capture_source,
17116 .unsol_event = alc663_m51va_unsol_event, 17011 .unsol_event = alc663_m51va_unsol_event,
17012 .setup = alc663_m51va_setup,
17117 .init_hook = alc663_m51va_inithook, 17013 .init_hook = alc663_m51va_inithook,
17118 }, 17014 },
17119 [ALC272_DELL_ZM1] = { 17015 [ALC272_DELL_ZM1] = {
@@ -17124,11 +17020,11 @@ static struct alc_config_preset alc662_presets[] = {
17124 .dac_nids = alc662_dac_nids, 17020 .dac_nids = alc662_dac_nids,
17125 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17021 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17126 .adc_nids = alc662_adc_nids, 17022 .adc_nids = alc662_adc_nids,
17127 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), 17023 .num_adc_nids = 1,
17128 .capsrc_nids = alc662_capsrc_nids, 17024 .capsrc_nids = alc662_capsrc_nids,
17129 .channel_mode = alc662_3ST_2ch_modes, 17025 .channel_mode = alc662_3ST_2ch_modes,
17130 .input_mux = &alc663_m51va_capture_source,
17131 .unsol_event = alc663_m51va_unsol_event, 17026 .unsol_event = alc663_m51va_unsol_event,
17027 .setup = alc663_m51va_setup,
17132 .init_hook = alc663_m51va_inithook, 17028 .init_hook = alc663_m51va_inithook,
17133 }, 17029 },
17134 [ALC272_SAMSUNG_NC10] = { 17030 [ALC272_SAMSUNG_NC10] = {
@@ -17139,8 +17035,9 @@ static struct alc_config_preset alc662_presets[] = {
17139 .dac_nids = alc272_dac_nids, 17035 .dac_nids = alc272_dac_nids,
17140 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17036 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17141 .channel_mode = alc662_3ST_2ch_modes, 17037 .channel_mode = alc662_3ST_2ch_modes,
17142 .input_mux = &alc272_nc10_capture_source, 17038 /*.input_mux = &alc272_nc10_capture_source,*/
17143 .unsol_event = alc663_mode4_unsol_event, 17039 .unsol_event = alc663_mode4_unsol_event,
17040 .setup = alc663_mode4_setup,
17144 .init_hook = alc663_mode4_inithook, 17041 .init_hook = alc663_mode4_inithook,
17145 }, 17042 },
17146}; 17043};
@@ -17260,25 +17157,6 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17260 return 0; 17157 return 0;
17261} 17158}
17262 17159
17263/* return the index of the src widget from the connection list of the nid.
17264 * return -1 if not found
17265 */
17266static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17267 hda_nid_t src)
17268{
17269 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17270 int i, conns;
17271
17272 conns = snd_hda_get_connections(codec, nid, conn_list,
17273 ARRAY_SIZE(conn_list));
17274 if (conns < 0)
17275 return -1;
17276 for (i = 0; i < conns; i++)
17277 if (conn_list[i] == src)
17278 return i;
17279 return -1;
17280}
17281
17282static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid) 17160static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17283{ 17161{
17284 unsigned int pincap = snd_hda_query_pin_caps(codec, nid); 17162 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
@@ -17295,7 +17173,7 @@ static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
17295 17173
17296 for (i = 0; i < AUTO_PIN_LAST; i++) { 17174 for (i = 0; i < AUTO_PIN_LAST; i++) {
17297 if (alc662_is_input_pin(codec, cfg->input_pins[i])) { 17175 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17298 idx = alc662_input_pin_idx(codec, 0x0b, 17176 idx = get_connection_index(codec, 0x0b,
17299 cfg->input_pins[i]); 17177 cfg->input_pins[i]);
17300 if (idx >= 0) { 17178 if (idx >= 0) {
17301 err = new_analog_input(spec, cfg->input_pins[i], 17179 err = new_analog_input(spec, cfg->input_pins[i],
@@ -17304,7 +17182,7 @@ static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
17304 if (err < 0) 17182 if (err < 0)
17305 return err; 17183 return err;
17306 } 17184 }
17307 idx = alc662_input_pin_idx(codec, 0x22, 17185 idx = get_connection_index(codec, 0x22,
17308 cfg->input_pins[i]); 17186 cfg->input_pins[i]);
17309 if (idx >= 0) { 17187 if (idx >= 0) {
17310 imux->items[imux->num_items].label = 17188 imux->items[imux->num_items].label =
@@ -17467,8 +17345,8 @@ static int patch_alc662(struct hda_codec *codec)
17467 alc662_models, 17345 alc662_models,
17468 alc662_cfg_tbl); 17346 alc662_cfg_tbl);
17469 if (board_config < 0) { 17347 if (board_config < 0) {
17470 printk(KERN_INFO "hda_codec: Unknown model for %s, " 17348 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17471 "trying auto-probe from BIOS...\n", codec->chip_name); 17349 codec->chip_name);
17472 board_config = ALC662_AUTO; 17350 board_config = ALC662_AUTO;
17473 } 17351 }
17474 17352
@@ -17493,7 +17371,7 @@ static int patch_alc662(struct hda_codec *codec)
17493 } 17371 }
17494 17372
17495 if (board_config != ALC662_AUTO) 17373 if (board_config != ALC662_AUTO)
17496 setup_preset(spec, &alc662_presets[board_config]); 17374 setup_preset(codec, &alc662_presets[board_config]);
17497 17375
17498 spec->stream_analog_playback = &alc662_pcm_analog_playback; 17376 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17499 spec->stream_analog_capture = &alc662_pcm_analog_capture; 17377 spec->stream_analog_capture = &alc662_pcm_analog_capture;
@@ -17509,7 +17387,7 @@ static int patch_alc662(struct hda_codec *codec)
17509 spec->capsrc_nids = alc662_capsrc_nids; 17387 spec->capsrc_nids = alc662_capsrc_nids;
17510 17388
17511 if (!spec->cap_mixer) 17389 if (!spec->cap_mixer)
17512 set_capture_mixer(spec); 17390 set_capture_mixer(codec);
17513 if (codec->vendor_id == 0x10ec0662) 17391 if (codec->vendor_id == 0x10ec0662)
17514 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 17392 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17515 else 17393 else
@@ -17545,23 +17423,23 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = {
17545 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 17423 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17546 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 17424 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
17547 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", 17425 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17548 .patch = patch_alc883 }, 17426 .patch = patch_alc882 },
17549 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", 17427 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17550 .patch = patch_alc662 }, 17428 .patch = patch_alc662 },
17551 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 17429 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
17552 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 17430 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
17553 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 17431 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
17554 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 17432 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
17555 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", 17433 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17556 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 17434 .patch = patch_alc882 },
17557 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 17435 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
17558 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 17436 .patch = patch_alc882 },
17559 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 17437 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
17560 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, 17438 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
17561 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 17439 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17562 .patch = patch_alc883 }, 17440 .patch = patch_alc882 },
17563 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 17441 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17564 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 17442 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
17565 {} /* terminator */ 17443 {} /* terminator */
17566}; 17444};
17567 17445