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.c4185
1 files changed, 2063 insertions, 2122 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fea976793ae5..7ed47f66ddd1 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,
@@ -226,6 +220,7 @@ enum {
226 ALC888_ACER_ASPIRE_4930G, 220 ALC888_ACER_ASPIRE_4930G,
227 ALC888_ACER_ASPIRE_6530G, 221 ALC888_ACER_ASPIRE_6530G,
228 ALC888_ACER_ASPIRE_8930G, 222 ALC888_ACER_ASPIRE_8930G,
223 ALC888_ACER_ASPIRE_7730G,
229 ALC883_MEDION, 224 ALC883_MEDION,
230 ALC883_MEDION_MD2, 225 ALC883_MEDION_MD2,
231 ALC883_LAPTOP_EAPD, 226 ALC883_LAPTOP_EAPD,
@@ -237,17 +232,20 @@ enum {
237 ALC888_3ST_HP, 232 ALC888_3ST_HP,
238 ALC888_6ST_DELL, 233 ALC888_6ST_DELL,
239 ALC883_MITAC, 234 ALC883_MITAC,
235 ALC883_CLEVO_M540R,
240 ALC883_CLEVO_M720, 236 ALC883_CLEVO_M720,
241 ALC883_FUJITSU_PI2515, 237 ALC883_FUJITSU_PI2515,
242 ALC888_FUJITSU_XA3530, 238 ALC888_FUJITSU_XA3530,
243 ALC883_3ST_6ch_INTEL, 239 ALC883_3ST_6ch_INTEL,
240 ALC889A_INTEL,
241 ALC889_INTEL,
244 ALC888_ASUS_M90V, 242 ALC888_ASUS_M90V,
245 ALC888_ASUS_EEE1601, 243 ALC888_ASUS_EEE1601,
246 ALC889A_MB31, 244 ALC889A_MB31,
247 ALC1200_ASUS_P5Q, 245 ALC1200_ASUS_P5Q,
248 ALC883_SONY_VAIO_TT, 246 ALC883_SONY_VAIO_TT,
249 ALC883_AUTO, 247 ALC882_AUTO,
250 ALC883_MODEL_LAST, 248 ALC882_MODEL_LAST,
251}; 249};
252 250
253/* for GPIO Poll */ 251/* for GPIO Poll */
@@ -262,6 +260,14 @@ enum {
262 ALC_INIT_GPIO3, 260 ALC_INIT_GPIO3,
263}; 261};
264 262
263struct alc_mic_route {
264 hda_nid_t pin;
265 unsigned char mux_idx;
266 unsigned char amix_idx;
267};
268
269#define MUX_IDX_UNDEF ((unsigned char)-1)
270
265struct alc_spec { 271struct alc_spec {
266 /* codec parameterization */ 272 /* codec parameterization */
267 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 273 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
@@ -304,6 +310,8 @@ struct alc_spec {
304 unsigned int num_mux_defs; 310 unsigned int num_mux_defs;
305 const struct hda_input_mux *input_mux; 311 const struct hda_input_mux *input_mux;
306 unsigned int cur_mux[3]; 312 unsigned int cur_mux[3];
313 struct alc_mic_route ext_mic;
314 struct alc_mic_route int_mic;
307 315
308 /* channel model */ 316 /* channel model */
309 const struct hda_channel_mode *channel_mode; 317 const struct hda_channel_mode *channel_mode;
@@ -320,6 +328,8 @@ struct alc_spec {
320 struct snd_array kctls; 328 struct snd_array kctls;
321 struct hda_input_mux private_imux[3]; 329 struct hda_input_mux private_imux[3];
322 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 330 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
331 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
332 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
323 333
324 /* hooks */ 334 /* hooks */
325 void (*init_hook)(struct hda_codec *codec); 335 void (*init_hook)(struct hda_codec *codec);
@@ -329,6 +339,7 @@ struct alc_spec {
329 unsigned int sense_updated: 1; 339 unsigned int sense_updated: 1;
330 unsigned int jack_present: 1; 340 unsigned int jack_present: 1;
331 unsigned int master_sw: 1; 341 unsigned int master_sw: 1;
342 unsigned int auto_mic:1;
332 343
333 /* other flags */ 344 /* other flags */
334 unsigned int no_analog :1; /* digital I/O only */ 345 unsigned int no_analog :1; /* digital I/O only */
@@ -370,6 +381,7 @@ struct alc_config_preset {
370 unsigned int num_mux_defs; 381 unsigned int num_mux_defs;
371 const struct hda_input_mux *input_mux; 382 const struct hda_input_mux *input_mux;
372 void (*unsol_event)(struct hda_codec *, unsigned int); 383 void (*unsol_event)(struct hda_codec *, unsigned int);
384 void (*setup)(struct hda_codec *);
373 void (*init_hook)(struct hda_codec *); 385 void (*init_hook)(struct hda_codec *);
374#ifdef CONFIG_SND_HDA_POWER_SAVE 386#ifdef CONFIG_SND_HDA_POWER_SAVE
375 struct hda_amp_list *loopbacks; 387 struct hda_amp_list *loopbacks;
@@ -417,7 +429,7 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
417 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 429 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
418 imux = &spec->input_mux[mux_idx]; 430 imux = &spec->input_mux[mux_idx];
419 431
420 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 432 type = get_wcaps_type(get_wcaps(codec, nid));
421 if (type == AC_WID_AUD_MIX) { 433 if (type == AC_WID_AUD_MIX) {
422 /* Matrix-mixer style (e.g. ALC882) */ 434 /* Matrix-mixer style (e.g. ALC882) */
423 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 435 unsigned int *cur_val = &spec->cur_mux[adc_idx];
@@ -842,9 +854,10 @@ static void print_realtek_coef(struct snd_info_buffer *buffer,
842/* 854/*
843 * set up from the preset table 855 * set up from the preset table
844 */ 856 */
845static void setup_preset(struct alc_spec *spec, 857static void setup_preset(struct hda_codec *codec,
846 const struct alc_config_preset *preset) 858 const struct alc_config_preset *preset)
847{ 859{
860 struct alc_spec *spec = codec->spec;
848 int i; 861 int i;
849 862
850 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) 863 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
@@ -886,6 +899,9 @@ static void setup_preset(struct alc_spec *spec,
886#ifdef CONFIG_SND_HDA_POWER_SAVE 899#ifdef CONFIG_SND_HDA_POWER_SAVE
887 spec->loopback.amplist = preset->loopbacks; 900 spec->loopback.amplist = preset->loopbacks;
888#endif 901#endif
902
903 if (preset->setup)
904 preset->setup(codec);
889} 905}
890 906
891/* Enable GPIO mask and set output */ 907/* Enable GPIO mask and set output */
@@ -965,30 +981,64 @@ static void alc_automute_pin(struct hda_codec *codec)
965 } 981 }
966} 982}
967 983
968#if 0 /* it's broken in some cases -- temporarily disabled */ 984static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
985 hda_nid_t nid)
986{
987 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
988 int i, nums;
989
990 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
991 for (i = 0; i < nums; i++)
992 if (conn[i] == nid)
993 return i;
994 return -1;
995}
996
969static void alc_mic_automute(struct hda_codec *codec) 997static void alc_mic_automute(struct hda_codec *codec)
970{ 998{
971 struct alc_spec *spec = codec->spec; 999 struct alc_spec *spec = codec->spec;
972 unsigned int present; 1000 struct alc_mic_route *dead, *alive;
973 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; 1001 unsigned int present, type;
974 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; 1002 hda_nid_t cap_nid;
975 unsigned int mix_nid = spec->capsrc_nids[0]; 1003
976 unsigned int capsrc_idx_mic, capsrc_idx_fmic; 1004 if (!spec->auto_mic)
977 1005 return;
978 capsrc_idx_mic = mic_nid - 0x18; 1006 if (!spec->int_mic.pin || !spec->ext_mic.pin)
979 capsrc_idx_fmic = fmic_nid - 0x18; 1007 return;
980 present = snd_hda_codec_read(codec, mic_nid, 0, 1008 if (snd_BUG_ON(!spec->adc_nids))
981 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1009 return;
982 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1010
983 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); 1011 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, 1012
985 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); 1013 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
986 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, 1014 AC_VERB_GET_PIN_SENSE, 0);
987 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 1015 present &= AC_PINSENSE_PRESENCE;
1016 if (present) {
1017 alive = &spec->ext_mic;
1018 dead = &spec->int_mic;
1019 } else {
1020 alive = &spec->int_mic;
1021 dead = &spec->ext_mic;
1022 }
1023
1024 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1025 if (type == AC_WID_AUD_MIX) {
1026 /* Matrix-mixer style (e.g. ALC882) */
1027 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1028 alive->mux_idx,
1029 HDA_AMP_MUTE, 0);
1030 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1031 dead->mux_idx,
1032 HDA_AMP_MUTE, HDA_AMP_MUTE);
1033 } else {
1034 /* MUX style (e.g. ALC880) */
1035 snd_hda_codec_write_cache(codec, cap_nid, 0,
1036 AC_VERB_SET_CONNECT_SEL,
1037 alive->mux_idx);
1038 }
1039
1040 /* FIXME: analog mixer */
988} 1041}
989#else
990#define alc_mic_automute(codec) do {} while(0) /* NOP */
991#endif /* disabled */
992 1042
993/* unsolicited event for HP jack sensing */ 1043/* unsolicited event for HP jack sensing */
994static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 1044static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1031,6 +1081,16 @@ static void alc888_coef_init(struct hda_codec *codec)
1031 AC_VERB_SET_PROC_COEF, 0x3030); 1081 AC_VERB_SET_PROC_COEF, 0x3030);
1032} 1082}
1033 1083
1084static void alc889_coef_init(struct hda_codec *codec)
1085{
1086 unsigned int tmp;
1087
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1089 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1092}
1093
1034static void alc_auto_init_amp(struct hda_codec *codec, int type) 1094static void alc_auto_init_amp(struct hda_codec *codec, int type)
1035{ 1095{
1036 unsigned int tmp; 1096 unsigned int tmp;
@@ -1088,15 +1148,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
1088 case 0x10ec0885: 1148 case 0x10ec0885:
1089 case 0x10ec0887: 1149 case 0x10ec0887:
1090 case 0x10ec0889: 1150 case 0x10ec0889:
1091 snd_hda_codec_write(codec, 0x20, 0, 1151 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; 1152 break;
1101 case 0x10ec0888: 1153 case 0x10ec0888:
1102 alc888_coef_init(codec); 1154 alc888_coef_init(codec);
@@ -1142,6 +1194,55 @@ static void alc_init_auto_hp(struct hda_codec *codec)
1142 spec->unsol_event = alc_sku_unsol_event; 1194 spec->unsol_event = alc_sku_unsol_event;
1143} 1195}
1144 1196
1197static void alc_init_auto_mic(struct hda_codec *codec)
1198{
1199 struct alc_spec *spec = codec->spec;
1200 struct auto_pin_cfg *cfg = &spec->autocfg;
1201 hda_nid_t fixed, ext;
1202 int i;
1203
1204 /* there must be only two mic inputs exclusively */
1205 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1206 if (cfg->input_pins[i])
1207 return;
1208
1209 fixed = ext = 0;
1210 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1211 hda_nid_t nid = cfg->input_pins[i];
1212 unsigned int defcfg;
1213 if (!nid)
1214 return;
1215 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1216 switch (get_defcfg_connect(defcfg)) {
1217 case AC_JACK_PORT_FIXED:
1218 if (fixed)
1219 return; /* already occupied */
1220 fixed = nid;
1221 break;
1222 case AC_JACK_PORT_COMPLEX:
1223 if (ext)
1224 return; /* already occupied */
1225 ext = nid;
1226 break;
1227 default:
1228 return; /* invalid entry */
1229 }
1230 }
1231 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1232 return; /* no unsol support */
1233 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1234 ext, fixed);
1235 spec->ext_mic.pin = ext;
1236 spec->int_mic.pin = fixed;
1237 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1238 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1239 spec->auto_mic = 1;
1240 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1241 AC_VERB_SET_UNSOLICITED_ENABLE,
1242 AC_USRSP_EN | ALC880_MIC_EVENT);
1243 spec->unsol_event = alc_sku_unsol_event;
1244}
1245
1145/* check subsystem ID and set up device-specific initialization; 1246/* check subsystem ID and set up device-specific initialization;
1146 * return 1 if initialized, 0 if invalid SSID 1247 * return 1 if initialized, 0 if invalid SSID
1147 */ 1248 */
@@ -1243,6 +1344,7 @@ do_sku:
1243 } 1344 }
1244 1345
1245 alc_init_auto_hp(codec); 1346 alc_init_auto_hp(codec);
1347 alc_init_auto_mic(codec);
1246 return 1; 1348 return 1;
1247} 1349}
1248 1350
@@ -1255,6 +1357,7 @@ static void alc_ssid_check(struct hda_codec *codec,
1255 "Enable default setup for auto mode as fallback\n"); 1357 "Enable default setup for auto mode as fallback\n");
1256 spec->init_amp = ALC_INIT_DEFAULT; 1358 spec->init_amp = ALC_INIT_DEFAULT;
1257 alc_init_auto_hp(codec); 1359 alc_init_auto_hp(codec);
1360 alc_init_auto_mic(codec);
1258 } 1361 }
1259} 1362}
1260 1363
@@ -1436,7 +1539,25 @@ static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1436 alc_automute_amp(codec); 1539 alc_automute_amp(codec);
1437} 1540}
1438 1541
1439static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec) 1542static void alc889_automute_setup(struct hda_codec *codec)
1543{
1544 struct alc_spec *spec = codec->spec;
1545
1546 spec->autocfg.hp_pins[0] = 0x15;
1547 spec->autocfg.speaker_pins[0] = 0x14;
1548 spec->autocfg.speaker_pins[1] = 0x16;
1549 spec->autocfg.speaker_pins[2] = 0x17;
1550 spec->autocfg.speaker_pins[3] = 0x19;
1551 spec->autocfg.speaker_pins[4] = 0x1a;
1552}
1553
1554static void alc889_intel_init_hook(struct hda_codec *codec)
1555{
1556 alc889_coef_init(codec);
1557 alc_automute_amp(codec);
1558}
1559
1560static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1440{ 1561{
1441 struct alc_spec *spec = codec->spec; 1562 struct alc_spec *spec = codec->spec;
1442 1563
@@ -1444,7 +1565,6 @@ static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1444 spec->autocfg.hp_pins[1] = 0x1b; /* hp */ 1565 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1445 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ 1566 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1446 spec->autocfg.speaker_pins[1] = 0x15; /* bass */ 1567 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1447 alc_automute_amp(codec);
1448} 1568}
1449 1569
1450/* 1570/*
@@ -1643,16 +1763,15 @@ static struct snd_kcontrol_new alc888_base_mixer[] = {
1643 { } /* end */ 1763 { } /* end */
1644}; 1764};
1645 1765
1646static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec) 1766static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
1647{ 1767{
1648 struct alc_spec *spec = codec->spec; 1768 struct alc_spec *spec = codec->spec;
1649 1769
1650 spec->autocfg.hp_pins[0] = 0x15; 1770 spec->autocfg.hp_pins[0] = 0x15;
1651 spec->autocfg.speaker_pins[0] = 0x14; 1771 spec->autocfg.speaker_pins[0] = 0x14;
1652 alc_automute_amp(codec);
1653} 1772}
1654 1773
1655static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec) 1774static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
1656{ 1775{
1657 struct alc_spec *spec = codec->spec; 1776 struct alc_spec *spec = codec->spec;
1658 1777
@@ -1660,10 +1779,9 @@ static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1660 spec->autocfg.speaker_pins[0] = 0x14; 1779 spec->autocfg.speaker_pins[0] = 0x14;
1661 spec->autocfg.speaker_pins[1] = 0x16; 1780 spec->autocfg.speaker_pins[1] = 0x16;
1662 spec->autocfg.speaker_pins[2] = 0x17; 1781 spec->autocfg.speaker_pins[2] = 0x17;
1663 alc_automute_amp(codec);
1664} 1782}
1665 1783
1666static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) 1784static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
1667{ 1785{
1668 struct alc_spec *spec = codec->spec; 1786 struct alc_spec *spec = codec->spec;
1669 1787
@@ -1671,7 +1789,6 @@ static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
1671 spec->autocfg.speaker_pins[0] = 0x14; 1789 spec->autocfg.speaker_pins[0] = 0x14;
1672 spec->autocfg.speaker_pins[1] = 0x16; 1790 spec->autocfg.speaker_pins[1] = 0x16;
1673 spec->autocfg.speaker_pins[2] = 0x1b; 1791 spec->autocfg.speaker_pins[2] = 0x1b;
1674 alc_automute_amp(codec);
1675} 1792}
1676 1793
1677/* 1794/*
@@ -2651,13 +2768,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); 2768 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2652} 2769}
2653 2770
2654static void alc880_uniwill_init_hook(struct hda_codec *codec) 2771static void alc880_uniwill_setup(struct hda_codec *codec)
2655{ 2772{
2656 struct alc_spec *spec = codec->spec; 2773 struct alc_spec *spec = codec->spec;
2657 2774
2658 spec->autocfg.hp_pins[0] = 0x14; 2775 spec->autocfg.hp_pins[0] = 0x14;
2659 spec->autocfg.speaker_pins[0] = 0x15; 2776 spec->autocfg.speaker_pins[0] = 0x15;
2660 spec->autocfg.speaker_pins[0] = 0x16; 2777 spec->autocfg.speaker_pins[0] = 0x16;
2778}
2779
2780static void alc880_uniwill_init_hook(struct hda_codec *codec)
2781{
2661 alc_automute_amp(codec); 2782 alc_automute_amp(codec);
2662 alc880_uniwill_mic_automute(codec); 2783 alc880_uniwill_mic_automute(codec);
2663} 2784}
@@ -2678,13 +2799,12 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2678 } 2799 }
2679} 2800}
2680 2801
2681static void alc880_uniwill_p53_init_hook(struct hda_codec *codec) 2802static void alc880_uniwill_p53_setup(struct hda_codec *codec)
2682{ 2803{
2683 struct alc_spec *spec = codec->spec; 2804 struct alc_spec *spec = codec->spec;
2684 2805
2685 spec->autocfg.hp_pins[0] = 0x14; 2806 spec->autocfg.hp_pins[0] = 0x14;
2686 spec->autocfg.speaker_pins[0] = 0x15; 2807 spec->autocfg.speaker_pins[0] = 0x15;
2687 alc_automute_amp(codec);
2688} 2808}
2689 2809
2690static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 2810static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -2947,13 +3067,12 @@ static struct hda_verb alc880_lg_init_verbs[] = {
2947}; 3067};
2948 3068
2949/* toggle speaker-output according to the hp-jack state */ 3069/* toggle speaker-output according to the hp-jack state */
2950static void alc880_lg_init_hook(struct hda_codec *codec) 3070static void alc880_lg_setup(struct hda_codec *codec)
2951{ 3071{
2952 struct alc_spec *spec = codec->spec; 3072 struct alc_spec *spec = codec->spec;
2953 3073
2954 spec->autocfg.hp_pins[0] = 0x1b; 3074 spec->autocfg.hp_pins[0] = 0x1b;
2955 spec->autocfg.speaker_pins[0] = 0x17; 3075 spec->autocfg.speaker_pins[0] = 0x17;
2956 alc_automute_amp(codec);
2957} 3076}
2958 3077
2959/* 3078/*
@@ -3032,13 +3151,12 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
3032}; 3151};
3033 3152
3034/* toggle speaker-output according to the hp-jack state */ 3153/* toggle speaker-output according to the hp-jack state */
3035static void alc880_lg_lw_init_hook(struct hda_codec *codec) 3154static void alc880_lg_lw_setup(struct hda_codec *codec)
3036{ 3155{
3037 struct alc_spec *spec = codec->spec; 3156 struct alc_spec *spec = codec->spec;
3038 3157
3039 spec->autocfg.hp_pins[0] = 0x1b; 3158 spec->autocfg.hp_pins[0] = 0x1b;
3040 spec->autocfg.speaker_pins[0] = 0x14; 3159 spec->autocfg.speaker_pins[0] = 0x14;
3041 alc_automute_amp(codec);
3042} 3160}
3043 3161
3044static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { 3162static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
@@ -3104,13 +3222,12 @@ static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3104 alc880_medion_rim_automute(codec); 3222 alc880_medion_rim_automute(codec);
3105} 3223}
3106 3224
3107static void alc880_medion_rim_init_hook(struct hda_codec *codec) 3225static void alc880_medion_rim_setup(struct hda_codec *codec)
3108{ 3226{
3109 struct alc_spec *spec = codec->spec; 3227 struct alc_spec *spec = codec->spec;
3110 3228
3111 spec->autocfg.hp_pins[0] = 0x14; 3229 spec->autocfg.hp_pins[0] = 0x14;
3112 spec->autocfg.speaker_pins[0] = 0x1b; 3230 spec->autocfg.speaker_pins[0] = 0x1b;
3113 alc880_medion_rim_automute(codec);
3114} 3231}
3115 3232
3116#ifdef CONFIG_SND_HDA_POWER_SAVE 3233#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -3977,7 +4094,8 @@ static struct alc_config_preset alc880_presets[] = {
3977 .channel_mode = alc880_2_jack_modes, 4094 .channel_mode = alc880_2_jack_modes,
3978 .input_mux = &alc880_f1734_capture_source, 4095 .input_mux = &alc880_f1734_capture_source,
3979 .unsol_event = alc880_uniwill_p53_unsol_event, 4096 .unsol_event = alc880_uniwill_p53_unsol_event,
3980 .init_hook = alc880_uniwill_p53_init_hook, 4097 .setup = alc880_uniwill_p53_setup,
4098 .init_hook = alc_automute_amp,
3981 }, 4099 },
3982 [ALC880_ASUS] = { 4100 [ALC880_ASUS] = {
3983 .mixers = { alc880_asus_mixer }, 4101 .mixers = { alc880_asus_mixer },
@@ -4054,6 +4172,7 @@ static struct alc_config_preset alc880_presets[] = {
4054 .need_dac_fix = 1, 4172 .need_dac_fix = 1,
4055 .input_mux = &alc880_capture_source, 4173 .input_mux = &alc880_capture_source,
4056 .unsol_event = alc880_uniwill_unsol_event, 4174 .unsol_event = alc880_uniwill_unsol_event,
4175 .setup = alc880_uniwill_setup,
4057 .init_hook = alc880_uniwill_init_hook, 4176 .init_hook = alc880_uniwill_init_hook,
4058 }, 4177 },
4059 [ALC880_UNIWILL_P53] = { 4178 [ALC880_UNIWILL_P53] = {
@@ -4066,7 +4185,8 @@ static struct alc_config_preset alc880_presets[] = {
4066 .channel_mode = alc880_threestack_modes, 4185 .channel_mode = alc880_threestack_modes,
4067 .input_mux = &alc880_capture_source, 4186 .input_mux = &alc880_capture_source,
4068 .unsol_event = alc880_uniwill_p53_unsol_event, 4187 .unsol_event = alc880_uniwill_p53_unsol_event,
4069 .init_hook = alc880_uniwill_p53_init_hook, 4188 .setup = alc880_uniwill_p53_setup,
4189 .init_hook = alc_automute_amp,
4070 }, 4190 },
4071 [ALC880_FUJITSU] = { 4191 [ALC880_FUJITSU] = {
4072 .mixers = { alc880_fujitsu_mixer }, 4192 .mixers = { alc880_fujitsu_mixer },
@@ -4080,7 +4200,8 @@ static struct alc_config_preset alc880_presets[] = {
4080 .channel_mode = alc880_2_jack_modes, 4200 .channel_mode = alc880_2_jack_modes,
4081 .input_mux = &alc880_capture_source, 4201 .input_mux = &alc880_capture_source,
4082 .unsol_event = alc880_uniwill_p53_unsol_event, 4202 .unsol_event = alc880_uniwill_p53_unsol_event,
4083 .init_hook = alc880_uniwill_p53_init_hook, 4203 .setup = alc880_uniwill_p53_setup,
4204 .init_hook = alc_automute_amp,
4084 }, 4205 },
4085 [ALC880_CLEVO] = { 4206 [ALC880_CLEVO] = {
4086 .mixers = { alc880_three_stack_mixer }, 4207 .mixers = { alc880_three_stack_mixer },
@@ -4106,7 +4227,8 @@ static struct alc_config_preset alc880_presets[] = {
4106 .need_dac_fix = 1, 4227 .need_dac_fix = 1,
4107 .input_mux = &alc880_lg_capture_source, 4228 .input_mux = &alc880_lg_capture_source,
4108 .unsol_event = alc_automute_amp_unsol_event, 4229 .unsol_event = alc_automute_amp_unsol_event,
4109 .init_hook = alc880_lg_init_hook, 4230 .setup = alc880_lg_setup,
4231 .init_hook = alc_automute_amp,
4110#ifdef CONFIG_SND_HDA_POWER_SAVE 4232#ifdef CONFIG_SND_HDA_POWER_SAVE
4111 .loopbacks = alc880_lg_loopbacks, 4233 .loopbacks = alc880_lg_loopbacks,
4112#endif 4234#endif
@@ -4122,7 +4244,8 @@ static struct alc_config_preset alc880_presets[] = {
4122 .channel_mode = alc880_lg_lw_modes, 4244 .channel_mode = alc880_lg_lw_modes,
4123 .input_mux = &alc880_lg_lw_capture_source, 4245 .input_mux = &alc880_lg_lw_capture_source,
4124 .unsol_event = alc_automute_amp_unsol_event, 4246 .unsol_event = alc_automute_amp_unsol_event,
4125 .init_hook = alc880_lg_lw_init_hook, 4247 .setup = alc880_lg_lw_setup,
4248 .init_hook = alc_automute_amp,
4126 }, 4249 },
4127 [ALC880_MEDION_RIM] = { 4250 [ALC880_MEDION_RIM] = {
4128 .mixers = { alc880_medion_rim_mixer }, 4251 .mixers = { alc880_medion_rim_mixer },
@@ -4136,7 +4259,8 @@ static struct alc_config_preset alc880_presets[] = {
4136 .channel_mode = alc880_2_jack_modes, 4259 .channel_mode = alc880_2_jack_modes,
4137 .input_mux = &alc880_medion_rim_capture_source, 4260 .input_mux = &alc880_medion_rim_capture_source,
4138 .unsol_event = alc880_medion_rim_unsol_event, 4261 .unsol_event = alc880_medion_rim_unsol_event,
4139 .init_hook = alc880_medion_rim_init_hook, 4262 .setup = alc880_medion_rim_setup,
4263 .init_hook = alc880_medion_rim_automute,
4140 }, 4264 },
4141#ifdef CONFIG_SND_DEBUG 4265#ifdef CONFIG_SND_DEBUG
4142 [ALC880_TEST] = { 4266 [ALC880_TEST] = {
@@ -4189,8 +4313,6 @@ static int add_control(struct alc_spec *spec, int type, const char *name,
4189#define alc880_fixed_pin_idx(nid) ((nid) - 0x14) 4313#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4190#define alc880_is_multi_pin(nid) ((nid) >= 0x18) 4314#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4191#define alc880_multi_pin_idx(nid) ((nid) - 0x18) 4315#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4192#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4193#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4194#define alc880_idx_to_dac(nid) ((nid) + 0x02) 4316#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4195#define alc880_dac_to_idx(nid) ((nid) - 0x02) 4317#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4196#define alc880_idx_to_mixer(nid) ((nid) + 0x0c) 4318#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
@@ -4278,13 +4400,19 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4278 if (err < 0) 4400 if (err < 0)
4279 return err; 4401 return err;
4280 } else { 4402 } else {
4281 sprintf(name, "%s Playback Volume", chname[i]); 4403 const char *pfx;
4404 if (cfg->line_outs == 1 &&
4405 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4406 pfx = "Speaker";
4407 else
4408 pfx = chname[i];
4409 sprintf(name, "%s Playback Volume", pfx);
4282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 4410 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4283 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 4411 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4284 HDA_OUTPUT)); 4412 HDA_OUTPUT));
4285 if (err < 0) 4413 if (err < 0)
4286 return err; 4414 return err;
4287 sprintf(name, "%s Playback Switch", chname[i]); 4415 sprintf(name, "%s Playback Switch", pfx);
4288 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 4416 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4289 HDA_COMPOSE_AMP_VAL(nid, 3, 2, 4417 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4290 HDA_INPUT)); 4418 HDA_INPUT));
@@ -4358,31 +4486,61 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4358 return 0; 4486 return 0;
4359} 4487}
4360 4488
4489static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
4490{
4491 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4492 return (pincap & AC_PINCAP_IN) != 0;
4493}
4494
4361/* create playback/capture controls for input pins */ 4495/* create playback/capture controls for input pins */
4362static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 4496static int alc_auto_create_input_ctls(struct hda_codec *codec,
4363 const struct auto_pin_cfg *cfg) 4497 const struct auto_pin_cfg *cfg,
4498 hda_nid_t mixer,
4499 hda_nid_t cap1, hda_nid_t cap2)
4364{ 4500{
4501 struct alc_spec *spec = codec->spec;
4365 struct hda_input_mux *imux = &spec->private_imux[0]; 4502 struct hda_input_mux *imux = &spec->private_imux[0];
4366 int i, err, idx; 4503 int i, err, idx;
4367 4504
4368 for (i = 0; i < AUTO_PIN_LAST; i++) { 4505 for (i = 0; i < AUTO_PIN_LAST; i++) {
4369 if (alc880_is_input_pin(cfg->input_pins[i])) { 4506 hda_nid_t pin;
4370 idx = alc880_input_pin_idx(cfg->input_pins[i]); 4507
4371 err = new_analog_input(spec, cfg->input_pins[i], 4508 pin = cfg->input_pins[i];
4372 auto_pin_cfg_labels[i], 4509 if (!alc_is_input_pin(codec, pin))
4373 idx, 0x0b); 4510 continue;
4374 if (err < 0) 4511
4375 return err; 4512 if (mixer) {
4513 idx = get_connection_index(codec, mixer, pin);
4514 if (idx >= 0) {
4515 err = new_analog_input(spec, pin,
4516 auto_pin_cfg_labels[i],
4517 idx, mixer);
4518 if (err < 0)
4519 return err;
4520 }
4521 }
4522
4523 if (!cap1)
4524 continue;
4525 idx = get_connection_index(codec, cap1, pin);
4526 if (idx < 0 && cap2)
4527 idx = get_connection_index(codec, cap2, pin);
4528 if (idx >= 0) {
4376 imux->items[imux->num_items].label = 4529 imux->items[imux->num_items].label =
4377 auto_pin_cfg_labels[i]; 4530 auto_pin_cfg_labels[i];
4378 imux->items[imux->num_items].index = 4531 imux->items[imux->num_items].index = idx;
4379 alc880_input_pin_idx(cfg->input_pins[i]);
4380 imux->num_items++; 4532 imux->num_items++;
4381 } 4533 }
4382 } 4534 }
4383 return 0; 4535 return 0;
4384} 4536}
4385 4537
4538static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4539 const struct auto_pin_cfg *cfg)
4540{
4541 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4542}
4543
4386static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, 4544static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4387 unsigned int pin_type) 4545 unsigned int pin_type)
4388{ 4546{
@@ -4448,7 +4606,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
4448 4606
4449 for (i = 0; i < AUTO_PIN_LAST; i++) { 4607 for (i = 0; i < AUTO_PIN_LAST; i++) {
4450 hda_nid_t nid = spec->autocfg.input_pins[i]; 4608 hda_nid_t nid = spec->autocfg.input_pins[i];
4451 if (alc880_is_input_pin(nid)) { 4609 if (alc_is_input_pin(codec, nid)) {
4452 alc_set_input_pin(codec, nid, i); 4610 alc_set_input_pin(codec, nid, i);
4453 if (nid != ALC880_PIN_CD_NID && 4611 if (nid != ALC880_PIN_CD_NID &&
4454 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 4612 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -4491,7 +4649,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4491 "Headphone"); 4649 "Headphone");
4492 if (err < 0) 4650 if (err < 0)
4493 return err; 4651 return err;
4494 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 4652 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
4495 if (err < 0) 4653 if (err < 0)
4496 return err; 4654 return err;
4497 4655
@@ -4505,12 +4663,6 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4505 &dig_nid, 1); 4663 &dig_nid, 1);
4506 if (err < 0) 4664 if (err < 0)
4507 continue; 4665 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) 4666 if (!i)
4515 spec->multiout.dig_out_nid = dig_nid; 4667 spec->multiout.dig_out_nid = dig_nid;
4516 else { 4668 else {
@@ -4547,8 +4699,42 @@ static void alc880_auto_init(struct hda_codec *codec)
4547 alc_inithook(codec); 4699 alc_inithook(codec);
4548} 4700}
4549 4701
4550static void set_capture_mixer(struct alc_spec *spec) 4702/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4703 * one of two digital mic pins, e.g. on ALC272
4704 */
4705static void fixup_automic_adc(struct hda_codec *codec)
4551{ 4706{
4707 struct alc_spec *spec = codec->spec;
4708 int i;
4709
4710 for (i = 0; i < spec->num_adc_nids; i++) {
4711 hda_nid_t cap = spec->capsrc_nids ?
4712 spec->capsrc_nids[i] : spec->adc_nids[i];
4713 int iidx, eidx;
4714
4715 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4716 if (iidx < 0)
4717 continue;
4718 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4719 if (eidx < 0)
4720 continue;
4721 spec->int_mic.mux_idx = iidx;
4722 spec->ext_mic.mux_idx = eidx;
4723 if (spec->capsrc_nids)
4724 spec->capsrc_nids += i;
4725 spec->adc_nids += i;
4726 spec->num_adc_nids = 1;
4727 return;
4728 }
4729 snd_printd(KERN_INFO "hda_codec: %s: "
4730 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4731 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4732 spec->auto_mic = 0; /* disable auto-mic to be sure */
4733}
4734
4735static void set_capture_mixer(struct hda_codec *codec)
4736{
4737 struct alc_spec *spec = codec->spec;
4552 static struct snd_kcontrol_new *caps[2][3] = { 4738 static struct snd_kcontrol_new *caps[2][3] = {
4553 { alc_capture_mixer_nosrc1, 4739 { alc_capture_mixer_nosrc1,
4554 alc_capture_mixer_nosrc2, 4740 alc_capture_mixer_nosrc2,
@@ -4559,7 +4745,10 @@ static void set_capture_mixer(struct alc_spec *spec)
4559 }; 4745 };
4560 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { 4746 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4561 int mux; 4747 int mux;
4562 if (spec->input_mux && spec->input_mux->num_items > 1) 4748 if (spec->auto_mic) {
4749 mux = 0;
4750 fixup_automic_adc(codec);
4751 } else if (spec->input_mux && spec->input_mux->num_items > 1)
4563 mux = 1; 4752 mux = 1;
4564 else 4753 else
4565 mux = 0; 4754 mux = 0;
@@ -4590,8 +4779,8 @@ static int patch_alc880(struct hda_codec *codec)
4590 alc880_models, 4779 alc880_models,
4591 alc880_cfg_tbl); 4780 alc880_cfg_tbl);
4592 if (board_config < 0) { 4781 if (board_config < 0) {
4593 printk(KERN_INFO "hda_codec: Unknown model for %s, " 4782 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4594 "trying auto-probe from BIOS...\n", codec->chip_name); 4783 codec->chip_name);
4595 board_config = ALC880_AUTO; 4784 board_config = ALC880_AUTO;
4596 } 4785 }
4597 4786
@@ -4616,7 +4805,7 @@ static int patch_alc880(struct hda_codec *codec)
4616 } 4805 }
4617 4806
4618 if (board_config != ALC880_AUTO) 4807 if (board_config != ALC880_AUTO)
4619 setup_preset(spec, &alc880_presets[board_config]); 4808 setup_preset(codec, &alc880_presets[board_config]);
4620 4809
4621 spec->stream_analog_playback = &alc880_pcm_analog_playback; 4810 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4622 spec->stream_analog_capture = &alc880_pcm_analog_capture; 4811 spec->stream_analog_capture = &alc880_pcm_analog_capture;
@@ -4629,7 +4818,7 @@ static int patch_alc880(struct hda_codec *codec)
4629 /* check whether NID 0x07 is valid */ 4818 /* check whether NID 0x07 is valid */
4630 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 4819 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
4631 /* get type */ 4820 /* get type */
4632 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 4821 wcap = get_wcaps_type(wcap);
4633 if (wcap != AC_WID_AUD_IN) { 4822 if (wcap != AC_WID_AUD_IN) {
4634 spec->adc_nids = alc880_adc_nids_alt; 4823 spec->adc_nids = alc880_adc_nids_alt;
4635 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 4824 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
@@ -4638,7 +4827,7 @@ static int patch_alc880(struct hda_codec *codec)
4638 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); 4827 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
4639 } 4828 }
4640 } 4829 }
4641 set_capture_mixer(spec); 4830 set_capture_mixer(codec);
4642 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4831 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4643 4832
4644 spec->vmaster_nid = 0x0c; 4833 spec->vmaster_nid = 0x0c;
@@ -5830,7 +6019,14 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5830 6019
5831 nid = cfg->line_out_pins[0]; 6020 nid = cfg->line_out_pins[0];
5832 if (nid) { 6021 if (nid) {
5833 err = alc260_add_playback_controls(spec, nid, "Front", &vols); 6022 const char *pfx;
6023 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6024 pfx = "Master";
6025 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6026 pfx = "Speaker";
6027 else
6028 pfx = "Front";
6029 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
5834 if (err < 0) 6030 if (err < 0)
5835 return err; 6031 return err;
5836 } 6032 }
@@ -5853,39 +6049,10 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5853} 6049}
5854 6050
5855/* create playback/capture controls for input pins */ 6051/* create playback/capture controls for input pins */
5856static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 6052static int alc260_auto_create_input_ctls(struct hda_codec *codec,
5857 const struct auto_pin_cfg *cfg) 6053 const struct auto_pin_cfg *cfg)
5858{ 6054{
5859 struct hda_input_mux *imux = &spec->private_imux[0]; 6055 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
5860 int i, err, idx;
5861
5862 for (i = 0; i < AUTO_PIN_LAST; i++) {
5863 if (cfg->input_pins[i] >= 0x12) {
5864 idx = cfg->input_pins[i] - 0x12;
5865 err = new_analog_input(spec, cfg->input_pins[i],
5866 auto_pin_cfg_labels[i], idx,
5867 0x07);
5868 if (err < 0)
5869 return err;
5870 imux->items[imux->num_items].label =
5871 auto_pin_cfg_labels[i];
5872 imux->items[imux->num_items].index = idx;
5873 imux->num_items++;
5874 }
5875 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
5876 idx = cfg->input_pins[i] - 0x09;
5877 err = new_analog_input(spec, cfg->input_pins[i],
5878 auto_pin_cfg_labels[i], idx,
5879 0x07);
5880 if (err < 0)
5881 return err;
5882 imux->items[imux->num_items].label =
5883 auto_pin_cfg_labels[i];
5884 imux->items[imux->num_items].index = idx;
5885 imux->num_items++;
5886 }
5887 }
5888 return 0;
5889} 6056}
5890 6057
5891static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, 6058static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
@@ -5999,7 +6166,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5999 return err; 6166 return err;
6000 if (!spec->kctls.list) 6167 if (!spec->kctls.list)
6001 return 0; /* can't find valid BIOS pin config */ 6168 return 0; /* can't find valid BIOS pin config */
6002 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); 6169 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
6003 if (err < 0) 6170 if (err < 0)
6004 return err; 6171 return err;
6005 6172
@@ -6234,8 +6401,7 @@ static int patch_alc260(struct hda_codec *codec)
6234 alc260_models, 6401 alc260_models,
6235 alc260_cfg_tbl); 6402 alc260_cfg_tbl);
6236 if (board_config < 0) { 6403 if (board_config < 0) {
6237 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, " 6404 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6238 "trying auto-probe from BIOS...\n",
6239 codec->chip_name); 6405 codec->chip_name);
6240 board_config = ALC260_AUTO; 6406 board_config = ALC260_AUTO;
6241 } 6407 }
@@ -6261,7 +6427,7 @@ static int patch_alc260(struct hda_codec *codec)
6261 } 6427 }
6262 6428
6263 if (board_config != ALC260_AUTO) 6429 if (board_config != ALC260_AUTO)
6264 setup_preset(spec, &alc260_presets[board_config]); 6430 setup_preset(codec, &alc260_presets[board_config]);
6265 6431
6266 spec->stream_analog_playback = &alc260_pcm_analog_playback; 6432 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6267 spec->stream_analog_capture = &alc260_pcm_analog_capture; 6433 spec->stream_analog_capture = &alc260_pcm_analog_capture;
@@ -6272,7 +6438,7 @@ static int patch_alc260(struct hda_codec *codec)
6272 if (!spec->adc_nids && spec->input_mux) { 6438 if (!spec->adc_nids && spec->input_mux) {
6273 /* check whether NID 0x04 is valid */ 6439 /* check whether NID 0x04 is valid */
6274 unsigned int wcap = get_wcaps(codec, 0x04); 6440 unsigned int wcap = get_wcaps(codec, 0x04);
6275 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 6441 wcap = get_wcaps_type(wcap);
6276 /* get type */ 6442 /* get type */
6277 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 6443 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6278 spec->adc_nids = alc260_adc_nids_alt; 6444 spec->adc_nids = alc260_adc_nids_alt;
@@ -6282,7 +6448,7 @@ static int patch_alc260(struct hda_codec *codec)
6282 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 6448 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6283 } 6449 }
6284 } 6450 }
6285 set_capture_mixer(spec); 6451 set_capture_mixer(codec);
6286 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); 6452 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
6287 6453
6288 spec->vmaster_nid = 0x08; 6454 spec->vmaster_nid = 0x08;
@@ -6301,7 +6467,7 @@ static int patch_alc260(struct hda_codec *codec)
6301 6467
6302 6468
6303/* 6469/*
6304 * ALC882 support 6470 * ALC882/883/885/888/889 support
6305 * 6471 *
6306 * ALC882 is almost identical with ALC880 but has cleaner and more flexible 6472 * 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. 6473 * configuration. Each pin widget can choose any input DACs and a mixer.
@@ -6313,22 +6479,35 @@ static int patch_alc260(struct hda_codec *codec)
6313 */ 6479 */
6314#define ALC882_DIGOUT_NID 0x06 6480#define ALC882_DIGOUT_NID 0x06
6315#define ALC882_DIGIN_NID 0x0a 6481#define ALC882_DIGIN_NID 0x0a
6482#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6483#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6484#define ALC1200_DIGOUT_NID 0x10
6485
6316 6486
6317static struct hda_channel_mode alc882_ch_modes[1] = { 6487static struct hda_channel_mode alc882_ch_modes[1] = {
6318 { 8, NULL } 6488 { 8, NULL }
6319}; 6489};
6320 6490
6491/* DACs */
6321static hda_nid_t alc882_dac_nids[4] = { 6492static hda_nid_t alc882_dac_nids[4] = {
6322 /* front, rear, clfe, rear_surr */ 6493 /* front, rear, clfe, rear_surr */
6323 0x02, 0x03, 0x04, 0x05 6494 0x02, 0x03, 0x04, 0x05
6324}; 6495};
6496#define alc883_dac_nids alc882_dac_nids
6325 6497
6326/* identical with ALC880 */ 6498/* ADCs */
6327#define alc882_adc_nids alc880_adc_nids 6499#define alc882_adc_nids alc880_adc_nids
6328#define alc882_adc_nids_alt alc880_adc_nids_alt 6500#define alc882_adc_nids_alt alc880_adc_nids_alt
6501#define alc883_adc_nids alc882_adc_nids_alt
6502static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6503static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6504#define alc889_adc_nids alc880_adc_nids
6329 6505
6330static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; 6506static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6331static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; 6507static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6508#define alc883_capsrc_nids alc882_capsrc_nids_alt
6509static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6510#define alc889_capsrc_nids alc882_capsrc_nids
6332 6511
6333/* input MUX */ 6512/* input MUX */
6334/* FIXME: should be a matrix-type input source selection */ 6513/* FIXME: should be a matrix-type input source selection */
@@ -6343,6 +6522,17 @@ static struct hda_input_mux alc882_capture_source = {
6343 }, 6522 },
6344}; 6523};
6345 6524
6525#define alc883_capture_source alc882_capture_source
6526
6527static struct hda_input_mux alc889_capture_source = {
6528 .num_items = 3,
6529 .items = {
6530 { "Front Mic", 0x0 },
6531 { "Mic", 0x3 },
6532 { "Line", 0x2 },
6533 },
6534};
6535
6346static struct hda_input_mux mb5_capture_source = { 6536static struct hda_input_mux mb5_capture_source = {
6347 .num_items = 3, 6537 .num_items = 3,
6348 .items = { 6538 .items = {
@@ -6352,6 +6542,77 @@ static struct hda_input_mux mb5_capture_source = {
6352 }, 6542 },
6353}; 6543};
6354 6544
6545static struct hda_input_mux alc883_3stack_6ch_intel = {
6546 .num_items = 4,
6547 .items = {
6548 { "Mic", 0x1 },
6549 { "Front Mic", 0x0 },
6550 { "Line", 0x2 },
6551 { "CD", 0x4 },
6552 },
6553};
6554
6555static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6556 .num_items = 2,
6557 .items = {
6558 { "Mic", 0x1 },
6559 { "Line", 0x2 },
6560 },
6561};
6562
6563static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6564 .num_items = 4,
6565 .items = {
6566 { "Mic", 0x0 },
6567 { "iMic", 0x1 },
6568 { "Line", 0x2 },
6569 { "CD", 0x4 },
6570 },
6571};
6572
6573static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6574 .num_items = 2,
6575 .items = {
6576 { "Mic", 0x0 },
6577 { "Int Mic", 0x1 },
6578 },
6579};
6580
6581static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6582 .num_items = 3,
6583 .items = {
6584 { "Mic", 0x0 },
6585 { "Front Mic", 0x1 },
6586 { "Line", 0x4 },
6587 },
6588};
6589
6590static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6591 .num_items = 2,
6592 .items = {
6593 { "Mic", 0x0 },
6594 { "Line", 0x2 },
6595 },
6596};
6597
6598static struct hda_input_mux alc889A_mb31_capture_source = {
6599 .num_items = 2,
6600 .items = {
6601 { "Mic", 0x0 },
6602 /* Front Mic (0x01) unused */
6603 { "Line", 0x2 },
6604 /* Line 2 (0x03) unused */
6605 /* CD (0x04) unsused? */
6606 },
6607};
6608
6609/*
6610 * 2ch mode
6611 */
6612static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6613 { 2, NULL }
6614};
6615
6355/* 6616/*
6356 * 2ch mode 6617 * 2ch mode
6357 */ 6618 */
@@ -6364,6 +6625,18 @@ static struct hda_verb alc882_3ST_ch2_init[] = {
6364}; 6625};
6365 6626
6366/* 6627/*
6628 * 4ch mode
6629 */
6630static struct hda_verb alc882_3ST_ch4_init[] = {
6631 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6632 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6635 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6636 { } /* end */
6637};
6638
6639/*
6367 * 6ch mode 6640 * 6ch mode
6368 */ 6641 */
6369static struct hda_verb alc882_3ST_ch6_init[] = { 6642static struct hda_verb alc882_3ST_ch6_init[] = {
@@ -6376,11 +6649,60 @@ static struct hda_verb alc882_3ST_ch6_init[] = {
6376 { } /* end */ 6649 { } /* end */
6377}; 6650};
6378 6651
6379static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { 6652static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
6380 { 2, alc882_3ST_ch2_init }, 6653 { 2, alc882_3ST_ch2_init },
6654 { 4, alc882_3ST_ch4_init },
6381 { 6, alc882_3ST_ch6_init }, 6655 { 6, alc882_3ST_ch6_init },
6382}; 6656};
6383 6657
6658#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6659
6660/*
6661 * 2ch mode
6662 */
6663static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6664 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6665 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6666 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6667 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6668 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6669 { } /* end */
6670};
6671
6672/*
6673 * 4ch mode
6674 */
6675static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6676 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6677 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6678 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6679 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6680 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6681 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6682 { } /* end */
6683};
6684
6685/*
6686 * 6ch mode
6687 */
6688static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6689 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6690 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6691 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6692 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6693 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6694 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6695 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6696 { } /* end */
6697};
6698
6699static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6700 { 2, alc883_3ST_ch2_clevo_init },
6701 { 4, alc883_3ST_ch4_clevo_init },
6702 { 6, alc883_3ST_ch6_clevo_init },
6703};
6704
6705
6384/* 6706/*
6385 * 6ch mode 6707 * 6ch mode
6386 */ 6708 */
@@ -6423,9 +6745,9 @@ static struct hda_verb alc885_mbp_ch2_init[] = {
6423}; 6745};
6424 6746
6425/* 6747/*
6426 * 6ch mode 6748 * 4ch mode
6427 */ 6749 */
6428static struct hda_verb alc885_mbp_ch6_init[] = { 6750static struct hda_verb alc885_mbp_ch4_init[] = {
6429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 6752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6431 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 6753 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
@@ -6434,9 +6756,9 @@ static struct hda_verb alc885_mbp_ch6_init[] = {
6434 { } /* end */ 6756 { } /* end */
6435}; 6757};
6436 6758
6437static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { 6759static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
6438 { 2, alc885_mbp_ch2_init }, 6760 { 2, alc885_mbp_ch2_init },
6439 { 6, alc885_mbp_ch6_init }, 6761 { 4, alc885_mbp_ch4_init },
6440}; 6762};
6441 6763
6442/* 6764/*
@@ -6468,6 +6790,189 @@ static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6468 { 6, alc885_mb5_ch6_init }, 6790 { 6, alc885_mb5_ch6_init },
6469}; 6791};
6470 6792
6793
6794/*
6795 * 2ch mode
6796 */
6797static struct hda_verb alc883_4ST_ch2_init[] = {
6798 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6799 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6800 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6801 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6804 { } /* end */
6805};
6806
6807/*
6808 * 4ch mode
6809 */
6810static struct hda_verb alc883_4ST_ch4_init[] = {
6811 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6812 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6815 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6818 { } /* end */
6819};
6820
6821/*
6822 * 6ch mode
6823 */
6824static struct hda_verb alc883_4ST_ch6_init[] = {
6825 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6826 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6827 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6828 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6829 { 0x18, 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
6836/*
6837 * 8ch mode
6838 */
6839static struct hda_verb alc883_4ST_ch8_init[] = {
6840 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6841 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6842 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6843 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6844 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6845 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6846 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6847 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6848 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6849 { } /* end */
6850};
6851
6852static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6853 { 2, alc883_4ST_ch2_init },
6854 { 4, alc883_4ST_ch4_init },
6855 { 6, alc883_4ST_ch6_init },
6856 { 8, alc883_4ST_ch8_init },
6857};
6858
6859
6860/*
6861 * 2ch mode
6862 */
6863static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6864 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6865 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6868 { } /* end */
6869};
6870
6871/*
6872 * 4ch mode
6873 */
6874static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6875 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6876 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6877 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6878 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6879 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6880 { } /* end */
6881};
6882
6883/*
6884 * 6ch mode
6885 */
6886static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6887 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6888 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6889 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6890 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6891 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6892 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6893 { } /* end */
6894};
6895
6896static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6897 { 2, alc883_3ST_ch2_intel_init },
6898 { 4, alc883_3ST_ch4_intel_init },
6899 { 6, alc883_3ST_ch6_intel_init },
6900};
6901
6902/*
6903 * 2ch mode
6904 */
6905static struct hda_verb alc889_ch2_intel_init[] = {
6906 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6907 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6908 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6909 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6910 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6911 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6912 { } /* end */
6913};
6914
6915/*
6916 * 6ch mode
6917 */
6918static struct hda_verb alc889_ch6_intel_init[] = {
6919 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6920 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6921 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6922 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6925 { } /* end */
6926};
6927
6928/*
6929 * 8ch mode
6930 */
6931static struct hda_verb alc889_ch8_intel_init[] = {
6932 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6933 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6934 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6935 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6936 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
6937 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6938 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6939 { } /* end */
6940};
6941
6942static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6943 { 2, alc889_ch2_intel_init },
6944 { 6, alc889_ch6_intel_init },
6945 { 8, alc889_ch8_intel_init },
6946};
6947
6948/*
6949 * 6ch mode
6950 */
6951static struct hda_verb alc883_sixstack_ch6_init[] = {
6952 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6953 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6954 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6955 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6956 { } /* end */
6957};
6958
6959/*
6960 * 8ch mode
6961 */
6962static struct hda_verb alc883_sixstack_ch8_init[] = {
6963 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6964 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6965 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6966 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6967 { } /* end */
6968};
6969
6970static struct hda_channel_mode alc883_sixstack_modes[2] = {
6971 { 6, alc883_sixstack_ch6_init },
6972 { 8, alc883_sixstack_ch8_init },
6973};
6974
6975
6471/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 6976/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6472 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 6977 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6473 */ 6978 */
@@ -6497,10 +7002,11 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
6497}; 7002};
6498 7003
6499static struct snd_kcontrol_new alc885_mbp3_mixer[] = { 7004static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
6500 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 7005 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6501 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), 7006 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
6502 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), 7007 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6503 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), 7008 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7009 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6505 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7011 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), 7012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
@@ -6603,7 +7109,7 @@ static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6603 { } /* end */ 7109 { } /* end */
6604}; 7110};
6605 7111
6606static struct hda_verb alc882_init_verbs[] = { 7112static struct hda_verb alc882_base_init_verbs[] = {
6607 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 7113 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
@@ -6621,6 +7127,13 @@ static struct hda_verb alc882_init_verbs[] = {
6621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7127 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7128 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6623 7129
7130 /* mute analog input loopbacks */
7131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7136
6624 /* Front Pin: output 0 (0x0c) */ 7137 /* Front Pin: output 0 (0x0c) */
6625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7139 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -6655,11 +7168,6 @@ static struct hda_verb alc882_init_verbs[] = {
6655 7168
6656 /* FIXME: use matrix-type input source selection */ 7169 /* FIXME: use matrix-type input source selection */
6657 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 7170 /* 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 */ 7171 /* Input mixer2 */
6664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
@@ -6670,9 +7178,6 @@ static struct hda_verb alc882_init_verbs[] = {
6670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 7180 {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 */ 7181 /* ADC2: mute amp left and right */
6677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6678 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7183 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -6683,6 +7188,18 @@ static struct hda_verb alc882_init_verbs[] = {
6683 { } 7188 { }
6684}; 7189};
6685 7190
7191static struct hda_verb alc882_adc1_init_verbs[] = {
7192 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7197 /* ADC1: mute amp left and right */
7198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7199 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7200 { }
7201};
7202
6686static struct hda_verb alc882_eapd_verbs[] = { 7203static struct hda_verb alc882_eapd_verbs[] = {
6687 /* change to EAPD mode */ 7204 /* change to EAPD mode */
6688 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 7205 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
@@ -6690,6 +7207,110 @@ static struct hda_verb alc882_eapd_verbs[] = {
6690 { } 7207 { }
6691}; 7208};
6692 7209
7210static struct hda_verb alc889_eapd_verbs[] = {
7211 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7212 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7213 { }
7214};
7215
7216static struct hda_verb alc_hp15_unsol_verbs[] = {
7217 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7219 {}
7220};
7221
7222static struct hda_verb alc885_init_verbs[] = {
7223 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7227 /* Rear mixer */
7228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7231 /* CLFE mixer */
7232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7235 /* Side mixer */
7236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7239
7240 /* mute analog input loopbacks */
7241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7244
7245 /* Front HP Pin: output 0 (0x0c) */
7246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7249 /* Front Pin: output 0 (0x0c) */
7250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7251 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7252 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7253 /* Rear Pin: output 1 (0x0d) */
7254 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7256 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7257 /* CLFE Pin: output 2 (0x0e) */
7258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7260 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7261 /* Side Pin: output 3 (0x0f) */
7262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7264 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7265 /* Mic (rear) pin: input vref at 80% */
7266 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7268 /* Front Mic pin: input vref at 80% */
7269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7271 /* Line In pin: input */
7272 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7274
7275 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7276 /* Input mixer1 */
7277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7280 /* Input mixer2 */
7281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7284 /* Input mixer3 */
7285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7288 /* ADC2: mute amp left and right */
7289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7290 /* ADC3: mute amp left and right */
7291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7292
7293 { }
7294};
7295
7296static struct hda_verb alc885_init_input_verbs[] = {
7297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7300 { }
7301};
7302
7303
7304/* Unmute Selector 24h and set the default input to front mic */
7305static struct hda_verb alc889_init_input_verbs[] = {
7306 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7308 { }
7309};
7310
7311
7312#define alc883_init_verbs alc882_base_init_verbs
7313
6693/* Mac Pro test */ 7314/* Mac Pro test */
6694static struct snd_kcontrol_new alc882_macpro_mixer[] = { 7315static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6695 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -6814,14 +7435,18 @@ static struct hda_verb alc885_mbp3_init_verbs[] = {
6814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7435 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7438 /* HP mixer */
7439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7441 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6817 /* Front Pin: output 0 (0x0c) */ 7442 /* Front Pin: output 0 (0x0c) */
6818 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6820 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 7445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6821 /* HP Pin: output 0 (0x0d) */ 7446 /* HP Pin: output 0 (0x0e) */
6822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, 7447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
6825 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7450 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6826 /* Mic (rear) pin: input vref at 80% */ 7451 /* Mic (rear) pin: input vref at 80% */
6827 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 7452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
@@ -6893,23 +7518,21 @@ static struct hda_verb alc885_imac24_init_verbs[] = {
6893}; 7518};
6894 7519
6895/* Toggle speaker-output according to the hp-jack state */ 7520/* Toggle speaker-output according to the hp-jack state */
6896static void alc885_imac24_automute_init_hook(struct hda_codec *codec) 7521static void alc885_imac24_setup(struct hda_codec *codec)
6897{ 7522{
6898 struct alc_spec *spec = codec->spec; 7523 struct alc_spec *spec = codec->spec;
6899 7524
6900 spec->autocfg.hp_pins[0] = 0x14; 7525 spec->autocfg.hp_pins[0] = 0x14;
6901 spec->autocfg.speaker_pins[0] = 0x18; 7526 spec->autocfg.speaker_pins[0] = 0x18;
6902 spec->autocfg.speaker_pins[1] = 0x1a; 7527 spec->autocfg.speaker_pins[1] = 0x1a;
6903 alc_automute_amp(codec);
6904} 7528}
6905 7529
6906static void alc885_mbp3_init_hook(struct hda_codec *codec) 7530static void alc885_mbp3_setup(struct hda_codec *codec)
6907{ 7531{
6908 struct alc_spec *spec = codec->spec; 7532 struct alc_spec *spec = codec->spec;
6909 7533
6910 spec->autocfg.hp_pins[0] = 0x15; 7534 spec->autocfg.hp_pins[0] = 0x15;
6911 spec->autocfg.speaker_pins[0] = 0x14; 7535 spec->autocfg.speaker_pins[0] = 0x14;
6912 alc_automute_amp(codec);
6913} 7536}
6914 7537
6915 7538
@@ -6937,13 +7560,12 @@ static void alc882_targa_automute(struct hda_codec *codec)
6937 spec->jack_present ? 1 : 3); 7560 spec->jack_present ? 1 : 3);
6938} 7561}
6939 7562
6940static void alc882_targa_init_hook(struct hda_codec *codec) 7563static void alc882_targa_setup(struct hda_codec *codec)
6941{ 7564{
6942 struct alc_spec *spec = codec->spec; 7565 struct alc_spec *spec = codec->spec;
6943 7566
6944 spec->autocfg.hp_pins[0] = 0x14; 7567 spec->autocfg.hp_pins[0] = 0x14;
6945 spec->autocfg.speaker_pins[0] = 0x1b; 7568 spec->autocfg.speaker_pins[0] = 0x1b;
6946 alc882_targa_automute(codec);
6947} 7569}
6948 7570
6949static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) 7571static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -7031,18 +7653,16 @@ static void alc885_macpro_init_hook(struct hda_codec *codec)
7031static void alc885_imac24_init_hook(struct hda_codec *codec) 7653static void alc885_imac24_init_hook(struct hda_codec *codec)
7032{ 7654{
7033 alc885_macpro_init_hook(codec); 7655 alc885_macpro_init_hook(codec);
7034 alc885_imac24_automute_init_hook(codec); 7656 alc_automute_amp(codec);
7035} 7657}
7036 7658
7037/* 7659/*
7038 * generic initialization of ADC, input mixers and output mixers 7660 * generic initialization of ADC, input mixers and output mixers
7039 */ 7661 */
7040static struct hda_verb alc882_auto_init_verbs[] = { 7662static struct hda_verb alc883_auto_init_verbs[] = {
7041 /* 7663 /*
7042 * Unmute ADC0-2 and set the default input to mic-in 7664 * Unmute ADC0-2 and set the default input to mic-in
7043 */ 7665 */
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}, 7666 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7047 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7048 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 7668 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -7083,11 +7703,6 @@ static struct hda_verb alc882_auto_init_verbs[] = {
7083 7703
7084 /* FIXME: use matrix-type input source selection */ 7704 /* FIXME: use matrix-type input source selection */
7085 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 7705 /* 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 */ 7706 /* Input mixer2 */
7092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 7707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 7708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
@@ -7102,820 +7717,6 @@ static struct hda_verb alc882_auto_init_verbs[] = {
7102 { } 7717 { }
7103}; 7718};
7104 7719
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) */ 7720/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7920static struct hda_verb alc889A_mb31_ch2_init[] = { 7721static struct hda_verb alc889A_mb31_ch2_init[] = {
7921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ 7722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
@@ -7966,34 +7767,7 @@ static struct hda_verb alc883_medion_eapd_verbs[] = {
7966 { } 7767 { }
7967}; 7768};
7968 7769
7969/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 7770#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 7771
7998static struct snd_kcontrol_new alc883_mitac_mixer[] = { 7772static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7999 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7773 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -8104,6 +7878,30 @@ static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8104 { } /* end */ 7878 { } /* end */
8105}; 7879};
8106 7880
7881static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7885 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7887 HDA_OUTPUT),
7888 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7889 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7890 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7892 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7897 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7902 { } /* end */
7903};
7904
8107static struct snd_kcontrol_new alc883_fivestack_mixer[] = { 7905static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
8108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8109 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -8344,93 +8142,14 @@ static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8344 { } /* end */ 8142 { } /* end */
8345}; 8143};
8346 8144
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 */ 8145/* toggle speaker-output according to the hp-jack state */
8426static void alc883_mitac_init_hook(struct hda_codec *codec) 8146static void alc883_mitac_setup(struct hda_codec *codec)
8427{ 8147{
8428 struct alc_spec *spec = codec->spec; 8148 struct alc_spec *spec = codec->spec;
8429 8149
8430 spec->autocfg.hp_pins[0] = 0x15; 8150 spec->autocfg.hp_pins[0] = 0x15;
8431 spec->autocfg.speaker_pins[0] = 0x14; 8151 spec->autocfg.speaker_pins[0] = 0x14;
8432 spec->autocfg.speaker_pins[1] = 0x17; 8152 spec->autocfg.speaker_pins[1] = 0x17;
8433 alc_automute_amp(codec);
8434} 8153}
8435 8154
8436/* auto-toggle front mic */ 8155/* auto-toggle front mic */
@@ -8462,6 +8181,22 @@ static struct hda_verb alc883_mitac_verbs[] = {
8462 { } /* end */ 8181 { } /* end */
8463}; 8182};
8464 8183
8184static struct hda_verb alc883_clevo_m540r_verbs[] = {
8185 /* HP */
8186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8188 /* Int speaker */
8189 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8190
8191 /* enable unsolicited event */
8192 /*
8193 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8194 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8195 */
8196
8197 { } /* end */
8198};
8199
8465static struct hda_verb alc883_clevo_m720_verbs[] = { 8200static struct hda_verb alc883_clevo_m720_verbs[] = {
8466 /* HP */ 8201 /* HP */
8467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 8202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -8585,7 +8320,7 @@ static struct hda_verb alc883_vaiott_verbs[] = {
8585 { } /* end */ 8320 { } /* end */
8586}; 8321};
8587 8322
8588static void alc888_3st_hp_init_hook(struct hda_codec *codec) 8323static void alc888_3st_hp_setup(struct hda_codec *codec)
8589{ 8324{
8590 struct alc_spec *spec = codec->spec; 8325 struct alc_spec *spec = codec->spec;
8591 8326
@@ -8593,7 +8328,6 @@ static void alc888_3st_hp_init_hook(struct hda_codec *codec)
8593 spec->autocfg.speaker_pins[0] = 0x14; 8328 spec->autocfg.speaker_pins[0] = 0x14;
8594 spec->autocfg.speaker_pins[1] = 0x16; 8329 spec->autocfg.speaker_pins[1] = 0x16;
8595 spec->autocfg.speaker_pins[2] = 0x18; 8330 spec->autocfg.speaker_pins[2] = 0x18;
8596 alc_automute_amp(codec);
8597} 8331}
8598 8332
8599static struct hda_verb alc888_3st_hp_verbs[] = { 8333static struct hda_verb alc888_3st_hp_verbs[] = {
@@ -8690,13 +8424,12 @@ static struct hda_verb alc883_medion_md2_verbs[] = {
8690}; 8424};
8691 8425
8692/* toggle speaker-output according to the hp-jack state */ 8426/* toggle speaker-output according to the hp-jack state */
8693static void alc883_medion_md2_init_hook(struct hda_codec *codec) 8427static void alc883_medion_md2_setup(struct hda_codec *codec)
8694{ 8428{
8695 struct alc_spec *spec = codec->spec; 8429 struct alc_spec *spec = codec->spec;
8696 8430
8697 spec->autocfg.hp_pins[0] = 0x14; 8431 spec->autocfg.hp_pins[0] = 0x14;
8698 spec->autocfg.speaker_pins[0] = 0x15; 8432 spec->autocfg.speaker_pins[0] = 0x15;
8699 alc_automute_amp(codec);
8700} 8433}
8701 8434
8702/* toggle speaker-output according to the hp-jack state */ 8435/* toggle speaker-output according to the hp-jack state */
@@ -8713,12 +8446,16 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8713 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8446 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8714} 8447}
8715 8448
8716static void alc883_clevo_m720_init_hook(struct hda_codec *codec) 8449static void alc883_clevo_m720_setup(struct hda_codec *codec)
8717{ 8450{
8718 struct alc_spec *spec = codec->spec; 8451 struct alc_spec *spec = codec->spec;
8719 8452
8720 spec->autocfg.hp_pins[0] = 0x15; 8453 spec->autocfg.hp_pins[0] = 0x15;
8721 spec->autocfg.speaker_pins[0] = 0x14; 8454 spec->autocfg.speaker_pins[0] = 0x14;
8455}
8456
8457static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8458{
8722 alc_automute_amp(codec); 8459 alc_automute_amp(codec);
8723 alc883_clevo_m720_mic_automute(codec); 8460 alc883_clevo_m720_mic_automute(codec);
8724} 8461}
@@ -8737,22 +8474,20 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8737} 8474}
8738 8475
8739/* toggle speaker-output according to the hp-jack state */ 8476/* toggle speaker-output according to the hp-jack state */
8740static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec) 8477static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
8741{ 8478{
8742 struct alc_spec *spec = codec->spec; 8479 struct alc_spec *spec = codec->spec;
8743 8480
8744 spec->autocfg.hp_pins[0] = 0x14; 8481 spec->autocfg.hp_pins[0] = 0x14;
8745 spec->autocfg.speaker_pins[0] = 0x15; 8482 spec->autocfg.speaker_pins[0] = 0x15;
8746 alc_automute_amp(codec);
8747} 8483}
8748 8484
8749static void alc883_haier_w66_init_hook(struct hda_codec *codec) 8485static void alc883_haier_w66_setup(struct hda_codec *codec)
8750{ 8486{
8751 struct alc_spec *spec = codec->spec; 8487 struct alc_spec *spec = codec->spec;
8752 8488
8753 spec->autocfg.hp_pins[0] = 0x1b; 8489 spec->autocfg.hp_pins[0] = 0x1b;
8754 spec->autocfg.speaker_pins[0] = 0x14; 8490 spec->autocfg.speaker_pins[0] = 0x14;
8755 alc_automute_amp(codec);
8756} 8491}
8757 8492
8758static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 8493static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
@@ -8791,14 +8526,13 @@ static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8791} 8526}
8792 8527
8793/* toggle speaker-output according to the hp-jack state */ 8528/* toggle speaker-output according to the hp-jack state */
8794static void alc883_acer_aspire_init_hook(struct hda_codec *codec) 8529static void alc883_acer_aspire_setup(struct hda_codec *codec)
8795{ 8530{
8796 struct alc_spec *spec = codec->spec; 8531 struct alc_spec *spec = codec->spec;
8797 8532
8798 spec->autocfg.hp_pins[0] = 0x14; 8533 spec->autocfg.hp_pins[0] = 0x14;
8799 spec->autocfg.speaker_pins[0] = 0x15; 8534 spec->autocfg.speaker_pins[0] = 0x15;
8800 spec->autocfg.speaker_pins[1] = 0x16; 8535 spec->autocfg.speaker_pins[1] = 0x16;
8801 alc_automute_amp(codec);
8802} 8536}
8803 8537
8804static struct hda_verb alc883_acer_eapd_verbs[] = { 8538static struct hda_verb alc883_acer_eapd_verbs[] = {
@@ -8819,7 +8553,14 @@ static struct hda_verb alc883_acer_eapd_verbs[] = {
8819 { } 8553 { }
8820}; 8554};
8821 8555
8822static void alc888_6st_dell_init_hook(struct hda_codec *codec) 8556static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8558 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8560 { } /* end */
8561};
8562
8563static void alc888_6st_dell_setup(struct hda_codec *codec)
8823{ 8564{
8824 struct alc_spec *spec = codec->spec; 8565 struct alc_spec *spec = codec->spec;
8825 8566
@@ -8828,10 +8569,9 @@ static void alc888_6st_dell_init_hook(struct hda_codec *codec)
8828 spec->autocfg.speaker_pins[1] = 0x15; 8569 spec->autocfg.speaker_pins[1] = 0x15;
8829 spec->autocfg.speaker_pins[2] = 0x16; 8570 spec->autocfg.speaker_pins[2] = 0x16;
8830 spec->autocfg.speaker_pins[3] = 0x17; 8571 spec->autocfg.speaker_pins[3] = 0x17;
8831 alc_automute_amp(codec);
8832} 8572}
8833 8573
8834static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) 8574static void alc888_lenovo_sky_setup(struct hda_codec *codec)
8835{ 8575{
8836 struct alc_spec *spec = codec->spec; 8576 struct alc_spec *spec = codec->spec;
8837 8577
@@ -8841,82 +8581,17 @@ static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
8841 spec->autocfg.speaker_pins[2] = 0x16; 8581 spec->autocfg.speaker_pins[2] = 0x16;
8842 spec->autocfg.speaker_pins[3] = 0x17; 8582 spec->autocfg.speaker_pins[3] = 0x17;
8843 spec->autocfg.speaker_pins[4] = 0x1a; 8583 spec->autocfg.speaker_pins[4] = 0x1a;
8844 alc_automute_amp(codec);
8845} 8584}
8846 8585
8847static void alc883_vaiott_init_hook(struct hda_codec *codec) 8586static void alc883_vaiott_setup(struct hda_codec *codec)
8848{ 8587{
8849 struct alc_spec *spec = codec->spec; 8588 struct alc_spec *spec = codec->spec;
8850 8589
8851 spec->autocfg.hp_pins[0] = 0x15; 8590 spec->autocfg.hp_pins[0] = 0x15;
8852 spec->autocfg.speaker_pins[0] = 0x14; 8591 spec->autocfg.speaker_pins[0] = 0x14;
8853 spec->autocfg.speaker_pins[1] = 0x17; 8592 spec->autocfg.speaker_pins[1] = 0x17;
8854 alc_automute_amp(codec);
8855} 8593}
8856 8594
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[] = { 8595static struct hda_verb alc888_asus_m90v_verbs[] = {
8921 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8922 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
@@ -8927,19 +8602,7 @@ static struct hda_verb alc888_asus_m90v_verbs[] = {
8927 { } /* end */ 8602 { } /* end */
8928}; 8603};
8929 8604
8930static void alc883_nb_mic_automute(struct hda_codec *codec) 8605static 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{ 8606{
8944 struct alc_spec *spec = codec->spec; 8607 struct alc_spec *spec = codec->spec;
8945 8608
@@ -8947,26 +8610,11 @@ static void alc883_M90V_init_hook(struct hda_codec *codec)
8947 spec->autocfg.speaker_pins[0] = 0x14; 8610 spec->autocfg.speaker_pins[0] = 0x14;
8948 spec->autocfg.speaker_pins[1] = 0x15; 8611 spec->autocfg.speaker_pins[1] = 0x15;
8949 spec->autocfg.speaker_pins[2] = 0x16; 8612 spec->autocfg.speaker_pins[2] = 0x16;
8950 alc_automute_pin(codec); 8613 spec->ext_mic.pin = 0x18;
8951} 8614 spec->int_mic.pin = 0x19;
8952 8615 spec->ext_mic.mux_idx = 0;
8953static void alc883_mode2_unsol_event(struct hda_codec *codec, 8616 spec->int_mic.mux_idx = 1;
8954 unsigned int res) 8617 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} 8618}
8971 8619
8972static struct hda_verb alc888_asus_eee1601_verbs[] = { 8620static struct hda_verb alc888_asus_eee1601_verbs[] = {
@@ -9027,25 +8675,44 @@ static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9027 alc889A_mb31_automute(codec); 8675 alc889A_mb31_automute(codec);
9028} 8676}
9029 8677
8678
9030#ifdef CONFIG_SND_HDA_POWER_SAVE 8679#ifdef CONFIG_SND_HDA_POWER_SAVE
9031#define alc883_loopbacks alc880_loopbacks 8680#define alc882_loopbacks alc880_loopbacks
9032#endif 8681#endif
9033 8682
9034/* pcm configuration: identical with ALC880 */ 8683/* pcm configuration: identical with ALC880 */
9035#define alc883_pcm_analog_playback alc880_pcm_analog_playback 8684#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9036#define alc883_pcm_analog_capture alc880_pcm_analog_capture 8685#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9037#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture 8686#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9038#define alc883_pcm_digital_playback alc880_pcm_digital_playback 8687#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9039#define alc883_pcm_digital_capture alc880_pcm_digital_capture 8688
8689static hda_nid_t alc883_slave_dig_outs[] = {
8690 ALC1200_DIGOUT_NID, 0,
8691};
8692
8693static hda_nid_t alc1200_slave_dig_outs[] = {
8694 ALC883_DIGOUT_NID, 0,
8695};
9040 8696
9041/* 8697/*
9042 * configuration and preset 8698 * configuration and preset
9043 */ 8699 */
9044static const char *alc883_models[ALC883_MODEL_LAST] = { 8700static const char *alc882_models[ALC882_MODEL_LAST] = {
9045 [ALC883_3ST_2ch_DIG] = "3stack-dig", 8701 [ALC882_3ST_DIG] = "3stack-dig",
8702 [ALC882_6ST_DIG] = "6stack-dig",
8703 [ALC882_ARIMA] = "arima",
8704 [ALC882_W2JC] = "w2jc",
8705 [ALC882_TARGA] = "targa",
8706 [ALC882_ASUS_A7J] = "asus-a7j",
8707 [ALC882_ASUS_A7M] = "asus-a7m",
8708 [ALC885_MACPRO] = "macpro",
8709 [ALC885_MB5] = "mb5",
8710 [ALC885_MBP3] = "mbp3",
8711 [ALC885_IMAC24] = "imac24",
8712 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
9046 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", 8713 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9047 [ALC883_3ST_6ch] = "3stack-6ch", 8714 [ALC883_3ST_6ch] = "3stack-6ch",
9048 [ALC883_6ST_DIG] = "6stack-dig", 8715 [ALC883_6ST_DIG] = "alc883-6stack-dig",
9049 [ALC883_TARGA_DIG] = "targa-dig", 8716 [ALC883_TARGA_DIG] = "targa-dig",
9050 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 8717 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
9051 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig", 8718 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
@@ -9054,6 +8721,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
9054 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", 8721 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
9055 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g", 8722 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
9056 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g", 8723 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
8724 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
9057 [ALC883_MEDION] = "medion", 8725 [ALC883_MEDION] = "medion",
9058 [ALC883_MEDION_MD2] = "medion-md2", 8726 [ALC883_MEDION_MD2] = "medion-md2",
9059 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 8727 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
@@ -9065,18 +8733,22 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
9065 [ALC888_3ST_HP] = "3stack-hp", 8733 [ALC888_3ST_HP] = "3stack-hp",
9066 [ALC888_6ST_DELL] = "6stack-dell", 8734 [ALC888_6ST_DELL] = "6stack-dell",
9067 [ALC883_MITAC] = "mitac", 8735 [ALC883_MITAC] = "mitac",
8736 [ALC883_CLEVO_M540R] = "clevo-m540r",
9068 [ALC883_CLEVO_M720] = "clevo-m720", 8737 [ALC883_CLEVO_M720] = "clevo-m720",
9069 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", 8738 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
9070 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", 8739 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
9071 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", 8740 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8741 [ALC889A_INTEL] = "intel-alc889a",
8742 [ALC889_INTEL] = "intel-x58",
9072 [ALC1200_ASUS_P5Q] = "asus-p5q", 8743 [ALC1200_ASUS_P5Q] = "asus-p5q",
9073 [ALC889A_MB31] = "mb31", 8744 [ALC889A_MB31] = "mb31",
9074 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt", 8745 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
9075 [ALC883_AUTO] = "auto", 8746 [ALC882_AUTO] = "auto",
9076}; 8747};
9077 8748
9078static struct snd_pci_quirk alc883_cfg_tbl[] = { 8749static struct snd_pci_quirk alc882_cfg_tbl[] = {
9079 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 8750 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8751
9080 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 8752 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
9081 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), 8753 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
9082 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE), 8754 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
@@ -9091,40 +8763,56 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9091 ALC888_ACER_ASPIRE_8930G), 8763 ALC888_ACER_ASPIRE_8930G),
9092 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", 8764 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9093 ALC888_ACER_ASPIRE_8930G), 8765 ALC888_ACER_ASPIRE_8930G),
9094 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), 8766 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9095 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), 8767 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
9096 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 8768 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
9097 ALC888_ACER_ASPIRE_6530G), 8769 ALC888_ACER_ASPIRE_6530G),
9098 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", 8770 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
9099 ALC888_ACER_ASPIRE_6530G), 8771 ALC888_ACER_ASPIRE_6530G),
8772 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8773 ALC888_ACER_ASPIRE_7730G),
9100 /* default Acer -- disabled as it causes more problems. 8774 /* default Acer -- disabled as it causes more problems.
9101 * model=auto should work fine now 8775 * model=auto should work fine now
9102 */ 8776 */
9103 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */ 8777 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
8778
9104 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 8779 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8780
9105 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 8781 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
9106 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8782 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9107 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8783 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
9108 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8784 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
9109 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), 8785 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
9110 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP), 8786 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8787
8788 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8789 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8790 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
9111 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8791 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8792 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8793 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8794 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
9112 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8795 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
9113 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), 8796 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
9114 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), 8797 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
9115 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8798 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8799
8800 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
9116 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8801 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
9117 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 8802 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
9118 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), 8803 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
9119 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), 8804 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9120 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 8805 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
9121 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), 8806 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
9122 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 8807 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
9123 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), 8808 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8809
9124 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 8810 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9125 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), 8811 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9126 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 8812 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
8813 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
9127 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), 8814 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
8815 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
9128 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), 8816 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
9129 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), 8817 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
9130 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 8818 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
@@ -9133,6 +8821,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9133 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), 8821 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9134 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), 8822 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9135 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), 8823 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8824 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
9136 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), 8825 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9137 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), 8826 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9138 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 8827 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
@@ -9146,11 +8835,15 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9146 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 8835 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
9147 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), 8836 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
9148 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 8837 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
8838 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
8839
9149 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 8840 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
9150 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), 8841 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9151 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), 8842 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8843 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
9152 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), 8844 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
9153 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 8845 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8846 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
9154 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 8847 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
9155 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", 8848 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
9156 ALC883_FUJITSU_PI2515), 8849 ALC883_FUJITSU_PI2515),
@@ -9165,24 +8858,186 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9165 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), 8858 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
9166 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), 8859 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
9167 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 8860 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8861
9168 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), 8862 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9169 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), 8863 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
9170 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), 8864 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
9171 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), 8865 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8866 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8867 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
9172 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 8868 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 8869
9177static hda_nid_t alc883_slave_dig_outs[] = { 8870 {}
9178 ALC1200_DIGOUT_NID, 0,
9179}; 8871};
9180 8872
9181static hda_nid_t alc1200_slave_dig_outs[] = { 8873/* codec SSID table for Intel Mac */
9182 ALC883_DIGOUT_NID, 0, 8874static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8875 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8876 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8877 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8878 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8879 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8880 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8881 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8882 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8883 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8884 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8885 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8886 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8887 * no perfect solution yet
8888 */
8889 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8890 {} /* terminator */
9183}; 8891};
9184 8892
9185static struct alc_config_preset alc883_presets[] = { 8893static struct alc_config_preset alc882_presets[] = {
8894 [ALC882_3ST_DIG] = {
8895 .mixers = { alc882_base_mixer },
8896 .init_verbs = { alc882_base_init_verbs,
8897 alc882_adc1_init_verbs },
8898 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8899 .dac_nids = alc882_dac_nids,
8900 .dig_out_nid = ALC882_DIGOUT_NID,
8901 .dig_in_nid = ALC882_DIGIN_NID,
8902 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8903 .channel_mode = alc882_ch_modes,
8904 .need_dac_fix = 1,
8905 .input_mux = &alc882_capture_source,
8906 },
8907 [ALC882_6ST_DIG] = {
8908 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8909 .init_verbs = { alc882_base_init_verbs,
8910 alc882_adc1_init_verbs },
8911 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8912 .dac_nids = alc882_dac_nids,
8913 .dig_out_nid = ALC882_DIGOUT_NID,
8914 .dig_in_nid = ALC882_DIGIN_NID,
8915 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8916 .channel_mode = alc882_sixstack_modes,
8917 .input_mux = &alc882_capture_source,
8918 },
8919 [ALC882_ARIMA] = {
8920 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8921 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8922 alc882_eapd_verbs },
8923 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8924 .dac_nids = alc882_dac_nids,
8925 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8926 .channel_mode = alc882_sixstack_modes,
8927 .input_mux = &alc882_capture_source,
8928 },
8929 [ALC882_W2JC] = {
8930 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
8931 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8932 alc882_eapd_verbs, alc880_gpio1_init_verbs },
8933 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8934 .dac_nids = alc882_dac_nids,
8935 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8936 .channel_mode = alc880_threestack_modes,
8937 .need_dac_fix = 1,
8938 .input_mux = &alc882_capture_source,
8939 .dig_out_nid = ALC882_DIGOUT_NID,
8940 },
8941 [ALC885_MBP3] = {
8942 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8943 .init_verbs = { alc885_mbp3_init_verbs,
8944 alc880_gpio1_init_verbs },
8945 .num_dacs = 2,
8946 .dac_nids = alc882_dac_nids,
8947 .hp_nid = 0x04,
8948 .channel_mode = alc885_mbp_4ch_modes,
8949 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
8950 .input_mux = &alc882_capture_source,
8951 .dig_out_nid = ALC882_DIGOUT_NID,
8952 .dig_in_nid = ALC882_DIGIN_NID,
8953 .unsol_event = alc_automute_amp_unsol_event,
8954 .setup = alc885_mbp3_setup,
8955 .init_hook = alc_automute_amp,
8956 },
8957 [ALC885_MB5] = {
8958 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8959 .init_verbs = { alc885_mb5_init_verbs,
8960 alc880_gpio1_init_verbs },
8961 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8962 .dac_nids = alc882_dac_nids,
8963 .channel_mode = alc885_mb5_6ch_modes,
8964 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8965 .input_mux = &mb5_capture_source,
8966 .dig_out_nid = ALC882_DIGOUT_NID,
8967 .dig_in_nid = ALC882_DIGIN_NID,
8968 },
8969 [ALC885_MACPRO] = {
8970 .mixers = { alc882_macpro_mixer },
8971 .init_verbs = { alc882_macpro_init_verbs },
8972 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8973 .dac_nids = alc882_dac_nids,
8974 .dig_out_nid = ALC882_DIGOUT_NID,
8975 .dig_in_nid = ALC882_DIGIN_NID,
8976 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8977 .channel_mode = alc882_ch_modes,
8978 .input_mux = &alc882_capture_source,
8979 .init_hook = alc885_macpro_init_hook,
8980 },
8981 [ALC885_IMAC24] = {
8982 .mixers = { alc885_imac24_mixer },
8983 .init_verbs = { alc885_imac24_init_verbs },
8984 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8985 .dac_nids = alc882_dac_nids,
8986 .dig_out_nid = ALC882_DIGOUT_NID,
8987 .dig_in_nid = ALC882_DIGIN_NID,
8988 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8989 .channel_mode = alc882_ch_modes,
8990 .input_mux = &alc882_capture_source,
8991 .unsol_event = alc_automute_amp_unsol_event,
8992 .setup = alc885_imac24_setup,
8993 .init_hook = alc885_imac24_init_hook,
8994 },
8995 [ALC882_TARGA] = {
8996 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
8997 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8998 alc880_gpio3_init_verbs, alc882_targa_verbs},
8999 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9000 .dac_nids = alc882_dac_nids,
9001 .dig_out_nid = ALC882_DIGOUT_NID,
9002 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9003 .adc_nids = alc882_adc_nids,
9004 .capsrc_nids = alc882_capsrc_nids,
9005 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9006 .channel_mode = alc882_3ST_6ch_modes,
9007 .need_dac_fix = 1,
9008 .input_mux = &alc882_capture_source,
9009 .unsol_event = alc882_targa_unsol_event,
9010 .setup = alc882_targa_setup,
9011 .init_hook = alc882_targa_automute,
9012 },
9013 [ALC882_ASUS_A7J] = {
9014 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
9015 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9016 alc882_asus_a7j_verbs},
9017 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9018 .dac_nids = alc882_dac_nids,
9019 .dig_out_nid = ALC882_DIGOUT_NID,
9020 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9021 .adc_nids = alc882_adc_nids,
9022 .capsrc_nids = alc882_capsrc_nids,
9023 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9024 .channel_mode = alc882_3ST_6ch_modes,
9025 .need_dac_fix = 1,
9026 .input_mux = &alc882_capture_source,
9027 },
9028 [ALC882_ASUS_A7M] = {
9029 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
9030 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9031 alc882_eapd_verbs, alc880_gpio1_init_verbs,
9032 alc882_asus_a7m_verbs },
9033 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9034 .dac_nids = alc882_dac_nids,
9035 .dig_out_nid = ALC882_DIGOUT_NID,
9036 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9037 .channel_mode = alc880_threestack_modes,
9038 .need_dac_fix = 1,
9039 .input_mux = &alc882_capture_source,
9040 },
9186 [ALC883_3ST_2ch_DIG] = { 9041 [ALC883_3ST_2ch_DIG] = {
9187 .mixers = { alc883_3ST_2ch_mixer }, 9042 .mixers = { alc883_3ST_2ch_mixer },
9188 .init_verbs = { alc883_init_verbs }, 9043 .init_verbs = { alc883_init_verbs },
@@ -9229,6 +9084,46 @@ static struct alc_config_preset alc883_presets[] = {
9229 .need_dac_fix = 1, 9084 .need_dac_fix = 1,
9230 .input_mux = &alc883_3stack_6ch_intel, 9085 .input_mux = &alc883_3stack_6ch_intel,
9231 }, 9086 },
9087 [ALC889A_INTEL] = {
9088 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9089 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9090 alc_hp15_unsol_verbs },
9091 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9092 .dac_nids = alc883_dac_nids,
9093 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9094 .adc_nids = alc889_adc_nids,
9095 .dig_out_nid = ALC883_DIGOUT_NID,
9096 .dig_in_nid = ALC883_DIGIN_NID,
9097 .slave_dig_outs = alc883_slave_dig_outs,
9098 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9099 .channel_mode = alc889_8ch_intel_modes,
9100 .capsrc_nids = alc889_capsrc_nids,
9101 .input_mux = &alc889_capture_source,
9102 .setup = alc889_automute_setup,
9103 .init_hook = alc_automute_amp,
9104 .unsol_event = alc_automute_amp_unsol_event,
9105 .need_dac_fix = 1,
9106 },
9107 [ALC889_INTEL] = {
9108 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9109 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
9110 alc889_eapd_verbs, alc_hp15_unsol_verbs},
9111 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9112 .dac_nids = alc883_dac_nids,
9113 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9114 .adc_nids = alc889_adc_nids,
9115 .dig_out_nid = ALC883_DIGOUT_NID,
9116 .dig_in_nid = ALC883_DIGIN_NID,
9117 .slave_dig_outs = alc883_slave_dig_outs,
9118 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9119 .channel_mode = alc889_8ch_intel_modes,
9120 .capsrc_nids = alc889_capsrc_nids,
9121 .input_mux = &alc889_capture_source,
9122 .setup = alc889_automute_setup,
9123 .init_hook = alc889_intel_init_hook,
9124 .unsol_event = alc_automute_amp_unsol_event,
9125 .need_dac_fix = 1,
9126 },
9232 [ALC883_6ST_DIG] = { 9127 [ALC883_6ST_DIG] = {
9233 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9128 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9234 .init_verbs = { alc883_init_verbs }, 9129 .init_verbs = { alc883_init_verbs },
@@ -9252,7 +9147,8 @@ static struct alc_config_preset alc883_presets[] = {
9252 .need_dac_fix = 1, 9147 .need_dac_fix = 1,
9253 .input_mux = &alc883_capture_source, 9148 .input_mux = &alc883_capture_source,
9254 .unsol_event = alc883_targa_unsol_event, 9149 .unsol_event = alc883_targa_unsol_event,
9255 .init_hook = alc883_targa_init_hook, 9150 .setup = alc882_targa_setup,
9151 .init_hook = alc882_targa_automute,
9256 }, 9152 },
9257 [ALC883_TARGA_2ch_DIG] = { 9153 [ALC883_TARGA_2ch_DIG] = {
9258 .mixers = { alc883_targa_2ch_mixer}, 9154 .mixers = { alc883_targa_2ch_mixer},
@@ -9267,7 +9163,8 @@ static struct alc_config_preset alc883_presets[] = {
9267 .channel_mode = alc883_3ST_2ch_modes, 9163 .channel_mode = alc883_3ST_2ch_modes,
9268 .input_mux = &alc883_capture_source, 9164 .input_mux = &alc883_capture_source,
9269 .unsol_event = alc883_targa_unsol_event, 9165 .unsol_event = alc883_targa_unsol_event,
9270 .init_hook = alc883_targa_init_hook, 9166 .setup = alc882_targa_setup,
9167 .init_hook = alc882_targa_automute,
9271 }, 9168 },
9272 [ALC883_TARGA_8ch_DIG] = { 9169 [ALC883_TARGA_8ch_DIG] = {
9273 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9170 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
@@ -9285,7 +9182,8 @@ static struct alc_config_preset alc883_presets[] = {
9285 .need_dac_fix = 1, 9182 .need_dac_fix = 1,
9286 .input_mux = &alc883_capture_source, 9183 .input_mux = &alc883_capture_source,
9287 .unsol_event = alc883_targa_unsol_event, 9184 .unsol_event = alc883_targa_unsol_event,
9288 .init_hook = alc883_targa_init_hook, 9185 .setup = alc882_targa_setup,
9186 .init_hook = alc882_targa_automute,
9289 }, 9187 },
9290 [ALC883_ACER] = { 9188 [ALC883_ACER] = {
9291 .mixers = { alc883_base_mixer }, 9189 .mixers = { alc883_base_mixer },
@@ -9311,7 +9209,8 @@ static struct alc_config_preset alc883_presets[] = {
9311 .channel_mode = alc883_3ST_2ch_modes, 9209 .channel_mode = alc883_3ST_2ch_modes,
9312 .input_mux = &alc883_capture_source, 9210 .input_mux = &alc883_capture_source,
9313 .unsol_event = alc_automute_amp_unsol_event, 9211 .unsol_event = alc_automute_amp_unsol_event,
9314 .init_hook = alc883_acer_aspire_init_hook, 9212 .setup = alc883_acer_aspire_setup,
9213 .init_hook = alc_automute_amp,
9315 }, 9214 },
9316 [ALC888_ACER_ASPIRE_4930G] = { 9215 [ALC888_ACER_ASPIRE_4930G] = {
9317 .mixers = { alc888_base_mixer, 9216 .mixers = { alc888_base_mixer,
@@ -9331,7 +9230,8 @@ static struct alc_config_preset alc883_presets[] = {
9331 ARRAY_SIZE(alc888_2_capture_sources), 9230 ARRAY_SIZE(alc888_2_capture_sources),
9332 .input_mux = alc888_2_capture_sources, 9231 .input_mux = alc888_2_capture_sources,
9333 .unsol_event = alc_automute_amp_unsol_event, 9232 .unsol_event = alc_automute_amp_unsol_event,
9334 .init_hook = alc888_acer_aspire_4930g_init_hook, 9233 .setup = alc888_acer_aspire_4930g_setup,
9234 .init_hook = alc_automute_amp,
9335 }, 9235 },
9336 [ALC888_ACER_ASPIRE_6530G] = { 9236 [ALC888_ACER_ASPIRE_6530G] = {
9337 .mixers = { alc888_acer_aspire_6530_mixer }, 9237 .mixers = { alc888_acer_aspire_6530_mixer },
@@ -9349,7 +9249,8 @@ static struct alc_config_preset alc883_presets[] = {
9349 ARRAY_SIZE(alc888_2_capture_sources), 9249 ARRAY_SIZE(alc888_2_capture_sources),
9350 .input_mux = alc888_acer_aspire_6530_sources, 9250 .input_mux = alc888_acer_aspire_6530_sources,
9351 .unsol_event = alc_automute_amp_unsol_event, 9251 .unsol_event = alc_automute_amp_unsol_event,
9352 .init_hook = alc888_acer_aspire_6530g_init_hook, 9252 .setup = alc888_acer_aspire_6530g_setup,
9253 .init_hook = alc_automute_amp,
9353 }, 9254 },
9354 [ALC888_ACER_ASPIRE_8930G] = { 9255 [ALC888_ACER_ASPIRE_8930G] = {
9355 .mixers = { alc888_base_mixer, 9256 .mixers = { alc888_base_mixer,
@@ -9370,7 +9271,28 @@ static struct alc_config_preset alc883_presets[] = {
9370 ARRAY_SIZE(alc889_capture_sources), 9271 ARRAY_SIZE(alc889_capture_sources),
9371 .input_mux = alc889_capture_sources, 9272 .input_mux = alc889_capture_sources,
9372 .unsol_event = alc_automute_amp_unsol_event, 9273 .unsol_event = alc_automute_amp_unsol_event,
9373 .init_hook = alc889_acer_aspire_8930g_init_hook, 9274 .setup = alc889_acer_aspire_8930g_setup,
9275 .init_hook = alc_automute_amp,
9276 },
9277 [ALC888_ACER_ASPIRE_7730G] = {
9278 .mixers = { alc883_3ST_6ch_mixer,
9279 alc883_chmode_mixer },
9280 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9281 alc888_acer_aspire_7730G_verbs },
9282 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9283 .dac_nids = alc883_dac_nids,
9284 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9285 .adc_nids = alc883_adc_nids_rev,
9286 .capsrc_nids = alc883_capsrc_nids_rev,
9287 .dig_out_nid = ALC883_DIGOUT_NID,
9288 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9289 .channel_mode = alc883_3ST_6ch_modes,
9290 .need_dac_fix = 1,
9291 .const_channel_count = 6,
9292 .input_mux = &alc883_capture_source,
9293 .unsol_event = alc_automute_amp_unsol_event,
9294 .setup = alc888_acer_aspire_6530g_setup,
9295 .init_hook = alc_automute_amp,
9374 }, 9296 },
9375 [ALC883_MEDION] = { 9297 [ALC883_MEDION] = {
9376 .mixers = { alc883_fivestack_mixer, 9298 .mixers = { alc883_fivestack_mixer,
@@ -9395,7 +9317,8 @@ static struct alc_config_preset alc883_presets[] = {
9395 .channel_mode = alc883_3ST_2ch_modes, 9317 .channel_mode = alc883_3ST_2ch_modes,
9396 .input_mux = &alc883_capture_source, 9318 .input_mux = &alc883_capture_source,
9397 .unsol_event = alc_automute_amp_unsol_event, 9319 .unsol_event = alc_automute_amp_unsol_event,
9398 .init_hook = alc883_medion_md2_init_hook, 9320 .setup = alc883_medion_md2_setup,
9321 .init_hook = alc_automute_amp,
9399 }, 9322 },
9400 [ALC883_LAPTOP_EAPD] = { 9323 [ALC883_LAPTOP_EAPD] = {
9401 .mixers = { alc883_base_mixer }, 9324 .mixers = { alc883_base_mixer },
@@ -9406,6 +9329,21 @@ static struct alc_config_preset alc883_presets[] = {
9406 .channel_mode = alc883_3ST_2ch_modes, 9329 .channel_mode = alc883_3ST_2ch_modes,
9407 .input_mux = &alc883_capture_source, 9330 .input_mux = &alc883_capture_source,
9408 }, 9331 },
9332 [ALC883_CLEVO_M540R] = {
9333 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9334 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9335 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9336 .dac_nids = alc883_dac_nids,
9337 .dig_out_nid = ALC883_DIGOUT_NID,
9338 .dig_in_nid = ALC883_DIGIN_NID,
9339 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9340 .channel_mode = alc883_3ST_6ch_clevo_modes,
9341 .need_dac_fix = 1,
9342 .input_mux = &alc883_capture_source,
9343 /* This machine has the hardware HP auto-muting, thus
9344 * we need no software mute via unsol event
9345 */
9346 },
9409 [ALC883_CLEVO_M720] = { 9347 [ALC883_CLEVO_M720] = {
9410 .mixers = { alc883_clevo_m720_mixer }, 9348 .mixers = { alc883_clevo_m720_mixer },
9411 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, 9349 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
@@ -9416,6 +9354,7 @@ static struct alc_config_preset alc883_presets[] = {
9416 .channel_mode = alc883_3ST_2ch_modes, 9354 .channel_mode = alc883_3ST_2ch_modes,
9417 .input_mux = &alc883_capture_source, 9355 .input_mux = &alc883_capture_source,
9418 .unsol_event = alc883_clevo_m720_unsol_event, 9356 .unsol_event = alc883_clevo_m720_unsol_event,
9357 .setup = alc883_clevo_m720_setup,
9419 .init_hook = alc883_clevo_m720_init_hook, 9358 .init_hook = alc883_clevo_m720_init_hook,
9420 }, 9359 },
9421 [ALC883_LENOVO_101E_2ch] = { 9360 [ALC883_LENOVO_101E_2ch] = {
@@ -9441,7 +9380,8 @@ static struct alc_config_preset alc883_presets[] = {
9441 .need_dac_fix = 1, 9380 .need_dac_fix = 1,
9442 .input_mux = &alc883_lenovo_nb0763_capture_source, 9381 .input_mux = &alc883_lenovo_nb0763_capture_source,
9443 .unsol_event = alc_automute_amp_unsol_event, 9382 .unsol_event = alc_automute_amp_unsol_event,
9444 .init_hook = alc883_medion_md2_init_hook, 9383 .setup = alc883_medion_md2_setup,
9384 .init_hook = alc_automute_amp,
9445 }, 9385 },
9446 [ALC888_LENOVO_MS7195_DIG] = { 9386 [ALC888_LENOVO_MS7195_DIG] = {
9447 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9387 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9466,7 +9406,8 @@ static struct alc_config_preset alc883_presets[] = {
9466 .channel_mode = alc883_3ST_2ch_modes, 9406 .channel_mode = alc883_3ST_2ch_modes,
9467 .input_mux = &alc883_capture_source, 9407 .input_mux = &alc883_capture_source,
9468 .unsol_event = alc_automute_amp_unsol_event, 9408 .unsol_event = alc_automute_amp_unsol_event,
9469 .init_hook = alc883_haier_w66_init_hook, 9409 .setup = alc883_haier_w66_setup,
9410 .init_hook = alc_automute_amp,
9470 }, 9411 },
9471 [ALC888_3ST_HP] = { 9412 [ALC888_3ST_HP] = {
9472 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9413 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9478,7 +9419,8 @@ static struct alc_config_preset alc883_presets[] = {
9478 .need_dac_fix = 1, 9419 .need_dac_fix = 1,
9479 .input_mux = &alc883_capture_source, 9420 .input_mux = &alc883_capture_source,
9480 .unsol_event = alc_automute_amp_unsol_event, 9421 .unsol_event = alc_automute_amp_unsol_event,
9481 .init_hook = alc888_3st_hp_init_hook, 9422 .setup = alc888_3st_hp_setup,
9423 .init_hook = alc_automute_amp,
9482 }, 9424 },
9483 [ALC888_6ST_DELL] = { 9425 [ALC888_6ST_DELL] = {
9484 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9426 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
@@ -9491,7 +9433,8 @@ static struct alc_config_preset alc883_presets[] = {
9491 .channel_mode = alc883_sixstack_modes, 9433 .channel_mode = alc883_sixstack_modes,
9492 .input_mux = &alc883_capture_source, 9434 .input_mux = &alc883_capture_source,
9493 .unsol_event = alc_automute_amp_unsol_event, 9435 .unsol_event = alc_automute_amp_unsol_event,
9494 .init_hook = alc888_6st_dell_init_hook, 9436 .setup = alc888_6st_dell_setup,
9437 .init_hook = alc_automute_amp,
9495 }, 9438 },
9496 [ALC883_MITAC] = { 9439 [ALC883_MITAC] = {
9497 .mixers = { alc883_mitac_mixer }, 9440 .mixers = { alc883_mitac_mixer },
@@ -9502,7 +9445,8 @@ static struct alc_config_preset alc883_presets[] = {
9502 .channel_mode = alc883_3ST_2ch_modes, 9445 .channel_mode = alc883_3ST_2ch_modes,
9503 .input_mux = &alc883_capture_source, 9446 .input_mux = &alc883_capture_source,
9504 .unsol_event = alc_automute_amp_unsol_event, 9447 .unsol_event = alc_automute_amp_unsol_event,
9505 .init_hook = alc883_mitac_init_hook, 9448 .setup = alc883_mitac_setup,
9449 .init_hook = alc_automute_amp,
9506 }, 9450 },
9507 [ALC883_FUJITSU_PI2515] = { 9451 [ALC883_FUJITSU_PI2515] = {
9508 .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, 9452 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
@@ -9515,7 +9459,8 @@ static struct alc_config_preset alc883_presets[] = {
9515 .channel_mode = alc883_3ST_2ch_modes, 9459 .channel_mode = alc883_3ST_2ch_modes,
9516 .input_mux = &alc883_fujitsu_pi2515_capture_source, 9460 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9517 .unsol_event = alc_automute_amp_unsol_event, 9461 .unsol_event = alc_automute_amp_unsol_event,
9518 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook, 9462 .setup = alc883_2ch_fujitsu_pi2515_setup,
9463 .init_hook = alc_automute_amp,
9519 }, 9464 },
9520 [ALC888_FUJITSU_XA3530] = { 9465 [ALC888_FUJITSU_XA3530] = {
9521 .mixers = { alc888_base_mixer, alc883_chmode_mixer }, 9466 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
@@ -9533,7 +9478,8 @@ static struct alc_config_preset alc883_presets[] = {
9533 ARRAY_SIZE(alc888_2_capture_sources), 9478 ARRAY_SIZE(alc888_2_capture_sources),
9534 .input_mux = alc888_2_capture_sources, 9479 .input_mux = alc888_2_capture_sources,
9535 .unsol_event = alc_automute_amp_unsol_event, 9480 .unsol_event = alc_automute_amp_unsol_event,
9536 .init_hook = alc888_fujitsu_xa3530_init_hook, 9481 .setup = alc888_fujitsu_xa3530_setup,
9482 .init_hook = alc_automute_amp,
9537 }, 9483 },
9538 [ALC888_LENOVO_SKY] = { 9484 [ALC888_LENOVO_SKY] = {
9539 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, 9485 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
@@ -9546,7 +9492,8 @@ static struct alc_config_preset alc883_presets[] = {
9546 .need_dac_fix = 1, 9492 .need_dac_fix = 1,
9547 .input_mux = &alc883_lenovo_sky_capture_source, 9493 .input_mux = &alc883_lenovo_sky_capture_source,
9548 .unsol_event = alc_automute_amp_unsol_event, 9494 .unsol_event = alc_automute_amp_unsol_event,
9549 .init_hook = alc888_lenovo_sky_init_hook, 9495 .setup = alc888_lenovo_sky_setup,
9496 .init_hook = alc_automute_amp,
9550 }, 9497 },
9551 [ALC888_ASUS_M90V] = { 9498 [ALC888_ASUS_M90V] = {
9552 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9499 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9559,8 +9506,9 @@ static struct alc_config_preset alc883_presets[] = {
9559 .channel_mode = alc883_3ST_6ch_modes, 9506 .channel_mode = alc883_3ST_6ch_modes,
9560 .need_dac_fix = 1, 9507 .need_dac_fix = 1,
9561 .input_mux = &alc883_fujitsu_pi2515_capture_source, 9508 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9562 .unsol_event = alc883_mode2_unsol_event, 9509 .unsol_event = alc_sku_unsol_event,
9563 .init_hook = alc883_mode2_inithook, 9510 .setup = alc883_mode2_setup,
9511 .init_hook = alc_inithook,
9564 }, 9512 },
9565 [ALC888_ASUS_EEE1601] = { 9513 [ALC888_ASUS_EEE1601] = {
9566 .mixers = { alc883_asus_eee1601_mixer }, 9514 .mixers = { alc883_asus_eee1601_mixer },
@@ -9613,15 +9561,45 @@ static struct alc_config_preset alc883_presets[] = {
9613 .channel_mode = alc883_3ST_2ch_modes, 9561 .channel_mode = alc883_3ST_2ch_modes,
9614 .input_mux = &alc883_capture_source, 9562 .input_mux = &alc883_capture_source,
9615 .unsol_event = alc_automute_amp_unsol_event, 9563 .unsol_event = alc_automute_amp_unsol_event,
9616 .init_hook = alc883_vaiott_init_hook, 9564 .setup = alc883_vaiott_setup,
9565 .init_hook = alc_automute_amp,
9617 }, 9566 },
9618}; 9567};
9619 9568
9620 9569
9621/* 9570/*
9571 * Pin config fixes
9572 */
9573enum {
9574 PINFIX_ABIT_AW9D_MAX
9575};
9576
9577static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9578 { 0x15, 0x01080104 }, /* side */
9579 { 0x16, 0x01011012 }, /* rear */
9580 { 0x17, 0x01016011 }, /* clfe */
9581 { }
9582};
9583
9584static const struct alc_pincfg *alc882_pin_fixes[] = {
9585 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9586};
9587
9588static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9589 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9590 {}
9591};
9592
9593/*
9622 * BIOS auto configuration 9594 * BIOS auto configuration
9623 */ 9595 */
9624static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, 9596static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9597 const struct auto_pin_cfg *cfg)
9598{
9599 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9600}
9601
9602static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
9625 hda_nid_t nid, int pin_type, 9603 hda_nid_t nid, int pin_type,
9626 int dac_idx) 9604 int dac_idx)
9627{ 9605{
@@ -9638,7 +9616,7 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9638 9616
9639} 9617}
9640 9618
9641static void alc883_auto_init_multi_out(struct hda_codec *codec) 9619static void alc882_auto_init_multi_out(struct hda_codec *codec)
9642{ 9620{
9643 struct alc_spec *spec = codec->spec; 9621 struct alc_spec *spec = codec->spec;
9644 int i; 9622 int i;
@@ -9647,12 +9625,12 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
9647 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 9625 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9648 int pin_type = get_pin_type(spec->autocfg.line_out_type); 9626 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9649 if (nid) 9627 if (nid)
9650 alc883_auto_set_output_and_unmute(codec, nid, pin_type, 9628 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
9651 i); 9629 i);
9652 } 9630 }
9653} 9631}
9654 9632
9655static void alc883_auto_init_hp_out(struct hda_codec *codec) 9633static void alc882_auto_init_hp_out(struct hda_codec *codec)
9656{ 9634{
9657 struct alc_spec *spec = codec->spec; 9635 struct alc_spec *spec = codec->spec;
9658 hda_nid_t pin; 9636 hda_nid_t pin;
@@ -9660,91 +9638,191 @@ static void alc883_auto_init_hp_out(struct hda_codec *codec)
9660 pin = spec->autocfg.hp_pins[0]; 9638 pin = spec->autocfg.hp_pins[0];
9661 if (pin) /* connect to front */ 9639 if (pin) /* connect to front */
9662 /* use dac 0 */ 9640 /* use dac 0 */
9663 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 9641 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9664 pin = spec->autocfg.speaker_pins[0]; 9642 pin = spec->autocfg.speaker_pins[0];
9665 if (pin) 9643 if (pin)
9666 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 9644 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9667} 9645}
9668 9646
9669#define alc883_is_input_pin(nid) alc880_is_input_pin(nid) 9647static 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{ 9648{
9674 struct alc_spec *spec = codec->spec; 9649 struct alc_spec *spec = codec->spec;
9675 int i; 9650 int i;
9676 9651
9677 for (i = 0; i < AUTO_PIN_LAST; i++) { 9652 for (i = 0; i < AUTO_PIN_LAST; i++) {
9678 hda_nid_t nid = spec->autocfg.input_pins[i]; 9653 hda_nid_t nid = spec->autocfg.input_pins[i];
9679 if (alc883_is_input_pin(nid)) { 9654 if (!nid)
9680 alc_set_input_pin(codec, nid, i); 9655 continue;
9681 if (nid != ALC883_PIN_CD_NID && 9656 alc_set_input_pin(codec, nid, i);
9682 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 9657 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9658 snd_hda_codec_write(codec, nid, 0,
9659 AC_VERB_SET_AMP_GAIN_MUTE,
9660 AMP_OUT_MUTE);
9661 }
9662}
9663
9664static void alc882_auto_init_input_src(struct hda_codec *codec)
9665{
9666 struct alc_spec *spec = codec->spec;
9667 int c;
9668
9669 for (c = 0; c < spec->num_adc_nids; c++) {
9670 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9671 hda_nid_t nid = spec->capsrc_nids[c];
9672 unsigned int mux_idx;
9673 const struct hda_input_mux *imux;
9674 int conns, mute, idx, item;
9675
9676 conns = snd_hda_get_connections(codec, nid, conn_list,
9677 ARRAY_SIZE(conn_list));
9678 if (conns < 0)
9679 continue;
9680 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9681 imux = &spec->input_mux[mux_idx];
9682 for (idx = 0; idx < conns; idx++) {
9683 /* if the current connection is the selected one,
9684 * unmute it as default - otherwise mute it
9685 */
9686 mute = AMP_IN_MUTE(idx);
9687 for (item = 0; item < imux->num_items; item++) {
9688 if (imux->items[item].index == idx) {
9689 if (spec->cur_mux[c] == item)
9690 mute = AMP_IN_UNMUTE(idx);
9691 break;
9692 }
9693 }
9694 /* check if we have a selector or mixer
9695 * we could check for the widget type instead, but
9696 * just check for Amp-In presence (in case of mixer
9697 * without amp-in there is something wrong, this
9698 * function shouldn't be used or capsrc nid is wrong)
9699 */
9700 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
9683 snd_hda_codec_write(codec, nid, 0, 9701 snd_hda_codec_write(codec, nid, 0,
9684 AC_VERB_SET_AMP_GAIN_MUTE, 9702 AC_VERB_SET_AMP_GAIN_MUTE,
9685 AMP_OUT_MUTE); 9703 mute);
9704 else if (mute != AMP_IN_MUTE(idx))
9705 snd_hda_codec_write(codec, nid, 0,
9706 AC_VERB_SET_CONNECT_SEL,
9707 idx);
9686 } 9708 }
9687 } 9709 }
9688} 9710}
9689 9711
9690#define alc883_auto_init_input_src alc882_auto_init_input_src 9712/* add mic boosts if needed */
9713static int alc_auto_add_mic_boost(struct hda_codec *codec)
9714{
9715 struct alc_spec *spec = codec->spec;
9716 int err;
9717 hda_nid_t nid;
9718
9719 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9720 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9721 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9722 "Mic Boost",
9723 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9724 if (err < 0)
9725 return err;
9726 }
9727 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9728 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9729 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9730 "Front Mic Boost",
9731 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9732 if (err < 0)
9733 return err;
9734 }
9735 return 0;
9736}
9691 9737
9692/* almost identical with ALC880 parser... */ 9738/* almost identical with ALC880 parser... */
9693static int alc883_parse_auto_config(struct hda_codec *codec) 9739static int alc882_parse_auto_config(struct hda_codec *codec)
9694{ 9740{
9695 struct alc_spec *spec = codec->spec; 9741 struct alc_spec *spec = codec->spec;
9696 int err = alc880_parse_auto_config(codec); 9742 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9697 struct auto_pin_cfg *cfg = &spec->autocfg; 9743 int i, err;
9698 int i;
9699 9744
9745 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9746 alc882_ignore);
9700 if (err < 0) 9747 if (err < 0)
9701 return err; 9748 return err;
9702 else if (!err) 9749 if (!spec->autocfg.line_outs)
9703 return 0; /* no config found */ 9750 return 0; /* can't find valid BIOS pin config */
9704 9751
9705 err = alc_auto_add_mic_boost(codec); 9752 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9753 if (err < 0)
9754 return err;
9755 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9756 if (err < 0)
9757 return err;
9758 err = alc880_auto_create_extra_out(spec,
9759 spec->autocfg.speaker_pins[0],
9760 "Speaker");
9761 if (err < 0)
9762 return err;
9763 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9764 "Headphone");
9765 if (err < 0)
9766 return err;
9767 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9706 if (err < 0) 9768 if (err < 0)
9707 return err; 9769 return err;
9708 9770
9709 /* hack - override the init verbs */ 9771 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9710 spec->init_verbs[0] = alc883_auto_init_verbs;
9711 9772
9712 /* setup input_mux for ALC889 */ 9773 /* check multiple SPDIF-out (for recent codecs) */
9713 if (codec->vendor_id == 0x10ec0889) { 9774 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9714 /* digital-mic input pin is excluded in alc880_auto_create..() 9775 hda_nid_t dig_nid;
9715 * because it's under 0x18 9776 err = snd_hda_get_connections(codec,
9716 */ 9777 spec->autocfg.dig_out_pins[i],
9717 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || 9778 &dig_nid, 1);
9718 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { 9779 if (err < 0)
9719 struct hda_input_mux *imux = &spec->private_imux[0]; 9780 continue;
9720 for (i = 1; i < 3; i++) 9781 if (!i)
9721 memcpy(&spec->private_imux[i], 9782 spec->multiout.dig_out_nid = dig_nid;
9722 &spec->private_imux[0], 9783 else {
9723 sizeof(spec->private_imux[0])); 9784 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9724 imux->items[imux->num_items].label = "Int DMic"; 9785 spec->slave_dig_outs[i - 1] = dig_nid;
9725 imux->items[imux->num_items].index = 0x0b; 9786 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9726 imux->num_items++; 9787 break;
9727 spec->num_mux_defs = 3;
9728 spec->input_mux = spec->private_imux;
9729 } 9788 }
9730 } 9789 }
9790 if (spec->autocfg.dig_in_pin)
9791 spec->dig_in_nid = ALC880_DIGIN_NID;
9792
9793 if (spec->kctls.list)
9794 add_mixer(spec, spec->kctls.list);
9795
9796 add_verb(spec, alc883_auto_init_verbs);
9797 /* if ADC 0x07 is available, initialize it, too */
9798 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9799 add_verb(spec, alc882_adc1_init_verbs);
9800
9801 spec->num_mux_defs = 1;
9802 spec->input_mux = &spec->private_imux[0];
9803
9804 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
9805
9806 err = alc_auto_add_mic_boost(codec);
9807 if (err < 0)
9808 return err;
9731 9809
9732 return 1; /* config found */ 9810 return 1; /* config found */
9733} 9811}
9734 9812
9735/* additional initialization for auto-configuration model */ 9813/* additional initialization for auto-configuration model */
9736static void alc883_auto_init(struct hda_codec *codec) 9814static void alc882_auto_init(struct hda_codec *codec)
9737{ 9815{
9738 struct alc_spec *spec = codec->spec; 9816 struct alc_spec *spec = codec->spec;
9739 alc883_auto_init_multi_out(codec); 9817 alc882_auto_init_multi_out(codec);
9740 alc883_auto_init_hp_out(codec); 9818 alc882_auto_init_hp_out(codec);
9741 alc883_auto_init_analog_input(codec); 9819 alc882_auto_init_analog_input(codec);
9742 alc883_auto_init_input_src(codec); 9820 alc882_auto_init_input_src(codec);
9743 if (spec->unsol_event) 9821 if (spec->unsol_event)
9744 alc_inithook(codec); 9822 alc_inithook(codec);
9745} 9823}
9746 9824
9747static int patch_alc883(struct hda_codec *codec) 9825static int patch_alc882(struct hda_codec *codec)
9748{ 9826{
9749 struct alc_spec *spec; 9827 struct alc_spec *spec;
9750 int err, board_config; 9828 int err, board_config;
@@ -9755,28 +9833,35 @@ static int patch_alc883(struct hda_codec *codec)
9755 9833
9756 codec->spec = spec; 9834 codec->spec = spec;
9757 9835
9758 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 9836 switch (codec->vendor_id) {
9837 case 0x10ec0882:
9838 case 0x10ec0885:
9839 break;
9840 default:
9841 /* ALC883 and variants */
9842 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9843 break;
9844 }
9759 9845
9760 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, 9846 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9761 alc883_models, 9847 alc882_models,
9762 alc883_cfg_tbl); 9848 alc882_cfg_tbl);
9763 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) { 9849
9764 /* Pick up systems that don't supply PCI SSID */ 9850 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9765 switch (codec->subsystem_id) { 9851 board_config = snd_hda_check_board_codec_sid_config(codec,
9766 case 0x106b3600: /* Macbook 3.1 */ 9852 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9767 board_config = ALC889A_MB31; 9853
9768 break; 9854 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
9769 default: 9855 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
9770 printk(KERN_INFO 9856 codec->chip_name);
9771 "hda_codec: Unknown model for %s, trying " 9857 board_config = ALC882_AUTO;
9772 "auto-probe from BIOS...\n", codec->chip_name);
9773 board_config = ALC883_AUTO;
9774 }
9775 } 9858 }
9776 9859
9777 if (board_config == ALC883_AUTO) { 9860 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9861
9862 if (board_config == ALC882_AUTO) {
9778 /* automatic parse from the BIOS config */ 9863 /* automatic parse from the BIOS config */
9779 err = alc883_parse_auto_config(codec); 9864 err = alc882_parse_auto_config(codec);
9780 if (err < 0) { 9865 if (err < 0) {
9781 alc_free(codec); 9866 alc_free(codec);
9782 return err; 9867 return err;
@@ -9784,7 +9869,7 @@ static int patch_alc883(struct hda_codec *codec)
9784 printk(KERN_INFO 9869 printk(KERN_INFO
9785 "hda_codec: Cannot set up configuration " 9870 "hda_codec: Cannot set up configuration "
9786 "from BIOS. Using base mode...\n"); 9871 "from BIOS. Using base mode...\n");
9787 board_config = ALC883_3ST_2ch_DIG; 9872 board_config = ALC882_3ST_DIG;
9788 } 9873 }
9789 } 9874 }
9790 9875
@@ -9794,63 +9879,61 @@ static int patch_alc883(struct hda_codec *codec)
9794 return err; 9879 return err;
9795 } 9880 }
9796 9881
9797 if (board_config != ALC883_AUTO) 9882 if (board_config != ALC882_AUTO)
9798 setup_preset(spec, &alc883_presets[board_config]); 9883 setup_preset(codec, &alc882_presets[board_config]);
9799 9884
9800 switch (codec->vendor_id) { 9885 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9801 case 0x10ec0888: 9886 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9802 if (!spec->num_adc_nids) { 9887 /* FIXME: setup DAC5 */
9803 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9888 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9804 spec->adc_nids = alc883_adc_nids; 9889 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9805 } 9890
9806 if (!spec->capsrc_nids) 9891 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9807 spec->capsrc_nids = alc883_capsrc_nids; 9892 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9893
9894 if (codec->vendor_id == 0x10ec0888)
9808 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ 9895 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
9809 break; 9896
9810 case 0x10ec0889: 9897 if (!spec->adc_nids && spec->input_mux) {
9811 if (!spec->num_adc_nids) { 9898 int i;
9812 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); 9899 spec->num_adc_nids = 0;
9813 spec->adc_nids = alc889_adc_nids; 9900 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9814 } 9901 hda_nid_t cap;
9815 if (!spec->capsrc_nids) 9902 hda_nid_t nid = alc882_adc_nids[i];
9816 spec->capsrc_nids = alc889_capsrc_nids; 9903 unsigned int wcap = get_wcaps(codec, nid);
9817 break; 9904 /* get type */
9818 default: 9905 wcap = get_wcaps_type(wcap);
9819 if (!spec->num_adc_nids) { 9906 if (wcap != AC_WID_AUD_IN)
9820 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9907 continue;
9821 spec->adc_nids = alc883_adc_nids; 9908 spec->private_adc_nids[spec->num_adc_nids] = nid;
9909 err = snd_hda_get_connections(codec, nid, &cap, 1);
9910 if (err < 0)
9911 continue;
9912 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9913 spec->num_adc_nids++;
9822 } 9914 }
9823 if (!spec->capsrc_nids) 9915 spec->adc_nids = spec->private_adc_nids;
9824 spec->capsrc_nids = alc883_capsrc_nids; 9916 spec->capsrc_nids = spec->private_capsrc_nids;
9825 break;
9826 } 9917 }
9827 9918
9828 spec->stream_analog_playback = &alc883_pcm_analog_playback; 9919 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); 9920 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9838 9921
9839 spec->vmaster_nid = 0x0c; 9922 spec->vmaster_nid = 0x0c;
9840 9923
9841 codec->patch_ops = alc_patch_ops; 9924 codec->patch_ops = alc_patch_ops;
9842 if (board_config == ALC883_AUTO) 9925 if (board_config == ALC882_AUTO)
9843 spec->init_hook = alc883_auto_init; 9926 spec->init_hook = alc882_auto_init;
9844
9845#ifdef CONFIG_SND_HDA_POWER_SAVE 9927#ifdef CONFIG_SND_HDA_POWER_SAVE
9846 if (!spec->loopback.amplist) 9928 if (!spec->loopback.amplist)
9847 spec->loopback.amplist = alc883_loopbacks; 9929 spec->loopback.amplist = alc882_loopbacks;
9848#endif 9930#endif
9849 codec->proc_widget_hook = print_realtek_coef; 9931 codec->proc_widget_hook = print_realtek_coef;
9850 9932
9851 return 0; 9933 return 0;
9852} 9934}
9853 9935
9936
9854/* 9937/*
9855 * ALC262 support 9938 * ALC262 support
9856 */ 9939 */
@@ -10026,13 +10109,12 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10026}; 10109};
10027 10110
10028/* mute/unmute internal speaker according to the hp jack and mute state */ 10111/* mute/unmute internal speaker according to the hp jack and mute state */
10029static void alc262_hp_t5735_init_hook(struct hda_codec *codec) 10112static void alc262_hp_t5735_setup(struct hda_codec *codec)
10030{ 10113{
10031 struct alc_spec *spec = codec->spec; 10114 struct alc_spec *spec = codec->spec;
10032 10115
10033 spec->autocfg.hp_pins[0] = 0x15; 10116 spec->autocfg.hp_pins[0] = 0x15;
10034 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ 10117 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10035 alc_automute_amp(codec);
10036} 10118}
10037 10119
10038static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { 10120static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
@@ -10189,22 +10271,20 @@ static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10189 alc262_hippo_automute(codec); 10271 alc262_hippo_automute(codec);
10190} 10272}
10191 10273
10192static void alc262_hippo_init_hook(struct hda_codec *codec) 10274static void alc262_hippo_setup(struct hda_codec *codec)
10193{ 10275{
10194 struct alc_spec *spec = codec->spec; 10276 struct alc_spec *spec = codec->spec;
10195 10277
10196 spec->autocfg.hp_pins[0] = 0x15; 10278 spec->autocfg.hp_pins[0] = 0x15;
10197 spec->autocfg.speaker_pins[0] = 0x14; 10279 spec->autocfg.speaker_pins[0] = 0x14;
10198 alc262_hippo_automute(codec);
10199} 10280}
10200 10281
10201static void alc262_hippo1_init_hook(struct hda_codec *codec) 10282static void alc262_hippo1_setup(struct hda_codec *codec)
10202{ 10283{
10203 struct alc_spec *spec = codec->spec; 10284 struct alc_spec *spec = codec->spec;
10204 10285
10205 spec->autocfg.hp_pins[0] = 0x1b; 10286 spec->autocfg.hp_pins[0] = 0x1b;
10206 spec->autocfg.speaker_pins[0] = 0x14; 10287 spec->autocfg.speaker_pins[0] = 0x14;
10207 alc262_hippo_automute(codec);
10208} 10288}
10209 10289
10210 10290
@@ -10261,13 +10341,12 @@ static struct hda_verb alc262_tyan_verbs[] = {
10261}; 10341};
10262 10342
10263/* unsolicited event for HP jack sensing */ 10343/* unsolicited event for HP jack sensing */
10264static void alc262_tyan_init_hook(struct hda_codec *codec) 10344static void alc262_tyan_setup(struct hda_codec *codec)
10265{ 10345{
10266 struct alc_spec *spec = codec->spec; 10346 struct alc_spec *spec = codec->spec;
10267 10347
10268 spec->autocfg.hp_pins[0] = 0x1b; 10348 spec->autocfg.hp_pins[0] = 0x1b;
10269 spec->autocfg.speaker_pins[0] = 0x15; 10349 spec->autocfg.speaker_pins[0] = 0x15;
10270 alc_automute_amp(codec);
10271} 10350}
10272 10351
10273 10352
@@ -10359,12 +10438,6 @@ static struct hda_verb alc262_eapd_verbs[] = {
10359 { } 10438 { }
10360}; 10439};
10361 10440
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[] = { 10441static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 10442 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10370 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 10443 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -10385,14 +10458,6 @@ static struct hda_verb alc262_sony_unsol_verbs[] = {
10385 {} 10458 {}
10386}; 10459};
10387 10460
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[] = { 10461static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10397 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 10462 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10398 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10463 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
@@ -10414,35 +10479,17 @@ static struct hda_verb alc262_toshiba_s06_verbs[] = {
10414 {} 10479 {}
10415}; 10480};
10416 10481
10417static void alc262_dmic_automute(struct hda_codec *codec) 10482static 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{ 10483{
10440 struct alc_spec *spec = codec->spec; 10484 struct alc_spec *spec = codec->spec;
10441 10485
10442 spec->autocfg.hp_pins[0] = 0x15; 10486 spec->autocfg.hp_pins[0] = 0x15;
10443 spec->autocfg.speaker_pins[0] = 0x14; 10487 spec->autocfg.speaker_pins[0] = 0x14;
10444 alc_automute_pin(codec); 10488 spec->ext_mic.pin = 0x18;
10445 alc262_dmic_automute(codec); 10489 spec->ext_mic.mux_idx = 0;
10490 spec->int_mic.pin = 0x12;
10491 spec->int_mic.mux_idx = 9;
10492 spec->auto_mic = 1;
10446} 10493}
10447 10494
10448/* 10495/*
@@ -10860,104 +10907,111 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10860 { } /* end */ 10907 { } /* end */
10861}; 10908};
10862 10909
10910/* We use two mixers depending on the output pin; 0x16 is a mono output
10911 * and thus it's bound with a different mixer.
10912 * This function returns which mixer amp should be used.
10913 */
10914static int alc262_check_volbit(hda_nid_t nid)
10915{
10916 if (!nid)
10917 return 0;
10918 else if (nid == 0x16)
10919 return 2;
10920 else
10921 return 1;
10922}
10923
10924static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10925 const char *pfx, int *vbits)
10926{
10927 char name[32];
10928 unsigned long val;
10929 int vbit;
10930
10931 vbit = alc262_check_volbit(nid);
10932 if (!vbit)
10933 return 0;
10934 if (*vbits & vbit) /* a volume control for this mixer already there */
10935 return 0;
10936 *vbits |= vbit;
10937 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10938 if (vbit == 2)
10939 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10940 else
10941 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10942 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10943}
10944
10945static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10946 const char *pfx)
10947{
10948 char name[32];
10949 unsigned long val;
10950
10951 if (!nid)
10952 return 0;
10953 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10954 if (nid == 0x16)
10955 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10956 else
10957 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10958 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10959}
10960
10863/* add playback controls from the parsed DAC table */ 10961/* add playback controls from the parsed DAC table */
10864static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, 10962static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10865 const struct auto_pin_cfg *cfg) 10963 const struct auto_pin_cfg *cfg)
10866{ 10964{
10867 hda_nid_t nid; 10965 const char *pfx;
10966 int vbits;
10868 int err; 10967 int err;
10869 10968
10870 spec->multiout.num_dacs = 1; /* only use one dac */ 10969 spec->multiout.num_dacs = 1; /* only use one dac */
10871 spec->multiout.dac_nids = spec->private_dac_nids; 10970 spec->multiout.dac_nids = spec->private_dac_nids;
10872 spec->multiout.dac_nids[0] = 2; 10971 spec->multiout.dac_nids[0] = 2;
10873 10972
10874 nid = cfg->line_out_pins[0]; 10973 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
10875 if (nid) { 10974 pfx = "Master";
10876 err = add_control(spec, ALC_CTL_WIDGET_VOL, 10975 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10877 "Front Playback Volume", 10976 pfx = "Speaker";
10878 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); 10977 else
10879 if (err < 0) 10978 pfx = "Front";
10880 return err; 10979 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
10881 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 10980 if (err < 0)
10882 "Front Playback Switch", 10981 return err;
10883 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 10982 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
10884 if (err < 0) 10983 if (err < 0)
10885 return err; 10984 return err;
10886 } 10985 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
10887 10986 if (err < 0)
10888 nid = cfg->speaker_pins[0]; 10987 return err;
10889 if (nid) {
10890 if (nid == 0x16) {
10891 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10892 "Speaker Playback Volume",
10893 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10894 HDA_OUTPUT));
10895 if (err < 0)
10896 return err;
10897 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10898 "Speaker Playback Switch",
10899 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10900 HDA_OUTPUT));
10901 if (err < 0)
10902 return err;
10903 } else {
10904 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10905 "Speaker Playback Switch",
10906 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10907 HDA_OUTPUT));
10908 if (err < 0)
10909 return err;
10910 }
10911 }
10912 nid = cfg->hp_pins[0];
10913 if (nid) {
10914 /* spec->multiout.hp_nid = 2; */
10915 if (nid == 0x16) {
10916 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10917 "Headphone Playback Volume",
10918 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10919 HDA_OUTPUT));
10920 if (err < 0)
10921 return err;
10922 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10923 "Headphone Playback Switch",
10924 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10925 HDA_OUTPUT));
10926 if (err < 0)
10927 return err;
10928 } else {
10929 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10930 "Headphone Playback Switch",
10931 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10932 HDA_OUTPUT));
10933 if (err < 0)
10934 return err;
10935 }
10936 }
10937 return 0;
10938}
10939
10940static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10941 const struct auto_pin_cfg *cfg)
10942{
10943 int err;
10944 10988
10945 err = alc880_auto_create_analog_input_ctls(spec, cfg); 10989 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
10990 alc262_check_volbit(cfg->speaker_pins[0]) |
10991 alc262_check_volbit(cfg->hp_pins[0]);
10992 if (vbits == 1 || vbits == 2)
10993 pfx = "Master"; /* only one mixer is used */
10994 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10995 pfx = "Speaker";
10996 else
10997 pfx = "Front";
10998 vbits = 0;
10999 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11000 if (err < 0)
11001 return err;
11002 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11003 &vbits);
11004 if (err < 0)
11005 return err;
11006 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11007 &vbits);
10946 if (err < 0) 11008 if (err < 0)
10947 return err; 11009 return err;
10948 /* digital-mic input pin is excluded in alc880_auto_create..()
10949 * because it's under 0x18
10950 */
10951 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10952 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10953 struct hda_input_mux *imux = &spec->private_imux[0];
10954 imux->items[imux->num_items].label = "Int Mic";
10955 imux->items[imux->num_items].index = 0x09;
10956 imux->num_items++;
10957 }
10958 return 0; 11010 return 0;
10959} 11011}
10960 11012
11013#define alc262_auto_create_input_ctls \
11014 alc880_auto_create_input_ctls
10961 11015
10962/* 11016/*
10963 * generic initialization of ADC, input mixers and output mixers 11017 * generic initialization of ADC, input mixers and output mixers
@@ -11275,7 +11329,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
11275 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); 11329 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11276 if (err < 0) 11330 if (err < 0)
11277 return err; 11331 return err;
11278 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); 11332 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
11279 if (err < 0) 11333 if (err < 0)
11280 return err; 11334 return err;
11281 11335
@@ -11406,7 +11460,7 @@ static struct alc_config_preset alc262_presets[] = {
11406 }, 11460 },
11407 [ALC262_HIPPO] = { 11461 [ALC262_HIPPO] = {
11408 .mixers = { alc262_hippo_mixer }, 11462 .mixers = { alc262_hippo_mixer },
11409 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, 11463 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
11410 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 11464 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11411 .dac_nids = alc262_dac_nids, 11465 .dac_nids = alc262_dac_nids,
11412 .hp_nid = 0x03, 11466 .hp_nid = 0x03,
@@ -11415,7 +11469,8 @@ static struct alc_config_preset alc262_presets[] = {
11415 .channel_mode = alc262_modes, 11469 .channel_mode = alc262_modes,
11416 .input_mux = &alc262_capture_source, 11470 .input_mux = &alc262_capture_source,
11417 .unsol_event = alc262_hippo_unsol_event, 11471 .unsol_event = alc262_hippo_unsol_event,
11418 .init_hook = alc262_hippo_init_hook, 11472 .setup = alc262_hippo_setup,
11473 .init_hook = alc262_hippo_automute,
11419 }, 11474 },
11420 [ALC262_HIPPO_1] = { 11475 [ALC262_HIPPO_1] = {
11421 .mixers = { alc262_hippo1_mixer }, 11476 .mixers = { alc262_hippo1_mixer },
@@ -11428,7 +11483,8 @@ static struct alc_config_preset alc262_presets[] = {
11428 .channel_mode = alc262_modes, 11483 .channel_mode = alc262_modes,
11429 .input_mux = &alc262_capture_source, 11484 .input_mux = &alc262_capture_source,
11430 .unsol_event = alc262_hippo_unsol_event, 11485 .unsol_event = alc262_hippo_unsol_event,
11431 .init_hook = alc262_hippo1_init_hook, 11486 .setup = alc262_hippo1_setup,
11487 .init_hook = alc262_hippo_automute,
11432 }, 11488 },
11433 [ALC262_FUJITSU] = { 11489 [ALC262_FUJITSU] = {
11434 .mixers = { alc262_fujitsu_mixer }, 11490 .mixers = { alc262_fujitsu_mixer },
@@ -11491,7 +11547,8 @@ static struct alc_config_preset alc262_presets[] = {
11491 .channel_mode = alc262_modes, 11547 .channel_mode = alc262_modes,
11492 .input_mux = &alc262_capture_source, 11548 .input_mux = &alc262_capture_source,
11493 .unsol_event = alc_automute_amp_unsol_event, 11549 .unsol_event = alc_automute_amp_unsol_event,
11494 .init_hook = alc262_hp_t5735_init_hook, 11550 .setup = alc262_hp_t5735_setup,
11551 .init_hook = alc_automute_amp,
11495 }, 11552 },
11496 [ALC262_HP_RP5700] = { 11553 [ALC262_HP_RP5700] = {
11497 .mixers = { alc262_hp_rp5700_mixer }, 11554 .mixers = { alc262_hp_rp5700_mixer },
@@ -11522,11 +11579,13 @@ static struct alc_config_preset alc262_presets[] = {
11522 .channel_mode = alc262_modes, 11579 .channel_mode = alc262_modes,
11523 .input_mux = &alc262_capture_source, 11580 .input_mux = &alc262_capture_source,
11524 .unsol_event = alc262_hippo_unsol_event, 11581 .unsol_event = alc262_hippo_unsol_event,
11525 .init_hook = alc262_hippo_init_hook, 11582 .setup = alc262_hippo_setup,
11583 .init_hook = alc262_hippo_automute,
11526 }, 11584 },
11527 [ALC262_BENQ_T31] = { 11585 [ALC262_BENQ_T31] = {
11528 .mixers = { alc262_benq_t31_mixer }, 11586 .mixers = { alc262_benq_t31_mixer },
11529 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, 11587 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11588 alc_hp15_unsol_verbs },
11530 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 11589 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11531 .dac_nids = alc262_dac_nids, 11590 .dac_nids = alc262_dac_nids,
11532 .hp_nid = 0x03, 11591 .hp_nid = 0x03,
@@ -11534,7 +11593,8 @@ static struct alc_config_preset alc262_presets[] = {
11534 .channel_mode = alc262_modes, 11593 .channel_mode = alc262_modes,
11535 .input_mux = &alc262_capture_source, 11594 .input_mux = &alc262_capture_source,
11536 .unsol_event = alc262_hippo_unsol_event, 11595 .unsol_event = alc262_hippo_unsol_event,
11537 .init_hook = alc262_hippo_init_hook, 11596 .setup = alc262_hippo_setup,
11597 .init_hook = alc262_hippo_automute,
11538 }, 11598 },
11539 [ALC262_ULTRA] = { 11599 [ALC262_ULTRA] = {
11540 .mixers = { alc262_ultra_mixer }, 11600 .mixers = { alc262_ultra_mixer },
@@ -11586,9 +11646,9 @@ static struct alc_config_preset alc262_presets[] = {
11586 .dig_out_nid = ALC262_DIGOUT_NID, 11646 .dig_out_nid = ALC262_DIGOUT_NID,
11587 .num_channel_mode = ARRAY_SIZE(alc262_modes), 11647 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11588 .channel_mode = alc262_modes, 11648 .channel_mode = alc262_modes,
11589 .input_mux = &alc262_dmic_capture_source, 11649 .unsol_event = alc_sku_unsol_event,
11590 .unsol_event = alc262_toshiba_s06_unsol_event, 11650 .setup = alc262_toshiba_s06_setup,
11591 .init_hook = alc262_toshiba_s06_init_hook, 11651 .init_hook = alc_inithook,
11592 }, 11652 },
11593 [ALC262_TOSHIBA_RX1] = { 11653 [ALC262_TOSHIBA_RX1] = {
11594 .mixers = { alc262_toshiba_rx1_mixer }, 11654 .mixers = { alc262_toshiba_rx1_mixer },
@@ -11600,7 +11660,8 @@ static struct alc_config_preset alc262_presets[] = {
11600 .channel_mode = alc262_modes, 11660 .channel_mode = alc262_modes,
11601 .input_mux = &alc262_capture_source, 11661 .input_mux = &alc262_capture_source,
11602 .unsol_event = alc262_hippo_unsol_event, 11662 .unsol_event = alc262_hippo_unsol_event,
11603 .init_hook = alc262_hippo_init_hook, 11663 .setup = alc262_hippo_setup,
11664 .init_hook = alc262_hippo_automute,
11604 }, 11665 },
11605 [ALC262_TYAN] = { 11666 [ALC262_TYAN] = {
11606 .mixers = { alc262_tyan_mixer }, 11667 .mixers = { alc262_tyan_mixer },
@@ -11613,7 +11674,8 @@ static struct alc_config_preset alc262_presets[] = {
11613 .channel_mode = alc262_modes, 11674 .channel_mode = alc262_modes,
11614 .input_mux = &alc262_capture_source, 11675 .input_mux = &alc262_capture_source,
11615 .unsol_event = alc_automute_amp_unsol_event, 11676 .unsol_event = alc_automute_amp_unsol_event,
11616 .init_hook = alc262_tyan_init_hook, 11677 .setup = alc262_tyan_setup,
11678 .init_hook = alc_automute_amp,
11617 }, 11679 },
11618}; 11680};
11619 11681
@@ -11648,8 +11710,8 @@ static int patch_alc262(struct hda_codec *codec)
11648 alc262_cfg_tbl); 11710 alc262_cfg_tbl);
11649 11711
11650 if (board_config < 0) { 11712 if (board_config < 0) {
11651 printk(KERN_INFO "hda_codec: Unknown model for %s, " 11713 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11652 "trying auto-probe from BIOS...\n", codec->chip_name); 11714 codec->chip_name);
11653 board_config = ALC262_AUTO; 11715 board_config = ALC262_AUTO;
11654 } 11716 }
11655 11717
@@ -11676,7 +11738,7 @@ static int patch_alc262(struct hda_codec *codec)
11676 } 11738 }
11677 11739
11678 if (board_config != ALC262_AUTO) 11740 if (board_config != ALC262_AUTO)
11679 setup_preset(spec, &alc262_presets[board_config]); 11741 setup_preset(codec, &alc262_presets[board_config]);
11680 11742
11681 spec->stream_analog_playback = &alc262_pcm_analog_playback; 11743 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11682 spec->stream_analog_capture = &alc262_pcm_analog_capture; 11744 spec->stream_analog_capture = &alc262_pcm_analog_capture;
@@ -11702,7 +11764,7 @@ static int patch_alc262(struct hda_codec *codec)
11702 unsigned int wcap = get_wcaps(codec, 0x07); 11764 unsigned int wcap = get_wcaps(codec, 0x07);
11703 11765
11704 /* get type */ 11766 /* get type */
11705 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 11767 wcap = get_wcaps_type(wcap);
11706 if (wcap != AC_WID_AUD_IN) { 11768 if (wcap != AC_WID_AUD_IN) {
11707 spec->adc_nids = alc262_adc_nids_alt; 11769 spec->adc_nids = alc262_adc_nids_alt;
11708 spec->num_adc_nids = 11770 spec->num_adc_nids =
@@ -11717,7 +11779,7 @@ static int patch_alc262(struct hda_codec *codec)
11717 } 11779 }
11718 } 11780 }
11719 if (!spec->cap_mixer && !spec->no_analog) 11781 if (!spec->cap_mixer && !spec->no_analog)
11720 set_capture_mixer(spec); 11782 set_capture_mixer(codec);
11721 if (!spec->no_analog) 11783 if (!spec->no_analog)
11722 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 11784 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11723 11785
@@ -11809,14 +11871,6 @@ static struct hda_verb alc268_toshiba_verbs[] = {
11809 { } /* end */ 11871 { } /* end */
11810}; 11872};
11811 11873
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 */ 11874/* Acer specific */
11821/* bind volumes of both NID 0x02 and 0x03 */ 11875/* bind volumes of both NID 0x02 and 0x03 */
11822static struct hda_bind_ctls alc268_acer_bind_master_vol = { 11876static struct hda_bind_ctls alc268_acer_bind_master_vol = {
@@ -11935,7 +11989,8 @@ static struct hda_verb alc268_acer_verbs[] = {
11935 11989
11936/* unsolicited event for HP jack sensing */ 11990/* unsolicited event for HP jack sensing */
11937#define alc268_toshiba_unsol_event alc262_hippo_unsol_event 11991#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11938#define alc268_toshiba_init_hook alc262_hippo_init_hook 11992#define alc268_toshiba_setup alc262_hippo_setup
11993#define alc268_toshiba_automute alc262_hippo_automute
11939 11994
11940static void alc268_acer_unsol_event(struct hda_codec *codec, 11995static void alc268_acer_unsol_event(struct hda_codec *codec,
11941 unsigned int res) 11996 unsigned int res)
@@ -11965,30 +12020,33 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11965 AMP_IN_MUTE(0), bits); 12020 AMP_IN_MUTE(0), bits);
11966} 12021}
11967 12022
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, 12023static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11980 unsigned int res) 12024 unsigned int res)
11981{ 12025{
11982 if ((res >> 26) == ALC880_HP_EVENT) 12026 switch (res >> 26) {
12027 case ALC880_HP_EVENT:
11983 alc268_aspire_one_speaker_automute(codec); 12028 alc268_aspire_one_speaker_automute(codec);
11984 if ((res >> 26) == ALC880_MIC_EVENT) 12029 break;
11985 alc268_acer_mic_automute(codec); 12030 case ALC880_MIC_EVENT:
12031 alc_mic_automute(codec);
12032 break;
12033 }
12034}
12035
12036static void alc268_acer_lc_setup(struct hda_codec *codec)
12037{
12038 struct alc_spec *spec = codec->spec;
12039 spec->ext_mic.pin = 0x18;
12040 spec->ext_mic.mux_idx = 0;
12041 spec->int_mic.pin = 0x12;
12042 spec->int_mic.mux_idx = 6;
12043 spec->auto_mic = 1;
11986} 12044}
11987 12045
11988static void alc268_acer_lc_init_hook(struct hda_codec *codec) 12046static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11989{ 12047{
11990 alc268_aspire_one_speaker_automute(codec); 12048 alc268_aspire_one_speaker_automute(codec);
11991 alc268_acer_mic_automute(codec); 12049 alc_mic_automute(codec);
11992} 12050}
11993 12051
11994static struct snd_kcontrol_new alc268_dell_mixer[] = { 12052static struct snd_kcontrol_new alc268_dell_mixer[] = {
@@ -12006,17 +12064,22 @@ static struct hda_verb alc268_dell_verbs[] = {
12006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 12064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 12065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 12066 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12067 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12009 { } 12068 { }
12010}; 12069};
12011 12070
12012/* mute/unmute internal speaker according to the hp jack and mute state */ 12071/* mute/unmute internal speaker according to the hp jack and mute state */
12013static void alc268_dell_init_hook(struct hda_codec *codec) 12072static void alc268_dell_setup(struct hda_codec *codec)
12014{ 12073{
12015 struct alc_spec *spec = codec->spec; 12074 struct alc_spec *spec = codec->spec;
12016 12075
12017 spec->autocfg.hp_pins[0] = 0x15; 12076 spec->autocfg.hp_pins[0] = 0x15;
12018 spec->autocfg.speaker_pins[0] = 0x14; 12077 spec->autocfg.speaker_pins[0] = 0x14;
12019 alc_automute_pin(codec); 12078 spec->ext_mic.pin = 0x18;
12079 spec->ext_mic.mux_idx = 0;
12080 spec->int_mic.pin = 0x19;
12081 spec->int_mic.mux_idx = 1;
12082 spec->auto_mic = 1;
12020} 12083}
12021 12084
12022static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { 12085static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
@@ -12037,38 +12100,16 @@ static struct hda_verb alc267_quanta_il1_verbs[] = {
12037 { } 12100 { }
12038}; 12101};
12039 12102
12040static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) 12103static 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{ 12104{
12053 struct alc_spec *spec = codec->spec; 12105 struct alc_spec *spec = codec->spec;
12054
12055 spec->autocfg.hp_pins[0] = 0x15; 12106 spec->autocfg.hp_pins[0] = 0x15;
12056 spec->autocfg.speaker_pins[0] = 0x14; 12107 spec->autocfg.speaker_pins[0] = 0x14;
12057 alc_automute_pin(codec); 12108 spec->ext_mic.pin = 0x18;
12058 alc267_quanta_il1_mic_automute(codec); 12109 spec->ext_mic.mux_idx = 0;
12059} 12110 spec->int_mic.pin = 0x19;
12060 12111 spec->int_mic.mux_idx = 1;
12061static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, 12112 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} 12113}
12073 12114
12074/* 12115/*
@@ -12148,21 +12189,16 @@ static struct hda_verb alc268_volume_init_verbs[] = {
12148 { } 12189 { }
12149}; 12190};
12150 12191
12192static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12193 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12194 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12195 { } /* end */
12196};
12197
12151static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 12198static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12152 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 12199 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12153 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 12200 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12154 { 12201 _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 */ 12202 { } /* end */
12167}; 12203};
12168 12204
@@ -12171,18 +12207,7 @@ static struct snd_kcontrol_new alc268_capture_mixer[] = {
12171 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 12207 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12172 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), 12208 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12173 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), 12209 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12174 { 12210 _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 */ 12211 { } /* end */
12187}; 12212};
12188 12213
@@ -12269,26 +12294,38 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12269 const char *ctlname, int idx) 12294 const char *ctlname, int idx)
12270{ 12295{
12271 char name[32]; 12296 char name[32];
12297 hda_nid_t dac;
12272 int err; 12298 int err;
12273 12299
12274 sprintf(name, "%s Playback Volume", ctlname); 12300 sprintf(name, "%s Playback Volume", ctlname);
12275 if (nid == 0x14) { 12301 switch (nid) {
12276 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 12302 case 0x14:
12277 HDA_COMPOSE_AMP_VAL(0x02, 3, idx, 12303 case 0x16:
12278 HDA_OUTPUT)); 12304 dac = 0x02;
12279 if (err < 0) 12305 break;
12280 return err; 12306 case 0x15:
12281 } else if (nid == 0x15) { 12307 dac = 0x03;
12308 break;
12309 default:
12310 return 0;
12311 }
12312 if (spec->multiout.dac_nids[0] != dac &&
12313 spec->multiout.dac_nids[1] != dac) {
12282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 12314 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12283 HDA_COMPOSE_AMP_VAL(0x03, 3, idx, 12315 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
12284 HDA_OUTPUT)); 12316 HDA_OUTPUT));
12285 if (err < 0) 12317 if (err < 0)
12286 return err; 12318 return err;
12287 } else 12319 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12288 return -1; 12320 }
12321
12289 sprintf(name, "%s Playback Switch", ctlname); 12322 sprintf(name, "%s Playback Switch", ctlname);
12290 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 12323 if (nid != 0x16)
12324 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12291 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); 12325 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12326 else /* mono */
12327 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12328 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
12292 if (err < 0) 12329 if (err < 0)
12293 return err; 12330 return err;
12294 return 0; 12331 return 0;
@@ -12301,14 +12338,19 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12301 hda_nid_t nid; 12338 hda_nid_t nid;
12302 int err; 12339 int err;
12303 12340
12304 spec->multiout.num_dacs = 2; /* only use one dac */
12305 spec->multiout.dac_nids = spec->private_dac_nids; 12341 spec->multiout.dac_nids = spec->private_dac_nids;
12306 spec->multiout.dac_nids[0] = 2;
12307 spec->multiout.dac_nids[1] = 3;
12308 12342
12309 nid = cfg->line_out_pins[0]; 12343 nid = cfg->line_out_pins[0];
12310 if (nid) 12344 if (nid) {
12311 alc268_new_analog_output(spec, nid, "Front", 0); 12345 const char *name;
12346 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12347 name = "Speaker";
12348 else
12349 name = "Front";
12350 err = alc268_new_analog_output(spec, nid, name, 0);
12351 if (err < 0)
12352 return err;
12353 }
12312 12354
12313 nid = cfg->speaker_pins[0]; 12355 nid = cfg->speaker_pins[0];
12314 if (nid == 0x1d) { 12356 if (nid == 0x1d) {
@@ -12317,16 +12359,23 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12317 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 12359 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12318 if (err < 0) 12360 if (err < 0)
12319 return err; 12361 return err;
12362 } else {
12363 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12364 if (err < 0)
12365 return err;
12320 } 12366 }
12321 nid = cfg->hp_pins[0]; 12367 nid = cfg->hp_pins[0];
12322 if (nid) 12368 if (nid) {
12323 alc268_new_analog_output(spec, nid, "Headphone", 0); 12369 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12370 if (err < 0)
12371 return err;
12372 }
12324 12373
12325 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; 12374 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12326 if (nid == 0x16) { 12375 if (nid == 0x16) {
12327 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12376 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12328 "Mono Playback Switch", 12377 "Mono Playback Switch",
12329 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); 12378 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
12330 if (err < 0) 12379 if (err < 0)
12331 return err; 12380 return err;
12332 } 12381 }
@@ -12334,38 +12383,46 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12334} 12383}
12335 12384
12336/* create playback/capture controls for input pins */ 12385/* create playback/capture controls for input pins */
12337static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, 12386static int alc268_auto_create_input_ctls(struct hda_codec *codec,
12338 const struct auto_pin_cfg *cfg) 12387 const struct auto_pin_cfg *cfg)
12339{ 12388{
12340 struct hda_input_mux *imux = &spec->private_imux[0]; 12389 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
12341 int i, idx1; 12390}
12342 12391
12343 for (i = 0; i < AUTO_PIN_LAST; i++) { 12392static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12344 switch(cfg->input_pins[i]) { 12393 hda_nid_t nid, int pin_type)
12345 case 0x18: 12394{
12346 idx1 = 0; /* Mic 1 */ 12395 int idx;
12347 break; 12396
12348 case 0x19: 12397 alc_set_pin_output(codec, nid, pin_type);
12349 idx1 = 1; /* Mic 2 */ 12398 if (nid == 0x14 || nid == 0x16)
12350 break; 12399 idx = 0;
12351 case 0x1a: 12400 else
12352 idx1 = 2; /* Line In */ 12401 idx = 1;
12353 break; 12402 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12354 case 0x1c: 12403}
12355 idx1 = 3; /* CD */ 12404
12356 break; 12405static void alc268_auto_init_multi_out(struct hda_codec *codec)
12357 case 0x12: 12406{
12358 case 0x13: 12407 struct alc_spec *spec = codec->spec;
12359 idx1 = 6; /* digital mics */ 12408 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12360 break; 12409 if (nid) {
12361 default: 12410 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12362 continue; 12411 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12363 }
12364 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12365 imux->items[imux->num_items].index = idx1;
12366 imux->num_items++;
12367 } 12412 }
12368 return 0; 12413}
12414
12415static void alc268_auto_init_hp_out(struct hda_codec *codec)
12416{
12417 struct alc_spec *spec = codec->spec;
12418 hda_nid_t pin;
12419
12420 pin = spec->autocfg.hp_pins[0];
12421 if (pin)
12422 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12423 pin = spec->autocfg.speaker_pins[0];
12424 if (pin)
12425 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12369} 12426}
12370 12427
12371static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) 12428static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
@@ -12376,9 +12433,10 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12376 hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; 12433 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12377 unsigned int dac_vol1, dac_vol2; 12434 unsigned int dac_vol1, dac_vol2;
12378 12435
12379 if (speaker_nid) { 12436 if (line_nid == 0x1d || speaker_nid == 0x1d) {
12380 snd_hda_codec_write(codec, speaker_nid, 0, 12437 snd_hda_codec_write(codec, speaker_nid, 0,
12381 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 12438 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12439 /* mute mixer inputs from 0x1d */
12382 snd_hda_codec_write(codec, 0x0f, 0, 12440 snd_hda_codec_write(codec, 0x0f, 0,
12383 AC_VERB_SET_AMP_GAIN_MUTE, 12441 AC_VERB_SET_AMP_GAIN_MUTE,
12384 AMP_IN_UNMUTE(1)); 12442 AMP_IN_UNMUTE(1));
@@ -12386,6 +12444,7 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12386 AC_VERB_SET_AMP_GAIN_MUTE, 12444 AC_VERB_SET_AMP_GAIN_MUTE,
12387 AMP_IN_UNMUTE(1)); 12445 AMP_IN_UNMUTE(1));
12388 } else { 12446 } else {
12447 /* unmute mixer inputs from 0x1d */
12389 snd_hda_codec_write(codec, 0x0f, 0, 12448 snd_hda_codec_write(codec, 0x0f, 0,
12390 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); 12449 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12391 snd_hda_codec_write(codec, 0x10, 0, 12450 snd_hda_codec_write(codec, 0x10, 0,
@@ -12442,7 +12501,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
12442 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 12501 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12443 if (err < 0) 12502 if (err < 0)
12444 return err; 12503 return err;
12445 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); 12504 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
12446 if (err < 0) 12505 if (err < 0)
12447 return err; 12506 return err;
12448 12507
@@ -12461,7 +12520,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
12461 add_mixer(spec, alc268_beep_mixer); 12520 add_mixer(spec, alc268_beep_mixer);
12462 12521
12463 add_verb(spec, alc268_volume_init_verbs); 12522 add_verb(spec, alc268_volume_init_verbs);
12464 spec->num_mux_defs = 1; 12523 spec->num_mux_defs = 2;
12465 spec->input_mux = &spec->private_imux[0]; 12524 spec->input_mux = &spec->private_imux[0];
12466 12525
12467 err = alc_auto_add_mic_boost(codec); 12526 err = alc_auto_add_mic_boost(codec);
@@ -12473,8 +12532,6 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
12473 return 1; 12532 return 1;
12474} 12533}
12475 12534
12476#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12477#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12478#define alc268_auto_init_analog_input alc882_auto_init_analog_input 12535#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12479 12536
12480/* init callback for auto-configuration model -- overriding the default init */ 12537/* init callback for auto-configuration model -- overriding the default init */
@@ -12517,12 +12574,13 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
12517 ALC268_ACER_ASPIRE_ONE), 12574 ALC268_ACER_ASPIRE_ONE),
12518 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), 12575 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
12519 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), 12576 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
12577 /* almost compatible with toshiba but with optional digital outs;
12578 * auto-probing seems working fine
12579 */
12520 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series", 12580 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12521 ALC268_TOSHIBA), 12581 ALC268_AUTO),
12522 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), 12582 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
12523 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), 12583 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12524 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12525 ALC268_TOSHIBA),
12526 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), 12584 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
12527 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 12585 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
12528 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), 12586 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
@@ -12530,9 +12588,19 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
12530 {} 12588 {}
12531}; 12589};
12532 12590
12591/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12592static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12593 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12594 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12595 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12596 ALC268_TOSHIBA),
12597 {}
12598};
12599
12533static struct alc_config_preset alc268_presets[] = { 12600static struct alc_config_preset alc268_presets[] = {
12534 [ALC267_QUANTA_IL1] = { 12601 [ALC267_QUANTA_IL1] = {
12535 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer }, 12602 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12603 alc268_capture_nosrc_mixer },
12536 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12604 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12537 alc267_quanta_il1_verbs }, 12605 alc267_quanta_il1_verbs },
12538 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12606 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -12542,9 +12610,9 @@ static struct alc_config_preset alc268_presets[] = {
12542 .hp_nid = 0x03, 12610 .hp_nid = 0x03,
12543 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12611 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12544 .channel_mode = alc268_modes, 12612 .channel_mode = alc268_modes,
12545 .input_mux = &alc268_capture_source, 12613 .unsol_event = alc_sku_unsol_event,
12546 .unsol_event = alc267_quanta_il1_unsol_event, 12614 .setup = alc267_quanta_il1_setup,
12547 .init_hook = alc267_quanta_il1_init_hook, 12615 .init_hook = alc_inithook,
12548 }, 12616 },
12549 [ALC268_3ST] = { 12617 [ALC268_3ST] = {
12550 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 12618 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
@@ -12576,10 +12644,11 @@ static struct alc_config_preset alc268_presets[] = {
12576 .channel_mode = alc268_modes, 12644 .channel_mode = alc268_modes,
12577 .input_mux = &alc268_capture_source, 12645 .input_mux = &alc268_capture_source,
12578 .unsol_event = alc268_toshiba_unsol_event, 12646 .unsol_event = alc268_toshiba_unsol_event,
12579 .init_hook = alc268_toshiba_init_hook, 12647 .setup = alc268_toshiba_setup,
12648 .init_hook = alc268_toshiba_automute,
12580 }, 12649 },
12581 [ALC268_ACER] = { 12650 [ALC268_ACER] = {
12582 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, 12651 .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer,
12583 alc268_beep_mixer }, 12652 alc268_beep_mixer },
12584 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12653 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12585 alc268_acer_verbs }, 12654 alc268_acer_verbs },
@@ -12615,7 +12684,7 @@ static struct alc_config_preset alc268_presets[] = {
12615 [ALC268_ACER_ASPIRE_ONE] = { 12684 [ALC268_ACER_ASPIRE_ONE] = {
12616 .mixers = { alc268_acer_aspire_one_mixer, 12685 .mixers = { alc268_acer_aspire_one_mixer,
12617 alc268_beep_mixer, 12686 alc268_beep_mixer,
12618 alc268_capture_alt_mixer }, 12687 alc268_capture_nosrc_mixer },
12619 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12688 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12620 alc268_acer_aspire_one_verbs }, 12689 alc268_acer_aspire_one_verbs },
12621 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12690 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -12626,22 +12695,26 @@ static struct alc_config_preset alc268_presets[] = {
12626 .hp_nid = 0x03, 12695 .hp_nid = 0x03,
12627 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12696 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12628 .channel_mode = alc268_modes, 12697 .channel_mode = alc268_modes,
12629 .input_mux = &alc268_acer_lc_capture_source,
12630 .unsol_event = alc268_acer_lc_unsol_event, 12698 .unsol_event = alc268_acer_lc_unsol_event,
12699 .setup = alc268_acer_lc_setup,
12631 .init_hook = alc268_acer_lc_init_hook, 12700 .init_hook = alc268_acer_lc_init_hook,
12632 }, 12701 },
12633 [ALC268_DELL] = { 12702 [ALC268_DELL] = {
12634 .mixers = { alc268_dell_mixer, alc268_beep_mixer }, 12703 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12704 alc268_capture_nosrc_mixer },
12635 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12705 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12636 alc268_dell_verbs }, 12706 alc268_dell_verbs },
12637 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12707 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12638 .dac_nids = alc268_dac_nids, 12708 .dac_nids = alc268_dac_nids,
12709 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12710 .adc_nids = alc268_adc_nids_alt,
12711 .capsrc_nids = alc268_capsrc_nids,
12639 .hp_nid = 0x02, 12712 .hp_nid = 0x02,
12640 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12713 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12641 .channel_mode = alc268_modes, 12714 .channel_mode = alc268_modes,
12642 .unsol_event = alc_sku_unsol_event, 12715 .unsol_event = alc_sku_unsol_event,
12643 .init_hook = alc268_dell_init_hook, 12716 .setup = alc268_dell_setup,
12644 .input_mux = &alc268_capture_source, 12717 .init_hook = alc_inithook,
12645 }, 12718 },
12646 [ALC268_ZEPTO] = { 12719 [ALC268_ZEPTO] = {
12647 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 12720 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
@@ -12658,8 +12731,8 @@ static struct alc_config_preset alc268_presets[] = {
12658 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12731 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12659 .channel_mode = alc268_modes, 12732 .channel_mode = alc268_modes,
12660 .input_mux = &alc268_capture_source, 12733 .input_mux = &alc268_capture_source,
12661 .unsol_event = alc268_toshiba_unsol_event, 12734 .setup = alc268_toshiba_setup,
12662 .init_hook = alc268_toshiba_init_hook 12735 .init_hook = alc268_toshiba_automute,
12663 }, 12736 },
12664#ifdef CONFIG_SND_DEBUG 12737#ifdef CONFIG_SND_DEBUG
12665 [ALC268_TEST] = { 12738 [ALC268_TEST] = {
@@ -12696,9 +12769,13 @@ static int patch_alc268(struct hda_codec *codec)
12696 alc268_models, 12769 alc268_models,
12697 alc268_cfg_tbl); 12770 alc268_cfg_tbl);
12698 12771
12772 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12773 board_config = snd_hda_check_board_codec_sid_config(codec,
12774 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12775
12699 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { 12776 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12700 printk(KERN_INFO "hda_codec: Unknown model for %s, " 12777 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12701 "trying auto-probe from BIOS...\n", codec->chip_name); 12778 codec->chip_name);
12702 board_config = ALC268_AUTO; 12779 board_config = ALC268_AUTO;
12703 } 12780 }
12704 12781
@@ -12717,7 +12794,7 @@ static int patch_alc268(struct hda_codec *codec)
12717 } 12794 }
12718 12795
12719 if (board_config != ALC268_AUTO) 12796 if (board_config != ALC268_AUTO)
12720 setup_preset(spec, &alc268_presets[board_config]); 12797 setup_preset(codec, &alc268_presets[board_config]);
12721 12798
12722 spec->stream_analog_playback = &alc268_pcm_analog_playback; 12799 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12723 spec->stream_analog_capture = &alc268_pcm_analog_capture; 12800 spec->stream_analog_capture = &alc268_pcm_analog_capture;
@@ -12754,11 +12831,15 @@ static int patch_alc268(struct hda_codec *codec)
12754 int i; 12831 int i;
12755 12832
12756 /* get type */ 12833 /* get type */
12757 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 12834 wcap = get_wcaps_type(wcap);
12758 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 12835 if (spec->auto_mic ||
12836 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
12759 spec->adc_nids = alc268_adc_nids_alt; 12837 spec->adc_nids = alc268_adc_nids_alt;
12760 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); 12838 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
12761 add_mixer(spec, alc268_capture_alt_mixer); 12839 if (spec->auto_mic || spec->input_mux->num_items == 1)
12840 add_mixer(spec, alc268_capture_nosrc_mixer);
12841 else
12842 add_mixer(spec, alc268_capture_alt_mixer);
12762 } else { 12843 } else {
12763 spec->adc_nids = alc268_adc_nids; 12844 spec->adc_nids = alc268_adc_nids;
12764 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); 12845 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
@@ -12769,6 +12850,8 @@ static int patch_alc268(struct hda_codec *codec)
12769 for (i = 0; i < spec->num_adc_nids; i++) 12850 for (i = 0; i < spec->num_adc_nids; i++)
12770 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], 12851 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12771 0, AC_VERB_SET_CONNECT_SEL, 12852 0, AC_VERB_SET_CONNECT_SEL,
12853 i < spec->num_mux_defs ?
12854 spec->input_mux[i].items[0].index :
12772 spec->input_mux->items[0].index); 12855 spec->input_mux->items[0].index);
12773 } 12856 }
12774 12857
@@ -12803,22 +12886,6 @@ static hda_nid_t alc269_capsrc_nids[1] = {
12803 * not a mux! 12886 * not a mux!
12804 */ 12887 */
12805 12888
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 12889#define alc269_modes alc260_modes
12823#define alc269_capture_source alc880_lg_lw_capture_source 12890#define alc269_capture_source alc880_lg_lw_capture_source
12824 12891
@@ -12980,16 +13047,6 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12980 AC_VERB_SET_PROC_COEF, 0x480); 13047 AC_VERB_SET_PROC_COEF, 0x480);
12981} 13048}
12982 13049
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) 13050static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12994{ 13051{
12995 unsigned int present_laptop; 13052 unsigned int present_laptop;
@@ -13016,10 +13073,14 @@ static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13016static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, 13073static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13017 unsigned int res) 13074 unsigned int res)
13018{ 13075{
13019 if ((res >> 26) == ALC880_HP_EVENT) 13076 switch (res >> 26) {
13077 case ALC880_HP_EVENT:
13020 alc269_quanta_fl1_speaker_automute(codec); 13078 alc269_quanta_fl1_speaker_automute(codec);
13021 if ((res >> 26) == ALC880_MIC_EVENT) 13079 break;
13022 alc269_quanta_fl1_mic_automute(codec); 13080 case ALC880_MIC_EVENT:
13081 alc_mic_automute(codec);
13082 break;
13083 }
13023} 13084}
13024 13085
13025static void alc269_lifebook_unsol_event(struct hda_codec *codec, 13086static void alc269_lifebook_unsol_event(struct hda_codec *codec,
@@ -13031,10 +13092,20 @@ static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13031 alc269_lifebook_mic_autoswitch(codec); 13092 alc269_lifebook_mic_autoswitch(codec);
13032} 13093}
13033 13094
13095static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13096{
13097 struct alc_spec *spec = codec->spec;
13098 spec->ext_mic.pin = 0x18;
13099 spec->ext_mic.mux_idx = 0;
13100 spec->int_mic.pin = 0x19;
13101 spec->int_mic.mux_idx = 1;
13102 spec->auto_mic = 1;
13103}
13104
13034static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) 13105static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13035{ 13106{
13036 alc269_quanta_fl1_speaker_automute(codec); 13107 alc269_quanta_fl1_speaker_automute(codec);
13037 alc269_quanta_fl1_mic_automute(codec); 13108 alc_mic_automute(codec);
13038} 13109}
13039 13110
13040static void alc269_lifebook_init_hook(struct hda_codec *codec) 13111static void alc269_lifebook_init_hook(struct hda_codec *codec)
@@ -13079,60 +13150,44 @@ static void alc269_speaker_automute(struct hda_codec *codec)
13079 AMP_IN_MUTE(0), bits); 13150 AMP_IN_MUTE(0), bits);
13080} 13151}
13081 13152
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 */ 13153/* unsolicited event for HP jack sensing */
13105static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, 13154static void alc269_eeepc_unsol_event(struct hda_codec *codec,
13106 unsigned int res) 13155 unsigned int res)
13107{ 13156{
13108 if ((res >> 26) == ALC880_HP_EVENT) 13157 switch (res >> 26) {
13158 case ALC880_HP_EVENT:
13109 alc269_speaker_automute(codec); 13159 alc269_speaker_automute(codec);
13110 13160 break;
13111 if ((res >> 26) == ALC880_MIC_EVENT) 13161 case ALC880_MIC_EVENT:
13112 alc269_eeepc_dmic_automute(codec); 13162 alc_mic_automute(codec);
13163 break;
13164 }
13113} 13165}
13114 13166
13115static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) 13167static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13116{ 13168{
13117 alc269_speaker_automute(codec); 13169 struct alc_spec *spec = codec->spec;
13118 alc269_eeepc_dmic_automute(codec); 13170 spec->ext_mic.pin = 0x18;
13171 spec->ext_mic.mux_idx = 0;
13172 spec->int_mic.pin = 0x12;
13173 spec->int_mic.mux_idx = 5;
13174 spec->auto_mic = 1;
13119} 13175}
13120 13176
13121/* unsolicited event for HP jack sensing */ 13177static 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{ 13178{
13125 if ((res >> 26) == ALC880_HP_EVENT) 13179 struct alc_spec *spec = codec->spec;
13126 alc269_speaker_automute(codec); 13180 spec->ext_mic.pin = 0x18;
13127 13181 spec->ext_mic.mux_idx = 0;
13128 if ((res >> 26) == ALC880_MIC_EVENT) 13182 spec->int_mic.pin = 0x19;
13129 alc269_eeepc_amic_automute(codec); 13183 spec->int_mic.mux_idx = 1;
13184 spec->auto_mic = 1;
13130} 13185}
13131 13186
13132static void alc269_eeepc_amic_inithook(struct hda_codec *codec) 13187static void alc269_eeepc_inithook(struct hda_codec *codec)
13133{ 13188{
13134 alc269_speaker_automute(codec); 13189 alc269_speaker_automute(codec);
13135 alc269_eeepc_amic_automute(codec); 13190 alc_mic_automute(codec);
13136} 13191}
13137 13192
13138/* 13193/*
@@ -13205,89 +13260,10 @@ static struct hda_verb alc269_init_verbs[] = {
13205 { } 13260 { }
13206}; 13261};
13207 13262
13208/* add playback controls from the parsed DAC table */ 13263#define alc269_auto_create_multi_out_ctls \
13209static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, 13264 alc268_auto_create_multi_out_ctls
13210 const struct auto_pin_cfg *cfg) 13265#define alc269_auto_create_input_ctls \
13211{ 13266 alc268_auto_create_input_ctls
13212 hda_nid_t nid;
13213 int err;
13214
13215 spec->multiout.num_dacs = 1; /* only use one dac */
13216 spec->multiout.dac_nids = spec->private_dac_nids;
13217 spec->multiout.dac_nids[0] = 2;
13218
13219 nid = cfg->line_out_pins[0];
13220 if (nid) {
13221 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13222 "Front Playback Volume",
13223 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13224 if (err < 0)
13225 return err;
13226 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13227 "Front Playback Switch",
13228 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13229 if (err < 0)
13230 return err;
13231 }
13232
13233 nid = cfg->speaker_pins[0];
13234 if (nid) {
13235 if (!cfg->line_out_pins[0]) {
13236 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13237 "Speaker Playback Volume",
13238 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13239 HDA_OUTPUT));
13240 if (err < 0)
13241 return err;
13242 }
13243 if (nid == 0x16) {
13244 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13245 "Speaker Playback Switch",
13246 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13247 HDA_OUTPUT));
13248 if (err < 0)
13249 return err;
13250 } else {
13251 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13252 "Speaker Playback Switch",
13253 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13254 HDA_OUTPUT));
13255 if (err < 0)
13256 return err;
13257 }
13258 }
13259 nid = cfg->hp_pins[0];
13260 if (nid) {
13261 /* spec->multiout.hp_nid = 2; */
13262 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13263 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13264 "Headphone Playback Volume",
13265 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13266 HDA_OUTPUT));
13267 if (err < 0)
13268 return err;
13269 }
13270 if (nid == 0x16) {
13271 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13272 "Headphone Playback Switch",
13273 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13274 HDA_OUTPUT));
13275 if (err < 0)
13276 return err;
13277 } else {
13278 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13279 "Headphone Playback Switch",
13280 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13281 HDA_OUTPUT));
13282 if (err < 0)
13283 return err;
13284 }
13285 }
13286 return 0;
13287}
13288
13289#define alc269_auto_create_analog_input_ctls \
13290 alc262_auto_create_analog_input_ctls
13291 13267
13292#ifdef CONFIG_SND_HDA_POWER_SAVE 13268#ifdef CONFIG_SND_HDA_POWER_SAVE
13293#define alc269_loopbacks alc880_loopbacks 13269#define alc269_loopbacks alc880_loopbacks
@@ -13337,7 +13313,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13337 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); 13313 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13338 if (err < 0) 13314 if (err < 0)
13339 return err; 13315 return err;
13340 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); 13316 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
13341 if (err < 0) 13317 if (err < 0)
13342 return err; 13318 return err;
13343 13319
@@ -13362,15 +13338,15 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13362 return err; 13338 return err;
13363 13339
13364 if (!spec->cap_mixer && !spec->no_analog) 13340 if (!spec->cap_mixer && !spec->no_analog)
13365 set_capture_mixer(spec); 13341 set_capture_mixer(codec);
13366 13342
13367 alc_ssid_check(codec, 0x15, 0x1b, 0x14); 13343 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13368 13344
13369 return 1; 13345 return 1;
13370} 13346}
13371 13347
13372#define alc269_auto_init_multi_out alc882_auto_init_multi_out 13348#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13373#define alc269_auto_init_hp_out alc882_auto_init_hp_out 13349#define alc269_auto_init_hp_out alc268_auto_init_hp_out
13374#define alc269_auto_init_analog_input alc882_auto_init_analog_input 13350#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13375 13351
13376 13352
@@ -13438,6 +13414,7 @@ static struct alc_config_preset alc269_presets[] = {
13438 .channel_mode = alc269_modes, 13414 .channel_mode = alc269_modes,
13439 .input_mux = &alc269_capture_source, 13415 .input_mux = &alc269_capture_source,
13440 .unsol_event = alc269_quanta_fl1_unsol_event, 13416 .unsol_event = alc269_quanta_fl1_unsol_event,
13417 .setup = alc269_quanta_fl1_setup,
13441 .init_hook = alc269_quanta_fl1_init_hook, 13418 .init_hook = alc269_quanta_fl1_init_hook,
13442 }, 13419 },
13443 [ALC269_ASUS_EEEPC_P703] = { 13420 [ALC269_ASUS_EEEPC_P703] = {
@@ -13450,9 +13427,9 @@ static struct alc_config_preset alc269_presets[] = {
13450 .hp_nid = 0x03, 13427 .hp_nid = 0x03,
13451 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13428 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13452 .channel_mode = alc269_modes, 13429 .channel_mode = alc269_modes,
13453 .input_mux = &alc269_eeepc_amic_capture_source, 13430 .unsol_event = alc269_eeepc_unsol_event,
13454 .unsol_event = alc269_eeepc_amic_unsol_event, 13431 .setup = alc269_eeepc_amic_setup,
13455 .init_hook = alc269_eeepc_amic_inithook, 13432 .init_hook = alc269_eeepc_inithook,
13456 }, 13433 },
13457 [ALC269_ASUS_EEEPC_P901] = { 13434 [ALC269_ASUS_EEEPC_P901] = {
13458 .mixers = { alc269_eeepc_mixer }, 13435 .mixers = { alc269_eeepc_mixer },
@@ -13464,9 +13441,9 @@ static struct alc_config_preset alc269_presets[] = {
13464 .hp_nid = 0x03, 13441 .hp_nid = 0x03,
13465 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13442 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13466 .channel_mode = alc269_modes, 13443 .channel_mode = alc269_modes,
13467 .input_mux = &alc269_eeepc_dmic_capture_source, 13444 .unsol_event = alc269_eeepc_unsol_event,
13468 .unsol_event = alc269_eeepc_dmic_unsol_event, 13445 .setup = alc269_eeepc_dmic_setup,
13469 .init_hook = alc269_eeepc_dmic_inithook, 13446 .init_hook = alc269_eeepc_inithook,
13470 }, 13447 },
13471 [ALC269_FUJITSU] = { 13448 [ALC269_FUJITSU] = {
13472 .mixers = { alc269_fujitsu_mixer }, 13449 .mixers = { alc269_fujitsu_mixer },
@@ -13478,9 +13455,9 @@ static struct alc_config_preset alc269_presets[] = {
13478 .hp_nid = 0x03, 13455 .hp_nid = 0x03,
13479 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13456 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13480 .channel_mode = alc269_modes, 13457 .channel_mode = alc269_modes,
13481 .input_mux = &alc269_eeepc_dmic_capture_source, 13458 .unsol_event = alc269_eeepc_unsol_event,
13482 .unsol_event = alc269_eeepc_dmic_unsol_event, 13459 .setup = alc269_eeepc_dmic_setup,
13483 .init_hook = alc269_eeepc_dmic_inithook, 13460 .init_hook = alc269_eeepc_inithook,
13484 }, 13461 },
13485 [ALC269_LIFEBOOK] = { 13462 [ALC269_LIFEBOOK] = {
13486 .mixers = { alc269_lifebook_mixer }, 13463 .mixers = { alc269_lifebook_mixer },
@@ -13515,8 +13492,8 @@ static int patch_alc269(struct hda_codec *codec)
13515 alc269_cfg_tbl); 13492 alc269_cfg_tbl);
13516 13493
13517 if (board_config < 0) { 13494 if (board_config < 0) {
13518 printk(KERN_INFO "hda_codec: Unknown model for %s, " 13495 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13519 "trying auto-probe from BIOS...\n", codec->chip_name); 13496 codec->chip_name);
13520 board_config = ALC269_AUTO; 13497 board_config = ALC269_AUTO;
13521 } 13498 }
13522 13499
@@ -13541,7 +13518,7 @@ static int patch_alc269(struct hda_codec *codec)
13541 } 13518 }
13542 13519
13543 if (board_config != ALC269_AUTO) 13520 if (board_config != ALC269_AUTO)
13544 setup_preset(spec, &alc269_presets[board_config]); 13521 setup_preset(codec, &alc269_presets[board_config]);
13545 13522
13546 if (codec->subsystem_id == 0x17aa3bf8) { 13523 if (codec->subsystem_id == 0x17aa3bf8) {
13547 /* Due to a hardware problem on Lenovo Ideadpad, we need to 13524 /* Due to a hardware problem on Lenovo Ideadpad, we need to
@@ -13560,7 +13537,7 @@ static int patch_alc269(struct hda_codec *codec)
13560 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 13537 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
13561 spec->capsrc_nids = alc269_capsrc_nids; 13538 spec->capsrc_nids = alc269_capsrc_nids;
13562 if (!spec->cap_mixer) 13539 if (!spec->cap_mixer)
13563 set_capture_mixer(spec); 13540 set_capture_mixer(codec);
13564 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 13541 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
13565 13542
13566 spec->vmaster_nid = 0x02; 13543 spec->vmaster_nid = 0x02;
@@ -14110,23 +14087,23 @@ static struct hda_verb alc861_auto_init_verbs[] = {
14110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 14087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, 14088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14112 14089
14113 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14114 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14115 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14116 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14117 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14094 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14118 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14095 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14119 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14096 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14120 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14097 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14121 14098
14122 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 14099 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14123 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 14100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14124 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 14101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 14102 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14126 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 14103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14127 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 14104 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14128 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 14105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14129 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 14106 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14130 14107
14131 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ 14108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
14132 14109
@@ -14198,64 +14175,96 @@ static struct hda_input_mux alc861_capture_source = {
14198 }, 14175 },
14199}; 14176};
14200 14177
14178static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14179{
14180 struct alc_spec *spec = codec->spec;
14181 hda_nid_t mix, srcs[5];
14182 int i, j, num;
14183
14184 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14185 return 0;
14186 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14187 if (num < 0)
14188 return 0;
14189 for (i = 0; i < num; i++) {
14190 unsigned int type;
14191 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
14192 if (type != AC_WID_AUD_OUT)
14193 continue;
14194 for (j = 0; j < spec->multiout.num_dacs; j++)
14195 if (spec->multiout.dac_nids[j] == srcs[i])
14196 break;
14197 if (j >= spec->multiout.num_dacs)
14198 return srcs[i];
14199 }
14200 return 0;
14201}
14202
14201/* fill in the dac_nids table from the parsed pin configuration */ 14203/* fill in the dac_nids table from the parsed pin configuration */
14202static int alc861_auto_fill_dac_nids(struct alc_spec *spec, 14204static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
14203 const struct auto_pin_cfg *cfg) 14205 const struct auto_pin_cfg *cfg)
14204{ 14206{
14207 struct alc_spec *spec = codec->spec;
14205 int i; 14208 int i;
14206 hda_nid_t nid; 14209 hda_nid_t nid, dac;
14207 14210
14208 spec->multiout.dac_nids = spec->private_dac_nids; 14211 spec->multiout.dac_nids = spec->private_dac_nids;
14209 for (i = 0; i < cfg->line_outs; i++) { 14212 for (i = 0; i < cfg->line_outs; i++) {
14210 nid = cfg->line_out_pins[i]; 14213 nid = cfg->line_out_pins[i];
14211 if (nid) { 14214 dac = alc861_look_for_dac(codec, nid);
14212 if (i >= ARRAY_SIZE(alc861_dac_nids)) 14215 if (!dac)
14213 continue; 14216 continue;
14214 spec->multiout.dac_nids[i] = alc861_dac_nids[i]; 14217 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
14215 }
14216 } 14218 }
14217 spec->multiout.num_dacs = cfg->line_outs;
14218 return 0; 14219 return 0;
14219} 14220}
14220 14221
14222static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14223 hda_nid_t nid, unsigned int chs)
14224{
14225 char name[32];
14226 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14227 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14228 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14229}
14230
14221/* add playback controls from the parsed DAC table */ 14231/* add playback controls from the parsed DAC table */
14222static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, 14232static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14223 const struct auto_pin_cfg *cfg) 14233 const struct auto_pin_cfg *cfg)
14224{ 14234{
14225 char name[32]; 14235 struct alc_spec *spec = codec->spec;
14226 static const char *chname[4] = { 14236 static const char *chname[4] = {
14227 "Front", "Surround", NULL /*CLFE*/, "Side" 14237 "Front", "Surround", NULL /*CLFE*/, "Side"
14228 }; 14238 };
14229 hda_nid_t nid; 14239 hda_nid_t nid;
14230 int i, idx, err; 14240 int i, err;
14241
14242 if (cfg->line_outs == 1) {
14243 const char *pfx = NULL;
14244 if (!cfg->hp_outs)
14245 pfx = "Master";
14246 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14247 pfx = "Speaker";
14248 if (pfx) {
14249 nid = spec->multiout.dac_nids[0];
14250 return alc861_create_out_sw(codec, pfx, nid, 3);
14251 }
14252 }
14231 14253
14232 for (i = 0; i < cfg->line_outs; i++) { 14254 for (i = 0; i < cfg->line_outs; i++) {
14233 nid = spec->multiout.dac_nids[i]; 14255 nid = spec->multiout.dac_nids[i];
14234 if (!nid) 14256 if (!nid)
14235 continue; 14257 continue;
14236 if (nid == 0x05) { 14258 if (i == 2) {
14237 /* Center/LFE */ 14259 /* Center/LFE */
14238 err = add_control(spec, ALC_CTL_BIND_MUTE, 14260 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) 14261 if (err < 0)
14243 return err; 14262 return err;
14244 err = add_control(spec, ALC_CTL_BIND_MUTE, 14263 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) 14264 if (err < 0)
14249 return err; 14265 return err;
14250 } else { 14266 } else {
14251 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; 14267 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) 14268 if (err < 0)
14260 return err; 14269 return err;
14261 } 14270 }
@@ -14263,8 +14272,9 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14263 return 0; 14272 return 0;
14264} 14273}
14265 14274
14266static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) 14275static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
14267{ 14276{
14277 struct alc_spec *spec = codec->spec;
14268 int err; 14278 int err;
14269 hda_nid_t nid; 14279 hda_nid_t nid;
14270 14280
@@ -14272,70 +14282,49 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14272 return 0; 14282 return 0;
14273 14283
14274 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 14284 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14275 nid = 0x03; 14285 nid = alc861_look_for_dac(codec, pin);
14276 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 14286 if (nid) {
14277 "Headphone Playback Switch", 14287 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14278 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 14288 if (err < 0)
14279 if (err < 0) 14289 return err;
14280 return err; 14290 spec->multiout.hp_nid = nid;
14281 spec->multiout.hp_nid = nid; 14291 }
14282 } 14292 }
14283 return 0; 14293 return 0;
14284} 14294}
14285 14295
14286/* create playback/capture controls for input pins */ 14296/* create playback/capture controls for input pins */
14287static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, 14297static int alc861_auto_create_input_ctls(struct hda_codec *codec,
14288 const struct auto_pin_cfg *cfg) 14298 const struct auto_pin_cfg *cfg)
14289{ 14299{
14290 struct hda_input_mux *imux = &spec->private_imux[0]; 14300 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
14291 int i, err, idx, idx1;
14292
14293 for (i = 0; i < AUTO_PIN_LAST; i++) {
14294 switch (cfg->input_pins[i]) {
14295 case 0x0c:
14296 idx1 = 1;
14297 idx = 2; /* Line In */
14298 break;
14299 case 0x0f:
14300 idx1 = 2;
14301 idx = 2; /* Line In */
14302 break;
14303 case 0x0d:
14304 idx1 = 0;
14305 idx = 1; /* Mic In */
14306 break;
14307 case 0x10:
14308 idx1 = 3;
14309 idx = 1; /* Mic In */
14310 break;
14311 case 0x11:
14312 idx1 = 4;
14313 idx = 0; /* CD */
14314 break;
14315 default:
14316 continue;
14317 }
14318
14319 err = new_analog_input(spec, cfg->input_pins[i],
14320 auto_pin_cfg_labels[i], idx, 0x15);
14321 if (err < 0)
14322 return err;
14323
14324 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
14325 imux->items[imux->num_items].index = idx1;
14326 imux->num_items++;
14327 }
14328 return 0;
14329} 14301}
14330 14302
14331static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, 14303static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14332 hda_nid_t nid, 14304 hda_nid_t nid,
14333 int pin_type, int dac_idx) 14305 int pin_type, hda_nid_t dac)
14334{ 14306{
14307 hda_nid_t mix, srcs[5];
14308 int i, num;
14309
14335 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 14310 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14336 pin_type); 14311 pin_type);
14337 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, 14312 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14338 AMP_OUT_UNMUTE); 14313 AMP_OUT_UNMUTE);
14314 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14315 return;
14316 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14317 if (num < 0)
14318 return;
14319 for (i = 0; i < num; i++) {
14320 unsigned int mute;
14321 if (srcs[i] == dac || srcs[i] == 0x15)
14322 mute = AMP_IN_UNMUTE(i);
14323 else
14324 mute = AMP_IN_MUTE(i);
14325 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14326 mute);
14327 }
14339} 14328}
14340 14329
14341static void alc861_auto_init_multi_out(struct hda_codec *codec) 14330static void alc861_auto_init_multi_out(struct hda_codec *codec)
@@ -14358,12 +14347,13 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
14358 hda_nid_t pin; 14347 hda_nid_t pin;
14359 14348
14360 pin = spec->autocfg.hp_pins[0]; 14349 pin = spec->autocfg.hp_pins[0];
14361 if (pin) /* connect to front */ 14350 if (pin)
14362 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, 14351 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14363 spec->multiout.dac_nids[0]); 14352 spec->multiout.hp_nid);
14364 pin = spec->autocfg.speaker_pins[0]; 14353 pin = spec->autocfg.speaker_pins[0];
14365 if (pin) 14354 if (pin)
14366 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 14355 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14356 spec->multiout.dac_nids[0]);
14367} 14357}
14368 14358
14369static void alc861_auto_init_analog_input(struct hda_codec *codec) 14359static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -14395,16 +14385,16 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
14395 if (!spec->autocfg.line_outs) 14385 if (!spec->autocfg.line_outs)
14396 return 0; /* can't find valid BIOS pin config */ 14386 return 0; /* can't find valid BIOS pin config */
14397 14387
14398 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); 14388 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
14399 if (err < 0) 14389 if (err < 0)
14400 return err; 14390 return err;
14401 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); 14391 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
14402 if (err < 0) 14392 if (err < 0)
14403 return err; 14393 return err;
14404 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 14394 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
14405 if (err < 0) 14395 if (err < 0)
14406 return err; 14396 return err;
14407 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); 14397 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
14408 if (err < 0) 14398 if (err < 0)
14409 return err; 14399 return err;
14410 14400
@@ -14423,7 +14413,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
14423 14413
14424 spec->adc_nids = alc861_adc_nids; 14414 spec->adc_nids = alc861_adc_nids;
14425 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 14415 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
14426 set_capture_mixer(spec); 14416 set_capture_mixer(codec);
14427 14417
14428 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); 14418 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14429 14419
@@ -14616,8 +14606,8 @@ static int patch_alc861(struct hda_codec *codec)
14616 alc861_cfg_tbl); 14606 alc861_cfg_tbl);
14617 14607
14618 if (board_config < 0) { 14608 if (board_config < 0) {
14619 printk(KERN_INFO "hda_codec: Unknown model for %s, " 14609 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14620 "trying auto-probe from BIOS...\n", codec->chip_name); 14610 codec->chip_name);
14621 board_config = ALC861_AUTO; 14611 board_config = ALC861_AUTO;
14622 } 14612 }
14623 14613
@@ -14642,7 +14632,7 @@ static int patch_alc861(struct hda_codec *codec)
14642 } 14632 }
14643 14633
14644 if (board_config != ALC861_AUTO) 14634 if (board_config != ALC861_AUTO)
14645 setup_preset(spec, &alc861_presets[board_config]); 14635 setup_preset(codec, &alc861_presets[board_config]);
14646 14636
14647 spec->stream_analog_playback = &alc861_pcm_analog_playback; 14637 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14648 spec->stream_analog_capture = &alc861_pcm_analog_capture; 14638 spec->stream_analog_capture = &alc861_pcm_analog_capture;
@@ -15045,12 +15035,15 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15045 HDA_AMP_MUTE, bits); 15035 HDA_AMP_MUTE, bits);
15046} 15036}
15047 15037
15048static void alc861vd_lenovo_init_hook(struct hda_codec *codec) 15038static void alc861vd_lenovo_setup(struct hda_codec *codec)
15049{ 15039{
15050 struct alc_spec *spec = codec->spec; 15040 struct alc_spec *spec = codec->spec;
15051
15052 spec->autocfg.hp_pins[0] = 0x1b; 15041 spec->autocfg.hp_pins[0] = 0x1b;
15053 spec->autocfg.speaker_pins[0] = 0x14; 15042 spec->autocfg.speaker_pins[0] = 0x14;
15043}
15044
15045static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15046{
15054 alc_automute_amp(codec); 15047 alc_automute_amp(codec);
15055 alc861vd_lenovo_mic_automute(codec); 15048 alc861vd_lenovo_mic_automute(codec);
15056} 15049}
@@ -15114,13 +15107,12 @@ static struct hda_verb alc861vd_dallas_verbs[] = {
15114}; 15107};
15115 15108
15116/* toggle speaker-output according to the hp-jack state */ 15109/* toggle speaker-output according to the hp-jack state */
15117static void alc861vd_dallas_init_hook(struct hda_codec *codec) 15110static void alc861vd_dallas_setup(struct hda_codec *codec)
15118{ 15111{
15119 struct alc_spec *spec = codec->spec; 15112 struct alc_spec *spec = codec->spec;
15120 15113
15121 spec->autocfg.hp_pins[0] = 0x15; 15114 spec->autocfg.hp_pins[0] = 0x15;
15122 spec->autocfg.speaker_pins[0] = 0x14; 15115 spec->autocfg.speaker_pins[0] = 0x14;
15123 alc_automute_amp(codec);
15124} 15116}
15125 15117
15126#ifdef CONFIG_SND_HDA_POWER_SAVE 15118#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -15234,6 +15226,7 @@ static struct alc_config_preset alc861vd_presets[] = {
15234 .channel_mode = alc861vd_3stack_2ch_modes, 15226 .channel_mode = alc861vd_3stack_2ch_modes,
15235 .input_mux = &alc861vd_capture_source, 15227 .input_mux = &alc861vd_capture_source,
15236 .unsol_event = alc861vd_lenovo_unsol_event, 15228 .unsol_event = alc861vd_lenovo_unsol_event,
15229 .setup = alc861vd_lenovo_setup,
15237 .init_hook = alc861vd_lenovo_init_hook, 15230 .init_hook = alc861vd_lenovo_init_hook,
15238 }, 15231 },
15239 [ALC861VD_DALLAS] = { 15232 [ALC861VD_DALLAS] = {
@@ -15245,7 +15238,8 @@ static struct alc_config_preset alc861vd_presets[] = {
15245 .channel_mode = alc861vd_3stack_2ch_modes, 15238 .channel_mode = alc861vd_3stack_2ch_modes,
15246 .input_mux = &alc861vd_dallas_capture_source, 15239 .input_mux = &alc861vd_dallas_capture_source,
15247 .unsol_event = alc_automute_amp_unsol_event, 15240 .unsol_event = alc_automute_amp_unsol_event,
15248 .init_hook = alc861vd_dallas_init_hook, 15241 .setup = alc861vd_dallas_setup,
15242 .init_hook = alc_automute_amp,
15249 }, 15243 },
15250 [ALC861VD_HP] = { 15244 [ALC861VD_HP] = {
15251 .mixers = { alc861vd_hp_mixer }, 15245 .mixers = { alc861vd_hp_mixer },
@@ -15257,7 +15251,8 @@ static struct alc_config_preset alc861vd_presets[] = {
15257 .channel_mode = alc861vd_3stack_2ch_modes, 15251 .channel_mode = alc861vd_3stack_2ch_modes,
15258 .input_mux = &alc861vd_hp_capture_source, 15252 .input_mux = &alc861vd_hp_capture_source,
15259 .unsol_event = alc_automute_amp_unsol_event, 15253 .unsol_event = alc_automute_amp_unsol_event,
15260 .init_hook = alc861vd_dallas_init_hook, 15254 .setup = alc861vd_dallas_setup,
15255 .init_hook = alc_automute_amp,
15261 }, 15256 },
15262 [ALC660VD_ASUS_V1S] = { 15257 [ALC660VD_ASUS_V1S] = {
15263 .mixers = { alc861vd_lenovo_mixer }, 15258 .mixers = { alc861vd_lenovo_mixer },
@@ -15272,6 +15267,7 @@ static struct alc_config_preset alc861vd_presets[] = {
15272 .channel_mode = alc861vd_3stack_2ch_modes, 15267 .channel_mode = alc861vd_3stack_2ch_modes,
15273 .input_mux = &alc861vd_capture_source, 15268 .input_mux = &alc861vd_capture_source,
15274 .unsol_event = alc861vd_lenovo_unsol_event, 15269 .unsol_event = alc861vd_lenovo_unsol_event,
15270 .setup = alc861vd_lenovo_setup,
15275 .init_hook = alc861vd_lenovo_init_hook, 15271 .init_hook = alc861vd_lenovo_init_hook,
15276 }, 15272 },
15277}; 15273};
@@ -15279,6 +15275,13 @@ static struct alc_config_preset alc861vd_presets[] = {
15279/* 15275/*
15280 * BIOS auto configuration 15276 * BIOS auto configuration
15281 */ 15277 */
15278static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15279 const struct auto_pin_cfg *cfg)
15280{
15281 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15282}
15283
15284
15282static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, 15285static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15283 hda_nid_t nid, int pin_type, int dac_idx) 15286 hda_nid_t nid, int pin_type, int dac_idx)
15284{ 15287{
@@ -15313,7 +15316,6 @@ static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15313 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 15316 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
15314} 15317}
15315 15318
15316#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15317#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID 15319#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15318 15320
15319static void alc861vd_auto_init_analog_input(struct hda_codec *codec) 15321static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
@@ -15323,7 +15325,7 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15323 15325
15324 for (i = 0; i < AUTO_PIN_LAST; i++) { 15326 for (i = 0; i < AUTO_PIN_LAST; i++) {
15325 hda_nid_t nid = spec->autocfg.input_pins[i]; 15327 hda_nid_t nid = spec->autocfg.input_pins[i];
15326 if (alc861vd_is_input_pin(nid)) { 15328 if (alc_is_input_pin(codec, nid)) {
15327 alc_set_input_pin(codec, nid, i); 15329 alc_set_input_pin(codec, nid, i);
15328 if (nid != ALC861VD_PIN_CD_NID && 15330 if (nid != ALC861VD_PIN_CD_NID &&
15329 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 15331 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -15387,13 +15389,25 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15387 if (err < 0) 15389 if (err < 0)
15388 return err; 15390 return err;
15389 } else { 15391 } else {
15390 sprintf(name, "%s Playback Volume", chname[i]); 15392 const char *pfx;
15393 if (cfg->line_outs == 1 &&
15394 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15395 if (!cfg->hp_pins)
15396 pfx = "Speaker";
15397 else
15398 pfx = "PCM";
15399 } else
15400 pfx = chname[i];
15401 sprintf(name, "%s Playback Volume", pfx);
15391 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 15402 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15392 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 15403 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15393 HDA_OUTPUT)); 15404 HDA_OUTPUT));
15394 if (err < 0) 15405 if (err < 0)
15395 return err; 15406 return err;
15396 sprintf(name, "%s Playback Switch", chname[i]); 15407 if (cfg->line_outs == 1 &&
15408 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15409 pfx = "Speaker";
15410 sprintf(name, "%s Playback Switch", pfx);
15397 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 15411 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15398 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 15412 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
15399 HDA_INPUT)); 15413 HDA_INPUT));
@@ -15486,7 +15500,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
15486 "Headphone"); 15500 "Headphone");
15487 if (err < 0) 15501 if (err < 0)
15488 return err; 15502 return err;
15489 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 15503 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
15490 if (err < 0) 15504 if (err < 0)
15491 return err; 15505 return err;
15492 15506
@@ -15540,8 +15554,8 @@ static int patch_alc861vd(struct hda_codec *codec)
15540 alc861vd_cfg_tbl); 15554 alc861vd_cfg_tbl);
15541 15555
15542 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { 15556 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15543 printk(KERN_INFO "hda_codec: Unknown model for %s, " 15557 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15544 "trying auto-probe from BIOS...\n", codec->chip_name); 15558 codec->chip_name);
15545 board_config = ALC861VD_AUTO; 15559 board_config = ALC861VD_AUTO;
15546 } 15560 }
15547 15561
@@ -15566,7 +15580,7 @@ static int patch_alc861vd(struct hda_codec *codec)
15566 } 15580 }
15567 15581
15568 if (board_config != ALC861VD_AUTO) 15582 if (board_config != ALC861VD_AUTO)
15569 setup_preset(spec, &alc861vd_presets[board_config]); 15583 setup_preset(codec, &alc861vd_presets[board_config]);
15570 15584
15571 if (codec->vendor_id == 0x10ec0660) { 15585 if (codec->vendor_id == 0x10ec0660) {
15572 /* always turn on EAPD */ 15586 /* always turn on EAPD */
@@ -15586,7 +15600,7 @@ static int patch_alc861vd(struct hda_codec *codec)
15586 if (!spec->capsrc_nids) 15600 if (!spec->capsrc_nids)
15587 spec->capsrc_nids = alc861vd_capsrc_nids; 15601 spec->capsrc_nids = alc861vd_capsrc_nids;
15588 15602
15589 set_capture_mixer(spec); 15603 set_capture_mixer(codec);
15590 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 15604 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
15591 15605
15592 spec->vmaster_nid = 0x02; 15606 spec->vmaster_nid = 0x02;
@@ -15627,9 +15641,9 @@ static hda_nid_t alc272_dac_nids[2] = {
15627 0x02, 0x03 15641 0x02, 0x03
15628}; 15642};
15629 15643
15630static hda_nid_t alc662_adc_nids[1] = { 15644static hda_nid_t alc662_adc_nids[2] = {
15631 /* ADC1-2 */ 15645 /* ADC1-2 */
15632 0x09, 15646 0x09, 0x08
15633}; 15647};
15634 15648
15635static hda_nid_t alc272_adc_nids[1] = { 15649static hda_nid_t alc272_adc_nids[1] = {
@@ -15637,7 +15651,7 @@ static hda_nid_t alc272_adc_nids[1] = {
15637 0x08, 15651 0x08,
15638}; 15652};
15639 15653
15640static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; 15654static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
15641static hda_nid_t alc272_capsrc_nids[1] = { 0x23 }; 15655static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15642 15656
15643 15657
@@ -15661,14 +15675,6 @@ static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15661 }, 15675 },
15662}; 15676};
15663 15677
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 = { 15678static struct hda_input_mux alc663_capture_source = {
15673 .num_items = 3, 15679 .num_items = 3,
15674 .items = { 15680 .items = {
@@ -15678,23 +15684,7 @@ static struct hda_input_mux alc663_capture_source = {
15678 }, 15684 },
15679}; 15685};
15680 15686
15681static struct hda_input_mux alc663_m51va_capture_source = { 15687#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 = { 15688static struct hda_input_mux alc272_nc10_capture_source = {
15699 .num_items = 16, 15689 .num_items = 16,
15700 .items = { 15690 .items = {
@@ -16363,47 +16353,44 @@ static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16363 alc662_lenovo_101e_ispeaker_automute(codec); 16353 alc662_lenovo_101e_ispeaker_automute(codec);
16364} 16354}
16365 16355
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 */ 16356/* unsolicited event for HP jack sensing */
16383static void alc662_eeepc_unsol_event(struct hda_codec *codec, 16357static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16384 unsigned int res) 16358 unsigned int res)
16385{ 16359{
16386 if ((res >> 26) == ALC880_MIC_EVENT) 16360 if ((res >> 26) == ALC880_MIC_EVENT)
16387 alc662_eeepc_mic_automute(codec); 16361 alc_mic_automute(codec);
16388 else 16362 else
16389 alc262_hippo_unsol_event(codec, res); 16363 alc262_hippo_unsol_event(codec, res);
16390} 16364}
16391 16365
16366static void alc662_eeepc_setup(struct hda_codec *codec)
16367{
16368 struct alc_spec *spec = codec->spec;
16369
16370 alc262_hippo1_setup(codec);
16371 spec->ext_mic.pin = 0x18;
16372 spec->ext_mic.mux_idx = 0;
16373 spec->int_mic.pin = 0x19;
16374 spec->int_mic.mux_idx = 1;
16375 spec->auto_mic = 1;
16376}
16377
16392static void alc662_eeepc_inithook(struct hda_codec *codec) 16378static void alc662_eeepc_inithook(struct hda_codec *codec)
16393{ 16379{
16394 alc262_hippo1_init_hook(codec); 16380 alc262_hippo_automute(codec);
16395 alc662_eeepc_mic_automute(codec); 16381 alc_mic_automute(codec);
16396} 16382}
16397 16383
16398static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) 16384static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
16399{ 16385{
16400 struct alc_spec *spec = codec->spec; 16386 struct alc_spec *spec = codec->spec;
16401 16387
16402 spec->autocfg.hp_pins[0] = 0x14; 16388 spec->autocfg.hp_pins[0] = 0x14;
16403 spec->autocfg.speaker_pins[0] = 0x1b; 16389 spec->autocfg.speaker_pins[0] = 0x1b;
16404 alc262_hippo_master_update(codec);
16405} 16390}
16406 16391
16392#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16393
16407static void alc663_m51va_speaker_automute(struct hda_codec *codec) 16394static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16408{ 16395{
16409 unsigned int present; 16396 unsigned int present;
@@ -16514,23 +16501,6 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16514 } 16501 }
16515} 16502}
16516 16503
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, 16504static void alc663_m51va_unsol_event(struct hda_codec *codec,
16535 unsigned int res) 16505 unsigned int res)
16536{ 16506{
@@ -16539,36 +16509,32 @@ static void alc663_m51va_unsol_event(struct hda_codec *codec,
16539 alc663_m51va_speaker_automute(codec); 16509 alc663_m51va_speaker_automute(codec);
16540 break; 16510 break;
16541 case ALC880_MIC_EVENT: 16511 case ALC880_MIC_EVENT:
16542 alc663_m51va_mic_automute(codec); 16512 alc_mic_automute(codec);
16543 break; 16513 break;
16544 } 16514 }
16545} 16515}
16546 16516
16517static void alc663_m51va_setup(struct hda_codec *codec)
16518{
16519 struct alc_spec *spec = codec->spec;
16520 spec->ext_mic.pin = 0x18;
16521 spec->ext_mic.mux_idx = 0;
16522 spec->int_mic.pin = 0x12;
16523 spec->int_mic.mux_idx = 1;
16524 spec->auto_mic = 1;
16525}
16526
16547static void alc663_m51va_inithook(struct hda_codec *codec) 16527static void alc663_m51va_inithook(struct hda_codec *codec)
16548{ 16528{
16549 alc663_m51va_speaker_automute(codec); 16529 alc663_m51va_speaker_automute(codec);
16550 alc663_m51va_mic_automute(codec); 16530 alc_mic_automute(codec);
16551} 16531}
16552 16532
16553/* ***************** Mode1 ******************************/ 16533/* ***************** Mode1 ******************************/
16554static void alc663_mode1_unsol_event(struct hda_codec *codec, 16534#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16555 unsigned int res) 16535#define alc663_mode1_setup alc663_m51va_setup
16556{ 16536#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 16537
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 ******************************/ 16538/* ***************** Mode2 ******************************/
16573static void alc662_mode2_unsol_event(struct hda_codec *codec, 16539static void alc662_mode2_unsol_event(struct hda_codec *codec,
16574 unsigned int res) 16540 unsigned int res)
@@ -16578,15 +16544,17 @@ static void alc662_mode2_unsol_event(struct hda_codec *codec,
16578 alc662_f5z_speaker_automute(codec); 16544 alc662_f5z_speaker_automute(codec);
16579 break; 16545 break;
16580 case ALC880_MIC_EVENT: 16546 case ALC880_MIC_EVENT:
16581 alc662_eeepc_mic_automute(codec); 16547 alc_mic_automute(codec);
16582 break; 16548 break;
16583 } 16549 }
16584} 16550}
16585 16551
16552#define alc662_mode2_setup alc663_m51va_setup
16553
16586static void alc662_mode2_inithook(struct hda_codec *codec) 16554static void alc662_mode2_inithook(struct hda_codec *codec)
16587{ 16555{
16588 alc662_f5z_speaker_automute(codec); 16556 alc662_f5z_speaker_automute(codec);
16589 alc662_eeepc_mic_automute(codec); 16557 alc_mic_automute(codec);
16590} 16558}
16591/* ***************** Mode3 ******************************/ 16559/* ***************** Mode3 ******************************/
16592static void alc663_mode3_unsol_event(struct hda_codec *codec, 16560static void alc663_mode3_unsol_event(struct hda_codec *codec,
@@ -16597,15 +16565,17 @@ static void alc663_mode3_unsol_event(struct hda_codec *codec,
16597 alc663_two_hp_m1_speaker_automute(codec); 16565 alc663_two_hp_m1_speaker_automute(codec);
16598 break; 16566 break;
16599 case ALC880_MIC_EVENT: 16567 case ALC880_MIC_EVENT:
16600 alc662_eeepc_mic_automute(codec); 16568 alc_mic_automute(codec);
16601 break; 16569 break;
16602 } 16570 }
16603} 16571}
16604 16572
16573#define alc663_mode3_setup alc663_m51va_setup
16574
16605static void alc663_mode3_inithook(struct hda_codec *codec) 16575static void alc663_mode3_inithook(struct hda_codec *codec)
16606{ 16576{
16607 alc663_two_hp_m1_speaker_automute(codec); 16577 alc663_two_hp_m1_speaker_automute(codec);
16608 alc662_eeepc_mic_automute(codec); 16578 alc_mic_automute(codec);
16609} 16579}
16610/* ***************** Mode4 ******************************/ 16580/* ***************** Mode4 ******************************/
16611static void alc663_mode4_unsol_event(struct hda_codec *codec, 16581static void alc663_mode4_unsol_event(struct hda_codec *codec,
@@ -16616,15 +16586,17 @@ static void alc663_mode4_unsol_event(struct hda_codec *codec,
16616 alc663_21jd_two_speaker_automute(codec); 16586 alc663_21jd_two_speaker_automute(codec);
16617 break; 16587 break;
16618 case ALC880_MIC_EVENT: 16588 case ALC880_MIC_EVENT:
16619 alc662_eeepc_mic_automute(codec); 16589 alc_mic_automute(codec);
16620 break; 16590 break;
16621 } 16591 }
16622} 16592}
16623 16593
16594#define alc663_mode4_setup alc663_m51va_setup
16595
16624static void alc663_mode4_inithook(struct hda_codec *codec) 16596static void alc663_mode4_inithook(struct hda_codec *codec)
16625{ 16597{
16626 alc663_21jd_two_speaker_automute(codec); 16598 alc663_21jd_two_speaker_automute(codec);
16627 alc662_eeepc_mic_automute(codec); 16599 alc_mic_automute(codec);
16628} 16600}
16629/* ***************** Mode5 ******************************/ 16601/* ***************** Mode5 ******************************/
16630static void alc663_mode5_unsol_event(struct hda_codec *codec, 16602static void alc663_mode5_unsol_event(struct hda_codec *codec,
@@ -16635,15 +16607,17 @@ static void alc663_mode5_unsol_event(struct hda_codec *codec,
16635 alc663_15jd_two_speaker_automute(codec); 16607 alc663_15jd_two_speaker_automute(codec);
16636 break; 16608 break;
16637 case ALC880_MIC_EVENT: 16609 case ALC880_MIC_EVENT:
16638 alc662_eeepc_mic_automute(codec); 16610 alc_mic_automute(codec);
16639 break; 16611 break;
16640 } 16612 }
16641} 16613}
16642 16614
16615#define alc663_mode5_setup alc663_m51va_setup
16616
16643static void alc663_mode5_inithook(struct hda_codec *codec) 16617static void alc663_mode5_inithook(struct hda_codec *codec)
16644{ 16618{
16645 alc663_15jd_two_speaker_automute(codec); 16619 alc663_15jd_two_speaker_automute(codec);
16646 alc662_eeepc_mic_automute(codec); 16620 alc_mic_automute(codec);
16647} 16621}
16648/* ***************** Mode6 ******************************/ 16622/* ***************** Mode6 ******************************/
16649static void alc663_mode6_unsol_event(struct hda_codec *codec, 16623static void alc663_mode6_unsol_event(struct hda_codec *codec,
@@ -16654,15 +16628,17 @@ static void alc663_mode6_unsol_event(struct hda_codec *codec,
16654 alc663_two_hp_m2_speaker_automute(codec); 16628 alc663_two_hp_m2_speaker_automute(codec);
16655 break; 16629 break;
16656 case ALC880_MIC_EVENT: 16630 case ALC880_MIC_EVENT:
16657 alc662_eeepc_mic_automute(codec); 16631 alc_mic_automute(codec);
16658 break; 16632 break;
16659 } 16633 }
16660} 16634}
16661 16635
16636#define alc663_mode6_setup alc663_m51va_setup
16637
16662static void alc663_mode6_inithook(struct hda_codec *codec) 16638static void alc663_mode6_inithook(struct hda_codec *codec)
16663{ 16639{
16664 alc663_two_hp_m2_speaker_automute(codec); 16640 alc663_two_hp_m2_speaker_automute(codec);
16665 alc662_eeepc_mic_automute(codec); 16641 alc_mic_automute(codec);
16666} 16642}
16667 16643
16668static void alc663_g71v_hp_automute(struct hda_codec *codec) 16644static void alc663_g71v_hp_automute(struct hda_codec *codec)
@@ -16704,16 +16680,18 @@ static void alc663_g71v_unsol_event(struct hda_codec *codec,
16704 alc663_g71v_front_automute(codec); 16680 alc663_g71v_front_automute(codec);
16705 break; 16681 break;
16706 case ALC880_MIC_EVENT: 16682 case ALC880_MIC_EVENT:
16707 alc662_eeepc_mic_automute(codec); 16683 alc_mic_automute(codec);
16708 break; 16684 break;
16709 } 16685 }
16710} 16686}
16711 16687
16688#define alc663_g71v_setup alc663_m51va_setup
16689
16712static void alc663_g71v_inithook(struct hda_codec *codec) 16690static void alc663_g71v_inithook(struct hda_codec *codec)
16713{ 16691{
16714 alc663_g71v_front_automute(codec); 16692 alc663_g71v_front_automute(codec);
16715 alc663_g71v_hp_automute(codec); 16693 alc663_g71v_hp_automute(codec);
16716 alc662_eeepc_mic_automute(codec); 16694 alc_mic_automute(codec);
16717} 16695}
16718 16696
16719static void alc663_g50v_unsol_event(struct hda_codec *codec, 16697static void alc663_g50v_unsol_event(struct hda_codec *codec,
@@ -16724,15 +16702,17 @@ static void alc663_g50v_unsol_event(struct hda_codec *codec,
16724 alc663_m51va_speaker_automute(codec); 16702 alc663_m51va_speaker_automute(codec);
16725 break; 16703 break;
16726 case ALC880_MIC_EVENT: 16704 case ALC880_MIC_EVENT:
16727 alc662_eeepc_mic_automute(codec); 16705 alc_mic_automute(codec);
16728 break; 16706 break;
16729 } 16707 }
16730} 16708}
16731 16709
16710#define alc663_g50v_setup alc663_m51va_setup
16711
16732static void alc663_g50v_inithook(struct hda_codec *codec) 16712static void alc663_g50v_inithook(struct hda_codec *codec)
16733{ 16713{
16734 alc663_m51va_speaker_automute(codec); 16714 alc663_m51va_speaker_automute(codec);
16735 alc662_eeepc_mic_automute(codec); 16715 alc_mic_automute(codec);
16736} 16716}
16737 16717
16738static struct snd_kcontrol_new alc662_ecs_mixer[] = { 16718static struct snd_kcontrol_new alc662_ecs_mixer[] = {
@@ -16936,8 +16916,8 @@ static struct alc_config_preset alc662_presets[] = {
16936 .dac_nids = alc662_dac_nids, 16916 .dac_nids = alc662_dac_nids,
16937 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16917 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16938 .channel_mode = alc662_3ST_2ch_modes, 16918 .channel_mode = alc662_3ST_2ch_modes,
16939 .input_mux = &alc662_eeepc_capture_source,
16940 .unsol_event = alc662_eeepc_unsol_event, 16919 .unsol_event = alc662_eeepc_unsol_event,
16920 .setup = alc662_eeepc_setup,
16941 .init_hook = alc662_eeepc_inithook, 16921 .init_hook = alc662_eeepc_inithook,
16942 }, 16922 },
16943 [ALC662_ASUS_EEEPC_EP20] = { 16923 [ALC662_ASUS_EEEPC_EP20] = {
@@ -16951,6 +16931,7 @@ static struct alc_config_preset alc662_presets[] = {
16951 .channel_mode = alc662_3ST_6ch_modes, 16931 .channel_mode = alc662_3ST_6ch_modes,
16952 .input_mux = &alc662_lenovo_101e_capture_source, 16932 .input_mux = &alc662_lenovo_101e_capture_source,
16953 .unsol_event = alc662_eeepc_unsol_event, 16933 .unsol_event = alc662_eeepc_unsol_event,
16934 .setup = alc662_eeepc_ep20_setup,
16954 .init_hook = alc662_eeepc_ep20_inithook, 16935 .init_hook = alc662_eeepc_ep20_inithook,
16955 }, 16936 },
16956 [ALC662_ECS] = { 16937 [ALC662_ECS] = {
@@ -16961,8 +16942,8 @@ static struct alc_config_preset alc662_presets[] = {
16961 .dac_nids = alc662_dac_nids, 16942 .dac_nids = alc662_dac_nids,
16962 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16943 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16963 .channel_mode = alc662_3ST_2ch_modes, 16944 .channel_mode = alc662_3ST_2ch_modes,
16964 .input_mux = &alc662_eeepc_capture_source,
16965 .unsol_event = alc662_eeepc_unsol_event, 16945 .unsol_event = alc662_eeepc_unsol_event,
16946 .setup = alc662_eeepc_setup,
16966 .init_hook = alc662_eeepc_inithook, 16947 .init_hook = alc662_eeepc_inithook,
16967 }, 16948 },
16968 [ALC663_ASUS_M51VA] = { 16949 [ALC663_ASUS_M51VA] = {
@@ -16973,8 +16954,8 @@ static struct alc_config_preset alc662_presets[] = {
16973 .dig_out_nid = ALC662_DIGOUT_NID, 16954 .dig_out_nid = ALC662_DIGOUT_NID,
16974 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16955 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16975 .channel_mode = alc662_3ST_2ch_modes, 16956 .channel_mode = alc662_3ST_2ch_modes,
16976 .input_mux = &alc663_m51va_capture_source,
16977 .unsol_event = alc663_m51va_unsol_event, 16957 .unsol_event = alc663_m51va_unsol_event,
16958 .setup = alc663_m51va_setup,
16978 .init_hook = alc663_m51va_inithook, 16959 .init_hook = alc663_m51va_inithook,
16979 }, 16960 },
16980 [ALC663_ASUS_G71V] = { 16961 [ALC663_ASUS_G71V] = {
@@ -16985,8 +16966,8 @@ static struct alc_config_preset alc662_presets[] = {
16985 .dig_out_nid = ALC662_DIGOUT_NID, 16966 .dig_out_nid = ALC662_DIGOUT_NID,
16986 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16987 .channel_mode = alc662_3ST_2ch_modes, 16968 .channel_mode = alc662_3ST_2ch_modes,
16988 .input_mux = &alc662_eeepc_capture_source,
16989 .unsol_event = alc663_g71v_unsol_event, 16969 .unsol_event = alc663_g71v_unsol_event,
16970 .setup = alc663_g71v_setup,
16990 .init_hook = alc663_g71v_inithook, 16971 .init_hook = alc663_g71v_inithook,
16991 }, 16972 },
16992 [ALC663_ASUS_H13] = { 16973 [ALC663_ASUS_H13] = {
@@ -16996,7 +16977,6 @@ static struct alc_config_preset alc662_presets[] = {
16996 .dac_nids = alc662_dac_nids, 16977 .dac_nids = alc662_dac_nids,
16997 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16978 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16998 .channel_mode = alc662_3ST_2ch_modes, 16979 .channel_mode = alc662_3ST_2ch_modes,
16999 .input_mux = &alc663_m51va_capture_source,
17000 .unsol_event = alc663_m51va_unsol_event, 16980 .unsol_event = alc663_m51va_unsol_event,
17001 .init_hook = alc663_m51va_inithook, 16981 .init_hook = alc663_m51va_inithook,
17002 }, 16982 },
@@ -17010,6 +16990,7 @@ static struct alc_config_preset alc662_presets[] = {
17010 .channel_mode = alc662_3ST_6ch_modes, 16990 .channel_mode = alc662_3ST_6ch_modes,
17011 .input_mux = &alc663_capture_source, 16991 .input_mux = &alc663_capture_source,
17012 .unsol_event = alc663_g50v_unsol_event, 16992 .unsol_event = alc663_g50v_unsol_event,
16993 .setup = alc663_g50v_setup,
17013 .init_hook = alc663_g50v_inithook, 16994 .init_hook = alc663_g50v_inithook,
17014 }, 16995 },
17015 [ALC663_ASUS_MODE1] = { 16996 [ALC663_ASUS_MODE1] = {
@@ -17023,8 +17004,8 @@ static struct alc_config_preset alc662_presets[] = {
17023 .dig_out_nid = ALC662_DIGOUT_NID, 17004 .dig_out_nid = ALC662_DIGOUT_NID,
17024 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17005 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17025 .channel_mode = alc662_3ST_2ch_modes, 17006 .channel_mode = alc662_3ST_2ch_modes,
17026 .input_mux = &alc662_eeepc_capture_source,
17027 .unsol_event = alc663_mode1_unsol_event, 17007 .unsol_event = alc663_mode1_unsol_event,
17008 .setup = alc663_mode1_setup,
17028 .init_hook = alc663_mode1_inithook, 17009 .init_hook = alc663_mode1_inithook,
17029 }, 17010 },
17030 [ALC662_ASUS_MODE2] = { 17011 [ALC662_ASUS_MODE2] = {
@@ -17037,8 +17018,8 @@ static struct alc_config_preset alc662_presets[] = {
17037 .dig_out_nid = ALC662_DIGOUT_NID, 17018 .dig_out_nid = ALC662_DIGOUT_NID,
17038 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17019 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17039 .channel_mode = alc662_3ST_2ch_modes, 17020 .channel_mode = alc662_3ST_2ch_modes,
17040 .input_mux = &alc662_eeepc_capture_source,
17041 .unsol_event = alc662_mode2_unsol_event, 17021 .unsol_event = alc662_mode2_unsol_event,
17022 .setup = alc662_mode2_setup,
17042 .init_hook = alc662_mode2_inithook, 17023 .init_hook = alc662_mode2_inithook,
17043 }, 17024 },
17044 [ALC663_ASUS_MODE3] = { 17025 [ALC663_ASUS_MODE3] = {
@@ -17052,8 +17033,8 @@ static struct alc_config_preset alc662_presets[] = {
17052 .dig_out_nid = ALC662_DIGOUT_NID, 17033 .dig_out_nid = ALC662_DIGOUT_NID,
17053 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17034 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17054 .channel_mode = alc662_3ST_2ch_modes, 17035 .channel_mode = alc662_3ST_2ch_modes,
17055 .input_mux = &alc662_eeepc_capture_source,
17056 .unsol_event = alc663_mode3_unsol_event, 17036 .unsol_event = alc663_mode3_unsol_event,
17037 .setup = alc663_mode3_setup,
17057 .init_hook = alc663_mode3_inithook, 17038 .init_hook = alc663_mode3_inithook,
17058 }, 17039 },
17059 [ALC663_ASUS_MODE4] = { 17040 [ALC663_ASUS_MODE4] = {
@@ -17067,8 +17048,8 @@ static struct alc_config_preset alc662_presets[] = {
17067 .dig_out_nid = ALC662_DIGOUT_NID, 17048 .dig_out_nid = ALC662_DIGOUT_NID,
17068 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17049 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17069 .channel_mode = alc662_3ST_2ch_modes, 17050 .channel_mode = alc662_3ST_2ch_modes,
17070 .input_mux = &alc662_eeepc_capture_source,
17071 .unsol_event = alc663_mode4_unsol_event, 17051 .unsol_event = alc663_mode4_unsol_event,
17052 .setup = alc663_mode4_setup,
17072 .init_hook = alc663_mode4_inithook, 17053 .init_hook = alc663_mode4_inithook,
17073 }, 17054 },
17074 [ALC663_ASUS_MODE5] = { 17055 [ALC663_ASUS_MODE5] = {
@@ -17082,8 +17063,8 @@ static struct alc_config_preset alc662_presets[] = {
17082 .dig_out_nid = ALC662_DIGOUT_NID, 17063 .dig_out_nid = ALC662_DIGOUT_NID,
17083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17064 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17084 .channel_mode = alc662_3ST_2ch_modes, 17065 .channel_mode = alc662_3ST_2ch_modes,
17085 .input_mux = &alc662_eeepc_capture_source,
17086 .unsol_event = alc663_mode5_unsol_event, 17066 .unsol_event = alc663_mode5_unsol_event,
17067 .setup = alc663_mode5_setup,
17087 .init_hook = alc663_mode5_inithook, 17068 .init_hook = alc663_mode5_inithook,
17088 }, 17069 },
17089 [ALC663_ASUS_MODE6] = { 17070 [ALC663_ASUS_MODE6] = {
@@ -17097,8 +17078,8 @@ static struct alc_config_preset alc662_presets[] = {
17097 .dig_out_nid = ALC662_DIGOUT_NID, 17078 .dig_out_nid = ALC662_DIGOUT_NID,
17098 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17079 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17099 .channel_mode = alc662_3ST_2ch_modes, 17080 .channel_mode = alc662_3ST_2ch_modes,
17100 .input_mux = &alc662_eeepc_capture_source,
17101 .unsol_event = alc663_mode6_unsol_event, 17081 .unsol_event = alc663_mode6_unsol_event,
17082 .setup = alc663_mode6_setup,
17102 .init_hook = alc663_mode6_inithook, 17083 .init_hook = alc663_mode6_inithook,
17103 }, 17084 },
17104 [ALC272_DELL] = { 17085 [ALC272_DELL] = {
@@ -17112,8 +17093,8 @@ static struct alc_config_preset alc662_presets[] = {
17112 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids), 17093 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17113 .capsrc_nids = alc272_capsrc_nids, 17094 .capsrc_nids = alc272_capsrc_nids,
17114 .channel_mode = alc662_3ST_2ch_modes, 17095 .channel_mode = alc662_3ST_2ch_modes,
17115 .input_mux = &alc663_m51va_capture_source,
17116 .unsol_event = alc663_m51va_unsol_event, 17096 .unsol_event = alc663_m51va_unsol_event,
17097 .setup = alc663_m51va_setup,
17117 .init_hook = alc663_m51va_inithook, 17098 .init_hook = alc663_m51va_inithook,
17118 }, 17099 },
17119 [ALC272_DELL_ZM1] = { 17100 [ALC272_DELL_ZM1] = {
@@ -17124,11 +17105,11 @@ static struct alc_config_preset alc662_presets[] = {
17124 .dac_nids = alc662_dac_nids, 17105 .dac_nids = alc662_dac_nids,
17125 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17106 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17126 .adc_nids = alc662_adc_nids, 17107 .adc_nids = alc662_adc_nids,
17127 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), 17108 .num_adc_nids = 1,
17128 .capsrc_nids = alc662_capsrc_nids, 17109 .capsrc_nids = alc662_capsrc_nids,
17129 .channel_mode = alc662_3ST_2ch_modes, 17110 .channel_mode = alc662_3ST_2ch_modes,
17130 .input_mux = &alc663_m51va_capture_source,
17131 .unsol_event = alc663_m51va_unsol_event, 17111 .unsol_event = alc663_m51va_unsol_event,
17112 .setup = alc663_m51va_setup,
17132 .init_hook = alc663_m51va_inithook, 17113 .init_hook = alc663_m51va_inithook,
17133 }, 17114 },
17134 [ALC272_SAMSUNG_NC10] = { 17115 [ALC272_SAMSUNG_NC10] = {
@@ -17139,8 +17120,9 @@ static struct alc_config_preset alc662_presets[] = {
17139 .dac_nids = alc272_dac_nids, 17120 .dac_nids = alc272_dac_nids,
17140 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17121 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17141 .channel_mode = alc662_3ST_2ch_modes, 17122 .channel_mode = alc662_3ST_2ch_modes,
17142 .input_mux = &alc272_nc10_capture_source, 17123 /*.input_mux = &alc272_nc10_capture_source,*/
17143 .unsol_event = alc663_mode4_unsol_event, 17124 .unsol_event = alc663_mode4_unsol_event,
17125 .setup = alc663_mode4_setup,
17144 .init_hook = alc663_mode4_inithook, 17126 .init_hook = alc663_mode4_inithook,
17145 }, 17127 },
17146}; 17128};
@@ -17192,13 +17174,25 @@ static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17192 if (err < 0) 17174 if (err < 0)
17193 return err; 17175 return err;
17194 } else { 17176 } else {
17195 sprintf(name, "%s Playback Volume", chname[i]); 17177 const char *pfx;
17178 if (cfg->line_outs == 1 &&
17179 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17180 if (!cfg->hp_pins)
17181 pfx = "Speaker";
17182 else
17183 pfx = "PCM";
17184 } else
17185 pfx = chname[i];
17186 sprintf(name, "%s Playback Volume", pfx);
17196 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 17187 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17197 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 17188 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17198 HDA_OUTPUT)); 17189 HDA_OUTPUT));
17199 if (err < 0) 17190 if (err < 0)
17200 return err; 17191 return err;
17201 sprintf(name, "%s Playback Switch", chname[i]); 17192 if (cfg->line_outs == 1 &&
17193 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17194 pfx = "Speaker";
17195 sprintf(name, "%s Playback Switch", pfx);
17202 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 17196 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17203 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), 17197 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17204 3, 0, HDA_INPUT)); 17198 3, 0, HDA_INPUT));
@@ -17260,62 +17254,9 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17260 return 0; 17254 return 0;
17261} 17255}
17262 17256
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)
17283{
17284 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
17285 return (pincap & AC_PINCAP_IN) != 0;
17286}
17287
17288/* create playback/capture controls for input pins */ 17257/* create playback/capture controls for input pins */
17289static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec, 17258#define alc662_auto_create_input_ctls \
17290 const struct auto_pin_cfg *cfg) 17259 alc880_auto_create_input_ctls
17291{
17292 struct alc_spec *spec = codec->spec;
17293 struct hda_input_mux *imux = &spec->private_imux[0];
17294 int i, err, idx;
17295
17296 for (i = 0; i < AUTO_PIN_LAST; i++) {
17297 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17298 idx = alc662_input_pin_idx(codec, 0x0b,
17299 cfg->input_pins[i]);
17300 if (idx >= 0) {
17301 err = new_analog_input(spec, cfg->input_pins[i],
17302 auto_pin_cfg_labels[i],
17303 idx, 0x0b);
17304 if (err < 0)
17305 return err;
17306 }
17307 idx = alc662_input_pin_idx(codec, 0x22,
17308 cfg->input_pins[i]);
17309 if (idx >= 0) {
17310 imux->items[imux->num_items].label =
17311 auto_pin_cfg_labels[i];
17312 imux->items[imux->num_items].index = idx;
17313 imux->num_items++;
17314 }
17315 }
17316 }
17317 return 0;
17318}
17319 17260
17320static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, 17261static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17321 hda_nid_t nid, int pin_type, 17262 hda_nid_t nid, int pin_type,
@@ -17369,7 +17310,7 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec)
17369 17310
17370 for (i = 0; i < AUTO_PIN_LAST; i++) { 17311 for (i = 0; i < AUTO_PIN_LAST; i++) {
17371 hda_nid_t nid = spec->autocfg.input_pins[i]; 17312 hda_nid_t nid = spec->autocfg.input_pins[i];
17372 if (alc662_is_input_pin(codec, nid)) { 17313 if (alc_is_input_pin(codec, nid)) {
17373 alc_set_input_pin(codec, nid, i); 17314 alc_set_input_pin(codec, nid, i);
17374 if (nid != ALC662_PIN_CD_NID && 17315 if (nid != ALC662_PIN_CD_NID &&
17375 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 17316 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -17410,7 +17351,7 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
17410 "Headphone"); 17351 "Headphone");
17411 if (err < 0) 17352 if (err < 0)
17412 return err; 17353 return err;
17413 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg); 17354 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
17414 if (err < 0) 17355 if (err < 0)
17415 return err; 17356 return err;
17416 17357
@@ -17467,8 +17408,8 @@ static int patch_alc662(struct hda_codec *codec)
17467 alc662_models, 17408 alc662_models,
17468 alc662_cfg_tbl); 17409 alc662_cfg_tbl);
17469 if (board_config < 0) { 17410 if (board_config < 0) {
17470 printk(KERN_INFO "hda_codec: Unknown model for %s, " 17411 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17471 "trying auto-probe from BIOS...\n", codec->chip_name); 17412 codec->chip_name);
17472 board_config = ALC662_AUTO; 17413 board_config = ALC662_AUTO;
17473 } 17414 }
17474 17415
@@ -17493,7 +17434,7 @@ static int patch_alc662(struct hda_codec *codec)
17493 } 17434 }
17494 17435
17495 if (board_config != ALC662_AUTO) 17436 if (board_config != ALC662_AUTO)
17496 setup_preset(spec, &alc662_presets[board_config]); 17437 setup_preset(codec, &alc662_presets[board_config]);
17497 17438
17498 spec->stream_analog_playback = &alc662_pcm_analog_playback; 17439 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17499 spec->stream_analog_capture = &alc662_pcm_analog_capture; 17440 spec->stream_analog_capture = &alc662_pcm_analog_capture;
@@ -17509,7 +17450,7 @@ static int patch_alc662(struct hda_codec *codec)
17509 spec->capsrc_nids = alc662_capsrc_nids; 17450 spec->capsrc_nids = alc662_capsrc_nids;
17510 17451
17511 if (!spec->cap_mixer) 17452 if (!spec->cap_mixer)
17512 set_capture_mixer(spec); 17453 set_capture_mixer(codec);
17513 if (codec->vendor_id == 0x10ec0662) 17454 if (codec->vendor_id == 0x10ec0662)
17514 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 17455 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17515 else 17456 else
@@ -17545,23 +17486,23 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = {
17545 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 17486 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17546 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 17487 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
17547 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", 17488 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17548 .patch = patch_alc883 }, 17489 .patch = patch_alc882 },
17549 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", 17490 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17550 .patch = patch_alc662 }, 17491 .patch = patch_alc662 },
17551 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 17492 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
17552 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 17493 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
17553 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 17494 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
17554 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 17495 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
17555 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", 17496 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17556 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 17497 .patch = patch_alc882 },
17557 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 17498 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
17558 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 17499 .patch = patch_alc882 },
17559 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 17500 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
17560 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, 17501 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
17561 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 17502 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17562 .patch = patch_alc883 }, 17503 .patch = patch_alc882 },
17563 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 17504 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17564 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 17505 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
17565 {} /* terminator */ 17506 {} /* terminator */
17566}; 17507};
17567 17508