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.c4567
1 files changed, 2310 insertions, 2257 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 33453319742..7810d3dcad8 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 */
@@ -275,13 +281,13 @@ struct alc_spec {
275 */ 281 */
276 unsigned int num_init_verbs; 282 unsigned int num_init_verbs;
277 283
278 char stream_name_analog[16]; /* analog PCM stream */ 284 char stream_name_analog[32]; /* analog PCM stream */
279 struct hda_pcm_stream *stream_analog_playback; 285 struct hda_pcm_stream *stream_analog_playback;
280 struct hda_pcm_stream *stream_analog_capture; 286 struct hda_pcm_stream *stream_analog_capture;
281 struct hda_pcm_stream *stream_analog_alt_playback; 287 struct hda_pcm_stream *stream_analog_alt_playback;
282 struct hda_pcm_stream *stream_analog_alt_capture; 288 struct hda_pcm_stream *stream_analog_alt_capture;
283 289
284 char stream_name_digital[16]; /* digital PCM stream */ 290 char stream_name_digital[32]; /* digital PCM stream */
285 struct hda_pcm_stream *stream_digital_playback; 291 struct hda_pcm_stream *stream_digital_playback;
286 struct hda_pcm_stream *stream_digital_capture; 292 struct hda_pcm_stream *stream_digital_capture;
287 293
@@ -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];
@@ -559,7 +571,7 @@ static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
559 571
560 /* Find enumerated value for current pinctl setting */ 572 /* Find enumerated value for current pinctl setting */
561 i = alc_pin_mode_min(dir); 573 i = alc_pin_mode_min(dir);
562 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) 574 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
563 i++; 575 i++;
564 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); 576 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
565 return 0; 577 return 0;
@@ -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 */
@@ -945,12 +961,13 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
945static void alc_automute_pin(struct hda_codec *codec) 961static void alc_automute_pin(struct hda_codec *codec)
946{ 962{
947 struct alc_spec *spec = codec->spec; 963 struct alc_spec *spec = codec->spec;
948 unsigned int present; 964 unsigned int present, pincap;
949 unsigned int nid = spec->autocfg.hp_pins[0]; 965 unsigned int nid = spec->autocfg.hp_pins[0];
950 int i; 966 int i;
951 967
952 /* need to execute and sync at first */ 968 pincap = snd_hda_query_pin_caps(codec, nid);
953 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); 969 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
970 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
954 present = snd_hda_codec_read(codec, nid, 0, 971 present = snd_hda_codec_read(codec, nid, 0,
955 AC_VERB_GET_PIN_SENSE, 0); 972 AC_VERB_GET_PIN_SENSE, 0);
956 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 973 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
@@ -964,30 +981,64 @@ static void alc_automute_pin(struct hda_codec *codec)
964 } 981 }
965} 982}
966 983
967#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
968static void alc_mic_automute(struct hda_codec *codec) 997static void alc_mic_automute(struct hda_codec *codec)
969{ 998{
970 struct alc_spec *spec = codec->spec; 999 struct alc_spec *spec = codec->spec;
971 unsigned int present; 1000 struct alc_mic_route *dead, *alive;
972 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; 1001 unsigned int present, type;
973 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; 1002 hda_nid_t cap_nid;
974 unsigned int mix_nid = spec->capsrc_nids[0]; 1003
975 unsigned int capsrc_idx_mic, capsrc_idx_fmic; 1004 if (!spec->auto_mic)
976 1005 return;
977 capsrc_idx_mic = mic_nid - 0x18; 1006 if (!spec->int_mic.pin || !spec->ext_mic.pin)
978 capsrc_idx_fmic = fmic_nid - 0x18; 1007 return;
979 present = snd_hda_codec_read(codec, mic_nid, 0, 1008 if (snd_BUG_ON(!spec->adc_nids))
980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1009 return;
981 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1010
982 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); 1011 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
983 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1012
984 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); 1013 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
985 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, 1014 AC_VERB_GET_PIN_SENSE, 0);
986 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 */
987} 1041}
988#else
989#define alc_mic_automute(codec) do {} while(0) /* NOP */
990#endif /* disabled */
991 1042
992/* unsolicited event for HP jack sensing */ 1043/* unsolicited event for HP jack sensing */
993static 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)
@@ -1030,6 +1081,16 @@ static void alc888_coef_init(struct hda_codec *codec)
1030 AC_VERB_SET_PROC_COEF, 0x3030); 1081 AC_VERB_SET_PROC_COEF, 0x3030);
1031} 1082}
1032 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
1033static void alc_auto_init_amp(struct hda_codec *codec, int type) 1094static void alc_auto_init_amp(struct hda_codec *codec, int type)
1034{ 1095{
1035 unsigned int tmp; 1096 unsigned int tmp;
@@ -1087,15 +1148,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
1087 case 0x10ec0885: 1148 case 0x10ec0885:
1088 case 0x10ec0887: 1149 case 0x10ec0887:
1089 case 0x10ec0889: 1150 case 0x10ec0889:
1090 snd_hda_codec_write(codec, 0x20, 0, 1151 alc889_coef_init(codec);
1091 AC_VERB_SET_COEF_INDEX, 7);
1092 tmp = snd_hda_codec_read(codec, 0x20, 0,
1093 AC_VERB_GET_PROC_COEF, 0);
1094 snd_hda_codec_write(codec, 0x20, 0,
1095 AC_VERB_SET_COEF_INDEX, 7);
1096 snd_hda_codec_write(codec, 0x20, 0,
1097 AC_VERB_SET_PROC_COEF,
1098 tmp | 0x2010);
1099 break; 1152 break;
1100 case 0x10ec0888: 1153 case 0x10ec0888:
1101 alc888_coef_init(codec); 1154 alc888_coef_init(codec);
@@ -1141,6 +1194,55 @@ static void alc_init_auto_hp(struct hda_codec *codec)
1141 spec->unsol_event = alc_sku_unsol_event; 1194 spec->unsol_event = alc_sku_unsol_event;
1142} 1195}
1143 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
1144/* check subsystem ID and set up device-specific initialization; 1246/* check subsystem ID and set up device-specific initialization;
1145 * return 1 if initialized, 0 if invalid SSID 1247 * return 1 if initialized, 0 if invalid SSID
1146 */ 1248 */
@@ -1242,6 +1344,7 @@ do_sku:
1242 } 1344 }
1243 1345
1244 alc_init_auto_hp(codec); 1346 alc_init_auto_hp(codec);
1347 alc_init_auto_mic(codec);
1245 return 1; 1348 return 1;
1246} 1349}
1247 1350
@@ -1254,6 +1357,7 @@ static void alc_ssid_check(struct hda_codec *codec,
1254 "Enable default setup for auto mode as fallback\n"); 1357 "Enable default setup for auto mode as fallback\n");
1255 spec->init_amp = ALC_INIT_DEFAULT; 1358 spec->init_amp = ALC_INIT_DEFAULT;
1256 alc_init_auto_hp(codec); 1359 alc_init_auto_hp(codec);
1360 alc_init_auto_mic(codec);
1257 } 1361 }
1258} 1362}
1259 1363
@@ -1392,7 +1496,7 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1392static void alc_automute_amp(struct hda_codec *codec) 1496static void alc_automute_amp(struct hda_codec *codec)
1393{ 1497{
1394 struct alc_spec *spec = codec->spec; 1498 struct alc_spec *spec = codec->spec;
1395 unsigned int val, mute; 1499 unsigned int val, mute, pincap;
1396 hda_nid_t nid; 1500 hda_nid_t nid;
1397 int i; 1501 int i;
1398 1502
@@ -1401,6 +1505,10 @@ static void alc_automute_amp(struct hda_codec *codec)
1401 nid = spec->autocfg.hp_pins[i]; 1505 nid = spec->autocfg.hp_pins[i];
1402 if (!nid) 1506 if (!nid)
1403 break; 1507 break;
1508 pincap = snd_hda_query_pin_caps(codec, nid);
1509 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1510 snd_hda_codec_read(codec, nid, 0,
1511 AC_VERB_SET_PIN_SENSE, 0);
1404 val = snd_hda_codec_read(codec, nid, 0, 1512 val = snd_hda_codec_read(codec, nid, 0,
1405 AC_VERB_GET_PIN_SENSE, 0); 1513 AC_VERB_GET_PIN_SENSE, 0);
1406 if (val & AC_PINSENSE_PRESENCE) { 1514 if (val & AC_PINSENSE_PRESENCE) {
@@ -1431,7 +1539,25 @@ static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1431 alc_automute_amp(codec); 1539 alc_automute_amp(codec);
1432} 1540}
1433 1541
1434static 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)
1435{ 1561{
1436 struct alc_spec *spec = codec->spec; 1562 struct alc_spec *spec = codec->spec;
1437 1563
@@ -1439,7 +1565,6 @@ static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1439 spec->autocfg.hp_pins[1] = 0x1b; /* hp */ 1565 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1440 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ 1566 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1441 spec->autocfg.speaker_pins[1] = 0x15; /* bass */ 1567 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1442 alc_automute_amp(codec);
1443} 1568}
1444 1569
1445/* 1570/*
@@ -1471,6 +1596,10 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1471static struct hda_verb alc888_acer_aspire_6530g_verbs[] = { 1596static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1472/* Bias voltage on for external mic port */ 1597/* Bias voltage on for external mic port */
1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80}, 1598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1599/* Front Mic: set to PIN_IN (empty by default) */
1600 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1601/* Unselect Front Mic by default in input mixer 3 */
1602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1474/* Enable unsolicited event for HP jack */ 1603/* Enable unsolicited event for HP jack */
1475 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 1604 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1476/* Enable speaker output */ 1605/* Enable speaker output */
@@ -1560,18 +1689,22 @@ static struct hda_input_mux alc888_2_capture_sources[2] = {
1560static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = { 1689static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1561 /* Interal mic only available on one ADC */ 1690 /* Interal mic only available on one ADC */
1562 { 1691 {
1563 .num_items = 3, 1692 .num_items = 5,
1564 .items = { 1693 .items = {
1565 { "Ext Mic", 0x0 }, 1694 { "Ext Mic", 0x0 },
1695 { "Line In", 0x2 },
1566 { "CD", 0x4 }, 1696 { "CD", 0x4 },
1697 { "Input Mix", 0xa },
1567 { "Int Mic", 0xb }, 1698 { "Int Mic", 0xb },
1568 }, 1699 },
1569 }, 1700 },
1570 { 1701 {
1571 .num_items = 2, 1702 .num_items = 4,
1572 .items = { 1703 .items = {
1573 { "Ext Mic", 0x0 }, 1704 { "Ext Mic", 0x0 },
1705 { "Line In", 0x2 },
1574 { "CD", 0x4 }, 1706 { "CD", 0x4 },
1707 { "Input Mix", 0xa },
1575 }, 1708 },
1576 } 1709 }
1577}; 1710};
@@ -1630,16 +1763,25 @@ static struct snd_kcontrol_new alc888_base_mixer[] = {
1630 { } /* end */ 1763 { } /* end */
1631}; 1764};
1632 1765
1633static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec) 1766static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
1634{ 1767{
1635 struct alc_spec *spec = codec->spec; 1768 struct alc_spec *spec = codec->spec;
1636 1769
1637 spec->autocfg.hp_pins[0] = 0x15; 1770 spec->autocfg.hp_pins[0] = 0x15;
1638 spec->autocfg.speaker_pins[0] = 0x14; 1771 spec->autocfg.speaker_pins[0] = 0x14;
1639 alc_automute_amp(codec);
1640} 1772}
1641 1773
1642static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) 1774static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
1775{
1776 struct alc_spec *spec = codec->spec;
1777
1778 spec->autocfg.hp_pins[0] = 0x15;
1779 spec->autocfg.speaker_pins[0] = 0x14;
1780 spec->autocfg.speaker_pins[1] = 0x16;
1781 spec->autocfg.speaker_pins[2] = 0x17;
1782}
1783
1784static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
1643{ 1785{
1644 struct alc_spec *spec = codec->spec; 1786 struct alc_spec *spec = codec->spec;
1645 1787
@@ -1647,7 +1789,6 @@ static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
1647 spec->autocfg.speaker_pins[0] = 0x14; 1789 spec->autocfg.speaker_pins[0] = 0x14;
1648 spec->autocfg.speaker_pins[1] = 0x16; 1790 spec->autocfg.speaker_pins[1] = 0x16;
1649 spec->autocfg.speaker_pins[2] = 0x1b; 1791 spec->autocfg.speaker_pins[2] = 0x1b;
1650 alc_automute_amp(codec);
1651} 1792}
1652 1793
1653/* 1794/*
@@ -2627,13 +2768,17 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2627 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);
2628} 2769}
2629 2770
2630static void alc880_uniwill_init_hook(struct hda_codec *codec) 2771static void alc880_uniwill_setup(struct hda_codec *codec)
2631{ 2772{
2632 struct alc_spec *spec = codec->spec; 2773 struct alc_spec *spec = codec->spec;
2633 2774
2634 spec->autocfg.hp_pins[0] = 0x14; 2775 spec->autocfg.hp_pins[0] = 0x14;
2635 spec->autocfg.speaker_pins[0] = 0x15; 2776 spec->autocfg.speaker_pins[0] = 0x15;
2636 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{
2637 alc_automute_amp(codec); 2782 alc_automute_amp(codec);
2638 alc880_uniwill_mic_automute(codec); 2783 alc880_uniwill_mic_automute(codec);
2639} 2784}
@@ -2654,13 +2799,12 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2654 } 2799 }
2655} 2800}
2656 2801
2657static void alc880_uniwill_p53_init_hook(struct hda_codec *codec) 2802static void alc880_uniwill_p53_setup(struct hda_codec *codec)
2658{ 2803{
2659 struct alc_spec *spec = codec->spec; 2804 struct alc_spec *spec = codec->spec;
2660 2805
2661 spec->autocfg.hp_pins[0] = 0x14; 2806 spec->autocfg.hp_pins[0] = 0x14;
2662 spec->autocfg.speaker_pins[0] = 0x15; 2807 spec->autocfg.speaker_pins[0] = 0x15;
2663 alc_automute_amp(codec);
2664} 2808}
2665 2809
2666static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 2810static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -2923,13 +3067,12 @@ static struct hda_verb alc880_lg_init_verbs[] = {
2923}; 3067};
2924 3068
2925/* toggle speaker-output according to the hp-jack state */ 3069/* toggle speaker-output according to the hp-jack state */
2926static void alc880_lg_init_hook(struct hda_codec *codec) 3070static void alc880_lg_setup(struct hda_codec *codec)
2927{ 3071{
2928 struct alc_spec *spec = codec->spec; 3072 struct alc_spec *spec = codec->spec;
2929 3073
2930 spec->autocfg.hp_pins[0] = 0x1b; 3074 spec->autocfg.hp_pins[0] = 0x1b;
2931 spec->autocfg.speaker_pins[0] = 0x17; 3075 spec->autocfg.speaker_pins[0] = 0x17;
2932 alc_automute_amp(codec);
2933} 3076}
2934 3077
2935/* 3078/*
@@ -3008,13 +3151,12 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
3008}; 3151};
3009 3152
3010/* toggle speaker-output according to the hp-jack state */ 3153/* toggle speaker-output according to the hp-jack state */
3011static void alc880_lg_lw_init_hook(struct hda_codec *codec) 3154static void alc880_lg_lw_setup(struct hda_codec *codec)
3012{ 3155{
3013 struct alc_spec *spec = codec->spec; 3156 struct alc_spec *spec = codec->spec;
3014 3157
3015 spec->autocfg.hp_pins[0] = 0x1b; 3158 spec->autocfg.hp_pins[0] = 0x1b;
3016 spec->autocfg.speaker_pins[0] = 0x14; 3159 spec->autocfg.speaker_pins[0] = 0x14;
3017 alc_automute_amp(codec);
3018} 3160}
3019 3161
3020static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { 3162static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
@@ -3080,13 +3222,12 @@ static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3080 alc880_medion_rim_automute(codec); 3222 alc880_medion_rim_automute(codec);
3081} 3223}
3082 3224
3083static void alc880_medion_rim_init_hook(struct hda_codec *codec) 3225static void alc880_medion_rim_setup(struct hda_codec *codec)
3084{ 3226{
3085 struct alc_spec *spec = codec->spec; 3227 struct alc_spec *spec = codec->spec;
3086 3228
3087 spec->autocfg.hp_pins[0] = 0x14; 3229 spec->autocfg.hp_pins[0] = 0x14;
3088 spec->autocfg.speaker_pins[0] = 0x1b; 3230 spec->autocfg.speaker_pins[0] = 0x1b;
3089 alc880_medion_rim_automute(codec);
3090} 3231}
3091 3232
3092#ifdef CONFIG_SND_HDA_POWER_SAVE 3233#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -3953,7 +4094,8 @@ static struct alc_config_preset alc880_presets[] = {
3953 .channel_mode = alc880_2_jack_modes, 4094 .channel_mode = alc880_2_jack_modes,
3954 .input_mux = &alc880_f1734_capture_source, 4095 .input_mux = &alc880_f1734_capture_source,
3955 .unsol_event = alc880_uniwill_p53_unsol_event, 4096 .unsol_event = alc880_uniwill_p53_unsol_event,
3956 .init_hook = alc880_uniwill_p53_init_hook, 4097 .setup = alc880_uniwill_p53_setup,
4098 .init_hook = alc_automute_amp,
3957 }, 4099 },
3958 [ALC880_ASUS] = { 4100 [ALC880_ASUS] = {
3959 .mixers = { alc880_asus_mixer }, 4101 .mixers = { alc880_asus_mixer },
@@ -4030,6 +4172,7 @@ static struct alc_config_preset alc880_presets[] = {
4030 .need_dac_fix = 1, 4172 .need_dac_fix = 1,
4031 .input_mux = &alc880_capture_source, 4173 .input_mux = &alc880_capture_source,
4032 .unsol_event = alc880_uniwill_unsol_event, 4174 .unsol_event = alc880_uniwill_unsol_event,
4175 .setup = alc880_uniwill_setup,
4033 .init_hook = alc880_uniwill_init_hook, 4176 .init_hook = alc880_uniwill_init_hook,
4034 }, 4177 },
4035 [ALC880_UNIWILL_P53] = { 4178 [ALC880_UNIWILL_P53] = {
@@ -4042,7 +4185,8 @@ static struct alc_config_preset alc880_presets[] = {
4042 .channel_mode = alc880_threestack_modes, 4185 .channel_mode = alc880_threestack_modes,
4043 .input_mux = &alc880_capture_source, 4186 .input_mux = &alc880_capture_source,
4044 .unsol_event = alc880_uniwill_p53_unsol_event, 4187 .unsol_event = alc880_uniwill_p53_unsol_event,
4045 .init_hook = alc880_uniwill_p53_init_hook, 4188 .setup = alc880_uniwill_p53_setup,
4189 .init_hook = alc_automute_amp,
4046 }, 4190 },
4047 [ALC880_FUJITSU] = { 4191 [ALC880_FUJITSU] = {
4048 .mixers = { alc880_fujitsu_mixer }, 4192 .mixers = { alc880_fujitsu_mixer },
@@ -4056,7 +4200,8 @@ static struct alc_config_preset alc880_presets[] = {
4056 .channel_mode = alc880_2_jack_modes, 4200 .channel_mode = alc880_2_jack_modes,
4057 .input_mux = &alc880_capture_source, 4201 .input_mux = &alc880_capture_source,
4058 .unsol_event = alc880_uniwill_p53_unsol_event, 4202 .unsol_event = alc880_uniwill_p53_unsol_event,
4059 .init_hook = alc880_uniwill_p53_init_hook, 4203 .setup = alc880_uniwill_p53_setup,
4204 .init_hook = alc_automute_amp,
4060 }, 4205 },
4061 [ALC880_CLEVO] = { 4206 [ALC880_CLEVO] = {
4062 .mixers = { alc880_three_stack_mixer }, 4207 .mixers = { alc880_three_stack_mixer },
@@ -4082,7 +4227,8 @@ static struct alc_config_preset alc880_presets[] = {
4082 .need_dac_fix = 1, 4227 .need_dac_fix = 1,
4083 .input_mux = &alc880_lg_capture_source, 4228 .input_mux = &alc880_lg_capture_source,
4084 .unsol_event = alc_automute_amp_unsol_event, 4229 .unsol_event = alc_automute_amp_unsol_event,
4085 .init_hook = alc880_lg_init_hook, 4230 .setup = alc880_lg_setup,
4231 .init_hook = alc_automute_amp,
4086#ifdef CONFIG_SND_HDA_POWER_SAVE 4232#ifdef CONFIG_SND_HDA_POWER_SAVE
4087 .loopbacks = alc880_lg_loopbacks, 4233 .loopbacks = alc880_lg_loopbacks,
4088#endif 4234#endif
@@ -4098,7 +4244,8 @@ static struct alc_config_preset alc880_presets[] = {
4098 .channel_mode = alc880_lg_lw_modes, 4244 .channel_mode = alc880_lg_lw_modes,
4099 .input_mux = &alc880_lg_lw_capture_source, 4245 .input_mux = &alc880_lg_lw_capture_source,
4100 .unsol_event = alc_automute_amp_unsol_event, 4246 .unsol_event = alc_automute_amp_unsol_event,
4101 .init_hook = alc880_lg_lw_init_hook, 4247 .setup = alc880_lg_lw_setup,
4248 .init_hook = alc_automute_amp,
4102 }, 4249 },
4103 [ALC880_MEDION_RIM] = { 4250 [ALC880_MEDION_RIM] = {
4104 .mixers = { alc880_medion_rim_mixer }, 4251 .mixers = { alc880_medion_rim_mixer },
@@ -4112,7 +4259,8 @@ static struct alc_config_preset alc880_presets[] = {
4112 .channel_mode = alc880_2_jack_modes, 4259 .channel_mode = alc880_2_jack_modes,
4113 .input_mux = &alc880_medion_rim_capture_source, 4260 .input_mux = &alc880_medion_rim_capture_source,
4114 .unsol_event = alc880_medion_rim_unsol_event, 4261 .unsol_event = alc880_medion_rim_unsol_event,
4115 .init_hook = alc880_medion_rim_init_hook, 4262 .setup = alc880_medion_rim_setup,
4263 .init_hook = alc880_medion_rim_automute,
4116 }, 4264 },
4117#ifdef CONFIG_SND_DEBUG 4265#ifdef CONFIG_SND_DEBUG
4118 [ALC880_TEST] = { 4266 [ALC880_TEST] = {
@@ -4165,8 +4313,6 @@ static int add_control(struct alc_spec *spec, int type, const char *name,
4165#define alc880_fixed_pin_idx(nid) ((nid) - 0x14) 4313#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4166#define alc880_is_multi_pin(nid) ((nid) >= 0x18) 4314#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4167#define alc880_multi_pin_idx(nid) ((nid) - 0x18) 4315#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4168#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4169#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4170#define alc880_idx_to_dac(nid) ((nid) + 0x02) 4316#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4171#define alc880_dac_to_idx(nid) ((nid) - 0x02) 4317#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4172#define alc880_idx_to_mixer(nid) ((nid) + 0x0c) 4318#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
@@ -4254,13 +4400,19 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4254 if (err < 0) 4400 if (err < 0)
4255 return err; 4401 return err;
4256 } else { 4402 } else {
4257 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);
4258 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 4410 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4259 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 4411 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4260 HDA_OUTPUT)); 4412 HDA_OUTPUT));
4261 if (err < 0) 4413 if (err < 0)
4262 return err; 4414 return err;
4263 sprintf(name, "%s Playback Switch", chname[i]); 4415 sprintf(name, "%s Playback Switch", pfx);
4264 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 4416 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4265 HDA_COMPOSE_AMP_VAL(nid, 3, 2, 4417 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4266 HDA_INPUT)); 4418 HDA_INPUT));
@@ -4334,31 +4486,61 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4334 return 0; 4486 return 0;
4335} 4487}
4336 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
4337/* create playback/capture controls for input pins */ 4495/* create playback/capture controls for input pins */
4338static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 4496static int alc_auto_create_input_ctls(struct hda_codec *codec,
4339 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)
4340{ 4500{
4501 struct alc_spec *spec = codec->spec;
4341 struct hda_input_mux *imux = &spec->private_imux[0]; 4502 struct hda_input_mux *imux = &spec->private_imux[0];
4342 int i, err, idx; 4503 int i, err, idx;
4343 4504
4344 for (i = 0; i < AUTO_PIN_LAST; i++) { 4505 for (i = 0; i < AUTO_PIN_LAST; i++) {
4345 if (alc880_is_input_pin(cfg->input_pins[i])) { 4506 hda_nid_t pin;
4346 idx = alc880_input_pin_idx(cfg->input_pins[i]); 4507
4347 err = new_analog_input(spec, cfg->input_pins[i], 4508 pin = cfg->input_pins[i];
4348 auto_pin_cfg_labels[i], 4509 if (!alc_is_input_pin(codec, pin))
4349 idx, 0x0b); 4510 continue;
4350 if (err < 0) 4511
4351 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) {
4352 imux->items[imux->num_items].label = 4529 imux->items[imux->num_items].label =
4353 auto_pin_cfg_labels[i]; 4530 auto_pin_cfg_labels[i];
4354 imux->items[imux->num_items].index = 4531 imux->items[imux->num_items].index = idx;
4355 alc880_input_pin_idx(cfg->input_pins[i]);
4356 imux->num_items++; 4532 imux->num_items++;
4357 } 4533 }
4358 } 4534 }
4359 return 0; 4535 return 0;
4360} 4536}
4361 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
4362static 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,
4363 unsigned int pin_type) 4545 unsigned int pin_type)
4364{ 4546{
@@ -4424,7 +4606,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
4424 4606
4425 for (i = 0; i < AUTO_PIN_LAST; i++) { 4607 for (i = 0; i < AUTO_PIN_LAST; i++) {
4426 hda_nid_t nid = spec->autocfg.input_pins[i]; 4608 hda_nid_t nid = spec->autocfg.input_pins[i];
4427 if (alc880_is_input_pin(nid)) { 4609 if (alc_is_input_pin(codec, nid)) {
4428 alc_set_input_pin(codec, nid, i); 4610 alc_set_input_pin(codec, nid, i);
4429 if (nid != ALC880_PIN_CD_NID && 4611 if (nid != ALC880_PIN_CD_NID &&
4430 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 4612 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -4467,7 +4649,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4467 "Headphone"); 4649 "Headphone");
4468 if (err < 0) 4650 if (err < 0)
4469 return err; 4651 return err;
4470 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 4652 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
4471 if (err < 0) 4653 if (err < 0)
4472 return err; 4654 return err;
4473 4655
@@ -4517,8 +4699,42 @@ static void alc880_auto_init(struct hda_codec *codec)
4517 alc_inithook(codec); 4699 alc_inithook(codec);
4518} 4700}
4519 4701
4520static 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)
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)
4521{ 4736{
4737 struct alc_spec *spec = codec->spec;
4522 static struct snd_kcontrol_new *caps[2][3] = { 4738 static struct snd_kcontrol_new *caps[2][3] = {
4523 { alc_capture_mixer_nosrc1, 4739 { alc_capture_mixer_nosrc1,
4524 alc_capture_mixer_nosrc2, 4740 alc_capture_mixer_nosrc2,
@@ -4529,7 +4745,10 @@ static void set_capture_mixer(struct alc_spec *spec)
4529 }; 4745 };
4530 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { 4746 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4531 int mux; 4747 int mux;
4532 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)
4533 mux = 1; 4752 mux = 1;
4534 else 4753 else
4535 mux = 0; 4754 mux = 0;
@@ -4560,8 +4779,8 @@ static int patch_alc880(struct hda_codec *codec)
4560 alc880_models, 4779 alc880_models,
4561 alc880_cfg_tbl); 4780 alc880_cfg_tbl);
4562 if (board_config < 0) { 4781 if (board_config < 0) {
4563 printk(KERN_INFO "hda_codec: Unknown model for %s, " 4782 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4564 "trying auto-probe from BIOS...\n", codec->chip_name); 4783 codec->chip_name);
4565 board_config = ALC880_AUTO; 4784 board_config = ALC880_AUTO;
4566 } 4785 }
4567 4786
@@ -4586,7 +4805,7 @@ static int patch_alc880(struct hda_codec *codec)
4586 } 4805 }
4587 4806
4588 if (board_config != ALC880_AUTO) 4807 if (board_config != ALC880_AUTO)
4589 setup_preset(spec, &alc880_presets[board_config]); 4808 setup_preset(codec, &alc880_presets[board_config]);
4590 4809
4591 spec->stream_analog_playback = &alc880_pcm_analog_playback; 4810 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4592 spec->stream_analog_capture = &alc880_pcm_analog_capture; 4811 spec->stream_analog_capture = &alc880_pcm_analog_capture;
@@ -4599,7 +4818,7 @@ static int patch_alc880(struct hda_codec *codec)
4599 /* check whether NID 0x07 is valid */ 4818 /* check whether NID 0x07 is valid */
4600 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 4819 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
4601 /* get type */ 4820 /* get type */
4602 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 4821 wcap = get_wcaps_type(wcap);
4603 if (wcap != AC_WID_AUD_IN) { 4822 if (wcap != AC_WID_AUD_IN) {
4604 spec->adc_nids = alc880_adc_nids_alt; 4823 spec->adc_nids = alc880_adc_nids_alt;
4605 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 4824 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
@@ -4608,7 +4827,7 @@ static int patch_alc880(struct hda_codec *codec)
4608 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); 4827 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
4609 } 4828 }
4610 } 4829 }
4611 set_capture_mixer(spec); 4830 set_capture_mixer(codec);
4612 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4831 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4613 4832
4614 spec->vmaster_nid = 0x0c; 4833 spec->vmaster_nid = 0x0c;
@@ -5800,7 +6019,14 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5800 6019
5801 nid = cfg->line_out_pins[0]; 6020 nid = cfg->line_out_pins[0];
5802 if (nid) { 6021 if (nid) {
5803 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);
5804 if (err < 0) 6030 if (err < 0)
5805 return err; 6031 return err;
5806 } 6032 }
@@ -5823,39 +6049,10 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5823} 6049}
5824 6050
5825/* create playback/capture controls for input pins */ 6051/* create playback/capture controls for input pins */
5826static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 6052static int alc260_auto_create_input_ctls(struct hda_codec *codec,
5827 const struct auto_pin_cfg *cfg) 6053 const struct auto_pin_cfg *cfg)
5828{ 6054{
5829 struct hda_input_mux *imux = &spec->private_imux[0]; 6055 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
5830 int i, err, idx;
5831
5832 for (i = 0; i < AUTO_PIN_LAST; i++) {
5833 if (cfg->input_pins[i] >= 0x12) {
5834 idx = cfg->input_pins[i] - 0x12;
5835 err = new_analog_input(spec, cfg->input_pins[i],
5836 auto_pin_cfg_labels[i], idx,
5837 0x07);
5838 if (err < 0)
5839 return err;
5840 imux->items[imux->num_items].label =
5841 auto_pin_cfg_labels[i];
5842 imux->items[imux->num_items].index = idx;
5843 imux->num_items++;
5844 }
5845 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
5846 idx = cfg->input_pins[i] - 0x09;
5847 err = new_analog_input(spec, cfg->input_pins[i],
5848 auto_pin_cfg_labels[i], idx,
5849 0x07);
5850 if (err < 0)
5851 return err;
5852 imux->items[imux->num_items].label =
5853 auto_pin_cfg_labels[i];
5854 imux->items[imux->num_items].index = idx;
5855 imux->num_items++;
5856 }
5857 }
5858 return 0;
5859} 6056}
5860 6057
5861static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, 6058static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
@@ -5969,7 +6166,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5969 return err; 6166 return err;
5970 if (!spec->kctls.list) 6167 if (!spec->kctls.list)
5971 return 0; /* can't find valid BIOS pin config */ 6168 return 0; /* can't find valid BIOS pin config */
5972 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); 6169 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
5973 if (err < 0) 6170 if (err < 0)
5974 return err; 6171 return err;
5975 6172
@@ -6204,8 +6401,7 @@ static int patch_alc260(struct hda_codec *codec)
6204 alc260_models, 6401 alc260_models,
6205 alc260_cfg_tbl); 6402 alc260_cfg_tbl);
6206 if (board_config < 0) { 6403 if (board_config < 0) {
6207 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, " 6404 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6208 "trying auto-probe from BIOS...\n",
6209 codec->chip_name); 6405 codec->chip_name);
6210 board_config = ALC260_AUTO; 6406 board_config = ALC260_AUTO;
6211 } 6407 }
@@ -6231,7 +6427,7 @@ static int patch_alc260(struct hda_codec *codec)
6231 } 6427 }
6232 6428
6233 if (board_config != ALC260_AUTO) 6429 if (board_config != ALC260_AUTO)
6234 setup_preset(spec, &alc260_presets[board_config]); 6430 setup_preset(codec, &alc260_presets[board_config]);
6235 6431
6236 spec->stream_analog_playback = &alc260_pcm_analog_playback; 6432 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6237 spec->stream_analog_capture = &alc260_pcm_analog_capture; 6433 spec->stream_analog_capture = &alc260_pcm_analog_capture;
@@ -6242,7 +6438,7 @@ static int patch_alc260(struct hda_codec *codec)
6242 if (!spec->adc_nids && spec->input_mux) { 6438 if (!spec->adc_nids && spec->input_mux) {
6243 /* check whether NID 0x04 is valid */ 6439 /* check whether NID 0x04 is valid */
6244 unsigned int wcap = get_wcaps(codec, 0x04); 6440 unsigned int wcap = get_wcaps(codec, 0x04);
6245 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 6441 wcap = get_wcaps_type(wcap);
6246 /* get type */ 6442 /* get type */
6247 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) {
6248 spec->adc_nids = alc260_adc_nids_alt; 6444 spec->adc_nids = alc260_adc_nids_alt;
@@ -6252,7 +6448,7 @@ static int patch_alc260(struct hda_codec *codec)
6252 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 6448 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6253 } 6449 }
6254 } 6450 }
6255 set_capture_mixer(spec); 6451 set_capture_mixer(codec);
6256 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); 6452 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
6257 6453
6258 spec->vmaster_nid = 0x08; 6454 spec->vmaster_nid = 0x08;
@@ -6271,7 +6467,7 @@ static int patch_alc260(struct hda_codec *codec)
6271 6467
6272 6468
6273/* 6469/*
6274 * ALC882 support 6470 * ALC882/883/885/888/889 support
6275 * 6471 *
6276 * 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
6277 * 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.
@@ -6283,22 +6479,35 @@ static int patch_alc260(struct hda_codec *codec)
6283 */ 6479 */
6284#define ALC882_DIGOUT_NID 0x06 6480#define ALC882_DIGOUT_NID 0x06
6285#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
6286 6486
6287static struct hda_channel_mode alc882_ch_modes[1] = { 6487static struct hda_channel_mode alc882_ch_modes[1] = {
6288 { 8, NULL } 6488 { 8, NULL }
6289}; 6489};
6290 6490
6491/* DACs */
6291static hda_nid_t alc882_dac_nids[4] = { 6492static hda_nid_t alc882_dac_nids[4] = {
6292 /* front, rear, clfe, rear_surr */ 6493 /* front, rear, clfe, rear_surr */
6293 0x02, 0x03, 0x04, 0x05 6494 0x02, 0x03, 0x04, 0x05
6294}; 6495};
6496#define alc883_dac_nids alc882_dac_nids
6295 6497
6296/* identical with ALC880 */ 6498/* ADCs */
6297#define alc882_adc_nids alc880_adc_nids 6499#define alc882_adc_nids alc880_adc_nids
6298#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
6299 6505
6300static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; 6506static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6301static 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
6302 6511
6303/* input MUX */ 6512/* input MUX */
6304/* FIXME: should be a matrix-type input source selection */ 6513/* FIXME: should be a matrix-type input source selection */
@@ -6313,6 +6522,17 @@ static struct hda_input_mux alc882_capture_source = {
6313 }, 6522 },
6314}; 6523};
6315 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
6316static struct hda_input_mux mb5_capture_source = { 6536static struct hda_input_mux mb5_capture_source = {
6317 .num_items = 3, 6537 .num_items = 3,
6318 .items = { 6538 .items = {
@@ -6322,6 +6542,77 @@ static struct hda_input_mux mb5_capture_source = {
6322 }, 6542 },
6323}; 6543};
6324 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
6325/* 6616/*
6326 * 2ch mode 6617 * 2ch mode
6327 */ 6618 */
@@ -6334,6 +6625,18 @@ static struct hda_verb alc882_3ST_ch2_init[] = {
6334}; 6625};
6335 6626
6336/* 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/*
6337 * 6ch mode 6640 * 6ch mode
6338 */ 6641 */
6339static struct hda_verb alc882_3ST_ch6_init[] = { 6642static struct hda_verb alc882_3ST_ch6_init[] = {
@@ -6346,11 +6649,60 @@ static struct hda_verb alc882_3ST_ch6_init[] = {
6346 { } /* end */ 6649 { } /* end */
6347}; 6650};
6348 6651
6349static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { 6652static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
6350 { 2, alc882_3ST_ch2_init }, 6653 { 2, alc882_3ST_ch2_init },
6654 { 4, alc882_3ST_ch4_init },
6351 { 6, alc882_3ST_ch6_init }, 6655 { 6, alc882_3ST_ch6_init },
6352}; 6656};
6353 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
6354/* 6706/*
6355 * 6ch mode 6707 * 6ch mode
6356 */ 6708 */
@@ -6393,9 +6745,9 @@ static struct hda_verb alc885_mbp_ch2_init[] = {
6393}; 6745};
6394 6746
6395/* 6747/*
6396 * 6ch mode 6748 * 4ch mode
6397 */ 6749 */
6398static struct hda_verb alc885_mbp_ch6_init[] = { 6750static struct hda_verb alc885_mbp_ch4_init[] = {
6399 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6400 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 6752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6401 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 6753 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
@@ -6404,9 +6756,9 @@ static struct hda_verb alc885_mbp_ch6_init[] = {
6404 { } /* end */ 6756 { } /* end */
6405}; 6757};
6406 6758
6407static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { 6759static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
6408 { 2, alc885_mbp_ch2_init }, 6760 { 2, alc885_mbp_ch2_init },
6409 { 6, alc885_mbp_ch6_init }, 6761 { 4, alc885_mbp_ch4_init },
6410}; 6762};
6411 6763
6412/* 6764/*
@@ -6438,6 +6790,189 @@ static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6438 { 6, alc885_mb5_ch6_init }, 6790 { 6, alc885_mb5_ch6_init },
6439}; 6791};
6440 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
6441/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 6976/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6442 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 6977 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6443 */ 6978 */
@@ -6467,10 +7002,11 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
6467}; 7002};
6468 7003
6469static struct snd_kcontrol_new alc885_mbp3_mixer[] = { 7004static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
6470 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 7005 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6471 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), 7006 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
6472 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), 7007 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6473 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),
6474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6475 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7011 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), 7012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
@@ -6573,7 +7109,7 @@ static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6573 { } /* end */ 7109 { } /* end */
6574}; 7110};
6575 7111
6576static struct hda_verb alc882_init_verbs[] = { 7112static struct hda_verb alc882_base_init_verbs[] = {
6577 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 7113 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
@@ -6591,6 +7127,13 @@ static struct hda_verb alc882_init_verbs[] = {
6591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7127 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7128 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6593 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
6594 /* Front Pin: output 0 (0x0c) */ 7137 /* Front Pin: output 0 (0x0c) */
6595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7139 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -6625,11 +7168,6 @@ static struct hda_verb alc882_init_verbs[] = {
6625 7168
6626 /* FIXME: use matrix-type input source selection */ 7169 /* FIXME: use matrix-type input source selection */
6627 /* 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 */
6628 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6630 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6631 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6632 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6633 /* Input mixer2 */ 7171 /* Input mixer2 */
6634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
@@ -6640,9 +7178,6 @@ static struct hda_verb alc882_init_verbs[] = {
6640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6642 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 7180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6643 /* ADC1: mute amp left and right */
6644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6645 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6646 /* ADC2: mute amp left and right */ 7181 /* ADC2: mute amp left and right */
6647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6648 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7183 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -6653,6 +7188,18 @@ static struct hda_verb alc882_init_verbs[] = {
6653 { } 7188 { }
6654}; 7189};
6655 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
6656static struct hda_verb alc882_eapd_verbs[] = { 7203static struct hda_verb alc882_eapd_verbs[] = {
6657 /* change to EAPD mode */ 7204 /* change to EAPD mode */
6658 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 7205 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
@@ -6660,6 +7207,110 @@ static struct hda_verb alc882_eapd_verbs[] = {
6660 { } 7207 { }
6661}; 7208};
6662 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
6663/* Mac Pro test */ 7314/* Mac Pro test */
6664static struct snd_kcontrol_new alc882_macpro_mixer[] = { 7315static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6665 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -6784,14 +7435,18 @@ static struct hda_verb alc885_mbp3_init_verbs[] = {
6784 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7435 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6786 {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)},
6787 /* Front Pin: output 0 (0x0c) */ 7442 /* Front Pin: output 0 (0x0c) */
6788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6790 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 7445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6791 /* HP Pin: output 0 (0x0d) */ 7446 /* HP Pin: output 0 (0x0e) */
6792 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, 7447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
6795 {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},
6796 /* Mic (rear) pin: input vref at 80% */ 7451 /* Mic (rear) pin: input vref at 80% */
6797 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 7452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
@@ -6863,23 +7518,21 @@ static struct hda_verb alc885_imac24_init_verbs[] = {
6863}; 7518};
6864 7519
6865/* Toggle speaker-output according to the hp-jack state */ 7520/* Toggle speaker-output according to the hp-jack state */
6866static void alc885_imac24_automute_init_hook(struct hda_codec *codec) 7521static void alc885_imac24_setup(struct hda_codec *codec)
6867{ 7522{
6868 struct alc_spec *spec = codec->spec; 7523 struct alc_spec *spec = codec->spec;
6869 7524
6870 spec->autocfg.hp_pins[0] = 0x14; 7525 spec->autocfg.hp_pins[0] = 0x14;
6871 spec->autocfg.speaker_pins[0] = 0x18; 7526 spec->autocfg.speaker_pins[0] = 0x18;
6872 spec->autocfg.speaker_pins[1] = 0x1a; 7527 spec->autocfg.speaker_pins[1] = 0x1a;
6873 alc_automute_amp(codec);
6874} 7528}
6875 7529
6876static void alc885_mbp3_init_hook(struct hda_codec *codec) 7530static void alc885_mbp3_setup(struct hda_codec *codec)
6877{ 7531{
6878 struct alc_spec *spec = codec->spec; 7532 struct alc_spec *spec = codec->spec;
6879 7533
6880 spec->autocfg.hp_pins[0] = 0x15; 7534 spec->autocfg.hp_pins[0] = 0x15;
6881 spec->autocfg.speaker_pins[0] = 0x14; 7535 spec->autocfg.speaker_pins[0] = 0x14;
6882 alc_automute_amp(codec);
6883} 7536}
6884 7537
6885 7538
@@ -6895,9 +7548,6 @@ static struct hda_verb alc882_targa_verbs[] = {
6895 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 7548 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6896 7549
6897 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6898 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6899 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6900 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6901 { } /* end */ 7551 { } /* end */
6902}; 7552};
6903 7553
@@ -6910,13 +7560,12 @@ static void alc882_targa_automute(struct hda_codec *codec)
6910 spec->jack_present ? 1 : 3); 7560 spec->jack_present ? 1 : 3);
6911} 7561}
6912 7562
6913static void alc882_targa_init_hook(struct hda_codec *codec) 7563static void alc882_targa_setup(struct hda_codec *codec)
6914{ 7564{
6915 struct alc_spec *spec = codec->spec; 7565 struct alc_spec *spec = codec->spec;
6916 7566
6917 spec->autocfg.hp_pins[0] = 0x14; 7567 spec->autocfg.hp_pins[0] = 0x14;
6918 spec->autocfg.speaker_pins[0] = 0x1b; 7568 spec->autocfg.speaker_pins[0] = 0x1b;
6919 alc882_targa_automute(codec);
6920} 7569}
6921 7570
6922static 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)
@@ -7004,18 +7653,16 @@ static void alc885_macpro_init_hook(struct hda_codec *codec)
7004static void alc885_imac24_init_hook(struct hda_codec *codec) 7653static void alc885_imac24_init_hook(struct hda_codec *codec)
7005{ 7654{
7006 alc885_macpro_init_hook(codec); 7655 alc885_macpro_init_hook(codec);
7007 alc885_imac24_automute_init_hook(codec); 7656 alc_automute_amp(codec);
7008} 7657}
7009 7658
7010/* 7659/*
7011 * generic initialization of ADC, input mixers and output mixers 7660 * generic initialization of ADC, input mixers and output mixers
7012 */ 7661 */
7013static struct hda_verb alc882_auto_init_verbs[] = { 7662static struct hda_verb alc883_auto_init_verbs[] = {
7014 /* 7663 /*
7015 * Unmute ADC0-2 and set the default input to mic-in 7664 * Unmute ADC0-2 and set the default input to mic-in
7016 */ 7665 */
7017 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7019 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7666 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7020 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 7668 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -7056,11 +7703,6 @@ static struct hda_verb alc882_auto_init_verbs[] = {
7056 7703
7057 /* FIXME: use matrix-type input source selection */ 7704 /* FIXME: use matrix-type input source selection */
7058 /* 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 */
7059 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7064 /* Input mixer2 */ 7706 /* Input mixer2 */
7065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 7707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 7708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
@@ -7075,819 +7717,6 @@ static struct hda_verb alc882_auto_init_verbs[] = {
7075 { } 7717 { }
7076}; 7718};
7077 7719
7078#ifdef CONFIG_SND_HDA_POWER_SAVE
7079#define alc882_loopbacks alc880_loopbacks
7080#endif
7081
7082/* pcm configuration: identical with ALC880 */
7083#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7084#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7085#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7086#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7087
7088/*
7089 * configuration and preset
7090 */
7091static const char *alc882_models[ALC882_MODEL_LAST] = {
7092 [ALC882_3ST_DIG] = "3stack-dig",
7093 [ALC882_6ST_DIG] = "6stack-dig",
7094 [ALC882_ARIMA] = "arima",
7095 [ALC882_W2JC] = "w2jc",
7096 [ALC882_TARGA] = "targa",
7097 [ALC882_ASUS_A7J] = "asus-a7j",
7098 [ALC882_ASUS_A7M] = "asus-a7m",
7099 [ALC885_MACPRO] = "macpro",
7100 [ALC885_MB5] = "mb5",
7101 [ALC885_MBP3] = "mbp3",
7102 [ALC885_IMAC24] = "imac24",
7103 [ALC882_AUTO] = "auto",
7104};
7105
7106static struct snd_pci_quirk alc882_cfg_tbl[] = {
7107 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
7108 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
7109 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
7110 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
7111 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
7112 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
7113 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
7114 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
7115 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
7116 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7117 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7118 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
7119 {}
7120};
7121
7122static struct alc_config_preset alc882_presets[] = {
7123 [ALC882_3ST_DIG] = {
7124 .mixers = { alc882_base_mixer },
7125 .init_verbs = { alc882_init_verbs },
7126 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7127 .dac_nids = alc882_dac_nids,
7128 .dig_out_nid = ALC882_DIGOUT_NID,
7129 .dig_in_nid = ALC882_DIGIN_NID,
7130 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7131 .channel_mode = alc882_ch_modes,
7132 .need_dac_fix = 1,
7133 .input_mux = &alc882_capture_source,
7134 },
7135 [ALC882_6ST_DIG] = {
7136 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7137 .init_verbs = { alc882_init_verbs },
7138 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7139 .dac_nids = alc882_dac_nids,
7140 .dig_out_nid = ALC882_DIGOUT_NID,
7141 .dig_in_nid = ALC882_DIGIN_NID,
7142 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7143 .channel_mode = alc882_sixstack_modes,
7144 .input_mux = &alc882_capture_source,
7145 },
7146 [ALC882_ARIMA] = {
7147 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7148 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7149 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7150 .dac_nids = alc882_dac_nids,
7151 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7152 .channel_mode = alc882_sixstack_modes,
7153 .input_mux = &alc882_capture_source,
7154 },
7155 [ALC882_W2JC] = {
7156 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7157 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7158 alc880_gpio1_init_verbs },
7159 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7160 .dac_nids = alc882_dac_nids,
7161 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7162 .channel_mode = alc880_threestack_modes,
7163 .need_dac_fix = 1,
7164 .input_mux = &alc882_capture_source,
7165 .dig_out_nid = ALC882_DIGOUT_NID,
7166 },
7167 [ALC885_MBP3] = {
7168 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7169 .init_verbs = { alc885_mbp3_init_verbs,
7170 alc880_gpio1_init_verbs },
7171 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7172 .dac_nids = alc882_dac_nids,
7173 .channel_mode = alc885_mbp_6ch_modes,
7174 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7175 .input_mux = &alc882_capture_source,
7176 .dig_out_nid = ALC882_DIGOUT_NID,
7177 .dig_in_nid = ALC882_DIGIN_NID,
7178 .unsol_event = alc_automute_amp_unsol_event,
7179 .init_hook = alc885_mbp3_init_hook,
7180 },
7181 [ALC885_MB5] = {
7182 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
7183 .init_verbs = { alc885_mb5_init_verbs,
7184 alc880_gpio1_init_verbs },
7185 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7186 .dac_nids = alc882_dac_nids,
7187 .channel_mode = alc885_mb5_6ch_modes,
7188 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
7189 .input_mux = &mb5_capture_source,
7190 .dig_out_nid = ALC882_DIGOUT_NID,
7191 .dig_in_nid = ALC882_DIGIN_NID,
7192 },
7193 [ALC885_MACPRO] = {
7194 .mixers = { alc882_macpro_mixer },
7195 .init_verbs = { alc882_macpro_init_verbs },
7196 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7197 .dac_nids = alc882_dac_nids,
7198 .dig_out_nid = ALC882_DIGOUT_NID,
7199 .dig_in_nid = ALC882_DIGIN_NID,
7200 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7201 .channel_mode = alc882_ch_modes,
7202 .input_mux = &alc882_capture_source,
7203 .init_hook = alc885_macpro_init_hook,
7204 },
7205 [ALC885_IMAC24] = {
7206 .mixers = { alc885_imac24_mixer },
7207 .init_verbs = { alc885_imac24_init_verbs },
7208 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7209 .dac_nids = alc882_dac_nids,
7210 .dig_out_nid = ALC882_DIGOUT_NID,
7211 .dig_in_nid = ALC882_DIGIN_NID,
7212 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7213 .channel_mode = alc882_ch_modes,
7214 .input_mux = &alc882_capture_source,
7215 .unsol_event = alc_automute_amp_unsol_event,
7216 .init_hook = alc885_imac24_init_hook,
7217 },
7218 [ALC882_TARGA] = {
7219 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
7220 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7221 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7222 .dac_nids = alc882_dac_nids,
7223 .dig_out_nid = ALC882_DIGOUT_NID,
7224 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7225 .adc_nids = alc882_adc_nids,
7226 .capsrc_nids = alc882_capsrc_nids,
7227 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7228 .channel_mode = alc882_3ST_6ch_modes,
7229 .need_dac_fix = 1,
7230 .input_mux = &alc882_capture_source,
7231 .unsol_event = alc882_targa_unsol_event,
7232 .init_hook = alc882_targa_init_hook,
7233 },
7234 [ALC882_ASUS_A7J] = {
7235 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
7236 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7237 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7238 .dac_nids = alc882_dac_nids,
7239 .dig_out_nid = ALC882_DIGOUT_NID,
7240 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7241 .adc_nids = alc882_adc_nids,
7242 .capsrc_nids = alc882_capsrc_nids,
7243 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7244 .channel_mode = alc882_3ST_6ch_modes,
7245 .need_dac_fix = 1,
7246 .input_mux = &alc882_capture_source,
7247 },
7248 [ALC882_ASUS_A7M] = {
7249 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7250 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7251 alc880_gpio1_init_verbs,
7252 alc882_asus_a7m_verbs },
7253 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7254 .dac_nids = alc882_dac_nids,
7255 .dig_out_nid = ALC882_DIGOUT_NID,
7256 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7257 .channel_mode = alc880_threestack_modes,
7258 .need_dac_fix = 1,
7259 .input_mux = &alc882_capture_source,
7260 },
7261};
7262
7263
7264/*
7265 * Pin config fixes
7266 */
7267enum {
7268 PINFIX_ABIT_AW9D_MAX
7269};
7270
7271static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7272 { 0x15, 0x01080104 }, /* side */
7273 { 0x16, 0x01011012 }, /* rear */
7274 { 0x17, 0x01016011 }, /* clfe */
7275 { }
7276};
7277
7278static const struct alc_pincfg *alc882_pin_fixes[] = {
7279 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7280};
7281
7282static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7283 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7284 {}
7285};
7286
7287/*
7288 * BIOS auto configuration
7289 */
7290static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7291 hda_nid_t nid, int pin_type,
7292 int dac_idx)
7293{
7294 /* set as output */
7295 struct alc_spec *spec = codec->spec;
7296 int idx;
7297
7298 alc_set_pin_output(codec, nid, pin_type);
7299 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7300 idx = 4;
7301 else
7302 idx = spec->multiout.dac_nids[dac_idx] - 2;
7303 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7304
7305}
7306
7307static void alc882_auto_init_multi_out(struct hda_codec *codec)
7308{
7309 struct alc_spec *spec = codec->spec;
7310 int i;
7311
7312 for (i = 0; i <= HDA_SIDE; i++) {
7313 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7314 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7315 if (nid)
7316 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
7317 i);
7318 }
7319}
7320
7321static void alc882_auto_init_hp_out(struct hda_codec *codec)
7322{
7323 struct alc_spec *spec = codec->spec;
7324 hda_nid_t pin;
7325
7326 pin = spec->autocfg.hp_pins[0];
7327 if (pin) /* connect to front */
7328 /* use dac 0 */
7329 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7330 pin = spec->autocfg.speaker_pins[0];
7331 if (pin)
7332 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
7333}
7334
7335#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7336#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7337
7338static void alc882_auto_init_analog_input(struct hda_codec *codec)
7339{
7340 struct alc_spec *spec = codec->spec;
7341 int i;
7342
7343 for (i = 0; i < AUTO_PIN_LAST; i++) {
7344 hda_nid_t nid = spec->autocfg.input_pins[i];
7345 if (!nid)
7346 continue;
7347 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
7348 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7349 snd_hda_codec_write(codec, nid, 0,
7350 AC_VERB_SET_AMP_GAIN_MUTE,
7351 AMP_OUT_MUTE);
7352 }
7353}
7354
7355static void alc882_auto_init_input_src(struct hda_codec *codec)
7356{
7357 struct alc_spec *spec = codec->spec;
7358 int c;
7359
7360 for (c = 0; c < spec->num_adc_nids; c++) {
7361 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7362 hda_nid_t nid = spec->capsrc_nids[c];
7363 unsigned int mux_idx;
7364 const struct hda_input_mux *imux;
7365 int conns, mute, idx, item;
7366
7367 conns = snd_hda_get_connections(codec, nid, conn_list,
7368 ARRAY_SIZE(conn_list));
7369 if (conns < 0)
7370 continue;
7371 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7372 imux = &spec->input_mux[mux_idx];
7373 for (idx = 0; idx < conns; idx++) {
7374 /* if the current connection is the selected one,
7375 * unmute it as default - otherwise mute it
7376 */
7377 mute = AMP_IN_MUTE(idx);
7378 for (item = 0; item < imux->num_items; item++) {
7379 if (imux->items[item].index == idx) {
7380 if (spec->cur_mux[c] == item)
7381 mute = AMP_IN_UNMUTE(idx);
7382 break;
7383 }
7384 }
7385 /* check if we have a selector or mixer
7386 * we could check for the widget type instead, but
7387 * just check for Amp-In presence (in case of mixer
7388 * without amp-in there is something wrong, this
7389 * function shouldn't be used or capsrc nid is wrong)
7390 */
7391 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7392 snd_hda_codec_write(codec, nid, 0,
7393 AC_VERB_SET_AMP_GAIN_MUTE,
7394 mute);
7395 else if (mute != AMP_IN_MUTE(idx))
7396 snd_hda_codec_write(codec, nid, 0,
7397 AC_VERB_SET_CONNECT_SEL,
7398 idx);
7399 }
7400 }
7401}
7402
7403/* add mic boosts if needed */
7404static int alc_auto_add_mic_boost(struct hda_codec *codec)
7405{
7406 struct alc_spec *spec = codec->spec;
7407 int err;
7408 hda_nid_t nid;
7409
7410 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
7411 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
7412 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7413 "Mic Boost",
7414 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7415 if (err < 0)
7416 return err;
7417 }
7418 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
7419 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
7420 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7421 "Front Mic Boost",
7422 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7423 if (err < 0)
7424 return err;
7425 }
7426 return 0;
7427}
7428
7429/* almost identical with ALC880 parser... */
7430static int alc882_parse_auto_config(struct hda_codec *codec)
7431{
7432 struct alc_spec *spec = codec->spec;
7433 int err = alc880_parse_auto_config(codec);
7434
7435 if (err < 0)
7436 return err;
7437 else if (!err)
7438 return 0; /* no config found */
7439
7440 err = alc_auto_add_mic_boost(codec);
7441 if (err < 0)
7442 return err;
7443
7444 /* hack - override the init verbs */
7445 spec->init_verbs[0] = alc882_auto_init_verbs;
7446
7447 return 1; /* config found */
7448}
7449
7450/* additional initialization for auto-configuration model */
7451static void alc882_auto_init(struct hda_codec *codec)
7452{
7453 struct alc_spec *spec = codec->spec;
7454 alc882_auto_init_multi_out(codec);
7455 alc882_auto_init_hp_out(codec);
7456 alc882_auto_init_analog_input(codec);
7457 alc882_auto_init_input_src(codec);
7458 if (spec->unsol_event)
7459 alc_inithook(codec);
7460}
7461
7462static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7463
7464static int patch_alc882(struct hda_codec *codec)
7465{
7466 struct alc_spec *spec;
7467 int err, board_config;
7468
7469 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7470 if (spec == NULL)
7471 return -ENOMEM;
7472
7473 codec->spec = spec;
7474
7475 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7476 alc882_models,
7477 alc882_cfg_tbl);
7478
7479 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
7480 /* Pick up systems that don't supply PCI SSID */
7481 switch (codec->subsystem_id) {
7482 case 0x106b0c00: /* Mac Pro */
7483 board_config = ALC885_MACPRO;
7484 break;
7485 case 0x106b1000: /* iMac 24 */
7486 case 0x106b2800: /* AppleTV */
7487 case 0x106b3e00: /* iMac 24 Aluminium */
7488 board_config = ALC885_IMAC24;
7489 break;
7490 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
7491 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
7492 case 0x106b00a4: /* MacbookPro4,1 */
7493 case 0x106b2c00: /* Macbook Pro rev3 */
7494 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
7495 case 0x106b3800: /* MacbookPro4,1 - latter revision */
7496 board_config = ALC885_MBP3;
7497 break;
7498 case 0x106b3f00: /* Macbook 5,1 */
7499 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7500 * seems not working, so apparently
7501 * no perfect solution yet
7502 */
7503 board_config = ALC885_MB5;
7504 break;
7505 default:
7506 /* ALC889A is handled better as ALC888-compatible */
7507 if (codec->revision_id == 0x100101 ||
7508 codec->revision_id == 0x100103) {
7509 alc_free(codec);
7510 return patch_alc883(codec);
7511 }
7512 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7513 "trying auto-probe from BIOS...\n",
7514 codec->chip_name);
7515 board_config = ALC882_AUTO;
7516 }
7517 }
7518
7519 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7520
7521 if (board_config == ALC882_AUTO) {
7522 /* automatic parse from the BIOS config */
7523 err = alc882_parse_auto_config(codec);
7524 if (err < 0) {
7525 alc_free(codec);
7526 return err;
7527 } else if (!err) {
7528 printk(KERN_INFO
7529 "hda_codec: Cannot set up configuration "
7530 "from BIOS. Using base mode...\n");
7531 board_config = ALC882_3ST_DIG;
7532 }
7533 }
7534
7535 err = snd_hda_attach_beep_device(codec, 0x1);
7536 if (err < 0) {
7537 alc_free(codec);
7538 return err;
7539 }
7540
7541 if (board_config != ALC882_AUTO)
7542 setup_preset(spec, &alc882_presets[board_config]);
7543
7544 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7545 spec->stream_analog_capture = &alc882_pcm_analog_capture;
7546 /* FIXME: setup DAC5 */
7547 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7548 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
7549
7550 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7551 spec->stream_digital_capture = &alc882_pcm_digital_capture;
7552
7553 if (!spec->adc_nids && spec->input_mux) {
7554 /* check whether NID 0x07 is valid */
7555 unsigned int wcap = get_wcaps(codec, 0x07);
7556 /* get type */
7557 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
7558 if (wcap != AC_WID_AUD_IN) {
7559 spec->adc_nids = alc882_adc_nids_alt;
7560 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
7561 spec->capsrc_nids = alc882_capsrc_nids_alt;
7562 } else {
7563 spec->adc_nids = alc882_adc_nids;
7564 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
7565 spec->capsrc_nids = alc882_capsrc_nids;
7566 }
7567 }
7568 set_capture_mixer(spec);
7569 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
7570
7571 spec->vmaster_nid = 0x0c;
7572
7573 codec->patch_ops = alc_patch_ops;
7574 if (board_config == ALC882_AUTO)
7575 spec->init_hook = alc882_auto_init;
7576#ifdef CONFIG_SND_HDA_POWER_SAVE
7577 if (!spec->loopback.amplist)
7578 spec->loopback.amplist = alc882_loopbacks;
7579#endif
7580 codec->proc_widget_hook = print_realtek_coef;
7581
7582 return 0;
7583}
7584
7585/*
7586 * ALC883 support
7587 *
7588 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7589 * configuration. Each pin widget can choose any input DACs and a mixer.
7590 * Each ADC is connected from a mixer of all inputs. This makes possible
7591 * 6-channel independent captures.
7592 *
7593 * In addition, an independent DAC for the multi-playback (not used in this
7594 * driver yet).
7595 */
7596#define ALC883_DIGOUT_NID 0x06
7597#define ALC883_DIGIN_NID 0x0a
7598
7599#define ALC1200_DIGOUT_NID 0x10
7600
7601static hda_nid_t alc883_dac_nids[4] = {
7602 /* front, rear, clfe, rear_surr */
7603 0x02, 0x03, 0x04, 0x05
7604};
7605
7606static hda_nid_t alc883_adc_nids[2] = {
7607 /* ADC1-2 */
7608 0x08, 0x09,
7609};
7610
7611static hda_nid_t alc883_adc_nids_alt[1] = {
7612 /* ADC1 */
7613 0x08,
7614};
7615
7616static hda_nid_t alc883_adc_nids_rev[2] = {
7617 /* ADC2-1 */
7618 0x09, 0x08
7619};
7620
7621#define alc889_adc_nids alc880_adc_nids
7622
7623static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7624
7625static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7626
7627#define alc889_capsrc_nids alc882_capsrc_nids
7628
7629/* input MUX */
7630/* FIXME: should be a matrix-type input source selection */
7631
7632static struct hda_input_mux alc883_capture_source = {
7633 .num_items = 4,
7634 .items = {
7635 { "Mic", 0x0 },
7636 { "Front Mic", 0x1 },
7637 { "Line", 0x2 },
7638 { "CD", 0x4 },
7639 },
7640};
7641
7642static struct hda_input_mux alc883_3stack_6ch_intel = {
7643 .num_items = 4,
7644 .items = {
7645 { "Mic", 0x1 },
7646 { "Front Mic", 0x0 },
7647 { "Line", 0x2 },
7648 { "CD", 0x4 },
7649 },
7650};
7651
7652static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7653 .num_items = 2,
7654 .items = {
7655 { "Mic", 0x1 },
7656 { "Line", 0x2 },
7657 },
7658};
7659
7660static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7661 .num_items = 4,
7662 .items = {
7663 { "Mic", 0x0 },
7664 { "iMic", 0x1 },
7665 { "Line", 0x2 },
7666 { "CD", 0x4 },
7667 },
7668};
7669
7670static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7671 .num_items = 2,
7672 .items = {
7673 { "Mic", 0x0 },
7674 { "Int Mic", 0x1 },
7675 },
7676};
7677
7678static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7679 .num_items = 3,
7680 .items = {
7681 { "Mic", 0x0 },
7682 { "Front Mic", 0x1 },
7683 { "Line", 0x4 },
7684 },
7685};
7686
7687static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7688 .num_items = 2,
7689 .items = {
7690 { "Mic", 0x0 },
7691 { "Line", 0x2 },
7692 },
7693};
7694
7695static struct hda_input_mux alc889A_mb31_capture_source = {
7696 .num_items = 2,
7697 .items = {
7698 { "Mic", 0x0 },
7699 /* Front Mic (0x01) unused */
7700 { "Line", 0x2 },
7701 /* Line 2 (0x03) unused */
7702 /* CD (0x04) unsused? */
7703 },
7704};
7705
7706/*
7707 * 2ch mode
7708 */
7709static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7710 { 2, NULL }
7711};
7712
7713/*
7714 * 2ch mode
7715 */
7716static struct hda_verb alc883_3ST_ch2_init[] = {
7717 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7718 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7719 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7720 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7721 { } /* end */
7722};
7723
7724/*
7725 * 4ch mode
7726 */
7727static struct hda_verb alc883_3ST_ch4_init[] = {
7728 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7729 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7730 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7731 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7732 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7733 { } /* end */
7734};
7735
7736/*
7737 * 6ch mode
7738 */
7739static struct hda_verb alc883_3ST_ch6_init[] = {
7740 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7741 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7742 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7743 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7744 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7745 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7746 { } /* end */
7747};
7748
7749static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
7750 { 2, alc883_3ST_ch2_init },
7751 { 4, alc883_3ST_ch4_init },
7752 { 6, alc883_3ST_ch6_init },
7753};
7754
7755
7756/*
7757 * 2ch mode
7758 */
7759static struct hda_verb alc883_4ST_ch2_init[] = {
7760 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7761 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7762 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7763 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7764 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7765 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7766 { } /* end */
7767};
7768
7769/*
7770 * 4ch mode
7771 */
7772static struct hda_verb alc883_4ST_ch4_init[] = {
7773 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7774 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7775 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7776 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7777 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7778 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7779 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7780 { } /* end */
7781};
7782
7783/*
7784 * 6ch mode
7785 */
7786static struct hda_verb alc883_4ST_ch6_init[] = {
7787 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7788 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7789 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7790 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7791 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7792 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7793 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7794 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7795 { } /* end */
7796};
7797
7798/*
7799 * 8ch mode
7800 */
7801static struct hda_verb alc883_4ST_ch8_init[] = {
7802 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7803 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7804 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7805 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7806 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7807 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7808 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7809 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7810 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7811 { } /* end */
7812};
7813
7814static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7815 { 2, alc883_4ST_ch2_init },
7816 { 4, alc883_4ST_ch4_init },
7817 { 6, alc883_4ST_ch6_init },
7818 { 8, alc883_4ST_ch8_init },
7819};
7820
7821
7822/*
7823 * 2ch mode
7824 */
7825static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7826 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7827 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7828 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7829 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7830 { } /* end */
7831};
7832
7833/*
7834 * 4ch mode
7835 */
7836static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7837 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7838 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7839 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7840 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7841 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7842 { } /* end */
7843};
7844
7845/*
7846 * 6ch mode
7847 */
7848static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7849 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7850 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7851 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7854 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7855 { } /* end */
7856};
7857
7858static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7859 { 2, alc883_3ST_ch2_intel_init },
7860 { 4, alc883_3ST_ch4_intel_init },
7861 { 6, alc883_3ST_ch6_intel_init },
7862};
7863
7864/*
7865 * 6ch mode
7866 */
7867static struct hda_verb alc883_sixstack_ch6_init[] = {
7868 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7869 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7870 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7871 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7872 { } /* end */
7873};
7874
7875/*
7876 * 8ch mode
7877 */
7878static struct hda_verb alc883_sixstack_ch8_init[] = {
7879 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7880 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7881 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7882 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7883 { } /* end */
7884};
7885
7886static struct hda_channel_mode alc883_sixstack_modes[2] = {
7887 { 6, alc883_sixstack_ch6_init },
7888 { 8, alc883_sixstack_ch8_init },
7889};
7890
7891/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */ 7720/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7892static struct hda_verb alc889A_mb31_ch2_init[] = { 7721static struct hda_verb alc889A_mb31_ch2_init[] = {
7893 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ 7722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
@@ -7938,34 +7767,7 @@ static struct hda_verb alc883_medion_eapd_verbs[] = {
7938 { } 7767 { }
7939}; 7768};
7940 7769
7941/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 7770#define alc883_base_mixer alc882_base_mixer
7942 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7943 */
7944
7945static struct snd_kcontrol_new alc883_base_mixer[] = {
7946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7949 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7950 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7952 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7953 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7955 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7957 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7958 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7960 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7963 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7964 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7965 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7966 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7967 { } /* end */
7968};
7969 7771
7970static struct snd_kcontrol_new alc883_mitac_mixer[] = { 7772static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7773 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -8076,6 +7878,30 @@ static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8076 { } /* end */ 7878 { } /* end */
8077}; 7879};
8078 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
8079static struct snd_kcontrol_new alc883_fivestack_mixer[] = { 7905static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
8080 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8081 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -8101,8 +7927,9 @@ static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
8101 7927
8102static struct snd_kcontrol_new alc883_targa_mixer[] = { 7928static struct snd_kcontrol_new alc883_targa_mixer[] = {
8103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7930 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8104 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8105 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7932 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8106 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7933 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8107 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7934 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8108 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 7935 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
@@ -8121,8 +7948,9 @@ static struct snd_kcontrol_new alc883_targa_mixer[] = {
8121 7948
8122static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = { 7949static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
8123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7950 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7951 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7952 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8125 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7953 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7954 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7955 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
@@ -8134,6 +7962,15 @@ static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
8134 { } /* end */ 7962 { } /* end */
8135}; 7963};
8136 7964
7965static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
7966 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7967 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7968 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7969 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7970 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7971 { } /* end */
7972};
7973
8137static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { 7974static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7975 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7976 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -8189,6 +8026,8 @@ static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 8026 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8190 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 8027 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8191 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT), 8028 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8029 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8030 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8031 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8032 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
@@ -8314,93 +8153,14 @@ static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8314 { } /* end */ 8153 { } /* end */
8315}; 8154};
8316 8155
8317static struct hda_verb alc883_init_verbs[] = {
8318 /* ADC1: mute amp left and right */
8319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8320 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8321 /* ADC2: mute amp left and right */
8322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8323 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8324 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8328 /* Rear mixer */
8329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8330 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8332 /* CLFE mixer */
8333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8336 /* Side mixer */
8337 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8340
8341 /* mute analog input loopbacks */
8342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8347
8348 /* Front Pin: output 0 (0x0c) */
8349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8352 /* Rear Pin: output 1 (0x0d) */
8353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8356 /* CLFE Pin: output 2 (0x0e) */
8357 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8358 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8359 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8360 /* Side Pin: output 3 (0x0f) */
8361 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8362 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8364 /* Mic (rear) pin: input vref at 80% */
8365 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8367 /* Front Mic pin: input vref at 80% */
8368 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8369 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8370 /* Line In pin: input */
8371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8373 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8374 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8375 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8376 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8377 /* CD pin widget for input */
8378 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8379
8380 /* FIXME: use matrix-type input source selection */
8381 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8382 /* Input mixer2 */
8383 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8386 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8387 /* Input mixer3 */
8388 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8389 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8391 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8392 { }
8393};
8394
8395/* toggle speaker-output according to the hp-jack state */ 8156/* toggle speaker-output according to the hp-jack state */
8396static void alc883_mitac_init_hook(struct hda_codec *codec) 8157static void alc883_mitac_setup(struct hda_codec *codec)
8397{ 8158{
8398 struct alc_spec *spec = codec->spec; 8159 struct alc_spec *spec = codec->spec;
8399 8160
8400 spec->autocfg.hp_pins[0] = 0x15; 8161 spec->autocfg.hp_pins[0] = 0x15;
8401 spec->autocfg.speaker_pins[0] = 0x14; 8162 spec->autocfg.speaker_pins[0] = 0x14;
8402 spec->autocfg.speaker_pins[1] = 0x17; 8163 spec->autocfg.speaker_pins[1] = 0x17;
8403 alc_automute_amp(codec);
8404} 8164}
8405 8165
8406/* auto-toggle front mic */ 8166/* auto-toggle front mic */
@@ -8432,6 +8192,22 @@ static struct hda_verb alc883_mitac_verbs[] = {
8432 { } /* end */ 8192 { } /* end */
8433}; 8193};
8434 8194
8195static struct hda_verb alc883_clevo_m540r_verbs[] = {
8196 /* HP */
8197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8199 /* Int speaker */
8200 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8201
8202 /* enable unsolicited event */
8203 /*
8204 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8205 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8206 */
8207
8208 { } /* end */
8209};
8210
8435static struct hda_verb alc883_clevo_m720_verbs[] = { 8211static struct hda_verb alc883_clevo_m720_verbs[] = {
8436 /* HP */ 8212 /* HP */
8437 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 8213 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -8555,7 +8331,7 @@ static struct hda_verb alc883_vaiott_verbs[] = {
8555 { } /* end */ 8331 { } /* end */
8556}; 8332};
8557 8333
8558static void alc888_3st_hp_init_hook(struct hda_codec *codec) 8334static void alc888_3st_hp_setup(struct hda_codec *codec)
8559{ 8335{
8560 struct alc_spec *spec = codec->spec; 8336 struct alc_spec *spec = codec->spec;
8561 8337
@@ -8563,7 +8339,6 @@ static void alc888_3st_hp_init_hook(struct hda_codec *codec)
8563 spec->autocfg.speaker_pins[0] = 0x14; 8339 spec->autocfg.speaker_pins[0] = 0x14;
8564 spec->autocfg.speaker_pins[1] = 0x16; 8340 spec->autocfg.speaker_pins[1] = 0x16;
8565 spec->autocfg.speaker_pins[2] = 0x18; 8341 spec->autocfg.speaker_pins[2] = 0x18;
8566 alc_automute_amp(codec);
8567} 8342}
8568 8343
8569static struct hda_verb alc888_3st_hp_verbs[] = { 8344static struct hda_verb alc888_3st_hp_verbs[] = {
@@ -8660,13 +8435,12 @@ static struct hda_verb alc883_medion_md2_verbs[] = {
8660}; 8435};
8661 8436
8662/* toggle speaker-output according to the hp-jack state */ 8437/* toggle speaker-output according to the hp-jack state */
8663static void alc883_medion_md2_init_hook(struct hda_codec *codec) 8438static void alc883_medion_md2_setup(struct hda_codec *codec)
8664{ 8439{
8665 struct alc_spec *spec = codec->spec; 8440 struct alc_spec *spec = codec->spec;
8666 8441
8667 spec->autocfg.hp_pins[0] = 0x14; 8442 spec->autocfg.hp_pins[0] = 0x14;
8668 spec->autocfg.speaker_pins[0] = 0x15; 8443 spec->autocfg.speaker_pins[0] = 0x15;
8669 alc_automute_amp(codec);
8670} 8444}
8671 8445
8672/* toggle speaker-output according to the hp-jack state */ 8446/* toggle speaker-output according to the hp-jack state */
@@ -8683,12 +8457,16 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8683 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8457 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8684} 8458}
8685 8459
8686static void alc883_clevo_m720_init_hook(struct hda_codec *codec) 8460static void alc883_clevo_m720_setup(struct hda_codec *codec)
8687{ 8461{
8688 struct alc_spec *spec = codec->spec; 8462 struct alc_spec *spec = codec->spec;
8689 8463
8690 spec->autocfg.hp_pins[0] = 0x15; 8464 spec->autocfg.hp_pins[0] = 0x15;
8691 spec->autocfg.speaker_pins[0] = 0x14; 8465 spec->autocfg.speaker_pins[0] = 0x14;
8466}
8467
8468static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8469{
8692 alc_automute_amp(codec); 8470 alc_automute_amp(codec);
8693 alc883_clevo_m720_mic_automute(codec); 8471 alc883_clevo_m720_mic_automute(codec);
8694} 8472}
@@ -8707,22 +8485,20 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8707} 8485}
8708 8486
8709/* toggle speaker-output according to the hp-jack state */ 8487/* toggle speaker-output according to the hp-jack state */
8710static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec) 8488static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
8711{ 8489{
8712 struct alc_spec *spec = codec->spec; 8490 struct alc_spec *spec = codec->spec;
8713 8491
8714 spec->autocfg.hp_pins[0] = 0x14; 8492 spec->autocfg.hp_pins[0] = 0x14;
8715 spec->autocfg.speaker_pins[0] = 0x15; 8493 spec->autocfg.speaker_pins[0] = 0x15;
8716 alc_automute_amp(codec);
8717} 8494}
8718 8495
8719static void alc883_haier_w66_init_hook(struct hda_codec *codec) 8496static void alc883_haier_w66_setup(struct hda_codec *codec)
8720{ 8497{
8721 struct alc_spec *spec = codec->spec; 8498 struct alc_spec *spec = codec->spec;
8722 8499
8723 spec->autocfg.hp_pins[0] = 0x1b; 8500 spec->autocfg.hp_pins[0] = 0x1b;
8724 spec->autocfg.speaker_pins[0] = 0x14; 8501 spec->autocfg.speaker_pins[0] = 0x14;
8725 alc_automute_amp(codec);
8726} 8502}
8727 8503
8728static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 8504static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
@@ -8761,14 +8537,13 @@ static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8761} 8537}
8762 8538
8763/* toggle speaker-output according to the hp-jack state */ 8539/* toggle speaker-output according to the hp-jack state */
8764static void alc883_acer_aspire_init_hook(struct hda_codec *codec) 8540static void alc883_acer_aspire_setup(struct hda_codec *codec)
8765{ 8541{
8766 struct alc_spec *spec = codec->spec; 8542 struct alc_spec *spec = codec->spec;
8767 8543
8768 spec->autocfg.hp_pins[0] = 0x14; 8544 spec->autocfg.hp_pins[0] = 0x14;
8769 spec->autocfg.speaker_pins[0] = 0x15; 8545 spec->autocfg.speaker_pins[0] = 0x15;
8770 spec->autocfg.speaker_pins[1] = 0x16; 8546 spec->autocfg.speaker_pins[1] = 0x16;
8771 alc_automute_amp(codec);
8772} 8547}
8773 8548
8774static struct hda_verb alc883_acer_eapd_verbs[] = { 8549static struct hda_verb alc883_acer_eapd_verbs[] = {
@@ -8789,7 +8564,14 @@ static struct hda_verb alc883_acer_eapd_verbs[] = {
8789 { } 8564 { }
8790}; 8565};
8791 8566
8792static void alc888_6st_dell_init_hook(struct hda_codec *codec) 8567static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8568 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8569 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8570 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8571 { } /* end */
8572};
8573
8574static void alc888_6st_dell_setup(struct hda_codec *codec)
8793{ 8575{
8794 struct alc_spec *spec = codec->spec; 8576 struct alc_spec *spec = codec->spec;
8795 8577
@@ -8798,10 +8580,9 @@ static void alc888_6st_dell_init_hook(struct hda_codec *codec)
8798 spec->autocfg.speaker_pins[1] = 0x15; 8580 spec->autocfg.speaker_pins[1] = 0x15;
8799 spec->autocfg.speaker_pins[2] = 0x16; 8581 spec->autocfg.speaker_pins[2] = 0x16;
8800 spec->autocfg.speaker_pins[3] = 0x17; 8582 spec->autocfg.speaker_pins[3] = 0x17;
8801 alc_automute_amp(codec);
8802} 8583}
8803 8584
8804static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) 8585static void alc888_lenovo_sky_setup(struct hda_codec *codec)
8805{ 8586{
8806 struct alc_spec *spec = codec->spec; 8587 struct alc_spec *spec = codec->spec;
8807 8588
@@ -8811,82 +8592,17 @@ static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
8811 spec->autocfg.speaker_pins[2] = 0x16; 8592 spec->autocfg.speaker_pins[2] = 0x16;
8812 spec->autocfg.speaker_pins[3] = 0x17; 8593 spec->autocfg.speaker_pins[3] = 0x17;
8813 spec->autocfg.speaker_pins[4] = 0x1a; 8594 spec->autocfg.speaker_pins[4] = 0x1a;
8814 alc_automute_amp(codec);
8815} 8595}
8816 8596
8817static void alc883_vaiott_init_hook(struct hda_codec *codec) 8597static void alc883_vaiott_setup(struct hda_codec *codec)
8818{ 8598{
8819 struct alc_spec *spec = codec->spec; 8599 struct alc_spec *spec = codec->spec;
8820 8600
8821 spec->autocfg.hp_pins[0] = 0x15; 8601 spec->autocfg.hp_pins[0] = 0x15;
8822 spec->autocfg.speaker_pins[0] = 0x14; 8602 spec->autocfg.speaker_pins[0] = 0x14;
8823 spec->autocfg.speaker_pins[1] = 0x17; 8603 spec->autocfg.speaker_pins[1] = 0x17;
8824 alc_automute_amp(codec);
8825} 8604}
8826 8605
8827/*
8828 * generic initialization of ADC, input mixers and output mixers
8829 */
8830static struct hda_verb alc883_auto_init_verbs[] = {
8831 /*
8832 * Unmute ADC0-2 and set the default input to mic-in
8833 */
8834 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8836 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8837 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8838
8839 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8840 * mixer widget
8841 * Note: PASD motherboards uses the Line In 2 as the input for
8842 * front panel mic (mic 2)
8843 */
8844 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8850
8851 /*
8852 * Set up output mixers (0x0c - 0x0f)
8853 */
8854 /* set vol=0 to output mixers */
8855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8858 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8859 /* set up input amps for analog loopback */
8860 /* Amp Indices: DAC = 0, mixer = 1 */
8861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8863 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8864 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8867 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8868 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8869 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8870 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8871
8872 /* FIXME: use matrix-type input source selection */
8873 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8874 /* Input mixer1 */
8875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8876 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8877 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8878 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
8879 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8880 /* Input mixer2 */
8881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8884 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
8885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8886
8887 { }
8888};
8889
8890static struct hda_verb alc888_asus_m90v_verbs[] = { 8606static struct hda_verb alc888_asus_m90v_verbs[] = {
8891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8608 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
@@ -8897,19 +8613,7 @@ static struct hda_verb alc888_asus_m90v_verbs[] = {
8897 { } /* end */ 8613 { } /* end */
8898}; 8614};
8899 8615
8900static void alc883_nb_mic_automute(struct hda_codec *codec) 8616static void alc883_mode2_setup(struct hda_codec *codec)
8901{
8902 unsigned int present;
8903
8904 present = snd_hda_codec_read(codec, 0x18, 0,
8905 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8906 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8907 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8908 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8909 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8910}
8911
8912static void alc883_M90V_init_hook(struct hda_codec *codec)
8913{ 8617{
8914 struct alc_spec *spec = codec->spec; 8618 struct alc_spec *spec = codec->spec;
8915 8619
@@ -8917,26 +8621,11 @@ static void alc883_M90V_init_hook(struct hda_codec *codec)
8917 spec->autocfg.speaker_pins[0] = 0x14; 8621 spec->autocfg.speaker_pins[0] = 0x14;
8918 spec->autocfg.speaker_pins[1] = 0x15; 8622 spec->autocfg.speaker_pins[1] = 0x15;
8919 spec->autocfg.speaker_pins[2] = 0x16; 8623 spec->autocfg.speaker_pins[2] = 0x16;
8920 alc_automute_pin(codec); 8624 spec->ext_mic.pin = 0x18;
8921} 8625 spec->int_mic.pin = 0x19;
8922 8626 spec->ext_mic.mux_idx = 0;
8923static void alc883_mode2_unsol_event(struct hda_codec *codec, 8627 spec->int_mic.mux_idx = 1;
8924 unsigned int res) 8628 spec->auto_mic = 1;
8925{
8926 switch (res >> 26) {
8927 case ALC880_MIC_EVENT:
8928 alc883_nb_mic_automute(codec);
8929 break;
8930 default:
8931 alc_sku_unsol_event(codec, res);
8932 break;
8933 }
8934}
8935
8936static void alc883_mode2_inithook(struct hda_codec *codec)
8937{
8938 alc883_M90V_init_hook(codec);
8939 alc883_nb_mic_automute(codec);
8940} 8629}
8941 8630
8942static struct hda_verb alc888_asus_eee1601_verbs[] = { 8631static struct hda_verb alc888_asus_eee1601_verbs[] = {
@@ -8997,25 +8686,44 @@ static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8997 alc889A_mb31_automute(codec); 8686 alc889A_mb31_automute(codec);
8998} 8687}
8999 8688
8689
9000#ifdef CONFIG_SND_HDA_POWER_SAVE 8690#ifdef CONFIG_SND_HDA_POWER_SAVE
9001#define alc883_loopbacks alc880_loopbacks 8691#define alc882_loopbacks alc880_loopbacks
9002#endif 8692#endif
9003 8693
9004/* pcm configuration: identical with ALC880 */ 8694/* pcm configuration: identical with ALC880 */
9005#define alc883_pcm_analog_playback alc880_pcm_analog_playback 8695#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9006#define alc883_pcm_analog_capture alc880_pcm_analog_capture 8696#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9007#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture 8697#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9008#define alc883_pcm_digital_playback alc880_pcm_digital_playback 8698#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9009#define alc883_pcm_digital_capture alc880_pcm_digital_capture 8699
8700static hda_nid_t alc883_slave_dig_outs[] = {
8701 ALC1200_DIGOUT_NID, 0,
8702};
8703
8704static hda_nid_t alc1200_slave_dig_outs[] = {
8705 ALC883_DIGOUT_NID, 0,
8706};
9010 8707
9011/* 8708/*
9012 * configuration and preset 8709 * configuration and preset
9013 */ 8710 */
9014static const char *alc883_models[ALC883_MODEL_LAST] = { 8711static const char *alc882_models[ALC882_MODEL_LAST] = {
9015 [ALC883_3ST_2ch_DIG] = "3stack-dig", 8712 [ALC882_3ST_DIG] = "3stack-dig",
8713 [ALC882_6ST_DIG] = "6stack-dig",
8714 [ALC882_ARIMA] = "arima",
8715 [ALC882_W2JC] = "w2jc",
8716 [ALC882_TARGA] = "targa",
8717 [ALC882_ASUS_A7J] = "asus-a7j",
8718 [ALC882_ASUS_A7M] = "asus-a7m",
8719 [ALC885_MACPRO] = "macpro",
8720 [ALC885_MB5] = "mb5",
8721 [ALC885_MBP3] = "mbp3",
8722 [ALC885_IMAC24] = "imac24",
8723 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
9016 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", 8724 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9017 [ALC883_3ST_6ch] = "3stack-6ch", 8725 [ALC883_3ST_6ch] = "3stack-6ch",
9018 [ALC883_6ST_DIG] = "6stack-dig", 8726 [ALC883_6ST_DIG] = "alc883-6stack-dig",
9019 [ALC883_TARGA_DIG] = "targa-dig", 8727 [ALC883_TARGA_DIG] = "targa-dig",
9020 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 8728 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
9021 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig", 8729 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
@@ -9024,6 +8732,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
9024 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", 8732 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
9025 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g", 8733 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
9026 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g", 8734 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
8735 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
9027 [ALC883_MEDION] = "medion", 8736 [ALC883_MEDION] = "medion",
9028 [ALC883_MEDION_MD2] = "medion-md2", 8737 [ALC883_MEDION_MD2] = "medion-md2",
9029 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 8738 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
@@ -9035,18 +8744,22 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
9035 [ALC888_3ST_HP] = "3stack-hp", 8744 [ALC888_3ST_HP] = "3stack-hp",
9036 [ALC888_6ST_DELL] = "6stack-dell", 8745 [ALC888_6ST_DELL] = "6stack-dell",
9037 [ALC883_MITAC] = "mitac", 8746 [ALC883_MITAC] = "mitac",
8747 [ALC883_CLEVO_M540R] = "clevo-m540r",
9038 [ALC883_CLEVO_M720] = "clevo-m720", 8748 [ALC883_CLEVO_M720] = "clevo-m720",
9039 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", 8749 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
9040 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", 8750 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
9041 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", 8751 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8752 [ALC889A_INTEL] = "intel-alc889a",
8753 [ALC889_INTEL] = "intel-x58",
9042 [ALC1200_ASUS_P5Q] = "asus-p5q", 8754 [ALC1200_ASUS_P5Q] = "asus-p5q",
9043 [ALC889A_MB31] = "mb31", 8755 [ALC889A_MB31] = "mb31",
9044 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt", 8756 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
9045 [ALC883_AUTO] = "auto", 8757 [ALC882_AUTO] = "auto",
9046}; 8758};
9047 8759
9048static struct snd_pci_quirk alc883_cfg_tbl[] = { 8760static struct snd_pci_quirk alc882_cfg_tbl[] = {
9049 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 8761 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8762
9050 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 8763 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
9051 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), 8764 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
9052 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE), 8765 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
@@ -9061,40 +8774,56 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9061 ALC888_ACER_ASPIRE_8930G), 8774 ALC888_ACER_ASPIRE_8930G),
9062 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", 8775 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9063 ALC888_ACER_ASPIRE_8930G), 8776 ALC888_ACER_ASPIRE_8930G),
9064 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), 8777 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9065 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), 8778 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
9066 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 8779 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
9067 ALC888_ACER_ASPIRE_4930G), 8780 ALC888_ACER_ASPIRE_6530G),
9068 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", 8781 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
9069 ALC888_ACER_ASPIRE_6530G), 8782 ALC888_ACER_ASPIRE_6530G),
8783 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8784 ALC888_ACER_ASPIRE_7730G),
9070 /* default Acer -- disabled as it causes more problems. 8785 /* default Acer -- disabled as it causes more problems.
9071 * model=auto should work fine now 8786 * model=auto should work fine now
9072 */ 8787 */
9073 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */ 8788 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
8789
9074 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 8790 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8791
9075 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 8792 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
9076 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8793 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9077 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8794 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
9078 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8795 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
9079 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), 8796 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
9080 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP), 8797 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8798
8799 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8800 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8801 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
9081 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8802 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8803 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8804 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8805 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
9082 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8806 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
9083 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), 8807 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
9084 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), 8808 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
9085 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8809 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8810
8811 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
9086 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8812 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
9087 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 8813 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
9088 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), 8814 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
9089 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), 8815 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9090 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 8816 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
9091 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), 8817 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
9092 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 8818 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
9093 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), 8819 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8820
9094 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 8821 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9095 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), 8822 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9096 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 8823 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
8824 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
9097 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), 8825 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
8826 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
9098 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), 8827 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
9099 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), 8828 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
9100 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 8829 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
@@ -9103,6 +8832,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9103 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), 8832 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9104 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), 8833 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9105 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), 8834 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8835 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
9106 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), 8836 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9107 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), 8837 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9108 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 8838 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
@@ -9116,11 +8846,15 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9116 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 8846 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
9117 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), 8847 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
9118 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 8848 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
8849 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
8850
9119 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 8851 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
9120 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), 8852 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9121 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), 8853 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8854 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
9122 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), 8855 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
9123 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 8856 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8857 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
9124 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 8858 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
9125 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", 8859 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
9126 ALC883_FUJITSU_PI2515), 8860 ALC883_FUJITSU_PI2515),
@@ -9135,24 +8869,186 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9135 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), 8869 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
9136 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), 8870 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
9137 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 8871 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8872
9138 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), 8873 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9139 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), 8874 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
9140 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), 8875 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
9141 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), 8876 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8877 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8878 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
9142 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 8879 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
9143 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
9144 {}
9145};
9146 8880
9147static hda_nid_t alc883_slave_dig_outs[] = { 8881 {}
9148 ALC1200_DIGOUT_NID, 0,
9149}; 8882};
9150 8883
9151static hda_nid_t alc1200_slave_dig_outs[] = { 8884/* codec SSID table for Intel Mac */
9152 ALC883_DIGOUT_NID, 0, 8885static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8886 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8887 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8888 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8889 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8890 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8891 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8892 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8893 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8894 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8895 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8896 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8897 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8898 * no perfect solution yet
8899 */
8900 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8901 {} /* terminator */
9153}; 8902};
9154 8903
9155static struct alc_config_preset alc883_presets[] = { 8904static struct alc_config_preset alc882_presets[] = {
8905 [ALC882_3ST_DIG] = {
8906 .mixers = { alc882_base_mixer },
8907 .init_verbs = { alc882_base_init_verbs,
8908 alc882_adc1_init_verbs },
8909 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8910 .dac_nids = alc882_dac_nids,
8911 .dig_out_nid = ALC882_DIGOUT_NID,
8912 .dig_in_nid = ALC882_DIGIN_NID,
8913 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8914 .channel_mode = alc882_ch_modes,
8915 .need_dac_fix = 1,
8916 .input_mux = &alc882_capture_source,
8917 },
8918 [ALC882_6ST_DIG] = {
8919 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8920 .init_verbs = { alc882_base_init_verbs,
8921 alc882_adc1_init_verbs },
8922 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8923 .dac_nids = alc882_dac_nids,
8924 .dig_out_nid = ALC882_DIGOUT_NID,
8925 .dig_in_nid = ALC882_DIGIN_NID,
8926 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8927 .channel_mode = alc882_sixstack_modes,
8928 .input_mux = &alc882_capture_source,
8929 },
8930 [ALC882_ARIMA] = {
8931 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8932 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8933 alc882_eapd_verbs },
8934 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8935 .dac_nids = alc882_dac_nids,
8936 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8937 .channel_mode = alc882_sixstack_modes,
8938 .input_mux = &alc882_capture_source,
8939 },
8940 [ALC882_W2JC] = {
8941 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
8942 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8943 alc882_eapd_verbs, alc880_gpio1_init_verbs },
8944 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8945 .dac_nids = alc882_dac_nids,
8946 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8947 .channel_mode = alc880_threestack_modes,
8948 .need_dac_fix = 1,
8949 .input_mux = &alc882_capture_source,
8950 .dig_out_nid = ALC882_DIGOUT_NID,
8951 },
8952 [ALC885_MBP3] = {
8953 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8954 .init_verbs = { alc885_mbp3_init_verbs,
8955 alc880_gpio1_init_verbs },
8956 .num_dacs = 2,
8957 .dac_nids = alc882_dac_nids,
8958 .hp_nid = 0x04,
8959 .channel_mode = alc885_mbp_4ch_modes,
8960 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
8961 .input_mux = &alc882_capture_source,
8962 .dig_out_nid = ALC882_DIGOUT_NID,
8963 .dig_in_nid = ALC882_DIGIN_NID,
8964 .unsol_event = alc_automute_amp_unsol_event,
8965 .setup = alc885_mbp3_setup,
8966 .init_hook = alc_automute_amp,
8967 },
8968 [ALC885_MB5] = {
8969 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8970 .init_verbs = { alc885_mb5_init_verbs,
8971 alc880_gpio1_init_verbs },
8972 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8973 .dac_nids = alc882_dac_nids,
8974 .channel_mode = alc885_mb5_6ch_modes,
8975 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8976 .input_mux = &mb5_capture_source,
8977 .dig_out_nid = ALC882_DIGOUT_NID,
8978 .dig_in_nid = ALC882_DIGIN_NID,
8979 },
8980 [ALC885_MACPRO] = {
8981 .mixers = { alc882_macpro_mixer },
8982 .init_verbs = { alc882_macpro_init_verbs },
8983 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8984 .dac_nids = alc882_dac_nids,
8985 .dig_out_nid = ALC882_DIGOUT_NID,
8986 .dig_in_nid = ALC882_DIGIN_NID,
8987 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8988 .channel_mode = alc882_ch_modes,
8989 .input_mux = &alc882_capture_source,
8990 .init_hook = alc885_macpro_init_hook,
8991 },
8992 [ALC885_IMAC24] = {
8993 .mixers = { alc885_imac24_mixer },
8994 .init_verbs = { alc885_imac24_init_verbs },
8995 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8996 .dac_nids = alc882_dac_nids,
8997 .dig_out_nid = ALC882_DIGOUT_NID,
8998 .dig_in_nid = ALC882_DIGIN_NID,
8999 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9000 .channel_mode = alc882_ch_modes,
9001 .input_mux = &alc882_capture_source,
9002 .unsol_event = alc_automute_amp_unsol_event,
9003 .setup = alc885_imac24_setup,
9004 .init_hook = alc885_imac24_init_hook,
9005 },
9006 [ALC882_TARGA] = {
9007 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
9008 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9009 alc880_gpio3_init_verbs, alc882_targa_verbs},
9010 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9011 .dac_nids = alc882_dac_nids,
9012 .dig_out_nid = ALC882_DIGOUT_NID,
9013 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9014 .adc_nids = alc882_adc_nids,
9015 .capsrc_nids = alc882_capsrc_nids,
9016 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9017 .channel_mode = alc882_3ST_6ch_modes,
9018 .need_dac_fix = 1,
9019 .input_mux = &alc882_capture_source,
9020 .unsol_event = alc882_targa_unsol_event,
9021 .setup = alc882_targa_setup,
9022 .init_hook = alc882_targa_automute,
9023 },
9024 [ALC882_ASUS_A7J] = {
9025 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
9026 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9027 alc882_asus_a7j_verbs},
9028 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9029 .dac_nids = alc882_dac_nids,
9030 .dig_out_nid = ALC882_DIGOUT_NID,
9031 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9032 .adc_nids = alc882_adc_nids,
9033 .capsrc_nids = alc882_capsrc_nids,
9034 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9035 .channel_mode = alc882_3ST_6ch_modes,
9036 .need_dac_fix = 1,
9037 .input_mux = &alc882_capture_source,
9038 },
9039 [ALC882_ASUS_A7M] = {
9040 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
9041 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9042 alc882_eapd_verbs, alc880_gpio1_init_verbs,
9043 alc882_asus_a7m_verbs },
9044 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9045 .dac_nids = alc882_dac_nids,
9046 .dig_out_nid = ALC882_DIGOUT_NID,
9047 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9048 .channel_mode = alc880_threestack_modes,
9049 .need_dac_fix = 1,
9050 .input_mux = &alc882_capture_source,
9051 },
9156 [ALC883_3ST_2ch_DIG] = { 9052 [ALC883_3ST_2ch_DIG] = {
9157 .mixers = { alc883_3ST_2ch_mixer }, 9053 .mixers = { alc883_3ST_2ch_mixer },
9158 .init_verbs = { alc883_init_verbs }, 9054 .init_verbs = { alc883_init_verbs },
@@ -9199,6 +9095,46 @@ static struct alc_config_preset alc883_presets[] = {
9199 .need_dac_fix = 1, 9095 .need_dac_fix = 1,
9200 .input_mux = &alc883_3stack_6ch_intel, 9096 .input_mux = &alc883_3stack_6ch_intel,
9201 }, 9097 },
9098 [ALC889A_INTEL] = {
9099 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9100 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9101 alc_hp15_unsol_verbs },
9102 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9103 .dac_nids = alc883_dac_nids,
9104 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9105 .adc_nids = alc889_adc_nids,
9106 .dig_out_nid = ALC883_DIGOUT_NID,
9107 .dig_in_nid = ALC883_DIGIN_NID,
9108 .slave_dig_outs = alc883_slave_dig_outs,
9109 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9110 .channel_mode = alc889_8ch_intel_modes,
9111 .capsrc_nids = alc889_capsrc_nids,
9112 .input_mux = &alc889_capture_source,
9113 .setup = alc889_automute_setup,
9114 .init_hook = alc_automute_amp,
9115 .unsol_event = alc_automute_amp_unsol_event,
9116 .need_dac_fix = 1,
9117 },
9118 [ALC889_INTEL] = {
9119 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9120 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
9121 alc889_eapd_verbs, alc_hp15_unsol_verbs},
9122 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9123 .dac_nids = alc883_dac_nids,
9124 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9125 .adc_nids = alc889_adc_nids,
9126 .dig_out_nid = ALC883_DIGOUT_NID,
9127 .dig_in_nid = ALC883_DIGIN_NID,
9128 .slave_dig_outs = alc883_slave_dig_outs,
9129 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9130 .channel_mode = alc889_8ch_intel_modes,
9131 .capsrc_nids = alc889_capsrc_nids,
9132 .input_mux = &alc889_capture_source,
9133 .setup = alc889_automute_setup,
9134 .init_hook = alc889_intel_init_hook,
9135 .unsol_event = alc_automute_amp_unsol_event,
9136 .need_dac_fix = 1,
9137 },
9202 [ALC883_6ST_DIG] = { 9138 [ALC883_6ST_DIG] = {
9203 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9139 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9204 .init_verbs = { alc883_init_verbs }, 9140 .init_verbs = { alc883_init_verbs },
@@ -9212,7 +9148,8 @@ static struct alc_config_preset alc883_presets[] = {
9212 }, 9148 },
9213 [ALC883_TARGA_DIG] = { 9149 [ALC883_TARGA_DIG] = {
9214 .mixers = { alc883_targa_mixer, alc883_chmode_mixer }, 9150 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9215 .init_verbs = { alc883_init_verbs, alc883_targa_verbs}, 9151 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9152 alc883_targa_verbs},
9216 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 9153 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9217 .dac_nids = alc883_dac_nids, 9154 .dac_nids = alc883_dac_nids,
9218 .dig_out_nid = ALC883_DIGOUT_NID, 9155 .dig_out_nid = ALC883_DIGOUT_NID,
@@ -9221,11 +9158,13 @@ static struct alc_config_preset alc883_presets[] = {
9221 .need_dac_fix = 1, 9158 .need_dac_fix = 1,
9222 .input_mux = &alc883_capture_source, 9159 .input_mux = &alc883_capture_source,
9223 .unsol_event = alc883_targa_unsol_event, 9160 .unsol_event = alc883_targa_unsol_event,
9224 .init_hook = alc883_targa_init_hook, 9161 .setup = alc882_targa_setup,
9162 .init_hook = alc882_targa_automute,
9225 }, 9163 },
9226 [ALC883_TARGA_2ch_DIG] = { 9164 [ALC883_TARGA_2ch_DIG] = {
9227 .mixers = { alc883_targa_2ch_mixer}, 9165 .mixers = { alc883_targa_2ch_mixer},
9228 .init_verbs = { alc883_init_verbs, alc883_targa_verbs}, 9166 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9167 alc883_targa_verbs},
9229 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 9168 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9230 .dac_nids = alc883_dac_nids, 9169 .dac_nids = alc883_dac_nids,
9231 .adc_nids = alc883_adc_nids_alt, 9170 .adc_nids = alc883_adc_nids_alt,
@@ -9235,10 +9174,12 @@ static struct alc_config_preset alc883_presets[] = {
9235 .channel_mode = alc883_3ST_2ch_modes, 9174 .channel_mode = alc883_3ST_2ch_modes,
9236 .input_mux = &alc883_capture_source, 9175 .input_mux = &alc883_capture_source,
9237 .unsol_event = alc883_targa_unsol_event, 9176 .unsol_event = alc883_targa_unsol_event,
9238 .init_hook = alc883_targa_init_hook, 9177 .setup = alc882_targa_setup,
9178 .init_hook = alc882_targa_automute,
9239 }, 9179 },
9240 [ALC883_TARGA_8ch_DIG] = { 9180 [ALC883_TARGA_8ch_DIG] = {
9241 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9181 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9182 alc883_chmode_mixer },
9242 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs, 9183 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9243 alc883_targa_verbs }, 9184 alc883_targa_verbs },
9244 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 9185 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
@@ -9253,7 +9194,8 @@ static struct alc_config_preset alc883_presets[] = {
9253 .need_dac_fix = 1, 9194 .need_dac_fix = 1,
9254 .input_mux = &alc883_capture_source, 9195 .input_mux = &alc883_capture_source,
9255 .unsol_event = alc883_targa_unsol_event, 9196 .unsol_event = alc883_targa_unsol_event,
9256 .init_hook = alc883_targa_init_hook, 9197 .setup = alc882_targa_setup,
9198 .init_hook = alc882_targa_automute,
9257 }, 9199 },
9258 [ALC883_ACER] = { 9200 [ALC883_ACER] = {
9259 .mixers = { alc883_base_mixer }, 9201 .mixers = { alc883_base_mixer },
@@ -9279,7 +9221,8 @@ static struct alc_config_preset alc883_presets[] = {
9279 .channel_mode = alc883_3ST_2ch_modes, 9221 .channel_mode = alc883_3ST_2ch_modes,
9280 .input_mux = &alc883_capture_source, 9222 .input_mux = &alc883_capture_source,
9281 .unsol_event = alc_automute_amp_unsol_event, 9223 .unsol_event = alc_automute_amp_unsol_event,
9282 .init_hook = alc883_acer_aspire_init_hook, 9224 .setup = alc883_acer_aspire_setup,
9225 .init_hook = alc_automute_amp,
9283 }, 9226 },
9284 [ALC888_ACER_ASPIRE_4930G] = { 9227 [ALC888_ACER_ASPIRE_4930G] = {
9285 .mixers = { alc888_base_mixer, 9228 .mixers = { alc888_base_mixer,
@@ -9299,7 +9242,8 @@ static struct alc_config_preset alc883_presets[] = {
9299 ARRAY_SIZE(alc888_2_capture_sources), 9242 ARRAY_SIZE(alc888_2_capture_sources),
9300 .input_mux = alc888_2_capture_sources, 9243 .input_mux = alc888_2_capture_sources,
9301 .unsol_event = alc_automute_amp_unsol_event, 9244 .unsol_event = alc_automute_amp_unsol_event,
9302 .init_hook = alc888_acer_aspire_4930g_init_hook, 9245 .setup = alc888_acer_aspire_4930g_setup,
9246 .init_hook = alc_automute_amp,
9303 }, 9247 },
9304 [ALC888_ACER_ASPIRE_6530G] = { 9248 [ALC888_ACER_ASPIRE_6530G] = {
9305 .mixers = { alc888_acer_aspire_6530_mixer }, 9249 .mixers = { alc888_acer_aspire_6530_mixer },
@@ -9317,7 +9261,8 @@ static struct alc_config_preset alc883_presets[] = {
9317 ARRAY_SIZE(alc888_2_capture_sources), 9261 ARRAY_SIZE(alc888_2_capture_sources),
9318 .input_mux = alc888_acer_aspire_6530_sources, 9262 .input_mux = alc888_acer_aspire_6530_sources,
9319 .unsol_event = alc_automute_amp_unsol_event, 9263 .unsol_event = alc_automute_amp_unsol_event,
9320 .init_hook = alc888_acer_aspire_4930g_init_hook, 9264 .setup = alc888_acer_aspire_6530g_setup,
9265 .init_hook = alc_automute_amp,
9321 }, 9266 },
9322 [ALC888_ACER_ASPIRE_8930G] = { 9267 [ALC888_ACER_ASPIRE_8930G] = {
9323 .mixers = { alc888_base_mixer, 9268 .mixers = { alc888_base_mixer,
@@ -9338,7 +9283,28 @@ static struct alc_config_preset alc883_presets[] = {
9338 ARRAY_SIZE(alc889_capture_sources), 9283 ARRAY_SIZE(alc889_capture_sources),
9339 .input_mux = alc889_capture_sources, 9284 .input_mux = alc889_capture_sources,
9340 .unsol_event = alc_automute_amp_unsol_event, 9285 .unsol_event = alc_automute_amp_unsol_event,
9341 .init_hook = alc889_acer_aspire_8930g_init_hook, 9286 .setup = alc889_acer_aspire_8930g_setup,
9287 .init_hook = alc_automute_amp,
9288 },
9289 [ALC888_ACER_ASPIRE_7730G] = {
9290 .mixers = { alc883_3ST_6ch_mixer,
9291 alc883_chmode_mixer },
9292 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9293 alc888_acer_aspire_7730G_verbs },
9294 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9295 .dac_nids = alc883_dac_nids,
9296 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9297 .adc_nids = alc883_adc_nids_rev,
9298 .capsrc_nids = alc883_capsrc_nids_rev,
9299 .dig_out_nid = ALC883_DIGOUT_NID,
9300 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9301 .channel_mode = alc883_3ST_6ch_modes,
9302 .need_dac_fix = 1,
9303 .const_channel_count = 6,
9304 .input_mux = &alc883_capture_source,
9305 .unsol_event = alc_automute_amp_unsol_event,
9306 .setup = alc888_acer_aspire_6530g_setup,
9307 .init_hook = alc_automute_amp,
9342 }, 9308 },
9343 [ALC883_MEDION] = { 9309 [ALC883_MEDION] = {
9344 .mixers = { alc883_fivestack_mixer, 9310 .mixers = { alc883_fivestack_mixer,
@@ -9363,7 +9329,8 @@ static struct alc_config_preset alc883_presets[] = {
9363 .channel_mode = alc883_3ST_2ch_modes, 9329 .channel_mode = alc883_3ST_2ch_modes,
9364 .input_mux = &alc883_capture_source, 9330 .input_mux = &alc883_capture_source,
9365 .unsol_event = alc_automute_amp_unsol_event, 9331 .unsol_event = alc_automute_amp_unsol_event,
9366 .init_hook = alc883_medion_md2_init_hook, 9332 .setup = alc883_medion_md2_setup,
9333 .init_hook = alc_automute_amp,
9367 }, 9334 },
9368 [ALC883_LAPTOP_EAPD] = { 9335 [ALC883_LAPTOP_EAPD] = {
9369 .mixers = { alc883_base_mixer }, 9336 .mixers = { alc883_base_mixer },
@@ -9374,6 +9341,21 @@ static struct alc_config_preset alc883_presets[] = {
9374 .channel_mode = alc883_3ST_2ch_modes, 9341 .channel_mode = alc883_3ST_2ch_modes,
9375 .input_mux = &alc883_capture_source, 9342 .input_mux = &alc883_capture_source,
9376 }, 9343 },
9344 [ALC883_CLEVO_M540R] = {
9345 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9346 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9347 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9348 .dac_nids = alc883_dac_nids,
9349 .dig_out_nid = ALC883_DIGOUT_NID,
9350 .dig_in_nid = ALC883_DIGIN_NID,
9351 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9352 .channel_mode = alc883_3ST_6ch_clevo_modes,
9353 .need_dac_fix = 1,
9354 .input_mux = &alc883_capture_source,
9355 /* This machine has the hardware HP auto-muting, thus
9356 * we need no software mute via unsol event
9357 */
9358 },
9377 [ALC883_CLEVO_M720] = { 9359 [ALC883_CLEVO_M720] = {
9378 .mixers = { alc883_clevo_m720_mixer }, 9360 .mixers = { alc883_clevo_m720_mixer },
9379 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, 9361 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
@@ -9384,6 +9366,7 @@ static struct alc_config_preset alc883_presets[] = {
9384 .channel_mode = alc883_3ST_2ch_modes, 9366 .channel_mode = alc883_3ST_2ch_modes,
9385 .input_mux = &alc883_capture_source, 9367 .input_mux = &alc883_capture_source,
9386 .unsol_event = alc883_clevo_m720_unsol_event, 9368 .unsol_event = alc883_clevo_m720_unsol_event,
9369 .setup = alc883_clevo_m720_setup,
9387 .init_hook = alc883_clevo_m720_init_hook, 9370 .init_hook = alc883_clevo_m720_init_hook,
9388 }, 9371 },
9389 [ALC883_LENOVO_101E_2ch] = { 9372 [ALC883_LENOVO_101E_2ch] = {
@@ -9409,7 +9392,8 @@ static struct alc_config_preset alc883_presets[] = {
9409 .need_dac_fix = 1, 9392 .need_dac_fix = 1,
9410 .input_mux = &alc883_lenovo_nb0763_capture_source, 9393 .input_mux = &alc883_lenovo_nb0763_capture_source,
9411 .unsol_event = alc_automute_amp_unsol_event, 9394 .unsol_event = alc_automute_amp_unsol_event,
9412 .init_hook = alc883_medion_md2_init_hook, 9395 .setup = alc883_medion_md2_setup,
9396 .init_hook = alc_automute_amp,
9413 }, 9397 },
9414 [ALC888_LENOVO_MS7195_DIG] = { 9398 [ALC888_LENOVO_MS7195_DIG] = {
9415 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9399 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9434,7 +9418,8 @@ static struct alc_config_preset alc883_presets[] = {
9434 .channel_mode = alc883_3ST_2ch_modes, 9418 .channel_mode = alc883_3ST_2ch_modes,
9435 .input_mux = &alc883_capture_source, 9419 .input_mux = &alc883_capture_source,
9436 .unsol_event = alc_automute_amp_unsol_event, 9420 .unsol_event = alc_automute_amp_unsol_event,
9437 .init_hook = alc883_haier_w66_init_hook, 9421 .setup = alc883_haier_w66_setup,
9422 .init_hook = alc_automute_amp,
9438 }, 9423 },
9439 [ALC888_3ST_HP] = { 9424 [ALC888_3ST_HP] = {
9440 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9425 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9446,7 +9431,8 @@ static struct alc_config_preset alc883_presets[] = {
9446 .need_dac_fix = 1, 9431 .need_dac_fix = 1,
9447 .input_mux = &alc883_capture_source, 9432 .input_mux = &alc883_capture_source,
9448 .unsol_event = alc_automute_amp_unsol_event, 9433 .unsol_event = alc_automute_amp_unsol_event,
9449 .init_hook = alc888_3st_hp_init_hook, 9434 .setup = alc888_3st_hp_setup,
9435 .init_hook = alc_automute_amp,
9450 }, 9436 },
9451 [ALC888_6ST_DELL] = { 9437 [ALC888_6ST_DELL] = {
9452 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9438 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
@@ -9459,7 +9445,8 @@ static struct alc_config_preset alc883_presets[] = {
9459 .channel_mode = alc883_sixstack_modes, 9445 .channel_mode = alc883_sixstack_modes,
9460 .input_mux = &alc883_capture_source, 9446 .input_mux = &alc883_capture_source,
9461 .unsol_event = alc_automute_amp_unsol_event, 9447 .unsol_event = alc_automute_amp_unsol_event,
9462 .init_hook = alc888_6st_dell_init_hook, 9448 .setup = alc888_6st_dell_setup,
9449 .init_hook = alc_automute_amp,
9463 }, 9450 },
9464 [ALC883_MITAC] = { 9451 [ALC883_MITAC] = {
9465 .mixers = { alc883_mitac_mixer }, 9452 .mixers = { alc883_mitac_mixer },
@@ -9470,7 +9457,8 @@ static struct alc_config_preset alc883_presets[] = {
9470 .channel_mode = alc883_3ST_2ch_modes, 9457 .channel_mode = alc883_3ST_2ch_modes,
9471 .input_mux = &alc883_capture_source, 9458 .input_mux = &alc883_capture_source,
9472 .unsol_event = alc_automute_amp_unsol_event, 9459 .unsol_event = alc_automute_amp_unsol_event,
9473 .init_hook = alc883_mitac_init_hook, 9460 .setup = alc883_mitac_setup,
9461 .init_hook = alc_automute_amp,
9474 }, 9462 },
9475 [ALC883_FUJITSU_PI2515] = { 9463 [ALC883_FUJITSU_PI2515] = {
9476 .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, 9464 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
@@ -9483,7 +9471,8 @@ static struct alc_config_preset alc883_presets[] = {
9483 .channel_mode = alc883_3ST_2ch_modes, 9471 .channel_mode = alc883_3ST_2ch_modes,
9484 .input_mux = &alc883_fujitsu_pi2515_capture_source, 9472 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9485 .unsol_event = alc_automute_amp_unsol_event, 9473 .unsol_event = alc_automute_amp_unsol_event,
9486 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook, 9474 .setup = alc883_2ch_fujitsu_pi2515_setup,
9475 .init_hook = alc_automute_amp,
9487 }, 9476 },
9488 [ALC888_FUJITSU_XA3530] = { 9477 [ALC888_FUJITSU_XA3530] = {
9489 .mixers = { alc888_base_mixer, alc883_chmode_mixer }, 9478 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
@@ -9501,7 +9490,8 @@ static struct alc_config_preset alc883_presets[] = {
9501 ARRAY_SIZE(alc888_2_capture_sources), 9490 ARRAY_SIZE(alc888_2_capture_sources),
9502 .input_mux = alc888_2_capture_sources, 9491 .input_mux = alc888_2_capture_sources,
9503 .unsol_event = alc_automute_amp_unsol_event, 9492 .unsol_event = alc_automute_amp_unsol_event,
9504 .init_hook = alc888_fujitsu_xa3530_init_hook, 9493 .setup = alc888_fujitsu_xa3530_setup,
9494 .init_hook = alc_automute_amp,
9505 }, 9495 },
9506 [ALC888_LENOVO_SKY] = { 9496 [ALC888_LENOVO_SKY] = {
9507 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, 9497 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
@@ -9514,7 +9504,8 @@ static struct alc_config_preset alc883_presets[] = {
9514 .need_dac_fix = 1, 9504 .need_dac_fix = 1,
9515 .input_mux = &alc883_lenovo_sky_capture_source, 9505 .input_mux = &alc883_lenovo_sky_capture_source,
9516 .unsol_event = alc_automute_amp_unsol_event, 9506 .unsol_event = alc_automute_amp_unsol_event,
9517 .init_hook = alc888_lenovo_sky_init_hook, 9507 .setup = alc888_lenovo_sky_setup,
9508 .init_hook = alc_automute_amp,
9518 }, 9509 },
9519 [ALC888_ASUS_M90V] = { 9510 [ALC888_ASUS_M90V] = {
9520 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9511 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9527,8 +9518,9 @@ static struct alc_config_preset alc883_presets[] = {
9527 .channel_mode = alc883_3ST_6ch_modes, 9518 .channel_mode = alc883_3ST_6ch_modes,
9528 .need_dac_fix = 1, 9519 .need_dac_fix = 1,
9529 .input_mux = &alc883_fujitsu_pi2515_capture_source, 9520 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9530 .unsol_event = alc883_mode2_unsol_event, 9521 .unsol_event = alc_sku_unsol_event,
9531 .init_hook = alc883_mode2_inithook, 9522 .setup = alc883_mode2_setup,
9523 .init_hook = alc_inithook,
9532 }, 9524 },
9533 [ALC888_ASUS_EEE1601] = { 9525 [ALC888_ASUS_EEE1601] = {
9534 .mixers = { alc883_asus_eee1601_mixer }, 9526 .mixers = { alc883_asus_eee1601_mixer },
@@ -9581,15 +9573,45 @@ static struct alc_config_preset alc883_presets[] = {
9581 .channel_mode = alc883_3ST_2ch_modes, 9573 .channel_mode = alc883_3ST_2ch_modes,
9582 .input_mux = &alc883_capture_source, 9574 .input_mux = &alc883_capture_source,
9583 .unsol_event = alc_automute_amp_unsol_event, 9575 .unsol_event = alc_automute_amp_unsol_event,
9584 .init_hook = alc883_vaiott_init_hook, 9576 .setup = alc883_vaiott_setup,
9577 .init_hook = alc_automute_amp,
9585 }, 9578 },
9586}; 9579};
9587 9580
9588 9581
9589/* 9582/*
9583 * Pin config fixes
9584 */
9585enum {
9586 PINFIX_ABIT_AW9D_MAX
9587};
9588
9589static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9590 { 0x15, 0x01080104 }, /* side */
9591 { 0x16, 0x01011012 }, /* rear */
9592 { 0x17, 0x01016011 }, /* clfe */
9593 { }
9594};
9595
9596static const struct alc_pincfg *alc882_pin_fixes[] = {
9597 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9598};
9599
9600static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9601 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9602 {}
9603};
9604
9605/*
9590 * BIOS auto configuration 9606 * BIOS auto configuration
9591 */ 9607 */
9592static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, 9608static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9609 const struct auto_pin_cfg *cfg)
9610{
9611 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9612}
9613
9614static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
9593 hda_nid_t nid, int pin_type, 9615 hda_nid_t nid, int pin_type,
9594 int dac_idx) 9616 int dac_idx)
9595{ 9617{
@@ -9606,7 +9628,7 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9606 9628
9607} 9629}
9608 9630
9609static void alc883_auto_init_multi_out(struct hda_codec *codec) 9631static void alc882_auto_init_multi_out(struct hda_codec *codec)
9610{ 9632{
9611 struct alc_spec *spec = codec->spec; 9633 struct alc_spec *spec = codec->spec;
9612 int i; 9634 int i;
@@ -9615,12 +9637,12 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
9615 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 9637 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9616 int pin_type = get_pin_type(spec->autocfg.line_out_type); 9638 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9617 if (nid) 9639 if (nid)
9618 alc883_auto_set_output_and_unmute(codec, nid, pin_type, 9640 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
9619 i); 9641 i);
9620 } 9642 }
9621} 9643}
9622 9644
9623static void alc883_auto_init_hp_out(struct hda_codec *codec) 9645static void alc882_auto_init_hp_out(struct hda_codec *codec)
9624{ 9646{
9625 struct alc_spec *spec = codec->spec; 9647 struct alc_spec *spec = codec->spec;
9626 hda_nid_t pin; 9648 hda_nid_t pin;
@@ -9628,91 +9650,191 @@ static void alc883_auto_init_hp_out(struct hda_codec *codec)
9628 pin = spec->autocfg.hp_pins[0]; 9650 pin = spec->autocfg.hp_pins[0];
9629 if (pin) /* connect to front */ 9651 if (pin) /* connect to front */
9630 /* use dac 0 */ 9652 /* use dac 0 */
9631 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 9653 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9632 pin = spec->autocfg.speaker_pins[0]; 9654 pin = spec->autocfg.speaker_pins[0];
9633 if (pin) 9655 if (pin)
9634 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 9656 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9635} 9657}
9636 9658
9637#define alc883_is_input_pin(nid) alc880_is_input_pin(nid) 9659static void alc882_auto_init_analog_input(struct hda_codec *codec)
9638#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9639
9640static void alc883_auto_init_analog_input(struct hda_codec *codec)
9641{ 9660{
9642 struct alc_spec *spec = codec->spec; 9661 struct alc_spec *spec = codec->spec;
9643 int i; 9662 int i;
9644 9663
9645 for (i = 0; i < AUTO_PIN_LAST; i++) { 9664 for (i = 0; i < AUTO_PIN_LAST; i++) {
9646 hda_nid_t nid = spec->autocfg.input_pins[i]; 9665 hda_nid_t nid = spec->autocfg.input_pins[i];
9647 if (alc883_is_input_pin(nid)) { 9666 if (!nid)
9648 alc_set_input_pin(codec, nid, i); 9667 continue;
9649 if (nid != ALC883_PIN_CD_NID && 9668 alc_set_input_pin(codec, nid, i);
9650 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 9669 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9670 snd_hda_codec_write(codec, nid, 0,
9671 AC_VERB_SET_AMP_GAIN_MUTE,
9672 AMP_OUT_MUTE);
9673 }
9674}
9675
9676static void alc882_auto_init_input_src(struct hda_codec *codec)
9677{
9678 struct alc_spec *spec = codec->spec;
9679 int c;
9680
9681 for (c = 0; c < spec->num_adc_nids; c++) {
9682 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9683 hda_nid_t nid = spec->capsrc_nids[c];
9684 unsigned int mux_idx;
9685 const struct hda_input_mux *imux;
9686 int conns, mute, idx, item;
9687
9688 conns = snd_hda_get_connections(codec, nid, conn_list,
9689 ARRAY_SIZE(conn_list));
9690 if (conns < 0)
9691 continue;
9692 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9693 imux = &spec->input_mux[mux_idx];
9694 for (idx = 0; idx < conns; idx++) {
9695 /* if the current connection is the selected one,
9696 * unmute it as default - otherwise mute it
9697 */
9698 mute = AMP_IN_MUTE(idx);
9699 for (item = 0; item < imux->num_items; item++) {
9700 if (imux->items[item].index == idx) {
9701 if (spec->cur_mux[c] == item)
9702 mute = AMP_IN_UNMUTE(idx);
9703 break;
9704 }
9705 }
9706 /* check if we have a selector or mixer
9707 * we could check for the widget type instead, but
9708 * just check for Amp-In presence (in case of mixer
9709 * without amp-in there is something wrong, this
9710 * function shouldn't be used or capsrc nid is wrong)
9711 */
9712 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
9651 snd_hda_codec_write(codec, nid, 0, 9713 snd_hda_codec_write(codec, nid, 0,
9652 AC_VERB_SET_AMP_GAIN_MUTE, 9714 AC_VERB_SET_AMP_GAIN_MUTE,
9653 AMP_OUT_MUTE); 9715 mute);
9716 else if (mute != AMP_IN_MUTE(idx))
9717 snd_hda_codec_write(codec, nid, 0,
9718 AC_VERB_SET_CONNECT_SEL,
9719 idx);
9654 } 9720 }
9655 } 9721 }
9656} 9722}
9657 9723
9658#define alc883_auto_init_input_src alc882_auto_init_input_src 9724/* add mic boosts if needed */
9725static int alc_auto_add_mic_boost(struct hda_codec *codec)
9726{
9727 struct alc_spec *spec = codec->spec;
9728 int err;
9729 hda_nid_t nid;
9730
9731 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9732 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9733 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9734 "Mic Boost",
9735 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9736 if (err < 0)
9737 return err;
9738 }
9739 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9740 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9741 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9742 "Front Mic Boost",
9743 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9744 if (err < 0)
9745 return err;
9746 }
9747 return 0;
9748}
9659 9749
9660/* almost identical with ALC880 parser... */ 9750/* almost identical with ALC880 parser... */
9661static int alc883_parse_auto_config(struct hda_codec *codec) 9751static int alc882_parse_auto_config(struct hda_codec *codec)
9662{ 9752{
9663 struct alc_spec *spec = codec->spec; 9753 struct alc_spec *spec = codec->spec;
9664 int err = alc880_parse_auto_config(codec); 9754 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9665 struct auto_pin_cfg *cfg = &spec->autocfg; 9755 int i, err;
9666 int i;
9667 9756
9757 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9758 alc882_ignore);
9668 if (err < 0) 9759 if (err < 0)
9669 return err; 9760 return err;
9670 else if (!err) 9761 if (!spec->autocfg.line_outs)
9671 return 0; /* no config found */ 9762 return 0; /* can't find valid BIOS pin config */
9672 9763
9673 err = alc_auto_add_mic_boost(codec); 9764 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9765 if (err < 0)
9766 return err;
9767 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9768 if (err < 0)
9769 return err;
9770 err = alc880_auto_create_extra_out(spec,
9771 spec->autocfg.speaker_pins[0],
9772 "Speaker");
9773 if (err < 0)
9774 return err;
9775 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9776 "Headphone");
9777 if (err < 0)
9778 return err;
9779 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9674 if (err < 0) 9780 if (err < 0)
9675 return err; 9781 return err;
9676 9782
9677 /* hack - override the init verbs */ 9783 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9678 spec->init_verbs[0] = alc883_auto_init_verbs;
9679 9784
9680 /* setup input_mux for ALC889 */ 9785 /* check multiple SPDIF-out (for recent codecs) */
9681 if (codec->vendor_id == 0x10ec0889) { 9786 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9682 /* digital-mic input pin is excluded in alc880_auto_create..() 9787 hda_nid_t dig_nid;
9683 * because it's under 0x18 9788 err = snd_hda_get_connections(codec,
9684 */ 9789 spec->autocfg.dig_out_pins[i],
9685 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || 9790 &dig_nid, 1);
9686 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { 9791 if (err < 0)
9687 struct hda_input_mux *imux = &spec->private_imux[0]; 9792 continue;
9688 for (i = 1; i < 3; i++) 9793 if (!i)
9689 memcpy(&spec->private_imux[i], 9794 spec->multiout.dig_out_nid = dig_nid;
9690 &spec->private_imux[0], 9795 else {
9691 sizeof(spec->private_imux[0])); 9796 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9692 imux->items[imux->num_items].label = "Int DMic"; 9797 spec->slave_dig_outs[i - 1] = dig_nid;
9693 imux->items[imux->num_items].index = 0x0b; 9798 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9694 imux->num_items++; 9799 break;
9695 spec->num_mux_defs = 3;
9696 spec->input_mux = spec->private_imux;
9697 } 9800 }
9698 } 9801 }
9802 if (spec->autocfg.dig_in_pin)
9803 spec->dig_in_nid = ALC880_DIGIN_NID;
9804
9805 if (spec->kctls.list)
9806 add_mixer(spec, spec->kctls.list);
9807
9808 add_verb(spec, alc883_auto_init_verbs);
9809 /* if ADC 0x07 is available, initialize it, too */
9810 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9811 add_verb(spec, alc882_adc1_init_verbs);
9812
9813 spec->num_mux_defs = 1;
9814 spec->input_mux = &spec->private_imux[0];
9815
9816 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
9817
9818 err = alc_auto_add_mic_boost(codec);
9819 if (err < 0)
9820 return err;
9699 9821
9700 return 1; /* config found */ 9822 return 1; /* config found */
9701} 9823}
9702 9824
9703/* additional initialization for auto-configuration model */ 9825/* additional initialization for auto-configuration model */
9704static void alc883_auto_init(struct hda_codec *codec) 9826static void alc882_auto_init(struct hda_codec *codec)
9705{ 9827{
9706 struct alc_spec *spec = codec->spec; 9828 struct alc_spec *spec = codec->spec;
9707 alc883_auto_init_multi_out(codec); 9829 alc882_auto_init_multi_out(codec);
9708 alc883_auto_init_hp_out(codec); 9830 alc882_auto_init_hp_out(codec);
9709 alc883_auto_init_analog_input(codec); 9831 alc882_auto_init_analog_input(codec);
9710 alc883_auto_init_input_src(codec); 9832 alc882_auto_init_input_src(codec);
9711 if (spec->unsol_event) 9833 if (spec->unsol_event)
9712 alc_inithook(codec); 9834 alc_inithook(codec);
9713} 9835}
9714 9836
9715static int patch_alc883(struct hda_codec *codec) 9837static int patch_alc882(struct hda_codec *codec)
9716{ 9838{
9717 struct alc_spec *spec; 9839 struct alc_spec *spec;
9718 int err, board_config; 9840 int err, board_config;
@@ -9723,28 +9845,35 @@ static int patch_alc883(struct hda_codec *codec)
9723 9845
9724 codec->spec = spec; 9846 codec->spec = spec;
9725 9847
9726 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 9848 switch (codec->vendor_id) {
9849 case 0x10ec0882:
9850 case 0x10ec0885:
9851 break;
9852 default:
9853 /* ALC883 and variants */
9854 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9855 break;
9856 }
9727 9857
9728 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, 9858 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9729 alc883_models, 9859 alc882_models,
9730 alc883_cfg_tbl); 9860 alc882_cfg_tbl);
9731 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) { 9861
9732 /* Pick up systems that don't supply PCI SSID */ 9862 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9733 switch (codec->subsystem_id) { 9863 board_config = snd_hda_check_board_codec_sid_config(codec,
9734 case 0x106b3600: /* Macbook 3.1 */ 9864 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9735 board_config = ALC889A_MB31; 9865
9736 break; 9866 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
9737 default: 9867 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
9738 printk(KERN_INFO 9868 codec->chip_name);
9739 "hda_codec: Unknown model for %s, trying " 9869 board_config = ALC882_AUTO;
9740 "auto-probe from BIOS...\n", codec->chip_name);
9741 board_config = ALC883_AUTO;
9742 }
9743 } 9870 }
9744 9871
9745 if (board_config == ALC883_AUTO) { 9872 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9873
9874 if (board_config == ALC882_AUTO) {
9746 /* automatic parse from the BIOS config */ 9875 /* automatic parse from the BIOS config */
9747 err = alc883_parse_auto_config(codec); 9876 err = alc882_parse_auto_config(codec);
9748 if (err < 0) { 9877 if (err < 0) {
9749 alc_free(codec); 9878 alc_free(codec);
9750 return err; 9879 return err;
@@ -9752,7 +9881,7 @@ static int patch_alc883(struct hda_codec *codec)
9752 printk(KERN_INFO 9881 printk(KERN_INFO
9753 "hda_codec: Cannot set up configuration " 9882 "hda_codec: Cannot set up configuration "
9754 "from BIOS. Using base mode...\n"); 9883 "from BIOS. Using base mode...\n");
9755 board_config = ALC883_3ST_2ch_DIG; 9884 board_config = ALC882_3ST_DIG;
9756 } 9885 }
9757 } 9886 }
9758 9887
@@ -9762,63 +9891,61 @@ static int patch_alc883(struct hda_codec *codec)
9762 return err; 9891 return err;
9763 } 9892 }
9764 9893
9765 if (board_config != ALC883_AUTO) 9894 if (board_config != ALC882_AUTO)
9766 setup_preset(spec, &alc883_presets[board_config]); 9895 setup_preset(codec, &alc882_presets[board_config]);
9767 9896
9768 switch (codec->vendor_id) { 9897 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9769 case 0x10ec0888: 9898 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9770 if (!spec->num_adc_nids) { 9899 /* FIXME: setup DAC5 */
9771 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9900 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9772 spec->adc_nids = alc883_adc_nids; 9901 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9773 } 9902
9774 if (!spec->capsrc_nids) 9903 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9775 spec->capsrc_nids = alc883_capsrc_nids; 9904 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9905
9906 if (codec->vendor_id == 0x10ec0888)
9776 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ 9907 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
9777 break; 9908
9778 case 0x10ec0889: 9909 if (!spec->adc_nids && spec->input_mux) {
9779 if (!spec->num_adc_nids) { 9910 int i;
9780 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); 9911 spec->num_adc_nids = 0;
9781 spec->adc_nids = alc889_adc_nids; 9912 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9782 } 9913 hda_nid_t cap;
9783 if (!spec->capsrc_nids) 9914 hda_nid_t nid = alc882_adc_nids[i];
9784 spec->capsrc_nids = alc889_capsrc_nids; 9915 unsigned int wcap = get_wcaps(codec, nid);
9785 break; 9916 /* get type */
9786 default: 9917 wcap = get_wcaps_type(wcap);
9787 if (!spec->num_adc_nids) { 9918 if (wcap != AC_WID_AUD_IN)
9788 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9919 continue;
9789 spec->adc_nids = alc883_adc_nids; 9920 spec->private_adc_nids[spec->num_adc_nids] = nid;
9921 err = snd_hda_get_connections(codec, nid, &cap, 1);
9922 if (err < 0)
9923 continue;
9924 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9925 spec->num_adc_nids++;
9790 } 9926 }
9791 if (!spec->capsrc_nids) 9927 spec->adc_nids = spec->private_adc_nids;
9792 spec->capsrc_nids = alc883_capsrc_nids; 9928 spec->capsrc_nids = spec->private_capsrc_nids;
9793 break;
9794 } 9929 }
9795 9930
9796 spec->stream_analog_playback = &alc883_pcm_analog_playback; 9931 set_capture_mixer(codec);
9797 spec->stream_analog_capture = &alc883_pcm_analog_capture;
9798 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
9799
9800 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9801 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9802
9803 if (!spec->cap_mixer)
9804 set_capture_mixer(spec);
9805 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 9932 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9806 9933
9807 spec->vmaster_nid = 0x0c; 9934 spec->vmaster_nid = 0x0c;
9808 9935
9809 codec->patch_ops = alc_patch_ops; 9936 codec->patch_ops = alc_patch_ops;
9810 if (board_config == ALC883_AUTO) 9937 if (board_config == ALC882_AUTO)
9811 spec->init_hook = alc883_auto_init; 9938 spec->init_hook = alc882_auto_init;
9812
9813#ifdef CONFIG_SND_HDA_POWER_SAVE 9939#ifdef CONFIG_SND_HDA_POWER_SAVE
9814 if (!spec->loopback.amplist) 9940 if (!spec->loopback.amplist)
9815 spec->loopback.amplist = alc883_loopbacks; 9941 spec->loopback.amplist = alc882_loopbacks;
9816#endif 9942#endif
9817 codec->proc_widget_hook = print_realtek_coef; 9943 codec->proc_widget_hook = print_realtek_coef;
9818 9944
9819 return 0; 9945 return 0;
9820} 9946}
9821 9947
9948
9822/* 9949/*
9823 * ALC262 support 9950 * ALC262 support
9824 */ 9951 */
@@ -9994,13 +10121,12 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9994}; 10121};
9995 10122
9996/* mute/unmute internal speaker according to the hp jack and mute state */ 10123/* mute/unmute internal speaker according to the hp jack and mute state */
9997static void alc262_hp_t5735_init_hook(struct hda_codec *codec) 10124static void alc262_hp_t5735_setup(struct hda_codec *codec)
9998{ 10125{
9999 struct alc_spec *spec = codec->spec; 10126 struct alc_spec *spec = codec->spec;
10000 10127
10001 spec->autocfg.hp_pins[0] = 0x15; 10128 spec->autocfg.hp_pins[0] = 0x15;
10002 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ 10129 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10003 alc_automute_amp(codec);
10004} 10130}
10005 10131
10006static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { 10132static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
@@ -10157,22 +10283,20 @@ static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10157 alc262_hippo_automute(codec); 10283 alc262_hippo_automute(codec);
10158} 10284}
10159 10285
10160static void alc262_hippo_init_hook(struct hda_codec *codec) 10286static void alc262_hippo_setup(struct hda_codec *codec)
10161{ 10287{
10162 struct alc_spec *spec = codec->spec; 10288 struct alc_spec *spec = codec->spec;
10163 10289
10164 spec->autocfg.hp_pins[0] = 0x15; 10290 spec->autocfg.hp_pins[0] = 0x15;
10165 spec->autocfg.speaker_pins[0] = 0x14; 10291 spec->autocfg.speaker_pins[0] = 0x14;
10166 alc262_hippo_automute(codec);
10167} 10292}
10168 10293
10169static void alc262_hippo1_init_hook(struct hda_codec *codec) 10294static void alc262_hippo1_setup(struct hda_codec *codec)
10170{ 10295{
10171 struct alc_spec *spec = codec->spec; 10296 struct alc_spec *spec = codec->spec;
10172 10297
10173 spec->autocfg.hp_pins[0] = 0x1b; 10298 spec->autocfg.hp_pins[0] = 0x1b;
10174 spec->autocfg.speaker_pins[0] = 0x14; 10299 spec->autocfg.speaker_pins[0] = 0x14;
10175 alc262_hippo_automute(codec);
10176} 10300}
10177 10301
10178 10302
@@ -10229,13 +10353,12 @@ static struct hda_verb alc262_tyan_verbs[] = {
10229}; 10353};
10230 10354
10231/* unsolicited event for HP jack sensing */ 10355/* unsolicited event for HP jack sensing */
10232static void alc262_tyan_init_hook(struct hda_codec *codec) 10356static void alc262_tyan_setup(struct hda_codec *codec)
10233{ 10357{
10234 struct alc_spec *spec = codec->spec; 10358 struct alc_spec *spec = codec->spec;
10235 10359
10236 spec->autocfg.hp_pins[0] = 0x1b; 10360 spec->autocfg.hp_pins[0] = 0x1b;
10237 spec->autocfg.speaker_pins[0] = 0x15; 10361 spec->autocfg.speaker_pins[0] = 0x15;
10238 alc_automute_amp(codec);
10239} 10362}
10240 10363
10241 10364
@@ -10327,12 +10450,6 @@ static struct hda_verb alc262_eapd_verbs[] = {
10327 { } 10450 { }
10328}; 10451};
10329 10452
10330static struct hda_verb alc262_hippo_unsol_verbs[] = {
10331 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10333 {}
10334};
10335
10336static struct hda_verb alc262_hippo1_unsol_verbs[] = { 10453static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10337 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 10454 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10338 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 10455 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -10353,14 +10470,6 @@ static struct hda_verb alc262_sony_unsol_verbs[] = {
10353 {} 10470 {}
10354}; 10471};
10355 10472
10356static struct hda_input_mux alc262_dmic_capture_source = {
10357 .num_items = 2,
10358 .items = {
10359 { "Int DMic", 0x9 },
10360 { "Mic", 0x0 },
10361 },
10362};
10363
10364static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { 10473static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 10474 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10366 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10475 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
@@ -10382,35 +10491,17 @@ static struct hda_verb alc262_toshiba_s06_verbs[] = {
10382 {} 10491 {}
10383}; 10492};
10384 10493
10385static void alc262_dmic_automute(struct hda_codec *codec) 10494static void alc262_toshiba_s06_setup(struct hda_codec *codec)
10386{
10387 unsigned int present;
10388
10389 present = snd_hda_codec_read(codec, 0x18, 0,
10390 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10391 snd_hda_codec_write(codec, 0x22, 0,
10392 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10393}
10394
10395
10396/* unsolicited event for HP jack sensing */
10397static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10398 unsigned int res)
10399{
10400 if ((res >> 26) == ALC880_MIC_EVENT)
10401 alc262_dmic_automute(codec);
10402 else
10403 alc_sku_unsol_event(codec, res);
10404}
10405
10406static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10407{ 10495{
10408 struct alc_spec *spec = codec->spec; 10496 struct alc_spec *spec = codec->spec;
10409 10497
10410 spec->autocfg.hp_pins[0] = 0x15; 10498 spec->autocfg.hp_pins[0] = 0x15;
10411 spec->autocfg.speaker_pins[0] = 0x14; 10499 spec->autocfg.speaker_pins[0] = 0x14;
10412 alc_automute_pin(codec); 10500 spec->ext_mic.pin = 0x18;
10413 alc262_dmic_automute(codec); 10501 spec->ext_mic.mux_idx = 0;
10502 spec->int_mic.pin = 0x12;
10503 spec->int_mic.mux_idx = 9;
10504 spec->auto_mic = 1;
10414} 10505}
10415 10506
10416/* 10507/*
@@ -10599,6 +10690,18 @@ static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10599 alc262_lenovo_3000_automute(codec, 1); 10690 alc262_lenovo_3000_automute(codec, 1);
10600} 10691}
10601 10692
10693static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10694 int dir, int idx, long *valp)
10695{
10696 int i, change = 0;
10697
10698 for (i = 0; i < 2; i++, valp++)
10699 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10700 HDA_AMP_MUTE,
10701 *valp ? 0 : HDA_AMP_MUTE);
10702 return change;
10703}
10704
10602/* bind hp and internal speaker mute (with plug check) */ 10705/* bind hp and internal speaker mute (with plug check) */
10603static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 10706static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10604 struct snd_ctl_elem_value *ucontrol) 10707 struct snd_ctl_elem_value *ucontrol)
@@ -10607,13 +10710,8 @@ static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10607 long *valp = ucontrol->value.integer.value; 10710 long *valp = ucontrol->value.integer.value;
10608 int change; 10711 int change;
10609 10712
10610 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 10713 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10611 HDA_AMP_MUTE, 10714 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
10612 valp ? 0 : HDA_AMP_MUTE);
10613 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10614 HDA_AMP_MUTE,
10615 valp ? 0 : HDA_AMP_MUTE);
10616
10617 if (change) 10715 if (change)
10618 alc262_fujitsu_automute(codec, 0); 10716 alc262_fujitsu_automute(codec, 0);
10619 return change; 10717 return change;
@@ -10648,10 +10746,7 @@ static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10648 long *valp = ucontrol->value.integer.value; 10746 long *valp = ucontrol->value.integer.value;
10649 int change; 10747 int change;
10650 10748
10651 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 10749 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
10652 HDA_AMP_MUTE,
10653 valp ? 0 : HDA_AMP_MUTE);
10654
10655 if (change) 10750 if (change)
10656 alc262_lenovo_3000_automute(codec, 0); 10751 alc262_lenovo_3000_automute(codec, 0);
10657 return change; 10752 return change;
@@ -10824,104 +10919,111 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10824 { } /* end */ 10919 { } /* end */
10825}; 10920};
10826 10921
10922/* We use two mixers depending on the output pin; 0x16 is a mono output
10923 * and thus it's bound with a different mixer.
10924 * This function returns which mixer amp should be used.
10925 */
10926static int alc262_check_volbit(hda_nid_t nid)
10927{
10928 if (!nid)
10929 return 0;
10930 else if (nid == 0x16)
10931 return 2;
10932 else
10933 return 1;
10934}
10935
10936static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10937 const char *pfx, int *vbits)
10938{
10939 char name[32];
10940 unsigned long val;
10941 int vbit;
10942
10943 vbit = alc262_check_volbit(nid);
10944 if (!vbit)
10945 return 0;
10946 if (*vbits & vbit) /* a volume control for this mixer already there */
10947 return 0;
10948 *vbits |= vbit;
10949 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10950 if (vbit == 2)
10951 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10952 else
10953 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10954 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10955}
10956
10957static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10958 const char *pfx)
10959{
10960 char name[32];
10961 unsigned long val;
10962
10963 if (!nid)
10964 return 0;
10965 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10966 if (nid == 0x16)
10967 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10968 else
10969 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10970 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10971}
10972
10827/* add playback controls from the parsed DAC table */ 10973/* add playback controls from the parsed DAC table */
10828static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, 10974static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10829 const struct auto_pin_cfg *cfg) 10975 const struct auto_pin_cfg *cfg)
10830{ 10976{
10831 hda_nid_t nid; 10977 const char *pfx;
10978 int vbits;
10832 int err; 10979 int err;
10833 10980
10834 spec->multiout.num_dacs = 1; /* only use one dac */ 10981 spec->multiout.num_dacs = 1; /* only use one dac */
10835 spec->multiout.dac_nids = spec->private_dac_nids; 10982 spec->multiout.dac_nids = spec->private_dac_nids;
10836 spec->multiout.dac_nids[0] = 2; 10983 spec->multiout.dac_nids[0] = 2;
10837 10984
10838 nid = cfg->line_out_pins[0]; 10985 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
10839 if (nid) { 10986 pfx = "Master";
10840 err = add_control(spec, ALC_CTL_WIDGET_VOL, 10987 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10841 "Front Playback Volume", 10988 pfx = "Speaker";
10842 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); 10989 else
10843 if (err < 0) 10990 pfx = "Front";
10844 return err; 10991 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
10845 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 10992 if (err < 0)
10846 "Front Playback Switch", 10993 return err;
10847 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 10994 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
10848 if (err < 0) 10995 if (err < 0)
10849 return err; 10996 return err;
10850 } 10997 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
10851 10998 if (err < 0)
10852 nid = cfg->speaker_pins[0]; 10999 return err;
10853 if (nid) {
10854 if (nid == 0x16) {
10855 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10856 "Speaker Playback Volume",
10857 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10858 HDA_OUTPUT));
10859 if (err < 0)
10860 return err;
10861 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10862 "Speaker Playback Switch",
10863 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10864 HDA_OUTPUT));
10865 if (err < 0)
10866 return err;
10867 } else {
10868 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10869 "Speaker Playback Switch",
10870 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10871 HDA_OUTPUT));
10872 if (err < 0)
10873 return err;
10874 }
10875 }
10876 nid = cfg->hp_pins[0];
10877 if (nid) {
10878 /* spec->multiout.hp_nid = 2; */
10879 if (nid == 0x16) {
10880 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10881 "Headphone Playback Volume",
10882 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10883 HDA_OUTPUT));
10884 if (err < 0)
10885 return err;
10886 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10887 "Headphone Playback Switch",
10888 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10889 HDA_OUTPUT));
10890 if (err < 0)
10891 return err;
10892 } else {
10893 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10894 "Headphone Playback Switch",
10895 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10896 HDA_OUTPUT));
10897 if (err < 0)
10898 return err;
10899 }
10900 }
10901 return 0;
10902}
10903
10904static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10905 const struct auto_pin_cfg *cfg)
10906{
10907 int err;
10908 11000
10909 err = alc880_auto_create_analog_input_ctls(spec, cfg); 11001 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11002 alc262_check_volbit(cfg->speaker_pins[0]) |
11003 alc262_check_volbit(cfg->hp_pins[0]);
11004 if (vbits == 1 || vbits == 2)
11005 pfx = "Master"; /* only one mixer is used */
11006 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11007 pfx = "Speaker";
11008 else
11009 pfx = "Front";
11010 vbits = 0;
11011 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11012 if (err < 0)
11013 return err;
11014 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11015 &vbits);
11016 if (err < 0)
11017 return err;
11018 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11019 &vbits);
10910 if (err < 0) 11020 if (err < 0)
10911 return err; 11021 return err;
10912 /* digital-mic input pin is excluded in alc880_auto_create..()
10913 * because it's under 0x18
10914 */
10915 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10916 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10917 struct hda_input_mux *imux = &spec->private_imux[0];
10918 imux->items[imux->num_items].label = "Int Mic";
10919 imux->items[imux->num_items].index = 0x09;
10920 imux->num_items++;
10921 }
10922 return 0; 11022 return 0;
10923} 11023}
10924 11024
11025#define alc262_auto_create_input_ctls \
11026 alc880_auto_create_input_ctls
10925 11027
10926/* 11028/*
10927 * generic initialization of ADC, input mixers and output mixers 11029 * generic initialization of ADC, input mixers and output mixers
@@ -11239,7 +11341,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
11239 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); 11341 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11240 if (err < 0) 11342 if (err < 0)
11241 return err; 11343 return err;
11242 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); 11344 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
11243 if (err < 0) 11345 if (err < 0)
11244 return err; 11346 return err;
11245 11347
@@ -11370,7 +11472,7 @@ static struct alc_config_preset alc262_presets[] = {
11370 }, 11472 },
11371 [ALC262_HIPPO] = { 11473 [ALC262_HIPPO] = {
11372 .mixers = { alc262_hippo_mixer }, 11474 .mixers = { alc262_hippo_mixer },
11373 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, 11475 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
11374 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 11476 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11375 .dac_nids = alc262_dac_nids, 11477 .dac_nids = alc262_dac_nids,
11376 .hp_nid = 0x03, 11478 .hp_nid = 0x03,
@@ -11379,7 +11481,8 @@ static struct alc_config_preset alc262_presets[] = {
11379 .channel_mode = alc262_modes, 11481 .channel_mode = alc262_modes,
11380 .input_mux = &alc262_capture_source, 11482 .input_mux = &alc262_capture_source,
11381 .unsol_event = alc262_hippo_unsol_event, 11483 .unsol_event = alc262_hippo_unsol_event,
11382 .init_hook = alc262_hippo_init_hook, 11484 .setup = alc262_hippo_setup,
11485 .init_hook = alc262_hippo_automute,
11383 }, 11486 },
11384 [ALC262_HIPPO_1] = { 11487 [ALC262_HIPPO_1] = {
11385 .mixers = { alc262_hippo1_mixer }, 11488 .mixers = { alc262_hippo1_mixer },
@@ -11392,7 +11495,8 @@ static struct alc_config_preset alc262_presets[] = {
11392 .channel_mode = alc262_modes, 11495 .channel_mode = alc262_modes,
11393 .input_mux = &alc262_capture_source, 11496 .input_mux = &alc262_capture_source,
11394 .unsol_event = alc262_hippo_unsol_event, 11497 .unsol_event = alc262_hippo_unsol_event,
11395 .init_hook = alc262_hippo1_init_hook, 11498 .setup = alc262_hippo1_setup,
11499 .init_hook = alc262_hippo_automute,
11396 }, 11500 },
11397 [ALC262_FUJITSU] = { 11501 [ALC262_FUJITSU] = {
11398 .mixers = { alc262_fujitsu_mixer }, 11502 .mixers = { alc262_fujitsu_mixer },
@@ -11455,7 +11559,8 @@ static struct alc_config_preset alc262_presets[] = {
11455 .channel_mode = alc262_modes, 11559 .channel_mode = alc262_modes,
11456 .input_mux = &alc262_capture_source, 11560 .input_mux = &alc262_capture_source,
11457 .unsol_event = alc_automute_amp_unsol_event, 11561 .unsol_event = alc_automute_amp_unsol_event,
11458 .init_hook = alc262_hp_t5735_init_hook, 11562 .setup = alc262_hp_t5735_setup,
11563 .init_hook = alc_automute_amp,
11459 }, 11564 },
11460 [ALC262_HP_RP5700] = { 11565 [ALC262_HP_RP5700] = {
11461 .mixers = { alc262_hp_rp5700_mixer }, 11566 .mixers = { alc262_hp_rp5700_mixer },
@@ -11486,11 +11591,13 @@ static struct alc_config_preset alc262_presets[] = {
11486 .channel_mode = alc262_modes, 11591 .channel_mode = alc262_modes,
11487 .input_mux = &alc262_capture_source, 11592 .input_mux = &alc262_capture_source,
11488 .unsol_event = alc262_hippo_unsol_event, 11593 .unsol_event = alc262_hippo_unsol_event,
11489 .init_hook = alc262_hippo_init_hook, 11594 .setup = alc262_hippo_setup,
11595 .init_hook = alc262_hippo_automute,
11490 }, 11596 },
11491 [ALC262_BENQ_T31] = { 11597 [ALC262_BENQ_T31] = {
11492 .mixers = { alc262_benq_t31_mixer }, 11598 .mixers = { alc262_benq_t31_mixer },
11493 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, 11599 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11600 alc_hp15_unsol_verbs },
11494 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 11601 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11495 .dac_nids = alc262_dac_nids, 11602 .dac_nids = alc262_dac_nids,
11496 .hp_nid = 0x03, 11603 .hp_nid = 0x03,
@@ -11498,7 +11605,8 @@ static struct alc_config_preset alc262_presets[] = {
11498 .channel_mode = alc262_modes, 11605 .channel_mode = alc262_modes,
11499 .input_mux = &alc262_capture_source, 11606 .input_mux = &alc262_capture_source,
11500 .unsol_event = alc262_hippo_unsol_event, 11607 .unsol_event = alc262_hippo_unsol_event,
11501 .init_hook = alc262_hippo_init_hook, 11608 .setup = alc262_hippo_setup,
11609 .init_hook = alc262_hippo_automute,
11502 }, 11610 },
11503 [ALC262_ULTRA] = { 11611 [ALC262_ULTRA] = {
11504 .mixers = { alc262_ultra_mixer }, 11612 .mixers = { alc262_ultra_mixer },
@@ -11550,9 +11658,9 @@ static struct alc_config_preset alc262_presets[] = {
11550 .dig_out_nid = ALC262_DIGOUT_NID, 11658 .dig_out_nid = ALC262_DIGOUT_NID,
11551 .num_channel_mode = ARRAY_SIZE(alc262_modes), 11659 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11552 .channel_mode = alc262_modes, 11660 .channel_mode = alc262_modes,
11553 .input_mux = &alc262_dmic_capture_source, 11661 .unsol_event = alc_sku_unsol_event,
11554 .unsol_event = alc262_toshiba_s06_unsol_event, 11662 .setup = alc262_toshiba_s06_setup,
11555 .init_hook = alc262_toshiba_s06_init_hook, 11663 .init_hook = alc_inithook,
11556 }, 11664 },
11557 [ALC262_TOSHIBA_RX1] = { 11665 [ALC262_TOSHIBA_RX1] = {
11558 .mixers = { alc262_toshiba_rx1_mixer }, 11666 .mixers = { alc262_toshiba_rx1_mixer },
@@ -11564,7 +11672,8 @@ static struct alc_config_preset alc262_presets[] = {
11564 .channel_mode = alc262_modes, 11672 .channel_mode = alc262_modes,
11565 .input_mux = &alc262_capture_source, 11673 .input_mux = &alc262_capture_source,
11566 .unsol_event = alc262_hippo_unsol_event, 11674 .unsol_event = alc262_hippo_unsol_event,
11567 .init_hook = alc262_hippo_init_hook, 11675 .setup = alc262_hippo_setup,
11676 .init_hook = alc262_hippo_automute,
11568 }, 11677 },
11569 [ALC262_TYAN] = { 11678 [ALC262_TYAN] = {
11570 .mixers = { alc262_tyan_mixer }, 11679 .mixers = { alc262_tyan_mixer },
@@ -11577,7 +11686,8 @@ static struct alc_config_preset alc262_presets[] = {
11577 .channel_mode = alc262_modes, 11686 .channel_mode = alc262_modes,
11578 .input_mux = &alc262_capture_source, 11687 .input_mux = &alc262_capture_source,
11579 .unsol_event = alc_automute_amp_unsol_event, 11688 .unsol_event = alc_automute_amp_unsol_event,
11580 .init_hook = alc262_tyan_init_hook, 11689 .setup = alc262_tyan_setup,
11690 .init_hook = alc_automute_amp,
11581 }, 11691 },
11582}; 11692};
11583 11693
@@ -11612,8 +11722,8 @@ static int patch_alc262(struct hda_codec *codec)
11612 alc262_cfg_tbl); 11722 alc262_cfg_tbl);
11613 11723
11614 if (board_config < 0) { 11724 if (board_config < 0) {
11615 printk(KERN_INFO "hda_codec: Unknown model for %s, " 11725 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11616 "trying auto-probe from BIOS...\n", codec->chip_name); 11726 codec->chip_name);
11617 board_config = ALC262_AUTO; 11727 board_config = ALC262_AUTO;
11618 } 11728 }
11619 11729
@@ -11640,7 +11750,7 @@ static int patch_alc262(struct hda_codec *codec)
11640 } 11750 }
11641 11751
11642 if (board_config != ALC262_AUTO) 11752 if (board_config != ALC262_AUTO)
11643 setup_preset(spec, &alc262_presets[board_config]); 11753 setup_preset(codec, &alc262_presets[board_config]);
11644 11754
11645 spec->stream_analog_playback = &alc262_pcm_analog_playback; 11755 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11646 spec->stream_analog_capture = &alc262_pcm_analog_capture; 11756 spec->stream_analog_capture = &alc262_pcm_analog_capture;
@@ -11666,7 +11776,7 @@ static int patch_alc262(struct hda_codec *codec)
11666 unsigned int wcap = get_wcaps(codec, 0x07); 11776 unsigned int wcap = get_wcaps(codec, 0x07);
11667 11777
11668 /* get type */ 11778 /* get type */
11669 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 11779 wcap = get_wcaps_type(wcap);
11670 if (wcap != AC_WID_AUD_IN) { 11780 if (wcap != AC_WID_AUD_IN) {
11671 spec->adc_nids = alc262_adc_nids_alt; 11781 spec->adc_nids = alc262_adc_nids_alt;
11672 spec->num_adc_nids = 11782 spec->num_adc_nids =
@@ -11681,7 +11791,7 @@ static int patch_alc262(struct hda_codec *codec)
11681 } 11791 }
11682 } 11792 }
11683 if (!spec->cap_mixer && !spec->no_analog) 11793 if (!spec->cap_mixer && !spec->no_analog)
11684 set_capture_mixer(spec); 11794 set_capture_mixer(codec);
11685 if (!spec->no_analog) 11795 if (!spec->no_analog)
11686 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 11796 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11687 11797
@@ -11773,14 +11883,6 @@ static struct hda_verb alc268_toshiba_verbs[] = {
11773 { } /* end */ 11883 { } /* end */
11774}; 11884};
11775 11885
11776static struct hda_input_mux alc268_acer_lc_capture_source = {
11777 .num_items = 2,
11778 .items = {
11779 { "i-Mic", 0x6 },
11780 { "E-Mic", 0x0 },
11781 },
11782};
11783
11784/* Acer specific */ 11886/* Acer specific */
11785/* bind volumes of both NID 0x02 and 0x03 */ 11887/* bind volumes of both NID 0x02 and 0x03 */
11786static struct hda_bind_ctls alc268_acer_bind_master_vol = { 11888static struct hda_bind_ctls alc268_acer_bind_master_vol = {
@@ -11822,12 +11924,7 @@ static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11822 long *valp = ucontrol->value.integer.value; 11924 long *valp = ucontrol->value.integer.value;
11823 int change; 11925 int change;
11824 11926
11825 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 11927 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11826 HDA_AMP_MUTE,
11827 valp[0] ? 0 : HDA_AMP_MUTE);
11828 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11829 HDA_AMP_MUTE,
11830 valp[1] ? 0 : HDA_AMP_MUTE);
11831 if (change) 11928 if (change)
11832 alc268_acer_automute(codec, 0); 11929 alc268_acer_automute(codec, 0);
11833 return change; 11930 return change;
@@ -11904,7 +12001,8 @@ static struct hda_verb alc268_acer_verbs[] = {
11904 12001
11905/* unsolicited event for HP jack sensing */ 12002/* unsolicited event for HP jack sensing */
11906#define alc268_toshiba_unsol_event alc262_hippo_unsol_event 12003#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11907#define alc268_toshiba_init_hook alc262_hippo_init_hook 12004#define alc268_toshiba_setup alc262_hippo_setup
12005#define alc268_toshiba_automute alc262_hippo_automute
11908 12006
11909static void alc268_acer_unsol_event(struct hda_codec *codec, 12007static void alc268_acer_unsol_event(struct hda_codec *codec,
11910 unsigned int res) 12008 unsigned int res)
@@ -11934,30 +12032,33 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11934 AMP_IN_MUTE(0), bits); 12032 AMP_IN_MUTE(0), bits);
11935} 12033}
11936 12034
11937
11938static void alc268_acer_mic_automute(struct hda_codec *codec)
11939{
11940 unsigned int present;
11941
11942 present = snd_hda_codec_read(codec, 0x18, 0,
11943 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11944 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11945 present ? 0x0 : 0x6);
11946}
11947
11948static void alc268_acer_lc_unsol_event(struct hda_codec *codec, 12035static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11949 unsigned int res) 12036 unsigned int res)
11950{ 12037{
11951 if ((res >> 26) == ALC880_HP_EVENT) 12038 switch (res >> 26) {
12039 case ALC880_HP_EVENT:
11952 alc268_aspire_one_speaker_automute(codec); 12040 alc268_aspire_one_speaker_automute(codec);
11953 if ((res >> 26) == ALC880_MIC_EVENT) 12041 break;
11954 alc268_acer_mic_automute(codec); 12042 case ALC880_MIC_EVENT:
12043 alc_mic_automute(codec);
12044 break;
12045 }
12046}
12047
12048static void alc268_acer_lc_setup(struct hda_codec *codec)
12049{
12050 struct alc_spec *spec = codec->spec;
12051 spec->ext_mic.pin = 0x18;
12052 spec->ext_mic.mux_idx = 0;
12053 spec->int_mic.pin = 0x12;
12054 spec->int_mic.mux_idx = 6;
12055 spec->auto_mic = 1;
11955} 12056}
11956 12057
11957static void alc268_acer_lc_init_hook(struct hda_codec *codec) 12058static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11958{ 12059{
11959 alc268_aspire_one_speaker_automute(codec); 12060 alc268_aspire_one_speaker_automute(codec);
11960 alc268_acer_mic_automute(codec); 12061 alc_mic_automute(codec);
11961} 12062}
11962 12063
11963static struct snd_kcontrol_new alc268_dell_mixer[] = { 12064static struct snd_kcontrol_new alc268_dell_mixer[] = {
@@ -11975,17 +12076,22 @@ static struct hda_verb alc268_dell_verbs[] = {
11975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 12076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 12077 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11977 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 12078 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12079 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11978 { } 12080 { }
11979}; 12081};
11980 12082
11981/* mute/unmute internal speaker according to the hp jack and mute state */ 12083/* mute/unmute internal speaker according to the hp jack and mute state */
11982static void alc268_dell_init_hook(struct hda_codec *codec) 12084static void alc268_dell_setup(struct hda_codec *codec)
11983{ 12085{
11984 struct alc_spec *spec = codec->spec; 12086 struct alc_spec *spec = codec->spec;
11985 12087
11986 spec->autocfg.hp_pins[0] = 0x15; 12088 spec->autocfg.hp_pins[0] = 0x15;
11987 spec->autocfg.speaker_pins[0] = 0x14; 12089 spec->autocfg.speaker_pins[0] = 0x14;
11988 alc_automute_pin(codec); 12090 spec->ext_mic.pin = 0x18;
12091 spec->ext_mic.mux_idx = 0;
12092 spec->int_mic.pin = 0x19;
12093 spec->int_mic.mux_idx = 1;
12094 spec->auto_mic = 1;
11989} 12095}
11990 12096
11991static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { 12097static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
@@ -12006,38 +12112,16 @@ static struct hda_verb alc267_quanta_il1_verbs[] = {
12006 { } 12112 { }
12007}; 12113};
12008 12114
12009static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) 12115static void alc267_quanta_il1_setup(struct hda_codec *codec)
12010{
12011 unsigned int present;
12012
12013 present = snd_hda_codec_read(codec, 0x18, 0,
12014 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12015 snd_hda_codec_write(codec, 0x23, 0,
12016 AC_VERB_SET_CONNECT_SEL,
12017 present ? 0x00 : 0x01);
12018}
12019
12020static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
12021{ 12116{
12022 struct alc_spec *spec = codec->spec; 12117 struct alc_spec *spec = codec->spec;
12023
12024 spec->autocfg.hp_pins[0] = 0x15; 12118 spec->autocfg.hp_pins[0] = 0x15;
12025 spec->autocfg.speaker_pins[0] = 0x14; 12119 spec->autocfg.speaker_pins[0] = 0x14;
12026 alc_automute_pin(codec); 12120 spec->ext_mic.pin = 0x18;
12027 alc267_quanta_il1_mic_automute(codec); 12121 spec->ext_mic.mux_idx = 0;
12028} 12122 spec->int_mic.pin = 0x19;
12029 12123 spec->int_mic.mux_idx = 1;
12030static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, 12124 spec->auto_mic = 1;
12031 unsigned int res)
12032{
12033 switch (res >> 26) {
12034 case ALC880_MIC_EVENT:
12035 alc267_quanta_il1_mic_automute(codec);
12036 break;
12037 default:
12038 alc_sku_unsol_event(codec, res);
12039 break;
12040 }
12041} 12125}
12042 12126
12043/* 12127/*
@@ -12117,21 +12201,16 @@ static struct hda_verb alc268_volume_init_verbs[] = {
12117 { } 12201 { }
12118}; 12202};
12119 12203
12204static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12205 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12206 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12207 { } /* end */
12208};
12209
12120static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 12210static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12121 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 12211 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12122 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 12212 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12123 { 12213 _DEFINE_CAPSRC(1),
12124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12125 /* The multiple "Capture Source" controls confuse alsamixer
12126 * So call somewhat different..
12127 */
12128 /* .name = "Capture Source", */
12129 .name = "Input Source",
12130 .count = 1,
12131 .info = alc_mux_enum_info,
12132 .get = alc_mux_enum_get,
12133 .put = alc_mux_enum_put,
12134 },
12135 { } /* end */ 12214 { } /* end */
12136}; 12215};
12137 12216
@@ -12140,18 +12219,7 @@ static struct snd_kcontrol_new alc268_capture_mixer[] = {
12140 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 12219 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12141 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), 12220 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12142 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), 12221 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12143 { 12222 _DEFINE_CAPSRC(2),
12144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12145 /* The multiple "Capture Source" controls confuse alsamixer
12146 * So call somewhat different..
12147 */
12148 /* .name = "Capture Source", */
12149 .name = "Input Source",
12150 .count = 2,
12151 .info = alc_mux_enum_info,
12152 .get = alc_mux_enum_get,
12153 .put = alc_mux_enum_put,
12154 },
12155 { } /* end */ 12223 { } /* end */
12156}; 12224};
12157 12225
@@ -12238,26 +12306,38 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12238 const char *ctlname, int idx) 12306 const char *ctlname, int idx)
12239{ 12307{
12240 char name[32]; 12308 char name[32];
12309 hda_nid_t dac;
12241 int err; 12310 int err;
12242 12311
12243 sprintf(name, "%s Playback Volume", ctlname); 12312 sprintf(name, "%s Playback Volume", ctlname);
12244 if (nid == 0x14) { 12313 switch (nid) {
12245 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 12314 case 0x14:
12246 HDA_COMPOSE_AMP_VAL(0x02, 3, idx, 12315 case 0x16:
12247 HDA_OUTPUT)); 12316 dac = 0x02;
12248 if (err < 0) 12317 break;
12249 return err; 12318 case 0x15:
12250 } else if (nid == 0x15) { 12319 dac = 0x03;
12320 break;
12321 default:
12322 return 0;
12323 }
12324 if (spec->multiout.dac_nids[0] != dac &&
12325 spec->multiout.dac_nids[1] != dac) {
12251 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 12326 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12252 HDA_COMPOSE_AMP_VAL(0x03, 3, idx, 12327 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
12253 HDA_OUTPUT)); 12328 HDA_OUTPUT));
12254 if (err < 0) 12329 if (err < 0)
12255 return err; 12330 return err;
12256 } else 12331 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12257 return -1; 12332 }
12333
12258 sprintf(name, "%s Playback Switch", ctlname); 12334 sprintf(name, "%s Playback Switch", ctlname);
12259 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 12335 if (nid != 0x16)
12336 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12260 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); 12337 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12338 else /* mono */
12339 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12340 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
12261 if (err < 0) 12341 if (err < 0)
12262 return err; 12342 return err;
12263 return 0; 12343 return 0;
@@ -12270,14 +12350,19 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12270 hda_nid_t nid; 12350 hda_nid_t nid;
12271 int err; 12351 int err;
12272 12352
12273 spec->multiout.num_dacs = 2; /* only use one dac */
12274 spec->multiout.dac_nids = spec->private_dac_nids; 12353 spec->multiout.dac_nids = spec->private_dac_nids;
12275 spec->multiout.dac_nids[0] = 2;
12276 spec->multiout.dac_nids[1] = 3;
12277 12354
12278 nid = cfg->line_out_pins[0]; 12355 nid = cfg->line_out_pins[0];
12279 if (nid) 12356 if (nid) {
12280 alc268_new_analog_output(spec, nid, "Front", 0); 12357 const char *name;
12358 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12359 name = "Speaker";
12360 else
12361 name = "Front";
12362 err = alc268_new_analog_output(spec, nid, name, 0);
12363 if (err < 0)
12364 return err;
12365 }
12281 12366
12282 nid = cfg->speaker_pins[0]; 12367 nid = cfg->speaker_pins[0];
12283 if (nid == 0x1d) { 12368 if (nid == 0x1d) {
@@ -12286,16 +12371,23 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12286 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 12371 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12287 if (err < 0) 12372 if (err < 0)
12288 return err; 12373 return err;
12374 } else {
12375 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12376 if (err < 0)
12377 return err;
12289 } 12378 }
12290 nid = cfg->hp_pins[0]; 12379 nid = cfg->hp_pins[0];
12291 if (nid) 12380 if (nid) {
12292 alc268_new_analog_output(spec, nid, "Headphone", 0); 12381 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12382 if (err < 0)
12383 return err;
12384 }
12293 12385
12294 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; 12386 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12295 if (nid == 0x16) { 12387 if (nid == 0x16) {
12296 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12388 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12297 "Mono Playback Switch", 12389 "Mono Playback Switch",
12298 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); 12390 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
12299 if (err < 0) 12391 if (err < 0)
12300 return err; 12392 return err;
12301 } 12393 }
@@ -12303,38 +12395,46 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12303} 12395}
12304 12396
12305/* create playback/capture controls for input pins */ 12397/* create playback/capture controls for input pins */
12306static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, 12398static int alc268_auto_create_input_ctls(struct hda_codec *codec,
12307 const struct auto_pin_cfg *cfg) 12399 const struct auto_pin_cfg *cfg)
12308{ 12400{
12309 struct hda_input_mux *imux = &spec->private_imux[0]; 12401 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
12310 int i, idx1; 12402}
12311 12403
12312 for (i = 0; i < AUTO_PIN_LAST; i++) { 12404static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12313 switch(cfg->input_pins[i]) { 12405 hda_nid_t nid, int pin_type)
12314 case 0x18: 12406{
12315 idx1 = 0; /* Mic 1 */ 12407 int idx;
12316 break; 12408
12317 case 0x19: 12409 alc_set_pin_output(codec, nid, pin_type);
12318 idx1 = 1; /* Mic 2 */ 12410 if (nid == 0x14 || nid == 0x16)
12319 break; 12411 idx = 0;
12320 case 0x1a: 12412 else
12321 idx1 = 2; /* Line In */ 12413 idx = 1;
12322 break; 12414 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12323 case 0x1c: 12415}
12324 idx1 = 3; /* CD */ 12416
12325 break; 12417static void alc268_auto_init_multi_out(struct hda_codec *codec)
12326 case 0x12: 12418{
12327 case 0x13: 12419 struct alc_spec *spec = codec->spec;
12328 idx1 = 6; /* digital mics */ 12420 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12329 break; 12421 if (nid) {
12330 default: 12422 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12331 continue; 12423 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12332 }
12333 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12334 imux->items[imux->num_items].index = idx1;
12335 imux->num_items++;
12336 } 12424 }
12337 return 0; 12425}
12426
12427static void alc268_auto_init_hp_out(struct hda_codec *codec)
12428{
12429 struct alc_spec *spec = codec->spec;
12430 hda_nid_t pin;
12431
12432 pin = spec->autocfg.hp_pins[0];
12433 if (pin)
12434 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12435 pin = spec->autocfg.speaker_pins[0];
12436 if (pin)
12437 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12338} 12438}
12339 12439
12340static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) 12440static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
@@ -12345,9 +12445,10 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12345 hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; 12445 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12346 unsigned int dac_vol1, dac_vol2; 12446 unsigned int dac_vol1, dac_vol2;
12347 12447
12348 if (speaker_nid) { 12448 if (line_nid == 0x1d || speaker_nid == 0x1d) {
12349 snd_hda_codec_write(codec, speaker_nid, 0, 12449 snd_hda_codec_write(codec, speaker_nid, 0,
12350 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 12450 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12451 /* mute mixer inputs from 0x1d */
12351 snd_hda_codec_write(codec, 0x0f, 0, 12452 snd_hda_codec_write(codec, 0x0f, 0,
12352 AC_VERB_SET_AMP_GAIN_MUTE, 12453 AC_VERB_SET_AMP_GAIN_MUTE,
12353 AMP_IN_UNMUTE(1)); 12454 AMP_IN_UNMUTE(1));
@@ -12355,6 +12456,7 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12355 AC_VERB_SET_AMP_GAIN_MUTE, 12456 AC_VERB_SET_AMP_GAIN_MUTE,
12356 AMP_IN_UNMUTE(1)); 12457 AMP_IN_UNMUTE(1));
12357 } else { 12458 } else {
12459 /* unmute mixer inputs from 0x1d */
12358 snd_hda_codec_write(codec, 0x0f, 0, 12460 snd_hda_codec_write(codec, 0x0f, 0,
12359 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); 12461 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12360 snd_hda_codec_write(codec, 0x10, 0, 12462 snd_hda_codec_write(codec, 0x10, 0,
@@ -12411,7 +12513,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
12411 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 12513 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12412 if (err < 0) 12514 if (err < 0)
12413 return err; 12515 return err;
12414 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); 12516 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
12415 if (err < 0) 12517 if (err < 0)
12416 return err; 12518 return err;
12417 12519
@@ -12430,18 +12532,18 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
12430 add_mixer(spec, alc268_beep_mixer); 12532 add_mixer(spec, alc268_beep_mixer);
12431 12533
12432 add_verb(spec, alc268_volume_init_verbs); 12534 add_verb(spec, alc268_volume_init_verbs);
12433 spec->num_mux_defs = 1; 12535 spec->num_mux_defs = 2;
12434 spec->input_mux = &spec->private_imux[0]; 12536 spec->input_mux = &spec->private_imux[0];
12435 12537
12436 err = alc_auto_add_mic_boost(codec); 12538 err = alc_auto_add_mic_boost(codec);
12437 if (err < 0) 12539 if (err < 0)
12438 return err; 12540 return err;
12439 12541
12542 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12543
12440 return 1; 12544 return 1;
12441} 12545}
12442 12546
12443#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12444#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12445#define alc268_auto_init_analog_input alc882_auto_init_analog_input 12547#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12446 12548
12447/* init callback for auto-configuration model -- overriding the default init */ 12549/* init callback for auto-configuration model -- overriding the default init */
@@ -12484,12 +12586,13 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
12484 ALC268_ACER_ASPIRE_ONE), 12586 ALC268_ACER_ASPIRE_ONE),
12485 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), 12587 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
12486 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), 12588 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
12589 /* almost compatible with toshiba but with optional digital outs;
12590 * auto-probing seems working fine
12591 */
12487 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series", 12592 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12488 ALC268_TOSHIBA), 12593 ALC268_AUTO),
12489 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), 12594 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
12490 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), 12595 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12491 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12492 ALC268_TOSHIBA),
12493 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), 12596 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
12494 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 12597 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
12495 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), 12598 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
@@ -12497,9 +12600,19 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
12497 {} 12600 {}
12498}; 12601};
12499 12602
12603/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12604static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12605 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12606 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12607 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12608 ALC268_TOSHIBA),
12609 {}
12610};
12611
12500static struct alc_config_preset alc268_presets[] = { 12612static struct alc_config_preset alc268_presets[] = {
12501 [ALC267_QUANTA_IL1] = { 12613 [ALC267_QUANTA_IL1] = {
12502 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer }, 12614 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12615 alc268_capture_nosrc_mixer },
12503 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12616 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12504 alc267_quanta_il1_verbs }, 12617 alc267_quanta_il1_verbs },
12505 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12618 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -12509,9 +12622,9 @@ static struct alc_config_preset alc268_presets[] = {
12509 .hp_nid = 0x03, 12622 .hp_nid = 0x03,
12510 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12623 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12511 .channel_mode = alc268_modes, 12624 .channel_mode = alc268_modes,
12512 .input_mux = &alc268_capture_source, 12625 .unsol_event = alc_sku_unsol_event,
12513 .unsol_event = alc267_quanta_il1_unsol_event, 12626 .setup = alc267_quanta_il1_setup,
12514 .init_hook = alc267_quanta_il1_init_hook, 12627 .init_hook = alc_inithook,
12515 }, 12628 },
12516 [ALC268_3ST] = { 12629 [ALC268_3ST] = {
12517 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 12630 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
@@ -12543,7 +12656,8 @@ static struct alc_config_preset alc268_presets[] = {
12543 .channel_mode = alc268_modes, 12656 .channel_mode = alc268_modes,
12544 .input_mux = &alc268_capture_source, 12657 .input_mux = &alc268_capture_source,
12545 .unsol_event = alc268_toshiba_unsol_event, 12658 .unsol_event = alc268_toshiba_unsol_event,
12546 .init_hook = alc268_toshiba_init_hook, 12659 .setup = alc268_toshiba_setup,
12660 .init_hook = alc268_toshiba_automute,
12547 }, 12661 },
12548 [ALC268_ACER] = { 12662 [ALC268_ACER] = {
12549 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, 12663 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
@@ -12582,7 +12696,7 @@ static struct alc_config_preset alc268_presets[] = {
12582 [ALC268_ACER_ASPIRE_ONE] = { 12696 [ALC268_ACER_ASPIRE_ONE] = {
12583 .mixers = { alc268_acer_aspire_one_mixer, 12697 .mixers = { alc268_acer_aspire_one_mixer,
12584 alc268_beep_mixer, 12698 alc268_beep_mixer,
12585 alc268_capture_alt_mixer }, 12699 alc268_capture_nosrc_mixer },
12586 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12700 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12587 alc268_acer_aspire_one_verbs }, 12701 alc268_acer_aspire_one_verbs },
12588 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12702 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -12593,22 +12707,26 @@ static struct alc_config_preset alc268_presets[] = {
12593 .hp_nid = 0x03, 12707 .hp_nid = 0x03,
12594 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12708 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12595 .channel_mode = alc268_modes, 12709 .channel_mode = alc268_modes,
12596 .input_mux = &alc268_acer_lc_capture_source,
12597 .unsol_event = alc268_acer_lc_unsol_event, 12710 .unsol_event = alc268_acer_lc_unsol_event,
12711 .setup = alc268_acer_lc_setup,
12598 .init_hook = alc268_acer_lc_init_hook, 12712 .init_hook = alc268_acer_lc_init_hook,
12599 }, 12713 },
12600 [ALC268_DELL] = { 12714 [ALC268_DELL] = {
12601 .mixers = { alc268_dell_mixer, alc268_beep_mixer }, 12715 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12716 alc268_capture_nosrc_mixer },
12602 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12717 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12603 alc268_dell_verbs }, 12718 alc268_dell_verbs },
12604 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12719 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12605 .dac_nids = alc268_dac_nids, 12720 .dac_nids = alc268_dac_nids,
12721 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12722 .adc_nids = alc268_adc_nids_alt,
12723 .capsrc_nids = alc268_capsrc_nids,
12606 .hp_nid = 0x02, 12724 .hp_nid = 0x02,
12607 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12725 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12608 .channel_mode = alc268_modes, 12726 .channel_mode = alc268_modes,
12609 .unsol_event = alc_sku_unsol_event, 12727 .unsol_event = alc_sku_unsol_event,
12610 .init_hook = alc268_dell_init_hook, 12728 .setup = alc268_dell_setup,
12611 .input_mux = &alc268_capture_source, 12729 .init_hook = alc_inithook,
12612 }, 12730 },
12613 [ALC268_ZEPTO] = { 12731 [ALC268_ZEPTO] = {
12614 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 12732 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
@@ -12625,8 +12743,8 @@ static struct alc_config_preset alc268_presets[] = {
12625 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12743 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12626 .channel_mode = alc268_modes, 12744 .channel_mode = alc268_modes,
12627 .input_mux = &alc268_capture_source, 12745 .input_mux = &alc268_capture_source,
12628 .unsol_event = alc268_toshiba_unsol_event, 12746 .setup = alc268_toshiba_setup,
12629 .init_hook = alc268_toshiba_init_hook 12747 .init_hook = alc268_toshiba_automute,
12630 }, 12748 },
12631#ifdef CONFIG_SND_DEBUG 12749#ifdef CONFIG_SND_DEBUG
12632 [ALC268_TEST] = { 12750 [ALC268_TEST] = {
@@ -12663,9 +12781,13 @@ static int patch_alc268(struct hda_codec *codec)
12663 alc268_models, 12781 alc268_models,
12664 alc268_cfg_tbl); 12782 alc268_cfg_tbl);
12665 12783
12784 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12785 board_config = snd_hda_check_board_codec_sid_config(codec,
12786 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12787
12666 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { 12788 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12667 printk(KERN_INFO "hda_codec: Unknown model for %s, " 12789 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12668 "trying auto-probe from BIOS...\n", codec->chip_name); 12790 codec->chip_name);
12669 board_config = ALC268_AUTO; 12791 board_config = ALC268_AUTO;
12670 } 12792 }
12671 12793
@@ -12684,7 +12806,7 @@ static int patch_alc268(struct hda_codec *codec)
12684 } 12806 }
12685 12807
12686 if (board_config != ALC268_AUTO) 12808 if (board_config != ALC268_AUTO)
12687 setup_preset(spec, &alc268_presets[board_config]); 12809 setup_preset(codec, &alc268_presets[board_config]);
12688 12810
12689 spec->stream_analog_playback = &alc268_pcm_analog_playback; 12811 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12690 spec->stream_analog_capture = &alc268_pcm_analog_capture; 12812 spec->stream_analog_capture = &alc268_pcm_analog_capture;
@@ -12721,11 +12843,15 @@ static int patch_alc268(struct hda_codec *codec)
12721 int i; 12843 int i;
12722 12844
12723 /* get type */ 12845 /* get type */
12724 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 12846 wcap = get_wcaps_type(wcap);
12725 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 12847 if (spec->auto_mic ||
12848 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
12726 spec->adc_nids = alc268_adc_nids_alt; 12849 spec->adc_nids = alc268_adc_nids_alt;
12727 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); 12850 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
12728 add_mixer(spec, alc268_capture_alt_mixer); 12851 if (spec->auto_mic || spec->input_mux->num_items == 1)
12852 add_mixer(spec, alc268_capture_nosrc_mixer);
12853 else
12854 add_mixer(spec, alc268_capture_alt_mixer);
12729 } else { 12855 } else {
12730 spec->adc_nids = alc268_adc_nids; 12856 spec->adc_nids = alc268_adc_nids;
12731 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); 12857 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
@@ -12736,6 +12862,8 @@ static int patch_alc268(struct hda_codec *codec)
12736 for (i = 0; i < spec->num_adc_nids; i++) 12862 for (i = 0; i < spec->num_adc_nids; i++)
12737 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], 12863 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12738 0, AC_VERB_SET_CONNECT_SEL, 12864 0, AC_VERB_SET_CONNECT_SEL,
12865 i < spec->num_mux_defs ?
12866 spec->input_mux[i].items[0].index :
12739 spec->input_mux->items[0].index); 12867 spec->input_mux->items[0].index);
12740 } 12868 }
12741 12869
@@ -12770,22 +12898,6 @@ static hda_nid_t alc269_capsrc_nids[1] = {
12770 * not a mux! 12898 * not a mux!
12771 */ 12899 */
12772 12900
12773static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12774 .num_items = 2,
12775 .items = {
12776 { "i-Mic", 0x5 },
12777 { "e-Mic", 0x0 },
12778 },
12779};
12780
12781static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12782 .num_items = 2,
12783 .items = {
12784 { "i-Mic", 0x1 },
12785 { "e-Mic", 0x0 },
12786 },
12787};
12788
12789#define alc269_modes alc260_modes 12901#define alc269_modes alc260_modes
12790#define alc269_capture_source alc880_lg_lw_capture_source 12902#define alc269_capture_source alc880_lg_lw_capture_source
12791 12903
@@ -12848,20 +12960,11 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12848 { } 12960 { }
12849}; 12961};
12850 12962
12851/* bind volumes of both NID 0x0c and 0x0d */
12852static struct hda_bind_ctls alc269_epc_bind_vol = {
12853 .ops = &snd_hda_bind_vol,
12854 .values = {
12855 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12856 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12857 0
12858 },
12859};
12860
12861static struct snd_kcontrol_new alc269_eeepc_mixer[] = { 12963static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12862 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 12964 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12863 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), 12965 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12864 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), 12966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12865 { } /* end */ 12968 { } /* end */
12866}; 12969};
12867 12970
@@ -12874,12 +12977,7 @@ static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12874}; 12977};
12875 12978
12876/* FSC amilo */ 12979/* FSC amilo */
12877static struct snd_kcontrol_new alc269_fujitsu_mixer[] = { 12980#define alc269_fujitsu_mixer alc269_eeepc_mixer
12878 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12880 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
12881 { } /* end */
12882};
12883 12981
12884static struct hda_verb alc269_quanta_fl1_verbs[] = { 12982static struct hda_verb alc269_quanta_fl1_verbs[] = {
12885 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 12983 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
@@ -12961,16 +13059,6 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12961 AC_VERB_SET_PROC_COEF, 0x480); 13059 AC_VERB_SET_PROC_COEF, 0x480);
12962} 13060}
12963 13061
12964static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12965{
12966 unsigned int present;
12967
12968 present = snd_hda_codec_read(codec, 0x18, 0,
12969 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12970 snd_hda_codec_write(codec, 0x23, 0,
12971 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12972}
12973
12974static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) 13062static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12975{ 13063{
12976 unsigned int present_laptop; 13064 unsigned int present_laptop;
@@ -12997,10 +13085,14 @@ static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12997static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, 13085static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12998 unsigned int res) 13086 unsigned int res)
12999{ 13087{
13000 if ((res >> 26) == ALC880_HP_EVENT) 13088 switch (res >> 26) {
13089 case ALC880_HP_EVENT:
13001 alc269_quanta_fl1_speaker_automute(codec); 13090 alc269_quanta_fl1_speaker_automute(codec);
13002 if ((res >> 26) == ALC880_MIC_EVENT) 13091 break;
13003 alc269_quanta_fl1_mic_automute(codec); 13092 case ALC880_MIC_EVENT:
13093 alc_mic_automute(codec);
13094 break;
13095 }
13004} 13096}
13005 13097
13006static void alc269_lifebook_unsol_event(struct hda_codec *codec, 13098static void alc269_lifebook_unsol_event(struct hda_codec *codec,
@@ -13012,10 +13104,20 @@ static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13012 alc269_lifebook_mic_autoswitch(codec); 13104 alc269_lifebook_mic_autoswitch(codec);
13013} 13105}
13014 13106
13107static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13108{
13109 struct alc_spec *spec = codec->spec;
13110 spec->ext_mic.pin = 0x18;
13111 spec->ext_mic.mux_idx = 0;
13112 spec->int_mic.pin = 0x19;
13113 spec->int_mic.mux_idx = 1;
13114 spec->auto_mic = 1;
13115}
13116
13015static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) 13117static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13016{ 13118{
13017 alc269_quanta_fl1_speaker_automute(codec); 13119 alc269_quanta_fl1_speaker_automute(codec);
13018 alc269_quanta_fl1_mic_automute(codec); 13120 alc_mic_automute(codec);
13019} 13121}
13020 13122
13021static void alc269_lifebook_init_hook(struct hda_codec *codec) 13123static void alc269_lifebook_init_hook(struct hda_codec *codec)
@@ -13060,60 +13162,44 @@ static void alc269_speaker_automute(struct hda_codec *codec)
13060 AMP_IN_MUTE(0), bits); 13162 AMP_IN_MUTE(0), bits);
13061} 13163}
13062 13164
13063static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13064{
13065 unsigned int present;
13066
13067 present = snd_hda_codec_read(codec, 0x18, 0,
13068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13069 snd_hda_codec_write(codec, 0x23, 0,
13070 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13071}
13072
13073static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13074{
13075 unsigned int present;
13076
13077 present = snd_hda_codec_read(codec, 0x18, 0,
13078 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13079 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13080 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13081 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13082 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13083}
13084
13085/* unsolicited event for HP jack sensing */ 13165/* unsolicited event for HP jack sensing */
13086static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, 13166static void alc269_eeepc_unsol_event(struct hda_codec *codec,
13087 unsigned int res) 13167 unsigned int res)
13088{ 13168{
13089 if ((res >> 26) == ALC880_HP_EVENT) 13169 switch (res >> 26) {
13170 case ALC880_HP_EVENT:
13090 alc269_speaker_automute(codec); 13171 alc269_speaker_automute(codec);
13091 13172 break;
13092 if ((res >> 26) == ALC880_MIC_EVENT) 13173 case ALC880_MIC_EVENT:
13093 alc269_eeepc_dmic_automute(codec); 13174 alc_mic_automute(codec);
13175 break;
13176 }
13094} 13177}
13095 13178
13096static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) 13179static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13097{ 13180{
13098 alc269_speaker_automute(codec); 13181 struct alc_spec *spec = codec->spec;
13099 alc269_eeepc_dmic_automute(codec); 13182 spec->ext_mic.pin = 0x18;
13183 spec->ext_mic.mux_idx = 0;
13184 spec->int_mic.pin = 0x12;
13185 spec->int_mic.mux_idx = 5;
13186 spec->auto_mic = 1;
13100} 13187}
13101 13188
13102/* unsolicited event for HP jack sensing */ 13189static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13103static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13104 unsigned int res)
13105{ 13190{
13106 if ((res >> 26) == ALC880_HP_EVENT) 13191 struct alc_spec *spec = codec->spec;
13107 alc269_speaker_automute(codec); 13192 spec->ext_mic.pin = 0x18;
13108 13193 spec->ext_mic.mux_idx = 0;
13109 if ((res >> 26) == ALC880_MIC_EVENT) 13194 spec->int_mic.pin = 0x19;
13110 alc269_eeepc_amic_automute(codec); 13195 spec->int_mic.mux_idx = 1;
13196 spec->auto_mic = 1;
13111} 13197}
13112 13198
13113static void alc269_eeepc_amic_inithook(struct hda_codec *codec) 13199static void alc269_eeepc_inithook(struct hda_codec *codec)
13114{ 13200{
13115 alc269_speaker_automute(codec); 13201 alc269_speaker_automute(codec);
13116 alc269_eeepc_amic_automute(codec); 13202 alc_mic_automute(codec);
13117} 13203}
13118 13204
13119/* 13205/*
@@ -13186,89 +13272,10 @@ static struct hda_verb alc269_init_verbs[] = {
13186 { } 13272 { }
13187}; 13273};
13188 13274
13189/* add playback controls from the parsed DAC table */ 13275#define alc269_auto_create_multi_out_ctls \
13190static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, 13276 alc268_auto_create_multi_out_ctls
13191 const struct auto_pin_cfg *cfg) 13277#define alc269_auto_create_input_ctls \
13192{ 13278 alc268_auto_create_input_ctls
13193 hda_nid_t nid;
13194 int err;
13195
13196 spec->multiout.num_dacs = 1; /* only use one dac */
13197 spec->multiout.dac_nids = spec->private_dac_nids;
13198 spec->multiout.dac_nids[0] = 2;
13199
13200 nid = cfg->line_out_pins[0];
13201 if (nid) {
13202 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13203 "Front Playback Volume",
13204 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13205 if (err < 0)
13206 return err;
13207 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13208 "Front Playback Switch",
13209 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13210 if (err < 0)
13211 return err;
13212 }
13213
13214 nid = cfg->speaker_pins[0];
13215 if (nid) {
13216 if (!cfg->line_out_pins[0]) {
13217 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13218 "Speaker Playback Volume",
13219 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13220 HDA_OUTPUT));
13221 if (err < 0)
13222 return err;
13223 }
13224 if (nid == 0x16) {
13225 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13226 "Speaker Playback Switch",
13227 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13228 HDA_OUTPUT));
13229 if (err < 0)
13230 return err;
13231 } else {
13232 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13233 "Speaker Playback Switch",
13234 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13235 HDA_OUTPUT));
13236 if (err < 0)
13237 return err;
13238 }
13239 }
13240 nid = cfg->hp_pins[0];
13241 if (nid) {
13242 /* spec->multiout.hp_nid = 2; */
13243 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13244 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13245 "Headphone Playback Volume",
13246 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13247 HDA_OUTPUT));
13248 if (err < 0)
13249 return err;
13250 }
13251 if (nid == 0x16) {
13252 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13253 "Headphone Playback Switch",
13254 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13255 HDA_OUTPUT));
13256 if (err < 0)
13257 return err;
13258 } else {
13259 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13260 "Headphone Playback Switch",
13261 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13262 HDA_OUTPUT));
13263 if (err < 0)
13264 return err;
13265 }
13266 }
13267 return 0;
13268}
13269
13270#define alc269_auto_create_analog_input_ctls \
13271 alc262_auto_create_analog_input_ctls
13272 13279
13273#ifdef CONFIG_SND_HDA_POWER_SAVE 13280#ifdef CONFIG_SND_HDA_POWER_SAVE
13274#define alc269_loopbacks alc880_loopbacks 13281#define alc269_loopbacks alc880_loopbacks
@@ -13318,7 +13325,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13318 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); 13325 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13319 if (err < 0) 13326 if (err < 0)
13320 return err; 13327 return err;
13321 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); 13328 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
13322 if (err < 0) 13329 if (err < 0)
13323 return err; 13330 return err;
13324 13331
@@ -13343,13 +13350,15 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13343 return err; 13350 return err;
13344 13351
13345 if (!spec->cap_mixer && !spec->no_analog) 13352 if (!spec->cap_mixer && !spec->no_analog)
13346 set_capture_mixer(spec); 13353 set_capture_mixer(codec);
13354
13355 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13347 13356
13348 return 1; 13357 return 1;
13349} 13358}
13350 13359
13351#define alc269_auto_init_multi_out alc882_auto_init_multi_out 13360#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13352#define alc269_auto_init_hp_out alc882_auto_init_hp_out 13361#define alc269_auto_init_hp_out alc268_auto_init_hp_out
13353#define alc269_auto_init_analog_input alc882_auto_init_analog_input 13362#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13354 13363
13355 13364
@@ -13373,7 +13382,8 @@ static const char *alc269_models[ALC269_MODEL_LAST] = {
13373 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", 13382 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
13374 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901", 13383 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
13375 [ALC269_FUJITSU] = "fujitsu", 13384 [ALC269_FUJITSU] = "fujitsu",
13376 [ALC269_LIFEBOOK] = "lifebook" 13385 [ALC269_LIFEBOOK] = "lifebook",
13386 [ALC269_AUTO] = "auto",
13377}; 13387};
13378 13388
13379static struct snd_pci_quirk alc269_cfg_tbl[] = { 13389static struct snd_pci_quirk alc269_cfg_tbl[] = {
@@ -13417,6 +13427,7 @@ static struct alc_config_preset alc269_presets[] = {
13417 .channel_mode = alc269_modes, 13427 .channel_mode = alc269_modes,
13418 .input_mux = &alc269_capture_source, 13428 .input_mux = &alc269_capture_source,
13419 .unsol_event = alc269_quanta_fl1_unsol_event, 13429 .unsol_event = alc269_quanta_fl1_unsol_event,
13430 .setup = alc269_quanta_fl1_setup,
13420 .init_hook = alc269_quanta_fl1_init_hook, 13431 .init_hook = alc269_quanta_fl1_init_hook,
13421 }, 13432 },
13422 [ALC269_ASUS_EEEPC_P703] = { 13433 [ALC269_ASUS_EEEPC_P703] = {
@@ -13429,9 +13440,9 @@ static struct alc_config_preset alc269_presets[] = {
13429 .hp_nid = 0x03, 13440 .hp_nid = 0x03,
13430 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13441 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13431 .channel_mode = alc269_modes, 13442 .channel_mode = alc269_modes,
13432 .input_mux = &alc269_eeepc_amic_capture_source, 13443 .unsol_event = alc269_eeepc_unsol_event,
13433 .unsol_event = alc269_eeepc_amic_unsol_event, 13444 .setup = alc269_eeepc_amic_setup,
13434 .init_hook = alc269_eeepc_amic_inithook, 13445 .init_hook = alc269_eeepc_inithook,
13435 }, 13446 },
13436 [ALC269_ASUS_EEEPC_P901] = { 13447 [ALC269_ASUS_EEEPC_P901] = {
13437 .mixers = { alc269_eeepc_mixer }, 13448 .mixers = { alc269_eeepc_mixer },
@@ -13443,9 +13454,9 @@ static struct alc_config_preset alc269_presets[] = {
13443 .hp_nid = 0x03, 13454 .hp_nid = 0x03,
13444 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13455 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13445 .channel_mode = alc269_modes, 13456 .channel_mode = alc269_modes,
13446 .input_mux = &alc269_eeepc_dmic_capture_source, 13457 .unsol_event = alc269_eeepc_unsol_event,
13447 .unsol_event = alc269_eeepc_dmic_unsol_event, 13458 .setup = alc269_eeepc_dmic_setup,
13448 .init_hook = alc269_eeepc_dmic_inithook, 13459 .init_hook = alc269_eeepc_inithook,
13449 }, 13460 },
13450 [ALC269_FUJITSU] = { 13461 [ALC269_FUJITSU] = {
13451 .mixers = { alc269_fujitsu_mixer }, 13462 .mixers = { alc269_fujitsu_mixer },
@@ -13457,9 +13468,9 @@ static struct alc_config_preset alc269_presets[] = {
13457 .hp_nid = 0x03, 13468 .hp_nid = 0x03,
13458 .num_channel_mode = ARRAY_SIZE(alc269_modes), 13469 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13459 .channel_mode = alc269_modes, 13470 .channel_mode = alc269_modes,
13460 .input_mux = &alc269_eeepc_dmic_capture_source, 13471 .unsol_event = alc269_eeepc_unsol_event,
13461 .unsol_event = alc269_eeepc_dmic_unsol_event, 13472 .setup = alc269_eeepc_dmic_setup,
13462 .init_hook = alc269_eeepc_dmic_inithook, 13473 .init_hook = alc269_eeepc_inithook,
13463 }, 13474 },
13464 [ALC269_LIFEBOOK] = { 13475 [ALC269_LIFEBOOK] = {
13465 .mixers = { alc269_lifebook_mixer }, 13476 .mixers = { alc269_lifebook_mixer },
@@ -13494,8 +13505,8 @@ static int patch_alc269(struct hda_codec *codec)
13494 alc269_cfg_tbl); 13505 alc269_cfg_tbl);
13495 13506
13496 if (board_config < 0) { 13507 if (board_config < 0) {
13497 printk(KERN_INFO "hda_codec: Unknown model for %s, " 13508 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13498 "trying auto-probe from BIOS...\n", codec->chip_name); 13509 codec->chip_name);
13499 board_config = ALC269_AUTO; 13510 board_config = ALC269_AUTO;
13500 } 13511 }
13501 13512
@@ -13520,7 +13531,7 @@ static int patch_alc269(struct hda_codec *codec)
13520 } 13531 }
13521 13532
13522 if (board_config != ALC269_AUTO) 13533 if (board_config != ALC269_AUTO)
13523 setup_preset(spec, &alc269_presets[board_config]); 13534 setup_preset(codec, &alc269_presets[board_config]);
13524 13535
13525 if (codec->subsystem_id == 0x17aa3bf8) { 13536 if (codec->subsystem_id == 0x17aa3bf8) {
13526 /* Due to a hardware problem on Lenovo Ideadpad, we need to 13537 /* Due to a hardware problem on Lenovo Ideadpad, we need to
@@ -13539,9 +13550,11 @@ static int patch_alc269(struct hda_codec *codec)
13539 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 13550 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
13540 spec->capsrc_nids = alc269_capsrc_nids; 13551 spec->capsrc_nids = alc269_capsrc_nids;
13541 if (!spec->cap_mixer) 13552 if (!spec->cap_mixer)
13542 set_capture_mixer(spec); 13553 set_capture_mixer(codec);
13543 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 13554 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
13544 13555
13556 spec->vmaster_nid = 0x02;
13557
13545 codec->patch_ops = alc_patch_ops; 13558 codec->patch_ops = alc_patch_ops;
13546 if (board_config == ALC269_AUTO) 13559 if (board_config == ALC269_AUTO)
13547 spec->init_hook = alc269_auto_init; 13560 spec->init_hook = alc269_auto_init;
@@ -14087,23 +14100,23 @@ static struct hda_verb alc861_auto_init_verbs[] = {
14087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 14100 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, 14101 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14089 14102
14090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14103 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14104 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14105 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14106 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14094 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14107 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14095 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14108 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14096 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14109 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14097 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14110 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14098 14111
14099 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 14112 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 14113 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 14114 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14102 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 14115 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 14116 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14104 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 14117 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 14118 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14106 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 14119 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14107 14120
14108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ 14121 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
14109 14122
@@ -14175,64 +14188,96 @@ static struct hda_input_mux alc861_capture_source = {
14175 }, 14188 },
14176}; 14189};
14177 14190
14191static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14192{
14193 struct alc_spec *spec = codec->spec;
14194 hda_nid_t mix, srcs[5];
14195 int i, j, num;
14196
14197 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14198 return 0;
14199 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14200 if (num < 0)
14201 return 0;
14202 for (i = 0; i < num; i++) {
14203 unsigned int type;
14204 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
14205 if (type != AC_WID_AUD_OUT)
14206 continue;
14207 for (j = 0; j < spec->multiout.num_dacs; j++)
14208 if (spec->multiout.dac_nids[j] == srcs[i])
14209 break;
14210 if (j >= spec->multiout.num_dacs)
14211 return srcs[i];
14212 }
14213 return 0;
14214}
14215
14178/* fill in the dac_nids table from the parsed pin configuration */ 14216/* fill in the dac_nids table from the parsed pin configuration */
14179static int alc861_auto_fill_dac_nids(struct alc_spec *spec, 14217static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
14180 const struct auto_pin_cfg *cfg) 14218 const struct auto_pin_cfg *cfg)
14181{ 14219{
14220 struct alc_spec *spec = codec->spec;
14182 int i; 14221 int i;
14183 hda_nid_t nid; 14222 hda_nid_t nid, dac;
14184 14223
14185 spec->multiout.dac_nids = spec->private_dac_nids; 14224 spec->multiout.dac_nids = spec->private_dac_nids;
14186 for (i = 0; i < cfg->line_outs; i++) { 14225 for (i = 0; i < cfg->line_outs; i++) {
14187 nid = cfg->line_out_pins[i]; 14226 nid = cfg->line_out_pins[i];
14188 if (nid) { 14227 dac = alc861_look_for_dac(codec, nid);
14189 if (i >= ARRAY_SIZE(alc861_dac_nids)) 14228 if (!dac)
14190 continue; 14229 continue;
14191 spec->multiout.dac_nids[i] = alc861_dac_nids[i]; 14230 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
14192 }
14193 } 14231 }
14194 spec->multiout.num_dacs = cfg->line_outs;
14195 return 0; 14232 return 0;
14196} 14233}
14197 14234
14235static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14236 hda_nid_t nid, unsigned int chs)
14237{
14238 char name[32];
14239 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14240 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14241 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14242}
14243
14198/* add playback controls from the parsed DAC table */ 14244/* add playback controls from the parsed DAC table */
14199static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, 14245static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14200 const struct auto_pin_cfg *cfg) 14246 const struct auto_pin_cfg *cfg)
14201{ 14247{
14202 char name[32]; 14248 struct alc_spec *spec = codec->spec;
14203 static const char *chname[4] = { 14249 static const char *chname[4] = {
14204 "Front", "Surround", NULL /*CLFE*/, "Side" 14250 "Front", "Surround", NULL /*CLFE*/, "Side"
14205 }; 14251 };
14206 hda_nid_t nid; 14252 hda_nid_t nid;
14207 int i, idx, err; 14253 int i, err;
14254
14255 if (cfg->line_outs == 1) {
14256 const char *pfx = NULL;
14257 if (!cfg->hp_outs)
14258 pfx = "Master";
14259 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14260 pfx = "Speaker";
14261 if (pfx) {
14262 nid = spec->multiout.dac_nids[0];
14263 return alc861_create_out_sw(codec, pfx, nid, 3);
14264 }
14265 }
14208 14266
14209 for (i = 0; i < cfg->line_outs; i++) { 14267 for (i = 0; i < cfg->line_outs; i++) {
14210 nid = spec->multiout.dac_nids[i]; 14268 nid = spec->multiout.dac_nids[i];
14211 if (!nid) 14269 if (!nid)
14212 continue; 14270 continue;
14213 if (nid == 0x05) { 14271 if (i == 2) {
14214 /* Center/LFE */ 14272 /* Center/LFE */
14215 err = add_control(spec, ALC_CTL_BIND_MUTE, 14273 err = alc861_create_out_sw(codec, "Center", nid, 1);
14216 "Center Playback Switch",
14217 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14218 HDA_OUTPUT));
14219 if (err < 0) 14274 if (err < 0)
14220 return err; 14275 return err;
14221 err = add_control(spec, ALC_CTL_BIND_MUTE, 14276 err = alc861_create_out_sw(codec, "LFE", nid, 2);
14222 "LFE Playback Switch",
14223 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14224 HDA_OUTPUT));
14225 if (err < 0) 14277 if (err < 0)
14226 return err; 14278 return err;
14227 } else { 14279 } else {
14228 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; 14280 err = alc861_create_out_sw(codec, chname[i], nid, 3);
14229 idx++)
14230 if (nid == alc861_dac_nids[idx])
14231 break;
14232 sprintf(name, "%s Playback Switch", chname[idx]);
14233 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14234 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14235 HDA_OUTPUT));
14236 if (err < 0) 14281 if (err < 0)
14237 return err; 14282 return err;
14238 } 14283 }
@@ -14240,8 +14285,9 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14240 return 0; 14285 return 0;
14241} 14286}
14242 14287
14243static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) 14288static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
14244{ 14289{
14290 struct alc_spec *spec = codec->spec;
14245 int err; 14291 int err;
14246 hda_nid_t nid; 14292 hda_nid_t nid;
14247 14293
@@ -14249,70 +14295,49 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14249 return 0; 14295 return 0;
14250 14296
14251 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 14297 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14252 nid = 0x03; 14298 nid = alc861_look_for_dac(codec, pin);
14253 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 14299 if (nid) {
14254 "Headphone Playback Switch", 14300 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14255 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 14301 if (err < 0)
14256 if (err < 0) 14302 return err;
14257 return err; 14303 spec->multiout.hp_nid = nid;
14258 spec->multiout.hp_nid = nid; 14304 }
14259 } 14305 }
14260 return 0; 14306 return 0;
14261} 14307}
14262 14308
14263/* create playback/capture controls for input pins */ 14309/* create playback/capture controls for input pins */
14264static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, 14310static int alc861_auto_create_input_ctls(struct hda_codec *codec,
14265 const struct auto_pin_cfg *cfg) 14311 const struct auto_pin_cfg *cfg)
14266{ 14312{
14267 struct hda_input_mux *imux = &spec->private_imux[0]; 14313 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
14268 int i, err, idx, idx1;
14269
14270 for (i = 0; i < AUTO_PIN_LAST; i++) {
14271 switch (cfg->input_pins[i]) {
14272 case 0x0c:
14273 idx1 = 1;
14274 idx = 2; /* Line In */
14275 break;
14276 case 0x0f:
14277 idx1 = 2;
14278 idx = 2; /* Line In */
14279 break;
14280 case 0x0d:
14281 idx1 = 0;
14282 idx = 1; /* Mic In */
14283 break;
14284 case 0x10:
14285 idx1 = 3;
14286 idx = 1; /* Mic In */
14287 break;
14288 case 0x11:
14289 idx1 = 4;
14290 idx = 0; /* CD */
14291 break;
14292 default:
14293 continue;
14294 }
14295
14296 err = new_analog_input(spec, cfg->input_pins[i],
14297 auto_pin_cfg_labels[i], idx, 0x15);
14298 if (err < 0)
14299 return err;
14300
14301 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
14302 imux->items[imux->num_items].index = idx1;
14303 imux->num_items++;
14304 }
14305 return 0;
14306} 14314}
14307 14315
14308static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, 14316static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14309 hda_nid_t nid, 14317 hda_nid_t nid,
14310 int pin_type, int dac_idx) 14318 int pin_type, hda_nid_t dac)
14311{ 14319{
14320 hda_nid_t mix, srcs[5];
14321 int i, num;
14322
14312 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 14323 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14313 pin_type); 14324 pin_type);
14314 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, 14325 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14315 AMP_OUT_UNMUTE); 14326 AMP_OUT_UNMUTE);
14327 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14328 return;
14329 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14330 if (num < 0)
14331 return;
14332 for (i = 0; i < num; i++) {
14333 unsigned int mute;
14334 if (srcs[i] == dac || srcs[i] == 0x15)
14335 mute = AMP_IN_UNMUTE(i);
14336 else
14337 mute = AMP_IN_MUTE(i);
14338 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14339 mute);
14340 }
14316} 14341}
14317 14342
14318static void alc861_auto_init_multi_out(struct hda_codec *codec) 14343static void alc861_auto_init_multi_out(struct hda_codec *codec)
@@ -14335,12 +14360,13 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
14335 hda_nid_t pin; 14360 hda_nid_t pin;
14336 14361
14337 pin = spec->autocfg.hp_pins[0]; 14362 pin = spec->autocfg.hp_pins[0];
14338 if (pin) /* connect to front */ 14363 if (pin)
14339 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, 14364 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14340 spec->multiout.dac_nids[0]); 14365 spec->multiout.hp_nid);
14341 pin = spec->autocfg.speaker_pins[0]; 14366 pin = spec->autocfg.speaker_pins[0];
14342 if (pin) 14367 if (pin)
14343 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 14368 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14369 spec->multiout.dac_nids[0]);
14344} 14370}
14345 14371
14346static void alc861_auto_init_analog_input(struct hda_codec *codec) 14372static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -14372,16 +14398,16 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
14372 if (!spec->autocfg.line_outs) 14398 if (!spec->autocfg.line_outs)
14373 return 0; /* can't find valid BIOS pin config */ 14399 return 0; /* can't find valid BIOS pin config */
14374 14400
14375 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); 14401 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
14376 if (err < 0) 14402 if (err < 0)
14377 return err; 14403 return err;
14378 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); 14404 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
14379 if (err < 0) 14405 if (err < 0)
14380 return err; 14406 return err;
14381 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 14407 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
14382 if (err < 0) 14408 if (err < 0)
14383 return err; 14409 return err;
14384 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); 14410 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
14385 if (err < 0) 14411 if (err < 0)
14386 return err; 14412 return err;
14387 14413
@@ -14400,7 +14426,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
14400 14426
14401 spec->adc_nids = alc861_adc_nids; 14427 spec->adc_nids = alc861_adc_nids;
14402 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 14428 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
14403 set_capture_mixer(spec); 14429 set_capture_mixer(codec);
14404 14430
14405 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); 14431 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14406 14432
@@ -14593,8 +14619,8 @@ static int patch_alc861(struct hda_codec *codec)
14593 alc861_cfg_tbl); 14619 alc861_cfg_tbl);
14594 14620
14595 if (board_config < 0) { 14621 if (board_config < 0) {
14596 printk(KERN_INFO "hda_codec: Unknown model for %s, " 14622 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14597 "trying auto-probe from BIOS...\n", codec->chip_name); 14623 codec->chip_name);
14598 board_config = ALC861_AUTO; 14624 board_config = ALC861_AUTO;
14599 } 14625 }
14600 14626
@@ -14619,7 +14645,7 @@ static int patch_alc861(struct hda_codec *codec)
14619 } 14645 }
14620 14646
14621 if (board_config != ALC861_AUTO) 14647 if (board_config != ALC861_AUTO)
14622 setup_preset(spec, &alc861_presets[board_config]); 14648 setup_preset(codec, &alc861_presets[board_config]);
14623 14649
14624 spec->stream_analog_playback = &alc861_pcm_analog_playback; 14650 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14625 spec->stream_analog_capture = &alc861_pcm_analog_capture; 14651 spec->stream_analog_capture = &alc861_pcm_analog_capture;
@@ -15022,12 +15048,15 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15022 HDA_AMP_MUTE, bits); 15048 HDA_AMP_MUTE, bits);
15023} 15049}
15024 15050
15025static void alc861vd_lenovo_init_hook(struct hda_codec *codec) 15051static void alc861vd_lenovo_setup(struct hda_codec *codec)
15026{ 15052{
15027 struct alc_spec *spec = codec->spec; 15053 struct alc_spec *spec = codec->spec;
15028
15029 spec->autocfg.hp_pins[0] = 0x1b; 15054 spec->autocfg.hp_pins[0] = 0x1b;
15030 spec->autocfg.speaker_pins[0] = 0x14; 15055 spec->autocfg.speaker_pins[0] = 0x14;
15056}
15057
15058static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15059{
15031 alc_automute_amp(codec); 15060 alc_automute_amp(codec);
15032 alc861vd_lenovo_mic_automute(codec); 15061 alc861vd_lenovo_mic_automute(codec);
15033} 15062}
@@ -15091,13 +15120,12 @@ static struct hda_verb alc861vd_dallas_verbs[] = {
15091}; 15120};
15092 15121
15093/* toggle speaker-output according to the hp-jack state */ 15122/* toggle speaker-output according to the hp-jack state */
15094static void alc861vd_dallas_init_hook(struct hda_codec *codec) 15123static void alc861vd_dallas_setup(struct hda_codec *codec)
15095{ 15124{
15096 struct alc_spec *spec = codec->spec; 15125 struct alc_spec *spec = codec->spec;
15097 15126
15098 spec->autocfg.hp_pins[0] = 0x15; 15127 spec->autocfg.hp_pins[0] = 0x15;
15099 spec->autocfg.speaker_pins[0] = 0x14; 15128 spec->autocfg.speaker_pins[0] = 0x14;
15100 alc_automute_amp(codec);
15101} 15129}
15102 15130
15103#ifdef CONFIG_SND_HDA_POWER_SAVE 15131#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -15136,7 +15164,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
15136 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 15164 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
15137 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), 15165 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
15138 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ 15166 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
15139 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), 15167 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
15140 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 15168 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
15141 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), 15169 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
15142 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 15170 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
@@ -15211,6 +15239,7 @@ static struct alc_config_preset alc861vd_presets[] = {
15211 .channel_mode = alc861vd_3stack_2ch_modes, 15239 .channel_mode = alc861vd_3stack_2ch_modes,
15212 .input_mux = &alc861vd_capture_source, 15240 .input_mux = &alc861vd_capture_source,
15213 .unsol_event = alc861vd_lenovo_unsol_event, 15241 .unsol_event = alc861vd_lenovo_unsol_event,
15242 .setup = alc861vd_lenovo_setup,
15214 .init_hook = alc861vd_lenovo_init_hook, 15243 .init_hook = alc861vd_lenovo_init_hook,
15215 }, 15244 },
15216 [ALC861VD_DALLAS] = { 15245 [ALC861VD_DALLAS] = {
@@ -15222,7 +15251,8 @@ static struct alc_config_preset alc861vd_presets[] = {
15222 .channel_mode = alc861vd_3stack_2ch_modes, 15251 .channel_mode = alc861vd_3stack_2ch_modes,
15223 .input_mux = &alc861vd_dallas_capture_source, 15252 .input_mux = &alc861vd_dallas_capture_source,
15224 .unsol_event = alc_automute_amp_unsol_event, 15253 .unsol_event = alc_automute_amp_unsol_event,
15225 .init_hook = alc861vd_dallas_init_hook, 15254 .setup = alc861vd_dallas_setup,
15255 .init_hook = alc_automute_amp,
15226 }, 15256 },
15227 [ALC861VD_HP] = { 15257 [ALC861VD_HP] = {
15228 .mixers = { alc861vd_hp_mixer }, 15258 .mixers = { alc861vd_hp_mixer },
@@ -15234,7 +15264,8 @@ static struct alc_config_preset alc861vd_presets[] = {
15234 .channel_mode = alc861vd_3stack_2ch_modes, 15264 .channel_mode = alc861vd_3stack_2ch_modes,
15235 .input_mux = &alc861vd_hp_capture_source, 15265 .input_mux = &alc861vd_hp_capture_source,
15236 .unsol_event = alc_automute_amp_unsol_event, 15266 .unsol_event = alc_automute_amp_unsol_event,
15237 .init_hook = alc861vd_dallas_init_hook, 15267 .setup = alc861vd_dallas_setup,
15268 .init_hook = alc_automute_amp,
15238 }, 15269 },
15239 [ALC660VD_ASUS_V1S] = { 15270 [ALC660VD_ASUS_V1S] = {
15240 .mixers = { alc861vd_lenovo_mixer }, 15271 .mixers = { alc861vd_lenovo_mixer },
@@ -15249,6 +15280,7 @@ static struct alc_config_preset alc861vd_presets[] = {
15249 .channel_mode = alc861vd_3stack_2ch_modes, 15280 .channel_mode = alc861vd_3stack_2ch_modes,
15250 .input_mux = &alc861vd_capture_source, 15281 .input_mux = &alc861vd_capture_source,
15251 .unsol_event = alc861vd_lenovo_unsol_event, 15282 .unsol_event = alc861vd_lenovo_unsol_event,
15283 .setup = alc861vd_lenovo_setup,
15252 .init_hook = alc861vd_lenovo_init_hook, 15284 .init_hook = alc861vd_lenovo_init_hook,
15253 }, 15285 },
15254}; 15286};
@@ -15256,6 +15288,13 @@ static struct alc_config_preset alc861vd_presets[] = {
15256/* 15288/*
15257 * BIOS auto configuration 15289 * BIOS auto configuration
15258 */ 15290 */
15291static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15292 const struct auto_pin_cfg *cfg)
15293{
15294 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15295}
15296
15297
15259static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, 15298static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15260 hda_nid_t nid, int pin_type, int dac_idx) 15299 hda_nid_t nid, int pin_type, int dac_idx)
15261{ 15300{
@@ -15290,7 +15329,6 @@ static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15290 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 15329 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
15291} 15330}
15292 15331
15293#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15294#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID 15332#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15295 15333
15296static void alc861vd_auto_init_analog_input(struct hda_codec *codec) 15334static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
@@ -15300,7 +15338,7 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15300 15338
15301 for (i = 0; i < AUTO_PIN_LAST; i++) { 15339 for (i = 0; i < AUTO_PIN_LAST; i++) {
15302 hda_nid_t nid = spec->autocfg.input_pins[i]; 15340 hda_nid_t nid = spec->autocfg.input_pins[i];
15303 if (alc861vd_is_input_pin(nid)) { 15341 if (alc_is_input_pin(codec, nid)) {
15304 alc_set_input_pin(codec, nid, i); 15342 alc_set_input_pin(codec, nid, i);
15305 if (nid != ALC861VD_PIN_CD_NID && 15343 if (nid != ALC861VD_PIN_CD_NID &&
15306 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 15344 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -15364,13 +15402,25 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15364 if (err < 0) 15402 if (err < 0)
15365 return err; 15403 return err;
15366 } else { 15404 } else {
15367 sprintf(name, "%s Playback Volume", chname[i]); 15405 const char *pfx;
15406 if (cfg->line_outs == 1 &&
15407 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15408 if (!cfg->hp_pins)
15409 pfx = "Speaker";
15410 else
15411 pfx = "PCM";
15412 } else
15413 pfx = chname[i];
15414 sprintf(name, "%s Playback Volume", pfx);
15368 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 15415 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15369 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 15416 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15370 HDA_OUTPUT)); 15417 HDA_OUTPUT));
15371 if (err < 0) 15418 if (err < 0)
15372 return err; 15419 return err;
15373 sprintf(name, "%s Playback Switch", chname[i]); 15420 if (cfg->line_outs == 1 &&
15421 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15422 pfx = "Speaker";
15423 sprintf(name, "%s Playback Switch", pfx);
15374 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 15424 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15375 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 15425 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
15376 HDA_INPUT)); 15426 HDA_INPUT));
@@ -15463,7 +15513,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
15463 "Headphone"); 15513 "Headphone");
15464 if (err < 0) 15514 if (err < 0)
15465 return err; 15515 return err;
15466 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 15516 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
15467 if (err < 0) 15517 if (err < 0)
15468 return err; 15518 return err;
15469 15519
@@ -15517,8 +15567,8 @@ static int patch_alc861vd(struct hda_codec *codec)
15517 alc861vd_cfg_tbl); 15567 alc861vd_cfg_tbl);
15518 15568
15519 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { 15569 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15520 printk(KERN_INFO "hda_codec: Unknown model for %s, " 15570 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15521 "trying auto-probe from BIOS...\n", codec->chip_name); 15571 codec->chip_name);
15522 board_config = ALC861VD_AUTO; 15572 board_config = ALC861VD_AUTO;
15523 } 15573 }
15524 15574
@@ -15543,7 +15593,7 @@ static int patch_alc861vd(struct hda_codec *codec)
15543 } 15593 }
15544 15594
15545 if (board_config != ALC861VD_AUTO) 15595 if (board_config != ALC861VD_AUTO)
15546 setup_preset(spec, &alc861vd_presets[board_config]); 15596 setup_preset(codec, &alc861vd_presets[board_config]);
15547 15597
15548 if (codec->vendor_id == 0x10ec0660) { 15598 if (codec->vendor_id == 0x10ec0660) {
15549 /* always turn on EAPD */ 15599 /* always turn on EAPD */
@@ -15556,11 +15606,14 @@ static int patch_alc861vd(struct hda_codec *codec)
15556 spec->stream_digital_playback = &alc861vd_pcm_digital_playback; 15606 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15557 spec->stream_digital_capture = &alc861vd_pcm_digital_capture; 15607 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15558 15608
15559 spec->adc_nids = alc861vd_adc_nids; 15609 if (!spec->adc_nids) {
15560 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 15610 spec->adc_nids = alc861vd_adc_nids;
15561 spec->capsrc_nids = alc861vd_capsrc_nids; 15611 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15612 }
15613 if (!spec->capsrc_nids)
15614 spec->capsrc_nids = alc861vd_capsrc_nids;
15562 15615
15563 set_capture_mixer(spec); 15616 set_capture_mixer(codec);
15564 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 15617 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
15565 15618
15566 spec->vmaster_nid = 0x02; 15619 spec->vmaster_nid = 0x02;
@@ -15601,9 +15654,9 @@ static hda_nid_t alc272_dac_nids[2] = {
15601 0x02, 0x03 15654 0x02, 0x03
15602}; 15655};
15603 15656
15604static hda_nid_t alc662_adc_nids[1] = { 15657static hda_nid_t alc662_adc_nids[2] = {
15605 /* ADC1-2 */ 15658 /* ADC1-2 */
15606 0x09, 15659 0x09, 0x08
15607}; 15660};
15608 15661
15609static hda_nid_t alc272_adc_nids[1] = { 15662static hda_nid_t alc272_adc_nids[1] = {
@@ -15611,7 +15664,7 @@ static hda_nid_t alc272_adc_nids[1] = {
15611 0x08, 15664 0x08,
15612}; 15665};
15613 15666
15614static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; 15667static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
15615static hda_nid_t alc272_capsrc_nids[1] = { 0x23 }; 15668static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15616 15669
15617 15670
@@ -15635,14 +15688,6 @@ static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15635 }, 15688 },
15636}; 15689};
15637 15690
15638static struct hda_input_mux alc662_eeepc_capture_source = {
15639 .num_items = 2,
15640 .items = {
15641 { "i-Mic", 0x1 },
15642 { "e-Mic", 0x0 },
15643 },
15644};
15645
15646static struct hda_input_mux alc663_capture_source = { 15691static struct hda_input_mux alc663_capture_source = {
15647 .num_items = 3, 15692 .num_items = 3,
15648 .items = { 15693 .items = {
@@ -15652,23 +15697,7 @@ static struct hda_input_mux alc663_capture_source = {
15652 }, 15697 },
15653}; 15698};
15654 15699
15655static struct hda_input_mux alc663_m51va_capture_source = { 15700#if 0 /* set to 1 for testing other input sources below */
15656 .num_items = 2,
15657 .items = {
15658 { "Ext-Mic", 0x0 },
15659 { "D-Mic", 0x9 },
15660 },
15661};
15662
15663#if 1 /* set to 0 for testing other input sources below */
15664static struct hda_input_mux alc272_nc10_capture_source = {
15665 .num_items = 2,
15666 .items = {
15667 { "Autoselect Mic", 0x0 },
15668 { "Internal Mic", 0x1 },
15669 },
15670};
15671#else
15672static struct hda_input_mux alc272_nc10_capture_source = { 15701static struct hda_input_mux alc272_nc10_capture_source = {
15673 .num_items = 16, 15702 .num_items = 16,
15674 .items = { 15703 .items = {
@@ -16337,47 +16366,44 @@ static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16337 alc662_lenovo_101e_ispeaker_automute(codec); 16366 alc662_lenovo_101e_ispeaker_automute(codec);
16338} 16367}
16339 16368
16340static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16341{
16342 unsigned int present;
16343
16344 present = snd_hda_codec_read(codec, 0x18, 0,
16345 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16346 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16347 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16348 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16349 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16350 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16351 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16352 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16353 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16354}
16355
16356/* unsolicited event for HP jack sensing */ 16369/* unsolicited event for HP jack sensing */
16357static void alc662_eeepc_unsol_event(struct hda_codec *codec, 16370static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16358 unsigned int res) 16371 unsigned int res)
16359{ 16372{
16360 if ((res >> 26) == ALC880_MIC_EVENT) 16373 if ((res >> 26) == ALC880_MIC_EVENT)
16361 alc662_eeepc_mic_automute(codec); 16374 alc_mic_automute(codec);
16362 else 16375 else
16363 alc262_hippo_unsol_event(codec, res); 16376 alc262_hippo_unsol_event(codec, res);
16364} 16377}
16365 16378
16379static void alc662_eeepc_setup(struct hda_codec *codec)
16380{
16381 struct alc_spec *spec = codec->spec;
16382
16383 alc262_hippo1_setup(codec);
16384 spec->ext_mic.pin = 0x18;
16385 spec->ext_mic.mux_idx = 0;
16386 spec->int_mic.pin = 0x19;
16387 spec->int_mic.mux_idx = 1;
16388 spec->auto_mic = 1;
16389}
16390
16366static void alc662_eeepc_inithook(struct hda_codec *codec) 16391static void alc662_eeepc_inithook(struct hda_codec *codec)
16367{ 16392{
16368 alc262_hippo1_init_hook(codec); 16393 alc262_hippo_automute(codec);
16369 alc662_eeepc_mic_automute(codec); 16394 alc_mic_automute(codec);
16370} 16395}
16371 16396
16372static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) 16397static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
16373{ 16398{
16374 struct alc_spec *spec = codec->spec; 16399 struct alc_spec *spec = codec->spec;
16375 16400
16376 spec->autocfg.hp_pins[0] = 0x14; 16401 spec->autocfg.hp_pins[0] = 0x14;
16377 spec->autocfg.speaker_pins[0] = 0x1b; 16402 spec->autocfg.speaker_pins[0] = 0x1b;
16378 alc262_hippo_master_update(codec);
16379} 16403}
16380 16404
16405#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16406
16381static void alc663_m51va_speaker_automute(struct hda_codec *codec) 16407static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16382{ 16408{
16383 unsigned int present; 16409 unsigned int present;
@@ -16488,23 +16514,6 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16488 } 16514 }
16489} 16515}
16490 16516
16491static void alc663_m51va_mic_automute(struct hda_codec *codec)
16492{
16493 unsigned int present;
16494
16495 present = snd_hda_codec_read(codec, 0x18, 0,
16496 AC_VERB_GET_PIN_SENSE, 0)
16497 & AC_PINSENSE_PRESENCE;
16498 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16499 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16500 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16501 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16502 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16503 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
16504 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16505 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
16506}
16507
16508static void alc663_m51va_unsol_event(struct hda_codec *codec, 16517static void alc663_m51va_unsol_event(struct hda_codec *codec,
16509 unsigned int res) 16518 unsigned int res)
16510{ 16519{
@@ -16513,36 +16522,32 @@ static void alc663_m51va_unsol_event(struct hda_codec *codec,
16513 alc663_m51va_speaker_automute(codec); 16522 alc663_m51va_speaker_automute(codec);
16514 break; 16523 break;
16515 case ALC880_MIC_EVENT: 16524 case ALC880_MIC_EVENT:
16516 alc663_m51va_mic_automute(codec); 16525 alc_mic_automute(codec);
16517 break; 16526 break;
16518 } 16527 }
16519} 16528}
16520 16529
16530static void alc663_m51va_setup(struct hda_codec *codec)
16531{
16532 struct alc_spec *spec = codec->spec;
16533 spec->ext_mic.pin = 0x18;
16534 spec->ext_mic.mux_idx = 0;
16535 spec->int_mic.pin = 0x12;
16536 spec->int_mic.mux_idx = 1;
16537 spec->auto_mic = 1;
16538}
16539
16521static void alc663_m51va_inithook(struct hda_codec *codec) 16540static void alc663_m51va_inithook(struct hda_codec *codec)
16522{ 16541{
16523 alc663_m51va_speaker_automute(codec); 16542 alc663_m51va_speaker_automute(codec);
16524 alc663_m51va_mic_automute(codec); 16543 alc_mic_automute(codec);
16525} 16544}
16526 16545
16527/* ***************** Mode1 ******************************/ 16546/* ***************** Mode1 ******************************/
16528static void alc663_mode1_unsol_event(struct hda_codec *codec, 16547#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16529 unsigned int res) 16548#define alc663_mode1_setup alc663_m51va_setup
16530{ 16549#define alc663_mode1_inithook alc663_m51va_inithook
16531 switch (res >> 26) {
16532 case ALC880_HP_EVENT:
16533 alc663_m51va_speaker_automute(codec);
16534 break;
16535 case ALC880_MIC_EVENT:
16536 alc662_eeepc_mic_automute(codec);
16537 break;
16538 }
16539}
16540 16550
16541static void alc663_mode1_inithook(struct hda_codec *codec)
16542{
16543 alc663_m51va_speaker_automute(codec);
16544 alc662_eeepc_mic_automute(codec);
16545}
16546/* ***************** Mode2 ******************************/ 16551/* ***************** Mode2 ******************************/
16547static void alc662_mode2_unsol_event(struct hda_codec *codec, 16552static void alc662_mode2_unsol_event(struct hda_codec *codec,
16548 unsigned int res) 16553 unsigned int res)
@@ -16552,15 +16557,17 @@ static void alc662_mode2_unsol_event(struct hda_codec *codec,
16552 alc662_f5z_speaker_automute(codec); 16557 alc662_f5z_speaker_automute(codec);
16553 break; 16558 break;
16554 case ALC880_MIC_EVENT: 16559 case ALC880_MIC_EVENT:
16555 alc662_eeepc_mic_automute(codec); 16560 alc_mic_automute(codec);
16556 break; 16561 break;
16557 } 16562 }
16558} 16563}
16559 16564
16565#define alc662_mode2_setup alc663_m51va_setup
16566
16560static void alc662_mode2_inithook(struct hda_codec *codec) 16567static void alc662_mode2_inithook(struct hda_codec *codec)
16561{ 16568{
16562 alc662_f5z_speaker_automute(codec); 16569 alc662_f5z_speaker_automute(codec);
16563 alc662_eeepc_mic_automute(codec); 16570 alc_mic_automute(codec);
16564} 16571}
16565/* ***************** Mode3 ******************************/ 16572/* ***************** Mode3 ******************************/
16566static void alc663_mode3_unsol_event(struct hda_codec *codec, 16573static void alc663_mode3_unsol_event(struct hda_codec *codec,
@@ -16571,15 +16578,17 @@ static void alc663_mode3_unsol_event(struct hda_codec *codec,
16571 alc663_two_hp_m1_speaker_automute(codec); 16578 alc663_two_hp_m1_speaker_automute(codec);
16572 break; 16579 break;
16573 case ALC880_MIC_EVENT: 16580 case ALC880_MIC_EVENT:
16574 alc662_eeepc_mic_automute(codec); 16581 alc_mic_automute(codec);
16575 break; 16582 break;
16576 } 16583 }
16577} 16584}
16578 16585
16586#define alc663_mode3_setup alc663_m51va_setup
16587
16579static void alc663_mode3_inithook(struct hda_codec *codec) 16588static void alc663_mode3_inithook(struct hda_codec *codec)
16580{ 16589{
16581 alc663_two_hp_m1_speaker_automute(codec); 16590 alc663_two_hp_m1_speaker_automute(codec);
16582 alc662_eeepc_mic_automute(codec); 16591 alc_mic_automute(codec);
16583} 16592}
16584/* ***************** Mode4 ******************************/ 16593/* ***************** Mode4 ******************************/
16585static void alc663_mode4_unsol_event(struct hda_codec *codec, 16594static void alc663_mode4_unsol_event(struct hda_codec *codec,
@@ -16590,15 +16599,17 @@ static void alc663_mode4_unsol_event(struct hda_codec *codec,
16590 alc663_21jd_two_speaker_automute(codec); 16599 alc663_21jd_two_speaker_automute(codec);
16591 break; 16600 break;
16592 case ALC880_MIC_EVENT: 16601 case ALC880_MIC_EVENT:
16593 alc662_eeepc_mic_automute(codec); 16602 alc_mic_automute(codec);
16594 break; 16603 break;
16595 } 16604 }
16596} 16605}
16597 16606
16607#define alc663_mode4_setup alc663_m51va_setup
16608
16598static void alc663_mode4_inithook(struct hda_codec *codec) 16609static void alc663_mode4_inithook(struct hda_codec *codec)
16599{ 16610{
16600 alc663_21jd_two_speaker_automute(codec); 16611 alc663_21jd_two_speaker_automute(codec);
16601 alc662_eeepc_mic_automute(codec); 16612 alc_mic_automute(codec);
16602} 16613}
16603/* ***************** Mode5 ******************************/ 16614/* ***************** Mode5 ******************************/
16604static void alc663_mode5_unsol_event(struct hda_codec *codec, 16615static void alc663_mode5_unsol_event(struct hda_codec *codec,
@@ -16609,15 +16620,17 @@ static void alc663_mode5_unsol_event(struct hda_codec *codec,
16609 alc663_15jd_two_speaker_automute(codec); 16620 alc663_15jd_two_speaker_automute(codec);
16610 break; 16621 break;
16611 case ALC880_MIC_EVENT: 16622 case ALC880_MIC_EVENT:
16612 alc662_eeepc_mic_automute(codec); 16623 alc_mic_automute(codec);
16613 break; 16624 break;
16614 } 16625 }
16615} 16626}
16616 16627
16628#define alc663_mode5_setup alc663_m51va_setup
16629
16617static void alc663_mode5_inithook(struct hda_codec *codec) 16630static void alc663_mode5_inithook(struct hda_codec *codec)
16618{ 16631{
16619 alc663_15jd_two_speaker_automute(codec); 16632 alc663_15jd_two_speaker_automute(codec);
16620 alc662_eeepc_mic_automute(codec); 16633 alc_mic_automute(codec);
16621} 16634}
16622/* ***************** Mode6 ******************************/ 16635/* ***************** Mode6 ******************************/
16623static void alc663_mode6_unsol_event(struct hda_codec *codec, 16636static void alc663_mode6_unsol_event(struct hda_codec *codec,
@@ -16628,15 +16641,17 @@ static void alc663_mode6_unsol_event(struct hda_codec *codec,
16628 alc663_two_hp_m2_speaker_automute(codec); 16641 alc663_two_hp_m2_speaker_automute(codec);
16629 break; 16642 break;
16630 case ALC880_MIC_EVENT: 16643 case ALC880_MIC_EVENT:
16631 alc662_eeepc_mic_automute(codec); 16644 alc_mic_automute(codec);
16632 break; 16645 break;
16633 } 16646 }
16634} 16647}
16635 16648
16649#define alc663_mode6_setup alc663_m51va_setup
16650
16636static void alc663_mode6_inithook(struct hda_codec *codec) 16651static void alc663_mode6_inithook(struct hda_codec *codec)
16637{ 16652{
16638 alc663_two_hp_m2_speaker_automute(codec); 16653 alc663_two_hp_m2_speaker_automute(codec);
16639 alc662_eeepc_mic_automute(codec); 16654 alc_mic_automute(codec);
16640} 16655}
16641 16656
16642static void alc663_g71v_hp_automute(struct hda_codec *codec) 16657static void alc663_g71v_hp_automute(struct hda_codec *codec)
@@ -16678,16 +16693,18 @@ static void alc663_g71v_unsol_event(struct hda_codec *codec,
16678 alc663_g71v_front_automute(codec); 16693 alc663_g71v_front_automute(codec);
16679 break; 16694 break;
16680 case ALC880_MIC_EVENT: 16695 case ALC880_MIC_EVENT:
16681 alc662_eeepc_mic_automute(codec); 16696 alc_mic_automute(codec);
16682 break; 16697 break;
16683 } 16698 }
16684} 16699}
16685 16700
16701#define alc663_g71v_setup alc663_m51va_setup
16702
16686static void alc663_g71v_inithook(struct hda_codec *codec) 16703static void alc663_g71v_inithook(struct hda_codec *codec)
16687{ 16704{
16688 alc663_g71v_front_automute(codec); 16705 alc663_g71v_front_automute(codec);
16689 alc663_g71v_hp_automute(codec); 16706 alc663_g71v_hp_automute(codec);
16690 alc662_eeepc_mic_automute(codec); 16707 alc_mic_automute(codec);
16691} 16708}
16692 16709
16693static void alc663_g50v_unsol_event(struct hda_codec *codec, 16710static void alc663_g50v_unsol_event(struct hda_codec *codec,
@@ -16698,15 +16715,17 @@ static void alc663_g50v_unsol_event(struct hda_codec *codec,
16698 alc663_m51va_speaker_automute(codec); 16715 alc663_m51va_speaker_automute(codec);
16699 break; 16716 break;
16700 case ALC880_MIC_EVENT: 16717 case ALC880_MIC_EVENT:
16701 alc662_eeepc_mic_automute(codec); 16718 alc_mic_automute(codec);
16702 break; 16719 break;
16703 } 16720 }
16704} 16721}
16705 16722
16723#define alc663_g50v_setup alc663_m51va_setup
16724
16706static void alc663_g50v_inithook(struct hda_codec *codec) 16725static void alc663_g50v_inithook(struct hda_codec *codec)
16707{ 16726{
16708 alc663_m51va_speaker_automute(codec); 16727 alc663_m51va_speaker_automute(codec);
16709 alc662_eeepc_mic_automute(codec); 16728 alc_mic_automute(codec);
16710} 16729}
16711 16730
16712static struct snd_kcontrol_new alc662_ecs_mixer[] = { 16731static struct snd_kcontrol_new alc662_ecs_mixer[] = {
@@ -16833,6 +16852,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
16833 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), 16852 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16834 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", 16853 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16835 ALC662_3ST_6ch_DIG), 16854 ALC662_3ST_6ch_DIG),
16855 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
16836 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10), 16856 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
16837 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", 16857 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16838 ALC662_3ST_6ch_DIG), 16858 ALC662_3ST_6ch_DIG),
@@ -16910,8 +16930,8 @@ static struct alc_config_preset alc662_presets[] = {
16910 .dac_nids = alc662_dac_nids, 16930 .dac_nids = alc662_dac_nids,
16911 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16931 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16912 .channel_mode = alc662_3ST_2ch_modes, 16932 .channel_mode = alc662_3ST_2ch_modes,
16913 .input_mux = &alc662_eeepc_capture_source,
16914 .unsol_event = alc662_eeepc_unsol_event, 16933 .unsol_event = alc662_eeepc_unsol_event,
16934 .setup = alc662_eeepc_setup,
16915 .init_hook = alc662_eeepc_inithook, 16935 .init_hook = alc662_eeepc_inithook,
16916 }, 16936 },
16917 [ALC662_ASUS_EEEPC_EP20] = { 16937 [ALC662_ASUS_EEEPC_EP20] = {
@@ -16925,6 +16945,7 @@ static struct alc_config_preset alc662_presets[] = {
16925 .channel_mode = alc662_3ST_6ch_modes, 16945 .channel_mode = alc662_3ST_6ch_modes,
16926 .input_mux = &alc662_lenovo_101e_capture_source, 16946 .input_mux = &alc662_lenovo_101e_capture_source,
16927 .unsol_event = alc662_eeepc_unsol_event, 16947 .unsol_event = alc662_eeepc_unsol_event,
16948 .setup = alc662_eeepc_ep20_setup,
16928 .init_hook = alc662_eeepc_ep20_inithook, 16949 .init_hook = alc662_eeepc_ep20_inithook,
16929 }, 16950 },
16930 [ALC662_ECS] = { 16951 [ALC662_ECS] = {
@@ -16935,8 +16956,8 @@ static struct alc_config_preset alc662_presets[] = {
16935 .dac_nids = alc662_dac_nids, 16956 .dac_nids = alc662_dac_nids,
16936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16957 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16937 .channel_mode = alc662_3ST_2ch_modes, 16958 .channel_mode = alc662_3ST_2ch_modes,
16938 .input_mux = &alc662_eeepc_capture_source,
16939 .unsol_event = alc662_eeepc_unsol_event, 16959 .unsol_event = alc662_eeepc_unsol_event,
16960 .setup = alc662_eeepc_setup,
16940 .init_hook = alc662_eeepc_inithook, 16961 .init_hook = alc662_eeepc_inithook,
16941 }, 16962 },
16942 [ALC663_ASUS_M51VA] = { 16963 [ALC663_ASUS_M51VA] = {
@@ -16947,8 +16968,8 @@ static struct alc_config_preset alc662_presets[] = {
16947 .dig_out_nid = ALC662_DIGOUT_NID, 16968 .dig_out_nid = ALC662_DIGOUT_NID,
16948 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16969 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16949 .channel_mode = alc662_3ST_2ch_modes, 16970 .channel_mode = alc662_3ST_2ch_modes,
16950 .input_mux = &alc663_m51va_capture_source,
16951 .unsol_event = alc663_m51va_unsol_event, 16971 .unsol_event = alc663_m51va_unsol_event,
16972 .setup = alc663_m51va_setup,
16952 .init_hook = alc663_m51va_inithook, 16973 .init_hook = alc663_m51va_inithook,
16953 }, 16974 },
16954 [ALC663_ASUS_G71V] = { 16975 [ALC663_ASUS_G71V] = {
@@ -16959,8 +16980,8 @@ static struct alc_config_preset alc662_presets[] = {
16959 .dig_out_nid = ALC662_DIGOUT_NID, 16980 .dig_out_nid = ALC662_DIGOUT_NID,
16960 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16981 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16961 .channel_mode = alc662_3ST_2ch_modes, 16982 .channel_mode = alc662_3ST_2ch_modes,
16962 .input_mux = &alc662_eeepc_capture_source,
16963 .unsol_event = alc663_g71v_unsol_event, 16983 .unsol_event = alc663_g71v_unsol_event,
16984 .setup = alc663_g71v_setup,
16964 .init_hook = alc663_g71v_inithook, 16985 .init_hook = alc663_g71v_inithook,
16965 }, 16986 },
16966 [ALC663_ASUS_H13] = { 16987 [ALC663_ASUS_H13] = {
@@ -16970,7 +16991,6 @@ static struct alc_config_preset alc662_presets[] = {
16970 .dac_nids = alc662_dac_nids, 16991 .dac_nids = alc662_dac_nids,
16971 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16992 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16972 .channel_mode = alc662_3ST_2ch_modes, 16993 .channel_mode = alc662_3ST_2ch_modes,
16973 .input_mux = &alc663_m51va_capture_source,
16974 .unsol_event = alc663_m51va_unsol_event, 16994 .unsol_event = alc663_m51va_unsol_event,
16975 .init_hook = alc663_m51va_inithook, 16995 .init_hook = alc663_m51va_inithook,
16976 }, 16996 },
@@ -16984,6 +17004,7 @@ static struct alc_config_preset alc662_presets[] = {
16984 .channel_mode = alc662_3ST_6ch_modes, 17004 .channel_mode = alc662_3ST_6ch_modes,
16985 .input_mux = &alc663_capture_source, 17005 .input_mux = &alc663_capture_source,
16986 .unsol_event = alc663_g50v_unsol_event, 17006 .unsol_event = alc663_g50v_unsol_event,
17007 .setup = alc663_g50v_setup,
16987 .init_hook = alc663_g50v_inithook, 17008 .init_hook = alc663_g50v_inithook,
16988 }, 17009 },
16989 [ALC663_ASUS_MODE1] = { 17010 [ALC663_ASUS_MODE1] = {
@@ -16997,8 +17018,8 @@ static struct alc_config_preset alc662_presets[] = {
16997 .dig_out_nid = ALC662_DIGOUT_NID, 17018 .dig_out_nid = ALC662_DIGOUT_NID,
16998 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17019 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16999 .channel_mode = alc662_3ST_2ch_modes, 17020 .channel_mode = alc662_3ST_2ch_modes,
17000 .input_mux = &alc662_eeepc_capture_source,
17001 .unsol_event = alc663_mode1_unsol_event, 17021 .unsol_event = alc663_mode1_unsol_event,
17022 .setup = alc663_mode1_setup,
17002 .init_hook = alc663_mode1_inithook, 17023 .init_hook = alc663_mode1_inithook,
17003 }, 17024 },
17004 [ALC662_ASUS_MODE2] = { 17025 [ALC662_ASUS_MODE2] = {
@@ -17011,8 +17032,8 @@ static struct alc_config_preset alc662_presets[] = {
17011 .dig_out_nid = ALC662_DIGOUT_NID, 17032 .dig_out_nid = ALC662_DIGOUT_NID,
17012 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17033 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17013 .channel_mode = alc662_3ST_2ch_modes, 17034 .channel_mode = alc662_3ST_2ch_modes,
17014 .input_mux = &alc662_eeepc_capture_source,
17015 .unsol_event = alc662_mode2_unsol_event, 17035 .unsol_event = alc662_mode2_unsol_event,
17036 .setup = alc662_mode2_setup,
17016 .init_hook = alc662_mode2_inithook, 17037 .init_hook = alc662_mode2_inithook,
17017 }, 17038 },
17018 [ALC663_ASUS_MODE3] = { 17039 [ALC663_ASUS_MODE3] = {
@@ -17026,8 +17047,8 @@ static struct alc_config_preset alc662_presets[] = {
17026 .dig_out_nid = ALC662_DIGOUT_NID, 17047 .dig_out_nid = ALC662_DIGOUT_NID,
17027 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17048 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17028 .channel_mode = alc662_3ST_2ch_modes, 17049 .channel_mode = alc662_3ST_2ch_modes,
17029 .input_mux = &alc662_eeepc_capture_source,
17030 .unsol_event = alc663_mode3_unsol_event, 17050 .unsol_event = alc663_mode3_unsol_event,
17051 .setup = alc663_mode3_setup,
17031 .init_hook = alc663_mode3_inithook, 17052 .init_hook = alc663_mode3_inithook,
17032 }, 17053 },
17033 [ALC663_ASUS_MODE4] = { 17054 [ALC663_ASUS_MODE4] = {
@@ -17041,8 +17062,8 @@ static struct alc_config_preset alc662_presets[] = {
17041 .dig_out_nid = ALC662_DIGOUT_NID, 17062 .dig_out_nid = ALC662_DIGOUT_NID,
17042 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17063 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17043 .channel_mode = alc662_3ST_2ch_modes, 17064 .channel_mode = alc662_3ST_2ch_modes,
17044 .input_mux = &alc662_eeepc_capture_source,
17045 .unsol_event = alc663_mode4_unsol_event, 17065 .unsol_event = alc663_mode4_unsol_event,
17066 .setup = alc663_mode4_setup,
17046 .init_hook = alc663_mode4_inithook, 17067 .init_hook = alc663_mode4_inithook,
17047 }, 17068 },
17048 [ALC663_ASUS_MODE5] = { 17069 [ALC663_ASUS_MODE5] = {
@@ -17056,8 +17077,8 @@ static struct alc_config_preset alc662_presets[] = {
17056 .dig_out_nid = ALC662_DIGOUT_NID, 17077 .dig_out_nid = ALC662_DIGOUT_NID,
17057 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17078 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17058 .channel_mode = alc662_3ST_2ch_modes, 17079 .channel_mode = alc662_3ST_2ch_modes,
17059 .input_mux = &alc662_eeepc_capture_source,
17060 .unsol_event = alc663_mode5_unsol_event, 17080 .unsol_event = alc663_mode5_unsol_event,
17081 .setup = alc663_mode5_setup,
17061 .init_hook = alc663_mode5_inithook, 17082 .init_hook = alc663_mode5_inithook,
17062 }, 17083 },
17063 [ALC663_ASUS_MODE6] = { 17084 [ALC663_ASUS_MODE6] = {
@@ -17071,8 +17092,8 @@ static struct alc_config_preset alc662_presets[] = {
17071 .dig_out_nid = ALC662_DIGOUT_NID, 17092 .dig_out_nid = ALC662_DIGOUT_NID,
17072 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17093 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17073 .channel_mode = alc662_3ST_2ch_modes, 17094 .channel_mode = alc662_3ST_2ch_modes,
17074 .input_mux = &alc662_eeepc_capture_source,
17075 .unsol_event = alc663_mode6_unsol_event, 17095 .unsol_event = alc663_mode6_unsol_event,
17096 .setup = alc663_mode6_setup,
17076 .init_hook = alc663_mode6_inithook, 17097 .init_hook = alc663_mode6_inithook,
17077 }, 17098 },
17078 [ALC272_DELL] = { 17099 [ALC272_DELL] = {
@@ -17086,8 +17107,8 @@ static struct alc_config_preset alc662_presets[] = {
17086 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids), 17107 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17087 .capsrc_nids = alc272_capsrc_nids, 17108 .capsrc_nids = alc272_capsrc_nids,
17088 .channel_mode = alc662_3ST_2ch_modes, 17109 .channel_mode = alc662_3ST_2ch_modes,
17089 .input_mux = &alc663_m51va_capture_source,
17090 .unsol_event = alc663_m51va_unsol_event, 17110 .unsol_event = alc663_m51va_unsol_event,
17111 .setup = alc663_m51va_setup,
17091 .init_hook = alc663_m51va_inithook, 17112 .init_hook = alc663_m51va_inithook,
17092 }, 17113 },
17093 [ALC272_DELL_ZM1] = { 17114 [ALC272_DELL_ZM1] = {
@@ -17098,11 +17119,11 @@ static struct alc_config_preset alc662_presets[] = {
17098 .dac_nids = alc662_dac_nids, 17119 .dac_nids = alc662_dac_nids,
17099 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17120 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17100 .adc_nids = alc662_adc_nids, 17121 .adc_nids = alc662_adc_nids,
17101 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), 17122 .num_adc_nids = 1,
17102 .capsrc_nids = alc662_capsrc_nids, 17123 .capsrc_nids = alc662_capsrc_nids,
17103 .channel_mode = alc662_3ST_2ch_modes, 17124 .channel_mode = alc662_3ST_2ch_modes,
17104 .input_mux = &alc663_m51va_capture_source,
17105 .unsol_event = alc663_m51va_unsol_event, 17125 .unsol_event = alc663_m51va_unsol_event,
17126 .setup = alc663_m51va_setup,
17106 .init_hook = alc663_m51va_inithook, 17127 .init_hook = alc663_m51va_inithook,
17107 }, 17128 },
17108 [ALC272_SAMSUNG_NC10] = { 17129 [ALC272_SAMSUNG_NC10] = {
@@ -17113,8 +17134,9 @@ static struct alc_config_preset alc662_presets[] = {
17113 .dac_nids = alc272_dac_nids, 17134 .dac_nids = alc272_dac_nids,
17114 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 17135 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17115 .channel_mode = alc662_3ST_2ch_modes, 17136 .channel_mode = alc662_3ST_2ch_modes,
17116 .input_mux = &alc272_nc10_capture_source, 17137 /*.input_mux = &alc272_nc10_capture_source,*/
17117 .unsol_event = alc663_mode4_unsol_event, 17138 .unsol_event = alc663_mode4_unsol_event,
17139 .setup = alc663_mode4_setup,
17118 .init_hook = alc663_mode4_inithook, 17140 .init_hook = alc663_mode4_inithook,
17119 }, 17141 },
17120}; 17142};
@@ -17124,58 +17146,145 @@ static struct alc_config_preset alc662_presets[] = {
17124 * BIOS auto configuration 17146 * BIOS auto configuration
17125 */ 17147 */
17126 17148
17149/* convert from MIX nid to DAC */
17150static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17151{
17152 if (nid == 0x0f)
17153 return 0x02;
17154 else if (nid >= 0x0c && nid <= 0x0e)
17155 return nid - 0x0c + 0x02;
17156 else
17157 return 0;
17158}
17159
17160/* get MIX nid connected to the given pin targeted to DAC */
17161static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17162 hda_nid_t dac)
17163{
17164 hda_nid_t mix[4];
17165 int i, num;
17166
17167 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17168 for (i = 0; i < num; i++) {
17169 if (alc662_mix_to_dac(mix[i]) == dac)
17170 return mix[i];
17171 }
17172 return 0;
17173}
17174
17175/* look for an empty DAC slot */
17176static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17177{
17178 struct alc_spec *spec = codec->spec;
17179 hda_nid_t srcs[5];
17180 int i, j, num;
17181
17182 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17183 if (num < 0)
17184 return 0;
17185 for (i = 0; i < num; i++) {
17186 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17187 if (!nid)
17188 continue;
17189 for (j = 0; j < spec->multiout.num_dacs; j++)
17190 if (spec->multiout.dac_nids[j] == nid)
17191 break;
17192 if (j >= spec->multiout.num_dacs)
17193 return nid;
17194 }
17195 return 0;
17196}
17197
17198/* fill in the dac_nids table from the parsed pin configuration */
17199static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17200 const struct auto_pin_cfg *cfg)
17201{
17202 struct alc_spec *spec = codec->spec;
17203 int i;
17204 hda_nid_t dac;
17205
17206 spec->multiout.dac_nids = spec->private_dac_nids;
17207 for (i = 0; i < cfg->line_outs; i++) {
17208 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17209 if (!dac)
17210 continue;
17211 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17212 }
17213 return 0;
17214}
17215
17216static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
17217 hda_nid_t nid, unsigned int chs)
17218{
17219 char name[32];
17220 sprintf(name, "%s Playback Volume", pfx);
17221 return add_control(spec, ALC_CTL_WIDGET_VOL, name,
17222 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17223}
17224
17225static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
17226 hda_nid_t nid, unsigned int chs)
17227{
17228 char name[32];
17229 sprintf(name, "%s Playback Switch", pfx);
17230 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17231 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17232}
17233
17234#define alc662_add_stereo_vol(spec, pfx, nid) \
17235 alc662_add_vol_ctl(spec, pfx, nid, 3)
17236#define alc662_add_stereo_sw(spec, pfx, nid) \
17237 alc662_add_sw_ctl(spec, pfx, nid, 3)
17238
17127/* add playback controls from the parsed DAC table */ 17239/* add playback controls from the parsed DAC table */
17128static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, 17240static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17129 const struct auto_pin_cfg *cfg) 17241 const struct auto_pin_cfg *cfg)
17130{ 17242{
17131 char name[32]; 17243 struct alc_spec *spec = codec->spec;
17132 static const char *chname[4] = { 17244 static const char *chname[4] = {
17133 "Front", "Surround", NULL /*CLFE*/, "Side" 17245 "Front", "Surround", NULL /*CLFE*/, "Side"
17134 }; 17246 };
17135 hda_nid_t nid; 17247 hda_nid_t nid, mix;
17136 int i, err; 17248 int i, err;
17137 17249
17138 for (i = 0; i < cfg->line_outs; i++) { 17250 for (i = 0; i < cfg->line_outs; i++) {
17139 if (!spec->multiout.dac_nids[i]) 17251 nid = spec->multiout.dac_nids[i];
17252 if (!nid)
17253 continue;
17254 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17255 if (!mix)
17140 continue; 17256 continue;
17141 nid = alc880_idx_to_dac(i);
17142 if (i == 2) { 17257 if (i == 2) {
17143 /* Center/LFE */ 17258 /* Center/LFE */
17144 err = add_control(spec, ALC_CTL_WIDGET_VOL, 17259 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
17145 "Center Playback Volume",
17146 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17147 HDA_OUTPUT));
17148 if (err < 0) 17260 if (err < 0)
17149 return err; 17261 return err;
17150 err = add_control(spec, ALC_CTL_WIDGET_VOL, 17262 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
17151 "LFE Playback Volume",
17152 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17153 HDA_OUTPUT));
17154 if (err < 0) 17263 if (err < 0)
17155 return err; 17264 return err;
17156 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 17265 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
17157 "Center Playback Switch",
17158 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
17159 HDA_INPUT));
17160 if (err < 0) 17266 if (err < 0)
17161 return err; 17267 return err;
17162 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 17268 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
17163 "LFE Playback Switch",
17164 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
17165 HDA_INPUT));
17166 if (err < 0) 17269 if (err < 0)
17167 return err; 17270 return err;
17168 } else { 17271 } else {
17169 sprintf(name, "%s Playback Volume", chname[i]); 17272 const char *pfx;
17170 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 17273 if (cfg->line_outs == 1 &&
17171 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 17274 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17172 HDA_OUTPUT)); 17275 if (cfg->hp_outs)
17276 pfx = "Speaker";
17277 else
17278 pfx = "PCM";
17279 } else
17280 pfx = chname[i];
17281 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17173 if (err < 0) 17282 if (err < 0)
17174 return err; 17283 return err;
17175 sprintf(name, "%s Playback Switch", chname[i]); 17284 if (cfg->line_outs == 1 &&
17176 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 17285 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17177 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), 17286 pfx = "Speaker";
17178 3, 0, HDA_INPUT)); 17287 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17179 if (err < 0) 17288 if (err < 0)
17180 return err; 17289 return err;
17181 } 17290 }
@@ -17184,139 +17293,75 @@ static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17184} 17293}
17185 17294
17186/* add playback controls for speaker and HP outputs */ 17295/* add playback controls for speaker and HP outputs */
17187static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, 17296/* return DAC nid if any new DAC is assigned */
17297static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
17188 const char *pfx) 17298 const char *pfx)
17189{ 17299{
17190 hda_nid_t nid; 17300 struct alc_spec *spec = codec->spec;
17301 hda_nid_t nid, mix;
17191 int err; 17302 int err;
17192 char name[32];
17193 17303
17194 if (!pin) 17304 if (!pin)
17195 return 0; 17305 return 0;
17196 17306 nid = alc662_look_for_dac(codec, pin);
17197 if (pin == 0x17) { 17307 if (!nid) {
17198 /* ALC663 has a mono output pin on 0x17 */ 17308 char name[32];
17199 sprintf(name, "%s Playback Switch", pfx); 17309 /* the corresponding DAC is already occupied */
17200 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 17310 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17201 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT)); 17311 return 0; /* no way */
17202 return err; 17312 /* create a switch only */
17203 }
17204
17205 if (alc880_is_fixed_pin(pin)) {
17206 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17207 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
17208 /* specify the DAC as the extra output */
17209 if (!spec->multiout.hp_nid)
17210 spec->multiout.hp_nid = nid;
17211 else
17212 spec->multiout.extra_out_nid[0] = nid;
17213 /* control HP volume/switch on the output mixer amp */
17214 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17215 sprintf(name, "%s Playback Volume", pfx);
17216 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17217 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17218 if (err < 0)
17219 return err;
17220 sprintf(name, "%s Playback Switch", pfx);
17221 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17222 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17223 if (err < 0)
17224 return err;
17225 } else if (alc880_is_multi_pin(pin)) {
17226 /* set manual connection */
17227 /* we have only a switch on HP-out PIN */
17228 sprintf(name, "%s Playback Switch", pfx); 17313 sprintf(name, "%s Playback Switch", pfx);
17229 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 17314 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17230 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 17315 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17231 if (err < 0)
17232 return err;
17233 } 17316 }
17234 return 0;
17235}
17236
17237/* return the index of the src widget from the connection list of the nid.
17238 * return -1 if not found
17239 */
17240static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17241 hda_nid_t src)
17242{
17243 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17244 int i, conns;
17245
17246 conns = snd_hda_get_connections(codec, nid, conn_list,
17247 ARRAY_SIZE(conn_list));
17248 if (conns < 0)
17249 return -1;
17250 for (i = 0; i < conns; i++)
17251 if (conn_list[i] == src)
17252 return i;
17253 return -1;
17254}
17255 17317
17256static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid) 17318 mix = alc662_dac_to_mix(codec, pin, nid);
17257{ 17319 if (!mix)
17258 unsigned int pincap = snd_hda_query_pin_caps(codec, nid); 17320 return 0;
17259 return (pincap & AC_PINCAP_IN) != 0; 17321 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17322 if (err < 0)
17323 return err;
17324 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17325 if (err < 0)
17326 return err;
17327 return nid;
17260} 17328}
17261 17329
17262/* create playback/capture controls for input pins */ 17330/* create playback/capture controls for input pins */
17263static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec, 17331#define alc662_auto_create_input_ctls \
17264 const struct auto_pin_cfg *cfg) 17332 alc880_auto_create_input_ctls
17265{
17266 struct alc_spec *spec = codec->spec;
17267 struct hda_input_mux *imux = &spec->private_imux[0];
17268 int i, err, idx;
17269
17270 for (i = 0; i < AUTO_PIN_LAST; i++) {
17271 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17272 idx = alc662_input_pin_idx(codec, 0x0b,
17273 cfg->input_pins[i]);
17274 if (idx >= 0) {
17275 err = new_analog_input(spec, cfg->input_pins[i],
17276 auto_pin_cfg_labels[i],
17277 idx, 0x0b);
17278 if (err < 0)
17279 return err;
17280 }
17281 idx = alc662_input_pin_idx(codec, 0x22,
17282 cfg->input_pins[i]);
17283 if (idx >= 0) {
17284 imux->items[imux->num_items].label =
17285 auto_pin_cfg_labels[i];
17286 imux->items[imux->num_items].index = idx;
17287 imux->num_items++;
17288 }
17289 }
17290 }
17291 return 0;
17292}
17293 17333
17294static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, 17334static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17295 hda_nid_t nid, int pin_type, 17335 hda_nid_t nid, int pin_type,
17296 int dac_idx) 17336 hda_nid_t dac)
17297{ 17337{
17338 int i, num;
17339 hda_nid_t srcs[4];
17340
17298 alc_set_pin_output(codec, nid, pin_type); 17341 alc_set_pin_output(codec, nid, pin_type);
17299 /* need the manual connection? */ 17342 /* need the manual connection? */
17300 if (alc880_is_multi_pin(nid)) { 17343 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17301 struct alc_spec *spec = codec->spec; 17344 if (num <= 1)
17302 int idx = alc880_multi_pin_idx(nid); 17345 return;
17303 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, 17346 for (i = 0; i < num; i++) {
17304 AC_VERB_SET_CONNECT_SEL, 17347 if (alc662_mix_to_dac(srcs[i]) != dac)
17305 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); 17348 continue;
17349 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17350 return;
17306 } 17351 }
17307} 17352}
17308 17353
17309static void alc662_auto_init_multi_out(struct hda_codec *codec) 17354static void alc662_auto_init_multi_out(struct hda_codec *codec)
17310{ 17355{
17311 struct alc_spec *spec = codec->spec; 17356 struct alc_spec *spec = codec->spec;
17357 int pin_type = get_pin_type(spec->autocfg.line_out_type);
17312 int i; 17358 int i;
17313 17359
17314 for (i = 0; i <= HDA_SIDE; i++) { 17360 for (i = 0; i <= HDA_SIDE; i++) {
17315 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 17361 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17316 int pin_type = get_pin_type(spec->autocfg.line_out_type);
17317 if (nid) 17362 if (nid)
17318 alc662_auto_set_output_and_unmute(codec, nid, pin_type, 17363 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
17319 i); 17364 spec->multiout.dac_nids[i]);
17320 } 17365 }
17321} 17366}
17322 17367
@@ -17326,12 +17371,13 @@ static void alc662_auto_init_hp_out(struct hda_codec *codec)
17326 hda_nid_t pin; 17371 hda_nid_t pin;
17327 17372
17328 pin = spec->autocfg.hp_pins[0]; 17373 pin = spec->autocfg.hp_pins[0];
17329 if (pin) /* connect to front */ 17374 if (pin)
17330 /* use dac 0 */ 17375 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17331 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 17376 spec->multiout.hp_nid);
17332 pin = spec->autocfg.speaker_pins[0]; 17377 pin = spec->autocfg.speaker_pins[0];
17333 if (pin) 17378 if (pin)
17334 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 17379 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17380 spec->multiout.extra_out_nid[0]);
17335} 17381}
17336 17382
17337#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID 17383#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
@@ -17343,7 +17389,7 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec)
17343 17389
17344 for (i = 0; i < AUTO_PIN_LAST; i++) { 17390 for (i = 0; i < AUTO_PIN_LAST; i++) {
17345 hda_nid_t nid = spec->autocfg.input_pins[i]; 17391 hda_nid_t nid = spec->autocfg.input_pins[i];
17346 if (alc662_is_input_pin(codec, nid)) { 17392 if (alc_is_input_pin(codec, nid)) {
17347 alc_set_input_pin(codec, nid, i); 17393 alc_set_input_pin(codec, nid, i);
17348 if (nid != ALC662_PIN_CD_NID && 17394 if (nid != ALC662_PIN_CD_NID &&
17349 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 17395 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -17369,22 +17415,26 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
17369 if (!spec->autocfg.line_outs) 17415 if (!spec->autocfg.line_outs)
17370 return 0; /* can't find valid BIOS pin config */ 17416 return 0; /* can't find valid BIOS pin config */
17371 17417
17372 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); 17418 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
17373 if (err < 0) 17419 if (err < 0)
17374 return err; 17420 return err;
17375 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); 17421 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
17376 if (err < 0) 17422 if (err < 0)
17377 return err; 17423 return err;
17378 err = alc662_auto_create_extra_out(spec, 17424 err = alc662_auto_create_extra_out(codec,
17379 spec->autocfg.speaker_pins[0], 17425 spec->autocfg.speaker_pins[0],
17380 "Speaker"); 17426 "Speaker");
17381 if (err < 0) 17427 if (err < 0)
17382 return err; 17428 return err;
17383 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 17429 if (err)
17430 spec->multiout.extra_out_nid[0] = err;
17431 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
17384 "Headphone"); 17432 "Headphone");
17385 if (err < 0) 17433 if (err < 0)
17386 return err; 17434 return err;
17387 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg); 17435 if (err)
17436 spec->multiout.hp_nid = err;
17437 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
17388 if (err < 0) 17438 if (err < 0)
17389 return err; 17439 return err;
17390 17440
@@ -17441,8 +17491,8 @@ static int patch_alc662(struct hda_codec *codec)
17441 alc662_models, 17491 alc662_models,
17442 alc662_cfg_tbl); 17492 alc662_cfg_tbl);
17443 if (board_config < 0) { 17493 if (board_config < 0) {
17444 printk(KERN_INFO "hda_codec: Unknown model for %s, " 17494 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17445 "trying auto-probe from BIOS...\n", codec->chip_name); 17495 codec->chip_name);
17446 board_config = ALC662_AUTO; 17496 board_config = ALC662_AUTO;
17447 } 17497 }
17448 17498
@@ -17467,7 +17517,7 @@ static int patch_alc662(struct hda_codec *codec)
17467 } 17517 }
17468 17518
17469 if (board_config != ALC662_AUTO) 17519 if (board_config != ALC662_AUTO)
17470 setup_preset(spec, &alc662_presets[board_config]); 17520 setup_preset(codec, &alc662_presets[board_config]);
17471 17521
17472 spec->stream_analog_playback = &alc662_pcm_analog_playback; 17522 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17473 spec->stream_analog_capture = &alc662_pcm_analog_capture; 17523 spec->stream_analog_capture = &alc662_pcm_analog_capture;
@@ -17475,12 +17525,15 @@ static int patch_alc662(struct hda_codec *codec)
17475 spec->stream_digital_playback = &alc662_pcm_digital_playback; 17525 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17476 spec->stream_digital_capture = &alc662_pcm_digital_capture; 17526 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17477 17527
17478 spec->adc_nids = alc662_adc_nids; 17528 if (!spec->adc_nids) {
17479 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 17529 spec->adc_nids = alc662_adc_nids;
17480 spec->capsrc_nids = alc662_capsrc_nids; 17530 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17531 }
17532 if (!spec->capsrc_nids)
17533 spec->capsrc_nids = alc662_capsrc_nids;
17481 17534
17482 if (!spec->cap_mixer) 17535 if (!spec->cap_mixer)
17483 set_capture_mixer(spec); 17536 set_capture_mixer(codec);
17484 if (codec->vendor_id == 0x10ec0662) 17537 if (codec->vendor_id == 0x10ec0662)
17485 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 17538 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17486 else 17539 else
@@ -17516,23 +17569,23 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = {
17516 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 17569 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17517 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 17570 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
17518 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", 17571 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17519 .patch = patch_alc883 }, 17572 .patch = patch_alc882 },
17520 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", 17573 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17521 .patch = patch_alc662 }, 17574 .patch = patch_alc662 },
17522 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 17575 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
17523 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 17576 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
17524 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 17577 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
17525 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 17578 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
17526 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", 17579 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17527 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 17580 .patch = patch_alc882 },
17528 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 17581 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
17529 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 17582 .patch = patch_alc882 },
17530 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 17583 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
17531 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, 17584 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
17532 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 17585 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17533 .patch = patch_alc883 }, 17586 .patch = patch_alc882 },
17534 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 17587 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17535 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 17588 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
17536 {} /* terminator */ 17589 {} /* terminator */
17537}; 17590};
17538 17591