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.c2328
1 files changed, 1309 insertions, 1019 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0fd258eba3a5..337d2a59c67e 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -190,6 +190,7 @@ enum {
190 ALC663_ASUS_MODE6, 190 ALC663_ASUS_MODE6,
191 ALC272_DELL, 191 ALC272_DELL,
192 ALC272_DELL_ZM1, 192 ALC272_DELL_ZM1,
193 ALC272_SAMSUNG_NC10,
193 ALC662_AUTO, 194 ALC662_AUTO,
194 ALC662_MODEL_LAST, 195 ALC662_MODEL_LAST,
195}; 196};
@@ -205,6 +206,7 @@ enum {
205 ALC882_ASUS_A7M, 206 ALC882_ASUS_A7M,
206 ALC885_MACPRO, 207 ALC885_MACPRO,
207 ALC885_MBP3, 208 ALC885_MBP3,
209 ALC885_MB5,
208 ALC885_IMAC24, 210 ALC885_IMAC24,
209 ALC882_AUTO, 211 ALC882_AUTO,
210 ALC882_MODEL_LAST, 212 ALC882_MODEL_LAST,
@@ -218,9 +220,11 @@ enum {
218 ALC883_6ST_DIG, 220 ALC883_6ST_DIG,
219 ALC883_TARGA_DIG, 221 ALC883_TARGA_DIG,
220 ALC883_TARGA_2ch_DIG, 222 ALC883_TARGA_2ch_DIG,
223 ALC883_TARGA_8ch_DIG,
221 ALC883_ACER, 224 ALC883_ACER,
222 ALC883_ACER_ASPIRE, 225 ALC883_ACER_ASPIRE,
223 ALC888_ACER_ASPIRE_4930G, 226 ALC888_ACER_ASPIRE_4930G,
227 ALC888_ACER_ASPIRE_8930G,
224 ALC883_MEDION, 228 ALC883_MEDION,
225 ALC883_MEDION_MD2, 229 ALC883_MEDION_MD2,
226 ALC883_LAPTOP_EAPD, 230 ALC883_LAPTOP_EAPD,
@@ -238,7 +242,9 @@ enum {
238 ALC883_3ST_6ch_INTEL, 242 ALC883_3ST_6ch_INTEL,
239 ALC888_ASUS_M90V, 243 ALC888_ASUS_M90V,
240 ALC888_ASUS_EEE1601, 244 ALC888_ASUS_EEE1601,
245 ALC889A_MB31,
241 ALC1200_ASUS_P5Q, 246 ALC1200_ASUS_P5Q,
247 ALC883_SONY_VAIO_TT,
242 ALC883_AUTO, 248 ALC883_AUTO,
243 ALC883_MODEL_LAST, 249 ALC883_MODEL_LAST,
244}; 250};
@@ -253,6 +259,15 @@ enum {
253/* for GPIO Poll */ 259/* for GPIO Poll */
254#define GPIO_MASK 0x03 260#define GPIO_MASK 0x03
255 261
262/* extra amp-initialization sequence types */
263enum {
264 ALC_INIT_NONE,
265 ALC_INIT_DEFAULT,
266 ALC_INIT_GPIO1,
267 ALC_INIT_GPIO2,
268 ALC_INIT_GPIO3,
269};
270
256struct alc_spec { 271struct alc_spec {
257 /* codec parameterization */ 272 /* codec parameterization */
258 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 273 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
@@ -266,13 +281,13 @@ struct alc_spec {
266 */ 281 */
267 unsigned int num_init_verbs; 282 unsigned int num_init_verbs;
268 283
269 char *stream_name_analog; /* analog PCM stream */ 284 char stream_name_analog[16]; /* analog PCM stream */
270 struct hda_pcm_stream *stream_analog_playback; 285 struct hda_pcm_stream *stream_analog_playback;
271 struct hda_pcm_stream *stream_analog_capture; 286 struct hda_pcm_stream *stream_analog_capture;
272 struct hda_pcm_stream *stream_analog_alt_playback; 287 struct hda_pcm_stream *stream_analog_alt_playback;
273 struct hda_pcm_stream *stream_analog_alt_capture; 288 struct hda_pcm_stream *stream_analog_alt_capture;
274 289
275 char *stream_name_digital; /* digital PCM stream */ 290 char stream_name_digital[16]; /* digital PCM stream */
276 struct hda_pcm_stream *stream_digital_playback; 291 struct hda_pcm_stream *stream_digital_playback;
277 struct hda_pcm_stream *stream_digital_capture; 292 struct hda_pcm_stream *stream_digital_capture;
278 293
@@ -301,6 +316,8 @@ struct alc_spec {
301 const struct hda_channel_mode *channel_mode; 316 const struct hda_channel_mode *channel_mode;
302 int num_channel_mode; 317 int num_channel_mode;
303 int need_dac_fix; 318 int need_dac_fix;
319 int const_channel_count;
320 int ext_channel_count;
304 321
305 /* PCM information */ 322 /* PCM information */
306 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ 323 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
@@ -322,6 +339,7 @@ struct alc_spec {
322 339
323 /* other flags */ 340 /* other flags */
324 unsigned int no_analog :1; /* digital I/O only */ 341 unsigned int no_analog :1; /* digital I/O only */
342 int init_amp;
325 343
326 /* for virtual master */ 344 /* for virtual master */
327 hda_nid_t vmaster_nid; 345 hda_nid_t vmaster_nid;
@@ -355,6 +373,7 @@ struct alc_config_preset {
355 unsigned int num_channel_mode; 373 unsigned int num_channel_mode;
356 const struct hda_channel_mode *channel_mode; 374 const struct hda_channel_mode *channel_mode;
357 int need_dac_fix; 375 int need_dac_fix;
376 int const_channel_count;
358 unsigned int num_mux_defs; 377 unsigned int num_mux_defs;
359 const struct hda_input_mux *input_mux; 378 const struct hda_input_mux *input_mux;
360 void (*unsol_event)(struct hda_codec *, unsigned int); 379 void (*unsol_event)(struct hda_codec *, unsigned int);
@@ -449,7 +468,7 @@ static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
449 struct alc_spec *spec = codec->spec; 468 struct alc_spec *spec = codec->spec;
450 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 469 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
451 spec->num_channel_mode, 470 spec->num_channel_mode,
452 spec->multiout.max_channels); 471 spec->ext_channel_count);
453} 472}
454 473
455static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, 474static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
@@ -459,9 +478,12 @@ static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
459 struct alc_spec *spec = codec->spec; 478 struct alc_spec *spec = codec->spec;
460 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 479 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
461 spec->num_channel_mode, 480 spec->num_channel_mode,
462 &spec->multiout.max_channels); 481 &spec->ext_channel_count);
463 if (err >= 0 && spec->need_dac_fix) 482 if (err >= 0 && !spec->const_channel_count) {
464 spec->multiout.num_dacs = spec->multiout.max_channels / 2; 483 spec->multiout.max_channels = spec->ext_channel_count;
484 if (spec->need_dac_fix)
485 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
486 }
465 return err; 487 return err;
466} 488}
467 489
@@ -841,8 +863,13 @@ static void setup_preset(struct alc_spec *spec,
841 spec->channel_mode = preset->channel_mode; 863 spec->channel_mode = preset->channel_mode;
842 spec->num_channel_mode = preset->num_channel_mode; 864 spec->num_channel_mode = preset->num_channel_mode;
843 spec->need_dac_fix = preset->need_dac_fix; 865 spec->need_dac_fix = preset->need_dac_fix;
866 spec->const_channel_count = preset->const_channel_count;
844 867
845 spec->multiout.max_channels = spec->channel_mode[0].channels; 868 if (preset->const_channel_count)
869 spec->multiout.max_channels = preset->const_channel_count;
870 else
871 spec->multiout.max_channels = spec->channel_mode[0].channels;
872 spec->ext_channel_count = spec->channel_mode[0].channels;
846 873
847 spec->multiout.num_dacs = preset->num_dacs; 874 spec->multiout.num_dacs = preset->num_dacs;
848 spec->multiout.dac_nids = preset->dac_nids; 875 spec->multiout.dac_nids = preset->dac_nids;
@@ -921,20 +948,26 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
921 alc_fix_pll(codec); 948 alc_fix_pll(codec);
922} 949}
923 950
924static void alc_sku_automute(struct hda_codec *codec) 951static void alc_automute_pin(struct hda_codec *codec)
925{ 952{
926 struct alc_spec *spec = codec->spec; 953 struct alc_spec *spec = codec->spec;
927 unsigned int present; 954 unsigned int present;
928 unsigned int hp_nid = spec->autocfg.hp_pins[0]; 955 unsigned int nid = spec->autocfg.hp_pins[0];
929 unsigned int sp_nid = spec->autocfg.speaker_pins[0]; 956 int i;
930 957
931 /* need to execute and sync at first */ 958 /* need to execute and sync at first */
932 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); 959 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
933 present = snd_hda_codec_read(codec, hp_nid, 0, 960 present = snd_hda_codec_read(codec, nid, 0,
934 AC_VERB_GET_PIN_SENSE, 0); 961 AC_VERB_GET_PIN_SENSE, 0);
935 spec->jack_present = (present & 0x80000000) != 0; 962 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
936 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 963 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
937 spec->jack_present ? 0 : PIN_OUT); 964 nid = spec->autocfg.speaker_pins[i];
965 if (!nid)
966 break;
967 snd_hda_codec_write(codec, nid, 0,
968 AC_VERB_SET_PIN_WIDGET_CONTROL,
969 spec->jack_present ? 0 : PIN_OUT);
970 }
938} 971}
939 972
940#if 0 /* it's broken in some acses -- temporarily disabled */ 973#if 0 /* it's broken in some acses -- temporarily disabled */
@@ -969,16 +1002,19 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
969 res >>= 28; 1002 res >>= 28;
970 else 1003 else
971 res >>= 26; 1004 res >>= 26;
972 if (res == ALC880_HP_EVENT) 1005 switch (res) {
973 alc_sku_automute(codec); 1006 case ALC880_HP_EVENT:
974 1007 alc_automute_pin(codec);
975 if (res == ALC880_MIC_EVENT) 1008 break;
1009 case ALC880_MIC_EVENT:
976 alc_mic_automute(codec); 1010 alc_mic_automute(codec);
1011 break;
1012 }
977} 1013}
978 1014
979static void alc_inithook(struct hda_codec *codec) 1015static void alc_inithook(struct hda_codec *codec)
980{ 1016{
981 alc_sku_automute(codec); 1017 alc_automute_pin(codec);
982 alc_mic_automute(codec); 1018 alc_mic_automute(codec);
983} 1019}
984 1020
@@ -1000,69 +1036,21 @@ static void alc888_coef_init(struct hda_codec *codec)
1000 AC_VERB_SET_PROC_COEF, 0x3030); 1036 AC_VERB_SET_PROC_COEF, 0x3030);
1001} 1037}
1002 1038
1003/* 32-bit subsystem ID for BIOS loading in HD Audio codec. 1039static void alc_auto_init_amp(struct hda_codec *codec, int type)
1004 * 31 ~ 16 : Manufacture ID
1005 * 15 ~ 8 : SKU ID
1006 * 7 ~ 0 : Assembly ID
1007 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1008 */
1009static void alc_subsystem_id(struct hda_codec *codec,
1010 unsigned int porta, unsigned int porte,
1011 unsigned int portd)
1012{ 1040{
1013 unsigned int ass, tmp, i; 1041 unsigned int tmp;
1014 unsigned nid;
1015 struct alc_spec *spec = codec->spec;
1016
1017 ass = codec->subsystem_id & 0xffff;
1018 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1019 goto do_sku;
1020
1021 /*
1022 * 31~30 : port conetcivity
1023 * 29~21 : reserve
1024 * 20 : PCBEEP input
1025 * 19~16 : Check sum (15:1)
1026 * 15~1 : Custom
1027 * 0 : override
1028 */
1029 nid = 0x1d;
1030 if (codec->vendor_id == 0x10ec0260)
1031 nid = 0x17;
1032 ass = snd_hda_codec_get_pincfg(codec, nid);
1033 if (!(ass & 1) && !(ass & 0x100000))
1034 return;
1035 if ((ass >> 30) != 1) /* no physical connection */
1036 return;
1037 1042
1038 /* check sum */ 1043 switch (type) {
1039 tmp = 0; 1044 case ALC_INIT_GPIO1:
1040 for (i = 1; i < 16; i++) {
1041 if ((ass >> i) & 1)
1042 tmp++;
1043 }
1044 if (((ass >> 16) & 0xf) != tmp)
1045 return;
1046do_sku:
1047 /*
1048 * 0 : override
1049 * 1 : Swap Jack
1050 * 2 : 0 --> Desktop, 1 --> Laptop
1051 * 3~5 : External Amplifier control
1052 * 7~6 : Reserved
1053 */
1054 tmp = (ass & 0x38) >> 3; /* external Amp control */
1055 switch (tmp) {
1056 case 1:
1057 snd_hda_sequence_write(codec, alc_gpio1_init_verbs); 1045 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1058 break; 1046 break;
1059 case 3: 1047 case ALC_INIT_GPIO2:
1060 snd_hda_sequence_write(codec, alc_gpio2_init_verbs); 1048 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1061 break; 1049 break;
1062 case 7: 1050 case ALC_INIT_GPIO3:
1063 snd_hda_sequence_write(codec, alc_gpio3_init_verbs); 1051 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1064 break; 1052 break;
1065 case 5: /* set EAPD output high */ 1053 case ALC_INIT_DEFAULT:
1066 switch (codec->vendor_id) { 1054 switch (codec->vendor_id) {
1067 case 0x10ec0260: 1055 case 0x10ec0260:
1068 snd_hda_codec_write(codec, 0x0f, 0, 1056 snd_hda_codec_write(codec, 0x0f, 0,
@@ -1116,7 +1104,7 @@ do_sku:
1116 tmp | 0x2010); 1104 tmp | 0x2010);
1117 break; 1105 break;
1118 case 0x10ec0888: 1106 case 0x10ec0888:
1119 /*alc888_coef_init(codec);*/ /* called in alc_init() */ 1107 alc888_coef_init(codec);
1120 break; 1108 break;
1121 case 0x10ec0267: 1109 case 0x10ec0267:
1122 case 0x10ec0268: 1110 case 0x10ec0268:
@@ -1131,7 +1119,107 @@ do_sku:
1131 tmp | 0x3000); 1119 tmp | 0x3000);
1132 break; 1120 break;
1133 } 1121 }
1134 default: 1122 break;
1123 }
1124}
1125
1126static void alc_init_auto_hp(struct hda_codec *codec)
1127{
1128 struct alc_spec *spec = codec->spec;
1129
1130 if (!spec->autocfg.hp_pins[0])
1131 return;
1132
1133 if (!spec->autocfg.speaker_pins[0]) {
1134 if (spec->autocfg.line_out_pins[0] &&
1135 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1136 spec->autocfg.speaker_pins[0] =
1137 spec->autocfg.line_out_pins[0];
1138 else
1139 return;
1140 }
1141
1142 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1143 spec->autocfg.hp_pins[0]);
1144 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1145 AC_VERB_SET_UNSOLICITED_ENABLE,
1146 AC_USRSP_EN | ALC880_HP_EVENT);
1147 spec->unsol_event = alc_sku_unsol_event;
1148}
1149
1150/* check subsystem ID and set up device-specific initialization;
1151 * return 1 if initialized, 0 if invalid SSID
1152 */
1153/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1154 * 31 ~ 16 : Manufacture ID
1155 * 15 ~ 8 : SKU ID
1156 * 7 ~ 0 : Assembly ID
1157 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1158 */
1159static int alc_subsystem_id(struct hda_codec *codec,
1160 hda_nid_t porta, hda_nid_t porte,
1161 hda_nid_t portd)
1162{
1163 unsigned int ass, tmp, i;
1164 unsigned nid;
1165 struct alc_spec *spec = codec->spec;
1166
1167 ass = codec->subsystem_id & 0xffff;
1168 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1169 goto do_sku;
1170
1171 /* invalid SSID, check the special NID pin defcfg instead */
1172 /*
1173 * 31~30 : port conetcivity
1174 * 29~21 : reserve
1175 * 20 : PCBEEP input
1176 * 19~16 : Check sum (15:1)
1177 * 15~1 : Custom
1178 * 0 : override
1179 */
1180 nid = 0x1d;
1181 if (codec->vendor_id == 0x10ec0260)
1182 nid = 0x17;
1183 ass = snd_hda_codec_get_pincfg(codec, nid);
1184 snd_printd("realtek: No valid SSID, "
1185 "checking pincfg 0x%08x for NID 0x%x\n",
1186 ass, nid);
1187 if (!(ass & 1) && !(ass & 0x100000))
1188 return 0;
1189 if ((ass >> 30) != 1) /* no physical connection */
1190 return 0;
1191
1192 /* check sum */
1193 tmp = 0;
1194 for (i = 1; i < 16; i++) {
1195 if ((ass >> i) & 1)
1196 tmp++;
1197 }
1198 if (((ass >> 16) & 0xf) != tmp)
1199 return 0;
1200do_sku:
1201 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1202 ass & 0xffff, codec->vendor_id);
1203 /*
1204 * 0 : override
1205 * 1 : Swap Jack
1206 * 2 : 0 --> Desktop, 1 --> Laptop
1207 * 3~5 : External Amplifier control
1208 * 7~6 : Reserved
1209 */
1210 tmp = (ass & 0x38) >> 3; /* external Amp control */
1211 switch (tmp) {
1212 case 1:
1213 spec->init_amp = ALC_INIT_GPIO1;
1214 break;
1215 case 3:
1216 spec->init_amp = ALC_INIT_GPIO2;
1217 break;
1218 case 7:
1219 spec->init_amp = ALC_INIT_GPIO3;
1220 break;
1221 case 5:
1222 spec->init_amp = ALC_INIT_DEFAULT;
1135 break; 1223 break;
1136 } 1224 }
1137 1225
@@ -1139,7 +1227,7 @@ do_sku:
1139 * when the external headphone out jack is plugged" 1227 * when the external headphone out jack is plugged"
1140 */ 1228 */
1141 if (!(ass & 0x8000)) 1229 if (!(ass & 0x8000))
1142 return; 1230 return 1;
1143 /* 1231 /*
1144 * 10~8 : Jack location 1232 * 10~8 : Jack location
1145 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered 1233 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
@@ -1147,14 +1235,6 @@ do_sku:
1147 * 15 : 1 --> enable the function "Mute internal speaker 1235 * 15 : 1 --> enable the function "Mute internal speaker
1148 * when the external headphone out jack is plugged" 1236 * when the external headphone out jack is plugged"
1149 */ 1237 */
1150 if (!spec->autocfg.speaker_pins[0]) {
1151 if (spec->autocfg.line_out_pins[0])
1152 spec->autocfg.speaker_pins[0] =
1153 spec->autocfg.line_out_pins[0];
1154 else
1155 return;
1156 }
1157
1158 if (!spec->autocfg.hp_pins[0]) { 1238 if (!spec->autocfg.hp_pins[0]) {
1159 tmp = (ass >> 11) & 0x3; /* HP to chassis */ 1239 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1160 if (tmp == 0) 1240 if (tmp == 0)
@@ -1164,23 +1244,23 @@ do_sku:
1164 else if (tmp == 2) 1244 else if (tmp == 2)
1165 spec->autocfg.hp_pins[0] = portd; 1245 spec->autocfg.hp_pins[0] = portd;
1166 else 1246 else
1167 return; 1247 return 1;
1168 } 1248 }
1169 if (spec->autocfg.hp_pins[0])
1170 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1171 AC_VERB_SET_UNSOLICITED_ENABLE,
1172 AC_USRSP_EN | ALC880_HP_EVENT);
1173 1249
1174#if 0 /* it's broken in some acses -- temporarily disabled */ 1250 alc_init_auto_hp(codec);
1175 if (spec->autocfg.input_pins[AUTO_PIN_MIC] && 1251 return 1;
1176 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]) 1252}
1177 snd_hda_codec_write(codec,
1178 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1179 AC_VERB_SET_UNSOLICITED_ENABLE,
1180 AC_USRSP_EN | ALC880_MIC_EVENT);
1181#endif /* disabled */
1182 1253
1183 spec->unsol_event = alc_sku_unsol_event; 1254static void alc_ssid_check(struct hda_codec *codec,
1255 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1256{
1257 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1258 struct alc_spec *spec = codec->spec;
1259 snd_printd("realtek: "
1260 "Enable default setup for auto mode as fallback\n");
1261 spec->init_amp = ALC_INIT_DEFAULT;
1262 alc_init_auto_hp(codec);
1263 }
1184} 1264}
1185 1265
1186/* 1266/*
@@ -1315,32 +1395,58 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1315 {} 1395 {}
1316}; 1396};
1317 1397
1318static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec) 1398static void alc_automute_amp(struct hda_codec *codec)
1319{ 1399{
1320 unsigned int present; 1400 struct alc_spec *spec = codec->spec;
1321 unsigned int bits; 1401 unsigned int val, mute;
1322 /* Line out presence */ 1402 hda_nid_t nid;
1323 present = snd_hda_codec_read(codec, 0x17, 0, 1403 int i;
1324 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1404
1325 /* HP out presence */ 1405 spec->jack_present = 0;
1326 present = present || snd_hda_codec_read(codec, 0x1b, 0, 1406 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1407 nid = spec->autocfg.hp_pins[i];
1328 bits = present ? HDA_AMP_MUTE : 0; 1408 if (!nid)
1409 break;
1410 val = snd_hda_codec_read(codec, nid, 0,
1411 AC_VERB_GET_PIN_SENSE, 0);
1412 if (val & AC_PINSENSE_PRESENCE) {
1413 spec->jack_present = 1;
1414 break;
1415 }
1416 }
1417
1418 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1329 /* Toggle internal speakers muting */ 1419 /* Toggle internal speakers muting */
1330 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 1420 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1331 HDA_AMP_MUTE, bits); 1421 nid = spec->autocfg.speaker_pins[i];
1332 /* Toggle internal bass muting */ 1422 if (!nid)
1333 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 1423 break;
1334 HDA_AMP_MUTE, bits); 1424 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1425 HDA_AMP_MUTE, mute);
1426 }
1335} 1427}
1336 1428
1337static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec, 1429static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1338 unsigned int res) 1430 unsigned int res)
1339{ 1431{
1340 if (res >> 26 == ALC880_HP_EVENT) 1432 if (codec->vendor_id == 0x10ec0880)
1341 alc888_fujitsu_xa3530_automute(codec); 1433 res >>= 28;
1434 else
1435 res >>= 26;
1436 if (res == ALC880_HP_EVENT)
1437 alc_automute_amp(codec);
1342} 1438}
1343 1439
1440static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1441{
1442 struct alc_spec *spec = codec->spec;
1443
1444 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1445 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1446 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1447 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1448 alc_automute_amp(codec);
1449}
1344 1450
1345/* 1451/*
1346 * ALC888 Acer Aspire 4930G model 1452 * ALC888 Acer Aspire 4930G model
@@ -1364,6 +1470,59 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1364 { } 1470 { }
1365}; 1471};
1366 1472
1473/*
1474 * ALC889 Acer Aspire 8930G model
1475 */
1476
1477static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1478/* Front Mic: set to PIN_IN (empty by default) */
1479 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1480/* Unselect Front Mic by default in input mixer 3 */
1481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1482/* Enable unsolicited event for HP jack */
1483 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1484/* Connect Internal Front to Front */
1485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1488/* Connect Internal Rear to Rear */
1489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1492/* Connect Internal CLFE to CLFE */
1493 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1494 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1495 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1496/* Connect HP out to Front */
1497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1500/* Enable all DACs */
1501/* DAC DISABLE/MUTE 1? */
1502/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1503 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1504 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1505/* DAC DISABLE/MUTE 2? */
1506/* some bit here disables the other DACs. Init=0x4900 */
1507 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1508 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1509/* Enable amplifiers */
1510 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1511 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1512/* DMIC fix
1513 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1514 * which makes the stereo useless. However, either the mic or the ALC889
1515 * makes the signal become a difference/sum signal instead of standard
1516 * stereo, which is annoying. So instead we flip this bit which makes the
1517 * codec replicate the sum signal to both channels, turning it into a
1518 * normal mono mic.
1519 */
1520/* DMIC_CONTROL? Init value = 0x0001 */
1521 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1522 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1523 { }
1524};
1525
1367static struct hda_input_mux alc888_2_capture_sources[2] = { 1526static struct hda_input_mux alc888_2_capture_sources[2] = {
1368 /* Front mic only available on one ADC */ 1527 /* Front mic only available on one ADC */
1369 { 1528 {
@@ -1385,6 +1544,38 @@ static struct hda_input_mux alc888_2_capture_sources[2] = {
1385 } 1544 }
1386}; 1545};
1387 1546
1547static struct hda_input_mux alc889_capture_sources[3] = {
1548 /* Digital mic only available on first "ADC" */
1549 {
1550 .num_items = 5,
1551 .items = {
1552 { "Mic", 0x0 },
1553 { "Line", 0x2 },
1554 { "CD", 0x4 },
1555 { "Front Mic", 0xb },
1556 { "Input Mix", 0xa },
1557 },
1558 },
1559 {
1560 .num_items = 4,
1561 .items = {
1562 { "Mic", 0x0 },
1563 { "Line", 0x2 },
1564 { "CD", 0x4 },
1565 { "Input Mix", 0xa },
1566 },
1567 },
1568 {
1569 .num_items = 4,
1570 .items = {
1571 { "Mic", 0x0 },
1572 { "Line", 0x2 },
1573 { "CD", 0x4 },
1574 { "Input Mix", 0xa },
1575 },
1576 }
1577};
1578
1388static struct snd_kcontrol_new alc888_base_mixer[] = { 1579static struct snd_kcontrol_new alc888_base_mixer[] = {
1389 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1580 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1390 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1581 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -1407,22 +1598,24 @@ static struct snd_kcontrol_new alc888_base_mixer[] = {
1407 { } /* end */ 1598 { } /* end */
1408}; 1599};
1409 1600
1410static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec) 1601static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
1411{ 1602{
1412 unsigned int present; 1603 struct alc_spec *spec = codec->spec;
1413 unsigned int bits; 1604
1414 present = snd_hda_codec_read(codec, 0x15, 0, 1605 spec->autocfg.hp_pins[0] = 0x15;
1415 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1606 spec->autocfg.speaker_pins[0] = 0x14;
1416 bits = present ? HDA_AMP_MUTE : 0; 1607 alc_automute_amp(codec);
1417 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1418 HDA_AMP_MUTE, bits);
1419} 1608}
1420 1609
1421static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec, 1610static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
1422 unsigned int res)
1423{ 1611{
1424 if (res >> 26 == ALC880_HP_EVENT) 1612 struct alc_spec *spec = codec->spec;
1425 alc888_acer_aspire_4930g_automute(codec); 1613
1614 spec->autocfg.hp_pins[0] = 0x15;
1615 spec->autocfg.speaker_pins[0] = 0x14;
1616 spec->autocfg.speaker_pins[1] = 0x16;
1617 spec->autocfg.speaker_pins[2] = 0x1b;
1618 alc_automute_amp(codec);
1426} 1619}
1427 1620
1428/* 1621/*
@@ -2390,21 +2583,6 @@ static struct hda_verb alc880_beep_init_verbs[] = {
2390 { } 2583 { }
2391}; 2584};
2392 2585
2393/* toggle speaker-output according to the hp-jack state */
2394static void alc880_uniwill_hp_automute(struct hda_codec *codec)
2395{
2396 unsigned int present;
2397 unsigned char bits;
2398
2399 present = snd_hda_codec_read(codec, 0x14, 0,
2400 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2401 bits = present ? HDA_AMP_MUTE : 0;
2402 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2403 HDA_AMP_MUTE, bits);
2404 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2405 HDA_AMP_MUTE, bits);
2406}
2407
2408/* auto-toggle front mic */ 2586/* auto-toggle front mic */
2409static void alc880_uniwill_mic_automute(struct hda_codec *codec) 2587static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2410{ 2588{
@@ -2417,9 +2595,14 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2417 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); 2595 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2418} 2596}
2419 2597
2420static void alc880_uniwill_automute(struct hda_codec *codec) 2598static void alc880_uniwill_init_hook(struct hda_codec *codec)
2421{ 2599{
2422 alc880_uniwill_hp_automute(codec); 2600 struct alc_spec *spec = codec->spec;
2601
2602 spec->autocfg.hp_pins[0] = 0x14;
2603 spec->autocfg.speaker_pins[0] = 0x15;
2604 spec->autocfg.speaker_pins[0] = 0x16;
2605 alc_automute_amp(codec);
2423 alc880_uniwill_mic_automute(codec); 2606 alc880_uniwill_mic_automute(codec);
2424} 2607}
2425 2608
@@ -2430,24 +2613,22 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2430 * definition. 4bit tag is placed at 28 bit! 2613 * definition. 4bit tag is placed at 28 bit!
2431 */ 2614 */
2432 switch (res >> 28) { 2615 switch (res >> 28) {
2433 case ALC880_HP_EVENT:
2434 alc880_uniwill_hp_automute(codec);
2435 break;
2436 case ALC880_MIC_EVENT: 2616 case ALC880_MIC_EVENT:
2437 alc880_uniwill_mic_automute(codec); 2617 alc880_uniwill_mic_automute(codec);
2438 break; 2618 break;
2619 default:
2620 alc_automute_amp_unsol_event(codec, res);
2621 break;
2439 } 2622 }
2440} 2623}
2441 2624
2442static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) 2625static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
2443{ 2626{
2444 unsigned int present; 2627 struct alc_spec *spec = codec->spec;
2445 unsigned char bits;
2446 2628
2447 present = snd_hda_codec_read(codec, 0x14, 0, 2629 spec->autocfg.hp_pins[0] = 0x14;
2448 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2630 spec->autocfg.speaker_pins[0] = 0x15;
2449 bits = present ? HDA_AMP_MUTE : 0; 2631 alc_automute_amp(codec);
2450 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
2451} 2632}
2452 2633
2453static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 2634static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -2469,10 +2650,10 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2469 /* Looks like the unsol event is incompatible with the standard 2650 /* Looks like the unsol event is incompatible with the standard
2470 * definition. 4bit tag is placed at 28 bit! 2651 * definition. 4bit tag is placed at 28 bit!
2471 */ 2652 */
2472 if ((res >> 28) == ALC880_HP_EVENT)
2473 alc880_uniwill_p53_hp_automute(codec);
2474 if ((res >> 28) == ALC880_DCVOL_EVENT) 2653 if ((res >> 28) == ALC880_DCVOL_EVENT)
2475 alc880_uniwill_p53_dcvol_automute(codec); 2654 alc880_uniwill_p53_dcvol_automute(codec);
2655 else
2656 alc_automute_amp_unsol_event(codec, res);
2476} 2657}
2477 2658
2478/* 2659/*
@@ -2542,6 +2723,7 @@ static struct hda_verb alc880_pin_asus_init_verbs[] = {
2542/* Enable GPIO mask and set output */ 2723/* Enable GPIO mask and set output */
2543#define alc880_gpio1_init_verbs alc_gpio1_init_verbs 2724#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2544#define alc880_gpio2_init_verbs alc_gpio2_init_verbs 2725#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2726#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
2545 2727
2546/* Clevo m520g init */ 2728/* Clevo m520g init */
2547static struct hda_verb alc880_pin_clevo_init_verbs[] = { 2729static struct hda_verb alc880_pin_clevo_init_verbs[] = {
@@ -2704,30 +2886,18 @@ static struct hda_verb alc880_lg_init_verbs[] = {
2704 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2886 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2705 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2887 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2706 /* jack sense */ 2888 /* jack sense */
2707 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, 2889 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2708 { } 2890 { }
2709}; 2891};
2710 2892
2711/* toggle speaker-output according to the hp-jack state */ 2893/* toggle speaker-output according to the hp-jack state */
2712static void alc880_lg_automute(struct hda_codec *codec) 2894static void alc880_lg_init_hook(struct hda_codec *codec)
2713{ 2895{
2714 unsigned int present; 2896 struct alc_spec *spec = codec->spec;
2715 unsigned char bits;
2716
2717 present = snd_hda_codec_read(codec, 0x1b, 0,
2718 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2719 bits = present ? HDA_AMP_MUTE : 0;
2720 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2721 HDA_AMP_MUTE, bits);
2722}
2723 2897
2724static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 2898 spec->autocfg.hp_pins[0] = 0x1b;
2725{ 2899 spec->autocfg.speaker_pins[0] = 0x17;
2726 /* Looks like the unsol event is incompatible with the standard 2900 alc_automute_amp(codec);
2727 * definition. 4bit tag is placed at 28 bit!
2728 */
2729 if ((res >> 28) == 0x01)
2730 alc880_lg_automute(codec);
2731} 2901}
2732 2902
2733/* 2903/*
@@ -2801,30 +2971,18 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
2801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2972 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2803 /* jack sense */ 2973 /* jack sense */
2804 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, 2974 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2805 { } 2975 { }
2806}; 2976};
2807 2977
2808/* toggle speaker-output according to the hp-jack state */ 2978/* toggle speaker-output according to the hp-jack state */
2809static void alc880_lg_lw_automute(struct hda_codec *codec) 2979static void alc880_lg_lw_init_hook(struct hda_codec *codec)
2810{ 2980{
2811 unsigned int present; 2981 struct alc_spec *spec = codec->spec;
2812 unsigned char bits;
2813 2982
2814 present = snd_hda_codec_read(codec, 0x1b, 0, 2983 spec->autocfg.hp_pins[0] = 0x1b;
2815 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2984 spec->autocfg.speaker_pins[0] = 0x14;
2816 bits = present ? HDA_AMP_MUTE : 0; 2985 alc_automute_amp(codec);
2817 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2818 HDA_AMP_MUTE, bits);
2819}
2820
2821static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2822{
2823 /* Looks like the unsol event is incompatible with the standard
2824 * definition. 4bit tag is placed at 28 bit!
2825 */
2826 if ((res >> 28) == 0x01)
2827 alc880_lg_lw_automute(codec);
2828} 2986}
2829 2987
2830static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { 2988static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
@@ -2871,16 +3029,10 @@ static struct hda_verb alc880_medion_rim_init_verbs[] = {
2871/* toggle speaker-output according to the hp-jack state */ 3029/* toggle speaker-output according to the hp-jack state */
2872static void alc880_medion_rim_automute(struct hda_codec *codec) 3030static void alc880_medion_rim_automute(struct hda_codec *codec)
2873{ 3031{
2874 unsigned int present; 3032 struct alc_spec *spec = codec->spec;
2875 unsigned char bits; 3033 alc_automute_amp(codec);
2876 3034 /* toggle EAPD */
2877 present = snd_hda_codec_read(codec, 0x14, 0, 3035 if (spec->jack_present)
2878 AC_VERB_GET_PIN_SENSE, 0)
2879 & AC_PINSENSE_PRESENCE;
2880 bits = present ? HDA_AMP_MUTE : 0;
2881 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2882 HDA_AMP_MUTE, bits);
2883 if (present)
2884 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); 3036 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2885 else 3037 else
2886 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); 3038 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
@@ -2896,6 +3048,15 @@ static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2896 alc880_medion_rim_automute(codec); 3048 alc880_medion_rim_automute(codec);
2897} 3049}
2898 3050
3051static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3052{
3053 struct alc_spec *spec = codec->spec;
3054
3055 spec->autocfg.hp_pins[0] = 0x14;
3056 spec->autocfg.speaker_pins[0] = 0x1b;
3057 alc880_medion_rim_automute(codec);
3058}
3059
2899#ifdef CONFIG_SND_HDA_POWER_SAVE 3060#ifdef CONFIG_SND_HDA_POWER_SAVE
2900static struct hda_amp_list alc880_loopbacks[] = { 3061static struct hda_amp_list alc880_loopbacks[] = {
2901 { 0x0b, HDA_INPUT, 0 }, 3062 { 0x0b, HDA_INPUT, 0 },
@@ -2924,8 +3085,7 @@ static int alc_init(struct hda_codec *codec)
2924 unsigned int i; 3085 unsigned int i;
2925 3086
2926 alc_fix_pll(codec); 3087 alc_fix_pll(codec);
2927 if (codec->vendor_id == 0x10ec0888) 3088 alc_auto_init_amp(codec, spec->init_amp);
2928 alc888_coef_init(codec);
2929 3089
2930 for (i = 0; i < spec->num_init_verbs; i++) 3090 for (i = 0; i < spec->num_init_verbs; i++)
2931 snd_hda_sequence_write(codec, spec->init_verbs[i]); 3091 snd_hda_sequence_write(codec, spec->init_verbs[i]);
@@ -3127,7 +3287,10 @@ static int alc_build_pcms(struct hda_codec *codec)
3127 if (spec->no_analog) 3287 if (spec->no_analog)
3128 goto skip_analog; 3288 goto skip_analog;
3129 3289
3290 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3291 "%s Analog", codec->chip_name);
3130 info->name = spec->stream_name_analog; 3292 info->name = spec->stream_name_analog;
3293
3131 if (spec->stream_analog_playback) { 3294 if (spec->stream_analog_playback) {
3132 if (snd_BUG_ON(!spec->multiout.dac_nids)) 3295 if (snd_BUG_ON(!spec->multiout.dac_nids))
3133 return -EINVAL; 3296 return -EINVAL;
@@ -3153,6 +3316,9 @@ static int alc_build_pcms(struct hda_codec *codec)
3153 skip_analog: 3316 skip_analog:
3154 /* SPDIF for stream index #1 */ 3317 /* SPDIF for stream index #1 */
3155 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 3318 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3319 snprintf(spec->stream_name_digital,
3320 sizeof(spec->stream_name_digital),
3321 "%s Digital", codec->chip_name);
3156 codec->num_pcms = 2; 3322 codec->num_pcms = 2;
3157 codec->slave_dig_outs = spec->multiout.slave_dig_outs; 3323 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3158 info = spec->pcm_rec + 1; 3324 info = spec->pcm_rec + 1;
@@ -3755,7 +3921,7 @@ static struct alc_config_preset alc880_presets[] = {
3755 .channel_mode = alc880_2_jack_modes, 3921 .channel_mode = alc880_2_jack_modes,
3756 .input_mux = &alc880_f1734_capture_source, 3922 .input_mux = &alc880_f1734_capture_source,
3757 .unsol_event = alc880_uniwill_p53_unsol_event, 3923 .unsol_event = alc880_uniwill_p53_unsol_event,
3758 .init_hook = alc880_uniwill_p53_hp_automute, 3924 .init_hook = alc880_uniwill_p53_init_hook,
3759 }, 3925 },
3760 [ALC880_ASUS] = { 3926 [ALC880_ASUS] = {
3761 .mixers = { alc880_asus_mixer }, 3927 .mixers = { alc880_asus_mixer },
@@ -3832,7 +3998,7 @@ static struct alc_config_preset alc880_presets[] = {
3832 .need_dac_fix = 1, 3998 .need_dac_fix = 1,
3833 .input_mux = &alc880_capture_source, 3999 .input_mux = &alc880_capture_source,
3834 .unsol_event = alc880_uniwill_unsol_event, 4000 .unsol_event = alc880_uniwill_unsol_event,
3835 .init_hook = alc880_uniwill_automute, 4001 .init_hook = alc880_uniwill_init_hook,
3836 }, 4002 },
3837 [ALC880_UNIWILL_P53] = { 4003 [ALC880_UNIWILL_P53] = {
3838 .mixers = { alc880_uniwill_p53_mixer }, 4004 .mixers = { alc880_uniwill_p53_mixer },
@@ -3844,7 +4010,7 @@ static struct alc_config_preset alc880_presets[] = {
3844 .channel_mode = alc880_threestack_modes, 4010 .channel_mode = alc880_threestack_modes,
3845 .input_mux = &alc880_capture_source, 4011 .input_mux = &alc880_capture_source,
3846 .unsol_event = alc880_uniwill_p53_unsol_event, 4012 .unsol_event = alc880_uniwill_p53_unsol_event,
3847 .init_hook = alc880_uniwill_p53_hp_automute, 4013 .init_hook = alc880_uniwill_p53_init_hook,
3848 }, 4014 },
3849 [ALC880_FUJITSU] = { 4015 [ALC880_FUJITSU] = {
3850 .mixers = { alc880_fujitsu_mixer }, 4016 .mixers = { alc880_fujitsu_mixer },
@@ -3858,7 +4024,7 @@ static struct alc_config_preset alc880_presets[] = {
3858 .channel_mode = alc880_2_jack_modes, 4024 .channel_mode = alc880_2_jack_modes,
3859 .input_mux = &alc880_capture_source, 4025 .input_mux = &alc880_capture_source,
3860 .unsol_event = alc880_uniwill_p53_unsol_event, 4026 .unsol_event = alc880_uniwill_p53_unsol_event,
3861 .init_hook = alc880_uniwill_p53_hp_automute, 4027 .init_hook = alc880_uniwill_p53_init_hook,
3862 }, 4028 },
3863 [ALC880_CLEVO] = { 4029 [ALC880_CLEVO] = {
3864 .mixers = { alc880_three_stack_mixer }, 4030 .mixers = { alc880_three_stack_mixer },
@@ -3883,8 +4049,8 @@ static struct alc_config_preset alc880_presets[] = {
3883 .channel_mode = alc880_lg_ch_modes, 4049 .channel_mode = alc880_lg_ch_modes,
3884 .need_dac_fix = 1, 4050 .need_dac_fix = 1,
3885 .input_mux = &alc880_lg_capture_source, 4051 .input_mux = &alc880_lg_capture_source,
3886 .unsol_event = alc880_lg_unsol_event, 4052 .unsol_event = alc_automute_amp_unsol_event,
3887 .init_hook = alc880_lg_automute, 4053 .init_hook = alc880_lg_init_hook,
3888#ifdef CONFIG_SND_HDA_POWER_SAVE 4054#ifdef CONFIG_SND_HDA_POWER_SAVE
3889 .loopbacks = alc880_lg_loopbacks, 4055 .loopbacks = alc880_lg_loopbacks,
3890#endif 4056#endif
@@ -3899,8 +4065,8 @@ static struct alc_config_preset alc880_presets[] = {
3899 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), 4065 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3900 .channel_mode = alc880_lg_lw_modes, 4066 .channel_mode = alc880_lg_lw_modes,
3901 .input_mux = &alc880_lg_lw_capture_source, 4067 .input_mux = &alc880_lg_lw_capture_source,
3902 .unsol_event = alc880_lg_lw_unsol_event, 4068 .unsol_event = alc_automute_amp_unsol_event,
3903 .init_hook = alc880_lg_lw_automute, 4069 .init_hook = alc880_lg_lw_init_hook,
3904 }, 4070 },
3905 [ALC880_MEDION_RIM] = { 4071 [ALC880_MEDION_RIM] = {
3906 .mixers = { alc880_medion_rim_mixer }, 4072 .mixers = { alc880_medion_rim_mixer },
@@ -3914,7 +4080,7 @@ static struct alc_config_preset alc880_presets[] = {
3914 .channel_mode = alc880_2_jack_modes, 4080 .channel_mode = alc880_2_jack_modes,
3915 .input_mux = &alc880_medion_rim_capture_source, 4081 .input_mux = &alc880_medion_rim_capture_source,
3916 .unsol_event = alc880_medion_rim_unsol_event, 4082 .unsol_event = alc880_medion_rim_unsol_event,
3917 .init_hook = alc880_medion_rim_automute, 4083 .init_hook = alc880_medion_rim_init_hook,
3918 }, 4084 },
3919#ifdef CONFIG_SND_DEBUG 4085#ifdef CONFIG_SND_DEBUG
3920 [ALC880_TEST] = { 4086 [ALC880_TEST] = {
@@ -4199,7 +4365,6 @@ static void alc880_auto_init_multi_out(struct hda_codec *codec)
4199 struct alc_spec *spec = codec->spec; 4365 struct alc_spec *spec = codec->spec;
4200 int i; 4366 int i;
4201 4367
4202 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
4203 for (i = 0; i < spec->autocfg.line_outs; i++) { 4368 for (i = 0; i < spec->autocfg.line_outs; i++) {
4204 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 4369 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4205 int pin_type = get_pin_type(spec->autocfg.line_out_type); 4370 int pin_type = get_pin_type(spec->autocfg.line_out_type);
@@ -4304,6 +4469,8 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4304 spec->num_mux_defs = 1; 4469 spec->num_mux_defs = 1;
4305 spec->input_mux = &spec->private_imux[0]; 4470 spec->input_mux = &spec->private_imux[0];
4306 4471
4472 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4473
4307 return 1; 4474 return 1;
4308} 4475}
4309 4476
@@ -4361,8 +4528,8 @@ static int patch_alc880(struct hda_codec *codec)
4361 alc880_models, 4528 alc880_models,
4362 alc880_cfg_tbl); 4529 alc880_cfg_tbl);
4363 if (board_config < 0) { 4530 if (board_config < 0) {
4364 printk(KERN_INFO "hda_codec: Unknown model for ALC880, " 4531 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4365 "trying auto-probe from BIOS...\n"); 4532 "trying auto-probe from BIOS...\n", codec->chip_name);
4366 board_config = ALC880_AUTO; 4533 board_config = ALC880_AUTO;
4367 } 4534 }
4368 4535
@@ -4389,12 +4556,10 @@ static int patch_alc880(struct hda_codec *codec)
4389 if (board_config != ALC880_AUTO) 4556 if (board_config != ALC880_AUTO)
4390 setup_preset(spec, &alc880_presets[board_config]); 4557 setup_preset(spec, &alc880_presets[board_config]);
4391 4558
4392 spec->stream_name_analog = "ALC880 Analog";
4393 spec->stream_analog_playback = &alc880_pcm_analog_playback; 4559 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4394 spec->stream_analog_capture = &alc880_pcm_analog_capture; 4560 spec->stream_analog_capture = &alc880_pcm_analog_capture;
4395 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; 4561 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
4396 4562
4397 spec->stream_name_digital = "ALC880 Digital";
4398 spec->stream_digital_playback = &alc880_pcm_digital_playback; 4563 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4399 spec->stream_digital_capture = &alc880_pcm_digital_capture; 4564 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4400 4565
@@ -5679,7 +5844,6 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
5679 struct alc_spec *spec = codec->spec; 5844 struct alc_spec *spec = codec->spec;
5680 hda_nid_t nid; 5845 hda_nid_t nid;
5681 5846
5682 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
5683 nid = spec->autocfg.line_out_pins[0]; 5847 nid = spec->autocfg.line_out_pins[0];
5684 if (nid) { 5848 if (nid) {
5685 int pin_type = get_pin_type(spec->autocfg.line_out_type); 5849 int pin_type = get_pin_type(spec->autocfg.line_out_type);
@@ -5789,6 +5953,8 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5789 spec->num_mux_defs = 1; 5953 spec->num_mux_defs = 1;
5790 spec->input_mux = &spec->private_imux[0]; 5954 spec->input_mux = &spec->private_imux[0];
5791 5955
5956 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5957
5792 return 1; 5958 return 1;
5793} 5959}
5794 5960
@@ -6006,8 +6172,9 @@ static int patch_alc260(struct hda_codec *codec)
6006 alc260_models, 6172 alc260_models,
6007 alc260_cfg_tbl); 6173 alc260_cfg_tbl);
6008 if (board_config < 0) { 6174 if (board_config < 0) {
6009 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " 6175 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6010 "trying auto-probe from BIOS...\n"); 6176 "trying auto-probe from BIOS...\n",
6177 codec->chip_name);
6011 board_config = ALC260_AUTO; 6178 board_config = ALC260_AUTO;
6012 } 6179 }
6013 6180
@@ -6034,11 +6201,9 @@ static int patch_alc260(struct hda_codec *codec)
6034 if (board_config != ALC260_AUTO) 6201 if (board_config != ALC260_AUTO)
6035 setup_preset(spec, &alc260_presets[board_config]); 6202 setup_preset(spec, &alc260_presets[board_config]);
6036 6203
6037 spec->stream_name_analog = "ALC260 Analog";
6038 spec->stream_analog_playback = &alc260_pcm_analog_playback; 6204 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6039 spec->stream_analog_capture = &alc260_pcm_analog_capture; 6205 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6040 6206
6041 spec->stream_name_digital = "ALC260 Digital";
6042 spec->stream_digital_playback = &alc260_pcm_digital_playback; 6207 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6043 spec->stream_digital_capture = &alc260_pcm_digital_capture; 6208 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6044 6209
@@ -6115,6 +6280,16 @@ static struct hda_input_mux alc882_capture_source = {
6115 { "CD", 0x4 }, 6280 { "CD", 0x4 },
6116 }, 6281 },
6117}; 6282};
6283
6284static struct hda_input_mux mb5_capture_source = {
6285 .num_items = 3,
6286 .items = {
6287 { "Mic", 0x1 },
6288 { "Line", 0x2 },
6289 { "CD", 0x4 },
6290 },
6291};
6292
6118/* 6293/*
6119 * 2ch mode 6294 * 2ch mode
6120 */ 6295 */
@@ -6202,6 +6377,34 @@ static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6202 { 6, alc885_mbp_ch6_init }, 6377 { 6, alc885_mbp_ch6_init },
6203}; 6378};
6204 6379
6380/*
6381 * 2ch
6382 * Speakers/Woofer/HP = Front
6383 * LineIn = Input
6384 */
6385static struct hda_verb alc885_mb5_ch2_init[] = {
6386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6388 { } /* end */
6389};
6390
6391/*
6392 * 6ch mode
6393 * Speakers/HP = Front
6394 * Woofer = LFE
6395 * LineIn = Surround
6396 */
6397static struct hda_verb alc885_mb5_ch6_init[] = {
6398 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6400 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6401 { } /* end */
6402};
6403
6404static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6405 { 2, alc885_mb5_ch2_init },
6406 { 6, alc885_mb5_ch6_init },
6407};
6205 6408
6206/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 6409/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6207 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 6410 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
@@ -6244,6 +6447,25 @@ static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
6244 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), 6447 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6245 { } /* end */ 6448 { } /* end */
6246}; 6449};
6450
6451static struct snd_kcontrol_new alc885_mb5_mixer[] = {
6452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6453 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6454 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6455 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6456 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6457 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6458 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6459 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
6460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6461 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6463 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6464 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6465 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6466 { } /* end */
6467};
6468
6247static struct snd_kcontrol_new alc882_w2jc_mixer[] = { 6469static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6248 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6470 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6249 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6471 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -6471,6 +6693,55 @@ static struct hda_verb alc882_macpro_init_verbs[] = {
6471 { } 6693 { }
6472}; 6694};
6473 6695
6696/* Macbook 5,1 */
6697static struct hda_verb alc885_mb5_init_verbs[] = {
6698 /* DACs */
6699 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6700 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6701 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6702 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6703 /* Front mixer */
6704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6706 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6707 /* Surround mixer */
6708 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6711 /* LFE mixer */
6712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6715 /* HP mixer */
6716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6718 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6719 /* Front Pin (0x0c) */
6720 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6722 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6723 /* LFE Pin (0x0e) */
6724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6726 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6727 /* HP Pin (0x0f) */
6728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6730 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
6731 /* Front Mic pin: input vref at 80% */
6732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6734 /* Line In pin */
6735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6737
6738 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6739 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6742 { }
6743};
6744
6474/* Macbook Pro rev3 */ 6745/* Macbook Pro rev3 */
6475static struct hda_verb alc885_mbp3_init_verbs[] = { 6746static struct hda_verb alc885_mbp3_init_verbs[] = {
6476 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 6747 /* Front mixer: unmute input/output amp left and right (volume = 0) */
@@ -6560,45 +6831,23 @@ static struct hda_verb alc885_imac24_init_verbs[] = {
6560}; 6831};
6561 6832
6562/* Toggle speaker-output according to the hp-jack state */ 6833/* Toggle speaker-output according to the hp-jack state */
6563static void alc885_imac24_automute(struct hda_codec *codec) 6834static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
6564{ 6835{
6565 unsigned int present; 6836 struct alc_spec *spec = codec->spec;
6566
6567 present = snd_hda_codec_read(codec, 0x14, 0,
6568 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6569 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6570 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6571 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6572 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6573}
6574 6837
6575/* Processes unsolicited events. */ 6838 spec->autocfg.hp_pins[0] = 0x14;
6576static void alc885_imac24_unsol_event(struct hda_codec *codec, 6839 spec->autocfg.speaker_pins[0] = 0x18;
6577 unsigned int res) 6840 spec->autocfg.speaker_pins[1] = 0x1a;
6578{ 6841 alc_automute_amp(codec);
6579 /* Headphone insertion or removal. */
6580 if ((res >> 26) == ALC880_HP_EVENT)
6581 alc885_imac24_automute(codec);
6582} 6842}
6583 6843
6584static void alc885_mbp3_automute(struct hda_codec *codec) 6844static void alc885_mbp3_init_hook(struct hda_codec *codec)
6585{ 6845{
6586 unsigned int present; 6846 struct alc_spec *spec = codec->spec;
6587
6588 present = snd_hda_codec_read(codec, 0x15, 0,
6589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6590 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6591 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6592 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6593 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6594 6847
6595} 6848 spec->autocfg.hp_pins[0] = 0x15;
6596static void alc885_mbp3_unsol_event(struct hda_codec *codec, 6849 spec->autocfg.speaker_pins[0] = 0x14;
6597 unsigned int res) 6850 alc_automute_amp(codec);
6598{
6599 /* Headphone insertion or removal. */
6600 if ((res >> 26) == ALC880_HP_EVENT)
6601 alc885_mbp3_automute(codec);
6602} 6851}
6603 6852
6604 6853
@@ -6623,24 +6872,25 @@ static struct hda_verb alc882_targa_verbs[] = {
6623/* toggle speaker-output according to the hp-jack state */ 6872/* toggle speaker-output according to the hp-jack state */
6624static void alc882_targa_automute(struct hda_codec *codec) 6873static void alc882_targa_automute(struct hda_codec *codec)
6625{ 6874{
6626 unsigned int present; 6875 struct alc_spec *spec = codec->spec;
6627 6876 alc_automute_amp(codec);
6628 present = snd_hda_codec_read(codec, 0x14, 0,
6629 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6630 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6631 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6632 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, 6877 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6633 present ? 1 : 3); 6878 spec->jack_present ? 1 : 3);
6879}
6880
6881static void alc882_targa_init_hook(struct hda_codec *codec)
6882{
6883 struct alc_spec *spec = codec->spec;
6884
6885 spec->autocfg.hp_pins[0] = 0x14;
6886 spec->autocfg.speaker_pins[0] = 0x1b;
6887 alc882_targa_automute(codec);
6634} 6888}
6635 6889
6636static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) 6890static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6637{ 6891{
6638 /* Looks like the unsol event is incompatible with the standard 6892 if ((res >> 26) == ALC880_HP_EVENT)
6639 * definition. 4bit tag is placed at 26 bit!
6640 */
6641 if (((res >> 26) == ALC880_HP_EVENT)) {
6642 alc882_targa_automute(codec); 6893 alc882_targa_automute(codec);
6643 }
6644} 6894}
6645 6895
6646static struct hda_verb alc882_asus_a7j_verbs[] = { 6896static struct hda_verb alc882_asus_a7j_verbs[] = {
@@ -6722,7 +6972,7 @@ static void alc885_macpro_init_hook(struct hda_codec *codec)
6722static void alc885_imac24_init_hook(struct hda_codec *codec) 6972static void alc885_imac24_init_hook(struct hda_codec *codec)
6723{ 6973{
6724 alc885_macpro_init_hook(codec); 6974 alc885_macpro_init_hook(codec);
6725 alc885_imac24_automute(codec); 6975 alc885_imac24_automute_init_hook(codec);
6726} 6976}
6727 6977
6728/* 6978/*
@@ -6815,6 +7065,7 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
6815 [ALC882_ASUS_A7J] = "asus-a7j", 7065 [ALC882_ASUS_A7J] = "asus-a7j",
6816 [ALC882_ASUS_A7M] = "asus-a7m", 7066 [ALC882_ASUS_A7M] = "asus-a7m",
6817 [ALC885_MACPRO] = "macpro", 7067 [ALC885_MACPRO] = "macpro",
7068 [ALC885_MB5] = "mb5",
6818 [ALC885_MBP3] = "mbp3", 7069 [ALC885_MBP3] = "mbp3",
6819 [ALC885_IMAC24] = "imac24", 7070 [ALC885_IMAC24] = "imac24",
6820 [ALC882_AUTO] = "auto", 7071 [ALC882_AUTO] = "auto",
@@ -6892,8 +7143,20 @@ static struct alc_config_preset alc882_presets[] = {
6892 .input_mux = &alc882_capture_source, 7143 .input_mux = &alc882_capture_source,
6893 .dig_out_nid = ALC882_DIGOUT_NID, 7144 .dig_out_nid = ALC882_DIGOUT_NID,
6894 .dig_in_nid = ALC882_DIGIN_NID, 7145 .dig_in_nid = ALC882_DIGIN_NID,
6895 .unsol_event = alc885_mbp3_unsol_event, 7146 .unsol_event = alc_automute_amp_unsol_event,
6896 .init_hook = alc885_mbp3_automute, 7147 .init_hook = alc885_mbp3_init_hook,
7148 },
7149 [ALC885_MB5] = {
7150 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
7151 .init_verbs = { alc885_mb5_init_verbs,
7152 alc880_gpio1_init_verbs },
7153 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7154 .dac_nids = alc882_dac_nids,
7155 .channel_mode = alc885_mb5_6ch_modes,
7156 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
7157 .input_mux = &mb5_capture_source,
7158 .dig_out_nid = ALC882_DIGOUT_NID,
7159 .dig_in_nid = ALC882_DIGIN_NID,
6897 }, 7160 },
6898 [ALC885_MACPRO] = { 7161 [ALC885_MACPRO] = {
6899 .mixers = { alc882_macpro_mixer }, 7162 .mixers = { alc882_macpro_mixer },
@@ -6917,7 +7180,7 @@ static struct alc_config_preset alc882_presets[] = {
6917 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 7180 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6918 .channel_mode = alc882_ch_modes, 7181 .channel_mode = alc882_ch_modes,
6919 .input_mux = &alc882_capture_source, 7182 .input_mux = &alc882_capture_source,
6920 .unsol_event = alc885_imac24_unsol_event, 7183 .unsol_event = alc_automute_amp_unsol_event,
6921 .init_hook = alc885_imac24_init_hook, 7184 .init_hook = alc885_imac24_init_hook,
6922 }, 7185 },
6923 [ALC882_TARGA] = { 7186 [ALC882_TARGA] = {
@@ -6934,7 +7197,7 @@ static struct alc_config_preset alc882_presets[] = {
6934 .need_dac_fix = 1, 7197 .need_dac_fix = 1,
6935 .input_mux = &alc882_capture_source, 7198 .input_mux = &alc882_capture_source,
6936 .unsol_event = alc882_targa_unsol_event, 7199 .unsol_event = alc882_targa_unsol_event,
6937 .init_hook = alc882_targa_automute, 7200 .init_hook = alc882_targa_init_hook,
6938 }, 7201 },
6939 [ALC882_ASUS_A7J] = { 7202 [ALC882_ASUS_A7J] = {
6940 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, 7203 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
@@ -7014,7 +7277,6 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec)
7014 struct alc_spec *spec = codec->spec; 7277 struct alc_spec *spec = codec->spec;
7015 int i; 7278 int i;
7016 7279
7017 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7018 for (i = 0; i <= HDA_SIDE; i++) { 7280 for (i = 0; i <= HDA_SIDE; i++) {
7019 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 7281 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7020 int pin_type = get_pin_type(spec->autocfg.line_out_type); 7282 int pin_type = get_pin_type(spec->autocfg.line_out_type);
@@ -7197,10 +7459,17 @@ static int patch_alc882(struct hda_codec *codec)
7197 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ 7459 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
7198 case 0x106b00a4: /* MacbookPro4,1 */ 7460 case 0x106b00a4: /* MacbookPro4,1 */
7199 case 0x106b2c00: /* Macbook Pro rev3 */ 7461 case 0x106b2c00: /* Macbook Pro rev3 */
7200 case 0x106b3600: /* Macbook 3.1 */ 7462 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
7201 case 0x106b3800: /* MacbookPro4,1 - latter revision */ 7463 case 0x106b3800: /* MacbookPro4,1 - latter revision */
7202 board_config = ALC885_MBP3; 7464 board_config = ALC885_MBP3;
7203 break; 7465 break;
7466 case 0x106b3f00: /* Macbook 5,1 */
7467 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7468 * seems not working, so apparently
7469 * no perfect solution yet
7470 */
7471 board_config = ALC885_MB5;
7472 break;
7204 default: 7473 default:
7205 /* ALC889A is handled better as ALC888-compatible */ 7474 /* ALC889A is handled better as ALC888-compatible */
7206 if (codec->revision_id == 0x100101 || 7475 if (codec->revision_id == 0x100101 ||
@@ -7208,8 +7477,9 @@ static int patch_alc882(struct hda_codec *codec)
7208 alc_free(codec); 7477 alc_free(codec);
7209 return patch_alc883(codec); 7478 return patch_alc883(codec);
7210 } 7479 }
7211 printk(KERN_INFO "hda_codec: Unknown model for ALC882, " 7480 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7212 "trying auto-probe from BIOS...\n"); 7481 "trying auto-probe from BIOS...\n",
7482 codec->chip_name);
7213 board_config = ALC882_AUTO; 7483 board_config = ALC882_AUTO;
7214 } 7484 }
7215 } 7485 }
@@ -7239,14 +7509,6 @@ static int patch_alc882(struct hda_codec *codec)
7239 if (board_config != ALC882_AUTO) 7509 if (board_config != ALC882_AUTO)
7240 setup_preset(spec, &alc882_presets[board_config]); 7510 setup_preset(spec, &alc882_presets[board_config]);
7241 7511
7242 if (codec->vendor_id == 0x10ec0885) {
7243 spec->stream_name_analog = "ALC885 Analog";
7244 spec->stream_name_digital = "ALC885 Digital";
7245 } else {
7246 spec->stream_name_analog = "ALC882 Analog";
7247 spec->stream_name_digital = "ALC882 Digital";
7248 }
7249
7250 spec->stream_analog_playback = &alc882_pcm_analog_playback; 7512 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7251 spec->stream_analog_capture = &alc882_pcm_analog_capture; 7513 spec->stream_analog_capture = &alc882_pcm_analog_capture;
7252 /* FIXME: setup DAC5 */ 7514 /* FIXME: setup DAC5 */
@@ -7399,6 +7661,17 @@ static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7399 }, 7661 },
7400}; 7662};
7401 7663
7664static struct hda_input_mux alc889A_mb31_capture_source = {
7665 .num_items = 2,
7666 .items = {
7667 { "Mic", 0x0 },
7668 /* Front Mic (0x01) unused */
7669 { "Line", 0x2 },
7670 /* Line 2 (0x03) unused */
7671 /* CD (0x04) unsused? */
7672 },
7673};
7674
7402/* 7675/*
7403 * 2ch mode 7676 * 2ch mode
7404 */ 7677 */
@@ -7448,6 +7721,73 @@ static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
7448 { 6, alc883_3ST_ch6_init }, 7721 { 6, alc883_3ST_ch6_init },
7449}; 7722};
7450 7723
7724
7725/*
7726 * 2ch mode
7727 */
7728static struct hda_verb alc883_4ST_ch2_init[] = {
7729 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7730 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7731 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7732 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7733 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7734 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7735 { } /* end */
7736};
7737
7738/*
7739 * 4ch mode
7740 */
7741static struct hda_verb alc883_4ST_ch4_init[] = {
7742 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7743 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7744 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7745 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7746 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7747 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7748 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7749 { } /* end */
7750};
7751
7752/*
7753 * 6ch mode
7754 */
7755static struct hda_verb alc883_4ST_ch6_init[] = {
7756 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7757 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7758 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7759 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7760 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7761 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7762 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7763 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7764 { } /* end */
7765};
7766
7767/*
7768 * 8ch mode
7769 */
7770static struct hda_verb alc883_4ST_ch8_init[] = {
7771 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7772 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7773 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7774 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7775 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7776 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
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
7783static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7784 { 2, alc883_4ST_ch2_init },
7785 { 4, alc883_4ST_ch4_init },
7786 { 6, alc883_4ST_ch6_init },
7787 { 8, alc883_4ST_ch8_init },
7788};
7789
7790
7451/* 7791/*
7452 * 2ch mode 7792 * 2ch mode
7453 */ 7793 */
@@ -7517,6 +7857,49 @@ static struct hda_channel_mode alc883_sixstack_modes[2] = {
7517 { 8, alc883_sixstack_ch8_init }, 7857 { 8, alc883_sixstack_ch8_init },
7518}; 7858};
7519 7859
7860/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7861static struct hda_verb alc889A_mb31_ch2_init[] = {
7862 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7863 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7864 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7865 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7866 { } /* end */
7867};
7868
7869/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7870static struct hda_verb alc889A_mb31_ch4_init[] = {
7871 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7872 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7873 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7874 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7875 { } /* end */
7876};
7877
7878/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7879static struct hda_verb alc889A_mb31_ch5_init[] = {
7880 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7882 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7884 { } /* end */
7885};
7886
7887/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7888static struct hda_verb alc889A_mb31_ch6_init[] = {
7889 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7891 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7893 { } /* end */
7894};
7895
7896static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7897 { 2, alc889A_mb31_ch2_init },
7898 { 4, alc889A_mb31_ch4_init },
7899 { 5, alc889A_mb31_ch5_init },
7900 { 6, alc889A_mb31_ch6_init },
7901};
7902
7520static struct hda_verb alc883_medion_eapd_verbs[] = { 7903static struct hda_verb alc883_medion_eapd_verbs[] = {
7521 /* eanable EAPD on medion laptop */ 7904 /* eanable EAPD on medion laptop */
7522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 7905 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
@@ -7782,8 +8165,6 @@ static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7782 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), 8165 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7783 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 8166 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7784 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 8167 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7785 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7786 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7787 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8168 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7788 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8169 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 8170 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
@@ -7797,6 +8178,42 @@ static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7797 { } /* end */ 8178 { } /* end */
7798}; 8179};
7799 8180
8181static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8182 /* Output mixers */
8183 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8184 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8185 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8186 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8187 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8188 HDA_OUTPUT),
8189 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8191 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8192 /* Output switches */
8193 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8194 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8195 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8196 /* Boost mixers */
8197 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8198 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8199 /* Input mixers */
8200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8202 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8204 { } /* end */
8205};
8206
8207static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8208 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8209 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8210 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8212 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8214 { } /* end */
8215};
8216
7800static struct hda_bind_ctls alc883_bind_cap_vol = { 8217static struct hda_bind_ctls alc883_bind_cap_vol = {
7801 .ops = &snd_hda_bind_vol, 8218 .ops = &snd_hda_bind_vol,
7802 .values = { 8219 .values = {
@@ -7932,16 +8349,14 @@ static struct hda_verb alc883_init_verbs[] = {
7932}; 8349};
7933 8350
7934/* toggle speaker-output according to the hp-jack state */ 8351/* toggle speaker-output according to the hp-jack state */
7935static void alc883_mitac_hp_automute(struct hda_codec *codec) 8352static void alc883_mitac_init_hook(struct hda_codec *codec)
7936{ 8353{
7937 unsigned int present; 8354 struct alc_spec *spec = codec->spec;
7938 8355
7939 present = snd_hda_codec_read(codec, 0x15, 0, 8356 spec->autocfg.hp_pins[0] = 0x15;
7940 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8357 spec->autocfg.speaker_pins[0] = 0x14;
7941 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8358 spec->autocfg.speaker_pins[1] = 0x17;
7942 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8359 alc_automute_amp(codec);
7943 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7944 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7945} 8360}
7946 8361
7947/* auto-toggle front mic */ 8362/* auto-toggle front mic */
@@ -7958,25 +8373,6 @@ static void alc883_mitac_mic_automute(struct hda_codec *codec)
7958} 8373}
7959*/ 8374*/
7960 8375
7961static void alc883_mitac_automute(struct hda_codec *codec)
7962{
7963 alc883_mitac_hp_automute(codec);
7964 /* alc883_mitac_mic_automute(codec); */
7965}
7966
7967static void alc883_mitac_unsol_event(struct hda_codec *codec,
7968 unsigned int res)
7969{
7970 switch (res >> 26) {
7971 case ALC880_HP_EVENT:
7972 alc883_mitac_hp_automute(codec);
7973 break;
7974 case ALC880_MIC_EVENT:
7975 /* alc883_mitac_mic_automute(codec); */
7976 break;
7977 }
7978}
7979
7980static struct hda_verb alc883_mitac_verbs[] = { 8376static struct hda_verb alc883_mitac_verbs[] = {
7981 /* HP */ 8377 /* HP */
7982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 8378 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -8028,14 +8424,24 @@ static struct hda_verb alc883_tagra_verbs[] = {
8028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8029 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8030 8426
8031 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 8427/* Connect Line-Out side jack (SPDIF) to Side */
8032 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 8428 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8033 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 8429 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8430 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8431/* Connect Mic jack to CLFE */
8432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8434 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8435/* Connect Line-in jack to Surround */
8436 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8438 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8439/* Connect HP out jack to Front */
8440 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8441 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8442 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8034 8443
8035 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 8444 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8036 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8037 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8038 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
8039 8445
8040 { } /* end */ 8446 { } /* end */
8041}; 8447};
@@ -8094,29 +8500,26 @@ static struct hda_verb alc888_6st_dell_verbs[] = {
8094 { } 8500 { }
8095}; 8501};
8096 8502
8097static void alc888_3st_hp_front_automute(struct hda_codec *codec) 8503static struct hda_verb alc883_vaiott_verbs[] = {
8098{ 8504 /* HP */
8099 unsigned int present, bits; 8505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8506 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8100 8507
8101 present = snd_hda_codec_read(codec, 0x1b, 0, 8508 /* enable unsolicited event */
8102 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8509 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8103 bits = present ? HDA_AMP_MUTE : 0; 8510
8104 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8511 { } /* end */
8105 HDA_AMP_MUTE, bits); 8512};
8106 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8107 HDA_AMP_MUTE, bits);
8108 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
8109 HDA_AMP_MUTE, bits);
8110}
8111 8513
8112static void alc888_3st_hp_unsol_event(struct hda_codec *codec, 8514static void alc888_3st_hp_init_hook(struct hda_codec *codec)
8113 unsigned int res)
8114{ 8515{
8115 switch (res >> 26) { 8516 struct alc_spec *spec = codec->spec;
8116 case ALC880_HP_EVENT: 8517
8117 alc888_3st_hp_front_automute(codec); 8518 spec->autocfg.hp_pins[0] = 0x1b;
8118 break; 8519 spec->autocfg.speaker_pins[0] = 0x14;
8119 } 8520 spec->autocfg.speaker_pins[1] = 0x16;
8521 spec->autocfg.speaker_pins[2] = 0x18;
8522 alc_automute_amp(codec);
8120} 8523}
8121 8524
8122static struct hda_verb alc888_3st_hp_verbs[] = { 8525static struct hda_verb alc888_3st_hp_verbs[] = {
@@ -8213,56 +8616,18 @@ static struct hda_verb alc883_medion_md2_verbs[] = {
8213}; 8616};
8214 8617
8215/* toggle speaker-output according to the hp-jack state */ 8618/* toggle speaker-output according to the hp-jack state */
8216static void alc883_medion_md2_automute(struct hda_codec *codec) 8619static void alc883_medion_md2_init_hook(struct hda_codec *codec)
8217{ 8620{
8218 unsigned int present; 8621 struct alc_spec *spec = codec->spec;
8219
8220 present = snd_hda_codec_read(codec, 0x14, 0,
8221 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8222 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8223 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8224}
8225
8226static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8227 unsigned int res)
8228{
8229 if ((res >> 26) == ALC880_HP_EVENT)
8230 alc883_medion_md2_automute(codec);
8231}
8232
8233/* toggle speaker-output according to the hp-jack state */
8234static void alc883_tagra_automute(struct hda_codec *codec)
8235{
8236 unsigned int present;
8237 unsigned char bits;
8238
8239 present = snd_hda_codec_read(codec, 0x14, 0,
8240 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8241 bits = present ? HDA_AMP_MUTE : 0;
8242 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8243 HDA_AMP_MUTE, bits);
8244 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8245 present ? 1 : 3);
8246}
8247 8622
8248static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) 8623 spec->autocfg.hp_pins[0] = 0x14;
8249{ 8624 spec->autocfg.speaker_pins[0] = 0x15;
8250 if ((res >> 26) == ALC880_HP_EVENT) 8625 alc_automute_amp(codec);
8251 alc883_tagra_automute(codec);
8252} 8626}
8253 8627
8254/* toggle speaker-output according to the hp-jack state */ 8628/* toggle speaker-output according to the hp-jack state */
8255static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) 8629#define alc883_tagra_init_hook alc882_targa_init_hook
8256{ 8630#define alc883_tagra_unsol_event alc882_targa_unsol_event
8257 unsigned int present;
8258 unsigned char bits;
8259
8260 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8261 & AC_PINSENSE_PRESENCE;
8262 bits = present ? HDA_AMP_MUTE : 0;
8263 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8264 HDA_AMP_MUTE, bits);
8265}
8266 8631
8267static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) 8632static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8268{ 8633{
@@ -8274,9 +8639,13 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8274 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8639 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8275} 8640}
8276 8641
8277static void alc883_clevo_m720_automute(struct hda_codec *codec) 8642static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8278{ 8643{
8279 alc883_clevo_m720_hp_automute(codec); 8644 struct alc_spec *spec = codec->spec;
8645
8646 spec->autocfg.hp_pins[0] = 0x15;
8647 spec->autocfg.speaker_pins[0] = 0x14;
8648 alc_automute_amp(codec);
8280 alc883_clevo_m720_mic_automute(codec); 8649 alc883_clevo_m720_mic_automute(codec);
8281} 8650}
8282 8651
@@ -8284,52 +8653,32 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8284 unsigned int res) 8653 unsigned int res)
8285{ 8654{
8286 switch (res >> 26) { 8655 switch (res >> 26) {
8287 case ALC880_HP_EVENT:
8288 alc883_clevo_m720_hp_automute(codec);
8289 break;
8290 case ALC880_MIC_EVENT: 8656 case ALC880_MIC_EVENT:
8291 alc883_clevo_m720_mic_automute(codec); 8657 alc883_clevo_m720_mic_automute(codec);
8292 break; 8658 break;
8659 default:
8660 alc_automute_amp_unsol_event(codec, res);
8661 break;
8293 } 8662 }
8294} 8663}
8295 8664
8296/* toggle speaker-output according to the hp-jack state */ 8665/* toggle speaker-output according to the hp-jack state */
8297static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) 8666static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
8298{ 8667{
8299 unsigned int present; 8668 struct alc_spec *spec = codec->spec;
8300 unsigned char bits;
8301
8302 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8303 & AC_PINSENSE_PRESENCE;
8304 bits = present ? HDA_AMP_MUTE : 0;
8305 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8306 HDA_AMP_MUTE, bits);
8307}
8308 8669
8309static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, 8670 spec->autocfg.hp_pins[0] = 0x14;
8310 unsigned int res) 8671 spec->autocfg.speaker_pins[0] = 0x15;
8311{ 8672 alc_automute_amp(codec);
8312 if ((res >> 26) == ALC880_HP_EVENT)
8313 alc883_2ch_fujitsu_pi2515_automute(codec);
8314} 8673}
8315 8674
8316static void alc883_haier_w66_automute(struct hda_codec *codec) 8675static void alc883_haier_w66_init_hook(struct hda_codec *codec)
8317{ 8676{
8318 unsigned int present; 8677 struct alc_spec *spec = codec->spec;
8319 unsigned char bits;
8320 8678
8321 present = snd_hda_codec_read(codec, 0x1b, 0, 8679 spec->autocfg.hp_pins[0] = 0x1b;
8322 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8680 spec->autocfg.speaker_pins[0] = 0x14;
8323 bits = present ? 0x80 : 0; 8681 alc_automute_amp(codec);
8324 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8325 0x80, bits);
8326}
8327
8328static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8329 unsigned int res)
8330{
8331 if ((res >> 26) == ALC880_HP_EVENT)
8332 alc883_haier_w66_automute(codec);
8333} 8682}
8334 8683
8335static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 8684static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
@@ -8337,8 +8686,8 @@ static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8337 unsigned int present; 8686 unsigned int present;
8338 unsigned char bits; 8687 unsigned char bits;
8339 8688
8340 present = snd_hda_codec_read(codec, 0x14, 0, 8689 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8690 & AC_PINSENSE_PRESENCE;
8342 bits = present ? HDA_AMP_MUTE : 0; 8691 bits = present ? HDA_AMP_MUTE : 0;
8343 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8692 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8344 HDA_AMP_MUTE, bits); 8693 HDA_AMP_MUTE, bits);
@@ -8368,23 +8717,14 @@ static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8368} 8717}
8369 8718
8370/* toggle speaker-output according to the hp-jack state */ 8719/* toggle speaker-output according to the hp-jack state */
8371static void alc883_acer_aspire_automute(struct hda_codec *codec) 8720static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
8372{ 8721{
8373 unsigned int present; 8722 struct alc_spec *spec = codec->spec;
8374
8375 present = snd_hda_codec_read(codec, 0x14, 0,
8376 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8377 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8378 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8379 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8380 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8381}
8382 8723
8383static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, 8724 spec->autocfg.hp_pins[0] = 0x14;
8384 unsigned int res) 8725 spec->autocfg.speaker_pins[0] = 0x15;
8385{ 8726 spec->autocfg.speaker_pins[1] = 0x16;
8386 if ((res >> 26) == ALC880_HP_EVENT) 8727 alc_automute_amp(codec);
8387 alc883_acer_aspire_automute(codec);
8388} 8728}
8389 8729
8390static struct hda_verb alc883_acer_eapd_verbs[] = { 8730static struct hda_verb alc883_acer_eapd_verbs[] = {
@@ -8405,75 +8745,39 @@ static struct hda_verb alc883_acer_eapd_verbs[] = {
8405 { } 8745 { }
8406}; 8746};
8407 8747
8408static void alc888_6st_dell_front_automute(struct hda_codec *codec) 8748static void alc888_6st_dell_init_hook(struct hda_codec *codec)
8409{ 8749{
8410 unsigned int present; 8750 struct alc_spec *spec = codec->spec;
8411
8412 present = snd_hda_codec_read(codec, 0x1b, 0,
8413 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8414 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8415 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8416 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8417 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8418 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8419 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8420 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8421 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8422}
8423 8751
8424static void alc888_6st_dell_unsol_event(struct hda_codec *codec, 8752 spec->autocfg.hp_pins[0] = 0x1b;
8425 unsigned int res) 8753 spec->autocfg.speaker_pins[0] = 0x14;
8426{ 8754 spec->autocfg.speaker_pins[1] = 0x15;
8427 switch (res >> 26) { 8755 spec->autocfg.speaker_pins[2] = 0x16;
8428 case ALC880_HP_EVENT: 8756 spec->autocfg.speaker_pins[3] = 0x17;
8429 /* printk(KERN_DEBUG "hp_event\n"); */ 8757 alc_automute_amp(codec);
8430 alc888_6st_dell_front_automute(codec);
8431 break;
8432 }
8433} 8758}
8434 8759
8435static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) 8760static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
8436{ 8761{
8437 unsigned int mute; 8762 struct alc_spec *spec = codec->spec;
8438 unsigned int present;
8439 8763
8440 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 8764 spec->autocfg.hp_pins[0] = 0x1b;
8441 present = snd_hda_codec_read(codec, 0x1b, 0, 8765 spec->autocfg.speaker_pins[0] = 0x14;
8442 AC_VERB_GET_PIN_SENSE, 0); 8766 spec->autocfg.speaker_pins[1] = 0x15;
8443 present = (present & 0x80000000) != 0; 8767 spec->autocfg.speaker_pins[2] = 0x16;
8444 if (present) { 8768 spec->autocfg.speaker_pins[3] = 0x17;
8445 /* mute internal speaker */ 8769 spec->autocfg.speaker_pins[4] = 0x1a;
8446 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8770 alc_automute_amp(codec);
8447 HDA_AMP_MUTE, HDA_AMP_MUTE);
8448 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8449 HDA_AMP_MUTE, HDA_AMP_MUTE);
8450 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8451 HDA_AMP_MUTE, HDA_AMP_MUTE);
8452 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8453 HDA_AMP_MUTE, HDA_AMP_MUTE);
8454 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8455 HDA_AMP_MUTE, HDA_AMP_MUTE);
8456 } else {
8457 /* unmute internal speaker if necessary */
8458 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8459 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8460 HDA_AMP_MUTE, mute);
8461 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8462 HDA_AMP_MUTE, mute);
8463 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8464 HDA_AMP_MUTE, mute);
8465 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8466 HDA_AMP_MUTE, mute);
8467 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8468 HDA_AMP_MUTE, mute);
8469 }
8470} 8771}
8471 8772
8472static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, 8773static void alc883_vaiott_init_hook(struct hda_codec *codec)
8473 unsigned int res)
8474{ 8774{
8475 if ((res >> 26) == ALC880_HP_EVENT) 8775 struct alc_spec *spec = codec->spec;
8476 alc888_lenovo_sky_front_automute(codec); 8776
8777 spec->autocfg.hp_pins[0] = 0x15;
8778 spec->autocfg.speaker_pins[0] = 0x14;
8779 spec->autocfg.speaker_pins[1] = 0x17;
8780 alc_automute_amp(codec);
8477} 8781}
8478 8782
8479/* 8783/*
@@ -8561,39 +8865,33 @@ static void alc883_nb_mic_automute(struct hda_codec *codec)
8561 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 8865 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8562} 8866}
8563 8867
8564static void alc883_M90V_speaker_automute(struct hda_codec *codec) 8868static void alc883_M90V_init_hook(struct hda_codec *codec)
8565{ 8869{
8566 unsigned int present; 8870 struct alc_spec *spec = codec->spec;
8567 unsigned char bits;
8568 8871
8569 present = snd_hda_codec_read(codec, 0x1b, 0, 8872 spec->autocfg.hp_pins[0] = 0x1b;
8570 AC_VERB_GET_PIN_SENSE, 0) 8873 spec->autocfg.speaker_pins[0] = 0x14;
8571 & AC_PINSENSE_PRESENCE; 8874 spec->autocfg.speaker_pins[1] = 0x15;
8572 bits = present ? 0 : PIN_OUT; 8875 spec->autocfg.speaker_pins[2] = 0x16;
8573 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 8876 alc_automute_pin(codec);
8574 bits);
8575 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8576 bits);
8577 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8578 bits);
8579} 8877}
8580 8878
8581static void alc883_mode2_unsol_event(struct hda_codec *codec, 8879static void alc883_mode2_unsol_event(struct hda_codec *codec,
8582 unsigned int res) 8880 unsigned int res)
8583{ 8881{
8584 switch (res >> 26) { 8882 switch (res >> 26) {
8585 case ALC880_HP_EVENT:
8586 alc883_M90V_speaker_automute(codec);
8587 break;
8588 case ALC880_MIC_EVENT: 8883 case ALC880_MIC_EVENT:
8589 alc883_nb_mic_automute(codec); 8884 alc883_nb_mic_automute(codec);
8590 break; 8885 break;
8886 default:
8887 alc_sku_unsol_event(codec, res);
8888 break;
8591 } 8889 }
8592} 8890}
8593 8891
8594static void alc883_mode2_inithook(struct hda_codec *codec) 8892static void alc883_mode2_inithook(struct hda_codec *codec)
8595{ 8893{
8596 alc883_M90V_speaker_automute(codec); 8894 alc883_M90V_init_hook(codec);
8597 alc883_nb_mic_automute(codec); 8895 alc883_nb_mic_automute(codec);
8598} 8896}
8599 8897
@@ -8610,32 +8908,49 @@ static struct hda_verb alc888_asus_eee1601_verbs[] = {
8610 { } /* end */ 8908 { } /* end */
8611}; 8909};
8612 8910
8613static void alc883_eee1601_speaker_automute(struct hda_codec *codec) 8911static void alc883_eee1601_inithook(struct hda_codec *codec)
8614{ 8912{
8615 unsigned int present; 8913 struct alc_spec *spec = codec->spec;
8616 unsigned char bits;
8617 8914
8618 present = snd_hda_codec_read(codec, 0x14, 0, 8915 spec->autocfg.hp_pins[0] = 0x14;
8619 AC_VERB_GET_PIN_SENSE, 0) 8916 spec->autocfg.speaker_pins[0] = 0x1b;
8620 & AC_PINSENSE_PRESENCE; 8917 alc_automute_pin(codec);
8621 bits = present ? 0 : PIN_OUT;
8622 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8623 bits);
8624} 8918}
8625 8919
8626static void alc883_eee1601_unsol_event(struct hda_codec *codec, 8920static struct hda_verb alc889A_mb31_verbs[] = {
8627 unsigned int res) 8921 /* Init rear pin (used as headphone output) */
8922 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8923 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8924 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8925 /* Init line pin (used as output in 4ch and 6ch mode) */
8926 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8927 /* Init line 2 pin (used as headphone out by default) */
8928 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8929 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8930 { } /* end */
8931};
8932
8933/* Mute speakers according to the headphone jack state */
8934static void alc889A_mb31_automute(struct hda_codec *codec)
8628{ 8935{
8629 switch (res >> 26) { 8936 unsigned int present;
8630 case ALC880_HP_EVENT: 8937
8631 alc883_eee1601_speaker_automute(codec); 8938 /* Mute only in 2ch or 4ch mode */
8632 break; 8939 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8940 == 0x00) {
8941 present = snd_hda_codec_read(codec, 0x15, 0,
8942 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8943 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8944 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8945 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8946 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8633 } 8947 }
8634} 8948}
8635 8949
8636static void alc883_eee1601_inithook(struct hda_codec *codec) 8950static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8637{ 8951{
8638 alc883_eee1601_speaker_automute(codec); 8952 if ((res >> 26) == ALC880_HP_EVENT)
8953 alc889A_mb31_automute(codec);
8639} 8954}
8640 8955
8641#ifdef CONFIG_SND_HDA_POWER_SAVE 8956#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -8659,9 +8974,11 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
8659 [ALC883_6ST_DIG] = "6stack-dig", 8974 [ALC883_6ST_DIG] = "6stack-dig",
8660 [ALC883_TARGA_DIG] = "targa-dig", 8975 [ALC883_TARGA_DIG] = "targa-dig",
8661 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 8976 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
8977 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
8662 [ALC883_ACER] = "acer", 8978 [ALC883_ACER] = "acer",
8663 [ALC883_ACER_ASPIRE] = "acer-aspire", 8979 [ALC883_ACER_ASPIRE] = "acer-aspire",
8664 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", 8980 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
8981 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
8665 [ALC883_MEDION] = "medion", 8982 [ALC883_MEDION] = "medion",
8666 [ALC883_MEDION_MD2] = "medion-md2", 8983 [ALC883_MEDION_MD2] = "medion-md2",
8667 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 8984 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
@@ -8678,6 +8995,8 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
8678 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", 8995 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
8679 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", 8996 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8680 [ALC1200_ASUS_P5Q] = "asus-p5q", 8997 [ALC1200_ASUS_P5Q] = "asus-p5q",
8998 [ALC889A_MB31] = "mb31",
8999 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
8681 [ALC883_AUTO] = "auto", 9000 [ALC883_AUTO] = "auto",
8682}; 9001};
8683 9002
@@ -8693,14 +9012,18 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8693 ALC888_ACER_ASPIRE_4930G), 9012 ALC888_ACER_ASPIRE_4930G),
8694 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", 9013 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8695 ALC888_ACER_ASPIRE_4930G), 9014 ALC888_ACER_ASPIRE_4930G),
9015 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9016 ALC888_ACER_ASPIRE_8930G),
8696 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), 9017 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
8697 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), 9018 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
8698 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 9019 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8699 ALC888_ACER_ASPIRE_4930G), 9020 ALC888_ACER_ASPIRE_4930G),
8700 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", 9021 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8701 ALC888_ACER_ASPIRE_4930G), 9022 ALC888_ACER_ASPIRE_4930G),
8702 /* default Acer */ 9023 /* default Acer -- disabled as it causes more problems.
8703 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), 9024 * model=auto should work fine now
9025 */
9026 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
8704 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 9027 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8705 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 9028 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
8706 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 9029 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
@@ -8736,6 +9059,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8736 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), 9059 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8737 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), 9060 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8738 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 9061 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
9062 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
8739 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 9063 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8740 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 9064 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
8741 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), 9065 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
@@ -8768,6 +9092,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8768 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), 9092 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
8769 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), 9093 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
8770 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 9094 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
9095 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
8771 {} 9096 {}
8772}; 9097};
8773 9098
@@ -8848,7 +9173,7 @@ static struct alc_config_preset alc883_presets[] = {
8848 .need_dac_fix = 1, 9173 .need_dac_fix = 1,
8849 .input_mux = &alc883_capture_source, 9174 .input_mux = &alc883_capture_source,
8850 .unsol_event = alc883_tagra_unsol_event, 9175 .unsol_event = alc883_tagra_unsol_event,
8851 .init_hook = alc883_tagra_automute, 9176 .init_hook = alc883_tagra_init_hook,
8852 }, 9177 },
8853 [ALC883_TARGA_2ch_DIG] = { 9178 [ALC883_TARGA_2ch_DIG] = {
8854 .mixers = { alc883_tagra_2ch_mixer}, 9179 .mixers = { alc883_tagra_2ch_mixer},
@@ -8862,7 +9187,25 @@ static struct alc_config_preset alc883_presets[] = {
8862 .channel_mode = alc883_3ST_2ch_modes, 9187 .channel_mode = alc883_3ST_2ch_modes,
8863 .input_mux = &alc883_capture_source, 9188 .input_mux = &alc883_capture_source,
8864 .unsol_event = alc883_tagra_unsol_event, 9189 .unsol_event = alc883_tagra_unsol_event,
8865 .init_hook = alc883_tagra_automute, 9190 .init_hook = alc883_tagra_init_hook,
9191 },
9192 [ALC883_TARGA_8ch_DIG] = {
9193 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9194 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9195 alc883_tagra_verbs },
9196 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9197 .dac_nids = alc883_dac_nids,
9198 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9199 .adc_nids = alc883_adc_nids_rev,
9200 .capsrc_nids = alc883_capsrc_nids_rev,
9201 .dig_out_nid = ALC883_DIGOUT_NID,
9202 .dig_in_nid = ALC883_DIGIN_NID,
9203 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9204 .channel_mode = alc883_4ST_8ch_modes,
9205 .need_dac_fix = 1,
9206 .input_mux = &alc883_capture_source,
9207 .unsol_event = alc883_tagra_unsol_event,
9208 .init_hook = alc883_tagra_init_hook,
8866 }, 9209 },
8867 [ALC883_ACER] = { 9210 [ALC883_ACER] = {
8868 .mixers = { alc883_base_mixer }, 9211 .mixers = { alc883_base_mixer },
@@ -8887,8 +9230,8 @@ static struct alc_config_preset alc883_presets[] = {
8887 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 9230 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8888 .channel_mode = alc883_3ST_2ch_modes, 9231 .channel_mode = alc883_3ST_2ch_modes,
8889 .input_mux = &alc883_capture_source, 9232 .input_mux = &alc883_capture_source,
8890 .unsol_event = alc883_acer_aspire_unsol_event, 9233 .unsol_event = alc_automute_amp_unsol_event,
8891 .init_hook = alc883_acer_aspire_automute, 9234 .init_hook = alc883_acer_aspire_init_hook,
8892 }, 9235 },
8893 [ALC888_ACER_ASPIRE_4930G] = { 9236 [ALC888_ACER_ASPIRE_4930G] = {
8894 .mixers = { alc888_base_mixer, 9237 .mixers = { alc888_base_mixer,
@@ -8907,8 +9250,29 @@ static struct alc_config_preset alc883_presets[] = {
8907 .num_mux_defs = 9250 .num_mux_defs =
8908 ARRAY_SIZE(alc888_2_capture_sources), 9251 ARRAY_SIZE(alc888_2_capture_sources),
8909 .input_mux = alc888_2_capture_sources, 9252 .input_mux = alc888_2_capture_sources,
8910 .unsol_event = alc888_acer_aspire_4930g_unsol_event, 9253 .unsol_event = alc_automute_amp_unsol_event,
8911 .init_hook = alc888_acer_aspire_4930g_automute, 9254 .init_hook = alc888_acer_aspire_4930g_init_hook,
9255 },
9256 [ALC888_ACER_ASPIRE_8930G] = {
9257 .mixers = { alc888_base_mixer,
9258 alc883_chmode_mixer },
9259 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9260 alc889_acer_aspire_8930g_verbs },
9261 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9262 .dac_nids = alc883_dac_nids,
9263 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9264 .adc_nids = alc889_adc_nids,
9265 .capsrc_nids = alc889_capsrc_nids,
9266 .dig_out_nid = ALC883_DIGOUT_NID,
9267 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9268 .channel_mode = alc883_3ST_6ch_modes,
9269 .need_dac_fix = 1,
9270 .const_channel_count = 6,
9271 .num_mux_defs =
9272 ARRAY_SIZE(alc889_capture_sources),
9273 .input_mux = alc889_capture_sources,
9274 .unsol_event = alc_automute_amp_unsol_event,
9275 .init_hook = alc889_acer_aspire_8930g_init_hook,
8912 }, 9276 },
8913 [ALC883_MEDION] = { 9277 [ALC883_MEDION] = {
8914 .mixers = { alc883_fivestack_mixer, 9278 .mixers = { alc883_fivestack_mixer,
@@ -8932,8 +9296,8 @@ static struct alc_config_preset alc883_presets[] = {
8932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 9296 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8933 .channel_mode = alc883_3ST_2ch_modes, 9297 .channel_mode = alc883_3ST_2ch_modes,
8934 .input_mux = &alc883_capture_source, 9298 .input_mux = &alc883_capture_source,
8935 .unsol_event = alc883_medion_md2_unsol_event, 9299 .unsol_event = alc_automute_amp_unsol_event,
8936 .init_hook = alc883_medion_md2_automute, 9300 .init_hook = alc883_medion_md2_init_hook,
8937 }, 9301 },
8938 [ALC883_LAPTOP_EAPD] = { 9302 [ALC883_LAPTOP_EAPD] = {
8939 .mixers = { alc883_base_mixer }, 9303 .mixers = { alc883_base_mixer },
@@ -8954,7 +9318,7 @@ static struct alc_config_preset alc883_presets[] = {
8954 .channel_mode = alc883_3ST_2ch_modes, 9318 .channel_mode = alc883_3ST_2ch_modes,
8955 .input_mux = &alc883_capture_source, 9319 .input_mux = &alc883_capture_source,
8956 .unsol_event = alc883_clevo_m720_unsol_event, 9320 .unsol_event = alc883_clevo_m720_unsol_event,
8957 .init_hook = alc883_clevo_m720_automute, 9321 .init_hook = alc883_clevo_m720_init_hook,
8958 }, 9322 },
8959 [ALC883_LENOVO_101E_2ch] = { 9323 [ALC883_LENOVO_101E_2ch] = {
8960 .mixers = { alc883_lenovo_101e_2ch_mixer}, 9324 .mixers = { alc883_lenovo_101e_2ch_mixer},
@@ -8978,8 +9342,8 @@ static struct alc_config_preset alc883_presets[] = {
8978 .channel_mode = alc883_3ST_2ch_modes, 9342 .channel_mode = alc883_3ST_2ch_modes,
8979 .need_dac_fix = 1, 9343 .need_dac_fix = 1,
8980 .input_mux = &alc883_lenovo_nb0763_capture_source, 9344 .input_mux = &alc883_lenovo_nb0763_capture_source,
8981 .unsol_event = alc883_medion_md2_unsol_event, 9345 .unsol_event = alc_automute_amp_unsol_event,
8982 .init_hook = alc883_medion_md2_automute, 9346 .init_hook = alc883_medion_md2_init_hook,
8983 }, 9347 },
8984 [ALC888_LENOVO_MS7195_DIG] = { 9348 [ALC888_LENOVO_MS7195_DIG] = {
8985 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9349 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9003,8 +9367,8 @@ static struct alc_config_preset alc883_presets[] = {
9003 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 9367 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9004 .channel_mode = alc883_3ST_2ch_modes, 9368 .channel_mode = alc883_3ST_2ch_modes,
9005 .input_mux = &alc883_capture_source, 9369 .input_mux = &alc883_capture_source,
9006 .unsol_event = alc883_haier_w66_unsol_event, 9370 .unsol_event = alc_automute_amp_unsol_event,
9007 .init_hook = alc883_haier_w66_automute, 9371 .init_hook = alc883_haier_w66_init_hook,
9008 }, 9372 },
9009 [ALC888_3ST_HP] = { 9373 [ALC888_3ST_HP] = {
9010 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9374 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9015,8 +9379,8 @@ static struct alc_config_preset alc883_presets[] = {
9015 .channel_mode = alc888_3st_hp_modes, 9379 .channel_mode = alc888_3st_hp_modes,
9016 .need_dac_fix = 1, 9380 .need_dac_fix = 1,
9017 .input_mux = &alc883_capture_source, 9381 .input_mux = &alc883_capture_source,
9018 .unsol_event = alc888_3st_hp_unsol_event, 9382 .unsol_event = alc_automute_amp_unsol_event,
9019 .init_hook = alc888_3st_hp_front_automute, 9383 .init_hook = alc888_3st_hp_init_hook,
9020 }, 9384 },
9021 [ALC888_6ST_DELL] = { 9385 [ALC888_6ST_DELL] = {
9022 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9386 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
@@ -9028,8 +9392,8 @@ static struct alc_config_preset alc883_presets[] = {
9028 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 9392 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9029 .channel_mode = alc883_sixstack_modes, 9393 .channel_mode = alc883_sixstack_modes,
9030 .input_mux = &alc883_capture_source, 9394 .input_mux = &alc883_capture_source,
9031 .unsol_event = alc888_6st_dell_unsol_event, 9395 .unsol_event = alc_automute_amp_unsol_event,
9032 .init_hook = alc888_6st_dell_front_automute, 9396 .init_hook = alc888_6st_dell_init_hook,
9033 }, 9397 },
9034 [ALC883_MITAC] = { 9398 [ALC883_MITAC] = {
9035 .mixers = { alc883_mitac_mixer }, 9399 .mixers = { alc883_mitac_mixer },
@@ -9039,8 +9403,8 @@ static struct alc_config_preset alc883_presets[] = {
9039 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 9403 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9040 .channel_mode = alc883_3ST_2ch_modes, 9404 .channel_mode = alc883_3ST_2ch_modes,
9041 .input_mux = &alc883_capture_source, 9405 .input_mux = &alc883_capture_source,
9042 .unsol_event = alc883_mitac_unsol_event, 9406 .unsol_event = alc_automute_amp_unsol_event,
9043 .init_hook = alc883_mitac_automute, 9407 .init_hook = alc883_mitac_init_hook,
9044 }, 9408 },
9045 [ALC883_FUJITSU_PI2515] = { 9409 [ALC883_FUJITSU_PI2515] = {
9046 .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, 9410 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
@@ -9052,8 +9416,8 @@ static struct alc_config_preset alc883_presets[] = {
9052 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 9416 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9053 .channel_mode = alc883_3ST_2ch_modes, 9417 .channel_mode = alc883_3ST_2ch_modes,
9054 .input_mux = &alc883_fujitsu_pi2515_capture_source, 9418 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9055 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, 9419 .unsol_event = alc_automute_amp_unsol_event,
9056 .init_hook = alc883_2ch_fujitsu_pi2515_automute, 9420 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
9057 }, 9421 },
9058 [ALC888_FUJITSU_XA3530] = { 9422 [ALC888_FUJITSU_XA3530] = {
9059 .mixers = { alc888_base_mixer, alc883_chmode_mixer }, 9423 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
@@ -9070,8 +9434,8 @@ static struct alc_config_preset alc883_presets[] = {
9070 .num_mux_defs = 9434 .num_mux_defs =
9071 ARRAY_SIZE(alc888_2_capture_sources), 9435 ARRAY_SIZE(alc888_2_capture_sources),
9072 .input_mux = alc888_2_capture_sources, 9436 .input_mux = alc888_2_capture_sources,
9073 .unsol_event = alc888_fujitsu_xa3530_unsol_event, 9437 .unsol_event = alc_automute_amp_unsol_event,
9074 .init_hook = alc888_fujitsu_xa3530_automute, 9438 .init_hook = alc888_fujitsu_xa3530_init_hook,
9075 }, 9439 },
9076 [ALC888_LENOVO_SKY] = { 9440 [ALC888_LENOVO_SKY] = {
9077 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, 9441 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
@@ -9083,8 +9447,8 @@ static struct alc_config_preset alc883_presets[] = {
9083 .channel_mode = alc883_sixstack_modes, 9447 .channel_mode = alc883_sixstack_modes,
9084 .need_dac_fix = 1, 9448 .need_dac_fix = 1,
9085 .input_mux = &alc883_lenovo_sky_capture_source, 9449 .input_mux = &alc883_lenovo_sky_capture_source,
9086 .unsol_event = alc883_lenovo_sky_unsol_event, 9450 .unsol_event = alc_automute_amp_unsol_event,
9087 .init_hook = alc888_lenovo_sky_front_automute, 9451 .init_hook = alc888_lenovo_sky_init_hook,
9088 }, 9452 },
9089 [ALC888_ASUS_M90V] = { 9453 [ALC888_ASUS_M90V] = {
9090 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 9454 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
@@ -9112,7 +9476,7 @@ static struct alc_config_preset alc883_presets[] = {
9112 .channel_mode = alc883_3ST_2ch_modes, 9476 .channel_mode = alc883_3ST_2ch_modes,
9113 .need_dac_fix = 1, 9477 .need_dac_fix = 1,
9114 .input_mux = &alc883_asus_eee1601_capture_source, 9478 .input_mux = &alc883_asus_eee1601_capture_source,
9115 .unsol_event = alc883_eee1601_unsol_event, 9479 .unsol_event = alc_sku_unsol_event,
9116 .init_hook = alc883_eee1601_inithook, 9480 .init_hook = alc883_eee1601_inithook,
9117 }, 9481 },
9118 [ALC1200_ASUS_P5Q] = { 9482 [ALC1200_ASUS_P5Q] = {
@@ -9127,6 +9491,32 @@ static struct alc_config_preset alc883_presets[] = {
9127 .channel_mode = alc883_sixstack_modes, 9491 .channel_mode = alc883_sixstack_modes,
9128 .input_mux = &alc883_capture_source, 9492 .input_mux = &alc883_capture_source,
9129 }, 9493 },
9494 [ALC889A_MB31] = {
9495 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9496 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9497 alc880_gpio1_init_verbs },
9498 .adc_nids = alc883_adc_nids,
9499 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9500 .dac_nids = alc883_dac_nids,
9501 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9502 .channel_mode = alc889A_mb31_6ch_modes,
9503 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9504 .input_mux = &alc889A_mb31_capture_source,
9505 .dig_out_nid = ALC883_DIGOUT_NID,
9506 .unsol_event = alc889A_mb31_unsol_event,
9507 .init_hook = alc889A_mb31_automute,
9508 },
9509 [ALC883_SONY_VAIO_TT] = {
9510 .mixers = { alc883_vaiott_mixer },
9511 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9512 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9513 .dac_nids = alc883_dac_nids,
9514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9515 .channel_mode = alc883_3ST_2ch_modes,
9516 .input_mux = &alc883_capture_source,
9517 .unsol_event = alc_automute_amp_unsol_event,
9518 .init_hook = alc883_vaiott_init_hook,
9519 },
9130}; 9520};
9131 9521
9132 9522
@@ -9155,7 +9545,6 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
9155 struct alc_spec *spec = codec->spec; 9545 struct alc_spec *spec = codec->spec;
9156 int i; 9546 int i;
9157 9547
9158 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
9159 for (i = 0; i <= HDA_SIDE; i++) { 9548 for (i = 0; i <= HDA_SIDE; i++) {
9160 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 9549 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9161 int pin_type = get_pin_type(spec->autocfg.line_out_type); 9550 int pin_type = get_pin_type(spec->autocfg.line_out_type);
@@ -9273,10 +9662,18 @@ static int patch_alc883(struct hda_codec *codec)
9273 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, 9662 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9274 alc883_models, 9663 alc883_models,
9275 alc883_cfg_tbl); 9664 alc883_cfg_tbl);
9276 if (board_config < 0) { 9665 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9277 printk(KERN_INFO "hda_codec: Unknown model for ALC883, " 9666 /* Pick up systems that don't supply PCI SSID */
9278 "trying auto-probe from BIOS...\n"); 9667 switch (codec->subsystem_id) {
9279 board_config = ALC883_AUTO; 9668 case 0x106b3600: /* Macbook 3.1 */
9669 board_config = ALC889A_MB31;
9670 break;
9671 default:
9672 printk(KERN_INFO
9673 "hda_codec: Unknown model for %s, trying "
9674 "auto-probe from BIOS...\n", codec->chip_name);
9675 board_config = ALC883_AUTO;
9676 }
9280 } 9677 }
9281 9678
9282 if (board_config == ALC883_AUTO) { 9679 if (board_config == ALC883_AUTO) {
@@ -9304,13 +9701,6 @@ static int patch_alc883(struct hda_codec *codec)
9304 9701
9305 switch (codec->vendor_id) { 9702 switch (codec->vendor_id) {
9306 case 0x10ec0888: 9703 case 0x10ec0888:
9307 if (codec->revision_id == 0x100101) {
9308 spec->stream_name_analog = "ALC1200 Analog";
9309 spec->stream_name_digital = "ALC1200 Digital";
9310 } else {
9311 spec->stream_name_analog = "ALC888 Analog";
9312 spec->stream_name_digital = "ALC888 Digital";
9313 }
9314 if (!spec->num_adc_nids) { 9704 if (!spec->num_adc_nids) {
9315 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9705 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9316 spec->adc_nids = alc883_adc_nids; 9706 spec->adc_nids = alc883_adc_nids;
@@ -9318,10 +9708,9 @@ static int patch_alc883(struct hda_codec *codec)
9318 if (!spec->capsrc_nids) 9708 if (!spec->capsrc_nids)
9319 spec->capsrc_nids = alc883_capsrc_nids; 9709 spec->capsrc_nids = alc883_capsrc_nids;
9320 spec->capture_style = CAPT_MIX; /* matrix-style capture */ 9710 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9711 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
9321 break; 9712 break;
9322 case 0x10ec0889: 9713 case 0x10ec0889:
9323 spec->stream_name_analog = "ALC889 Analog";
9324 spec->stream_name_digital = "ALC889 Digital";
9325 if (!spec->num_adc_nids) { 9714 if (!spec->num_adc_nids) {
9326 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); 9715 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9327 spec->adc_nids = alc889_adc_nids; 9716 spec->adc_nids = alc889_adc_nids;
@@ -9332,8 +9721,6 @@ static int patch_alc883(struct hda_codec *codec)
9332 capture */ 9721 capture */
9333 break; 9722 break;
9334 default: 9723 default:
9335 spec->stream_name_analog = "ALC883 Analog";
9336 spec->stream_name_digital = "ALC883 Digital";
9337 if (!spec->num_adc_nids) { 9724 if (!spec->num_adc_nids) {
9338 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9725 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9339 spec->adc_nids = alc883_adc_nids; 9726 spec->adc_nids = alc883_adc_nids;
@@ -9413,24 +9800,6 @@ static struct snd_kcontrol_new alc262_base_mixer[] = {
9413 { } /* end */ 9800 { } /* end */
9414}; 9801};
9415 9802
9416static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9417 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9418 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9419 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9420 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9421 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9422 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9425 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9426 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9427 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9428 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9429 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9430 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9431 { } /* end */
9432};
9433
9434/* update HP, line and mono-out pins according to the master switch */ 9803/* update HP, line and mono-out pins according to the master switch */
9435static void alc262_hp_master_update(struct hda_codec *codec) 9804static void alc262_hp_master_update(struct hda_codec *codec)
9436{ 9805{
@@ -9486,14 +9855,7 @@ static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9486 alc262_hp_wildwest_automute(codec); 9855 alc262_hp_wildwest_automute(codec);
9487} 9856}
9488 9857
9489static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, 9858#define alc262_hp_master_sw_get alc260_hp_master_sw_get
9490 struct snd_ctl_elem_value *ucontrol)
9491{
9492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9493 struct alc_spec *spec = codec->spec;
9494 *ucontrol->value.integer.value = spec->master_sw;
9495 return 0;
9496}
9497 9859
9498static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, 9860static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9499 struct snd_ctl_elem_value *ucontrol) 9861 struct snd_ctl_elem_value *ucontrol)
@@ -9509,14 +9871,17 @@ static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9509 return 1; 9871 return 1;
9510} 9872}
9511 9873
9874#define ALC262_HP_MASTER_SWITCH \
9875 { \
9876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9877 .name = "Master Playback Switch", \
9878 .info = snd_ctl_boolean_mono_info, \
9879 .get = alc262_hp_master_sw_get, \
9880 .put = alc262_hp_master_sw_put, \
9881 }
9882
9512static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { 9883static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
9513 { 9884 ALC262_HP_MASTER_SWITCH,
9514 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9515 .name = "Master Playback Switch",
9516 .info = snd_ctl_boolean_mono_info,
9517 .get = alc262_hp_master_sw_get,
9518 .put = alc262_hp_master_sw_put,
9519 },
9520 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9885 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9521 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9886 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 9887 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
@@ -9540,13 +9905,7 @@ static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
9540}; 9905};
9541 9906
9542static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { 9907static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
9543 { 9908 ALC262_HP_MASTER_SWITCH,
9544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9545 .name = "Master Playback Switch",
9546 .info = snd_ctl_boolean_mono_info,
9547 .get = alc262_hp_master_sw_get,
9548 .put = alc262_hp_master_sw_put,
9549 },
9550 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9909 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9551 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 9910 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9552 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 9911 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
@@ -9573,32 +9932,13 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9573}; 9932};
9574 9933
9575/* mute/unmute internal speaker according to the hp jack and mute state */ 9934/* mute/unmute internal speaker according to the hp jack and mute state */
9576static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) 9935static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9577{ 9936{
9578 struct alc_spec *spec = codec->spec; 9937 struct alc_spec *spec = codec->spec;
9579 9938
9580 if (force || !spec->sense_updated) { 9939 spec->autocfg.hp_pins[0] = 0x15;
9581 unsigned int present; 9940 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9582 present = snd_hda_codec_read(codec, 0x15, 0, 9941 alc_automute_amp(codec);
9583 AC_VERB_GET_PIN_SENSE, 0);
9584 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9585 spec->sense_updated = 1;
9586 }
9587 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9588 spec->jack_present ? HDA_AMP_MUTE : 0);
9589}
9590
9591static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9592 unsigned int res)
9593{
9594 if ((res >> 26) != ALC880_HP_EVENT)
9595 return;
9596 alc262_hp_t5735_automute(codec, 1);
9597}
9598
9599static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9600{
9601 alc262_hp_t5735_automute(codec, 1);
9602} 9942}
9603 9943
9604static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { 9944static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
@@ -9651,46 +9991,132 @@ static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9651 }, 9991 },
9652}; 9992};
9653 9993
9654/* bind hp and internal speaker mute (with plug check) */ 9994/* bind hp and internal speaker mute (with plug check) as master switch */
9655static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, 9995static void alc262_hippo_master_update(struct hda_codec *codec)
9656 struct snd_ctl_elem_value *ucontrol)
9657{ 9996{
9658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9997 struct alc_spec *spec = codec->spec;
9659 long *valp = ucontrol->value.integer.value; 9998 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9660 int change; 9999 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10000 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10001 unsigned int mute;
9661 10002
9662 /* change hp mute */ 10003 /* HP */
9663 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 10004 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9664 HDA_AMP_MUTE, 10005 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9665 valp[0] ? 0 : HDA_AMP_MUTE); 10006 HDA_AMP_MUTE, mute);
9666 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 10007 /* mute internal speaker per jack sense */
9667 HDA_AMP_MUTE, 10008 if (spec->jack_present)
9668 valp[1] ? 0 : HDA_AMP_MUTE); 10009 mute = HDA_AMP_MUTE;
9669 if (change) { 10010 if (line_nid)
9670 /* change speaker according to HP jack state */ 10011 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9671 struct alc_spec *spec = codec->spec;
9672 unsigned int mute;
9673 if (spec->jack_present)
9674 mute = HDA_AMP_MUTE;
9675 else
9676 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9677 HDA_OUTPUT, 0);
9678 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9679 HDA_AMP_MUTE, mute); 10012 HDA_AMP_MUTE, mute);
10013 if (speaker_nid && speaker_nid != line_nid)
10014 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10015 HDA_AMP_MUTE, mute);
10016}
10017
10018#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10019
10020static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10021 struct snd_ctl_elem_value *ucontrol)
10022{
10023 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10024 struct alc_spec *spec = codec->spec;
10025 int val = !!*ucontrol->value.integer.value;
10026
10027 if (val == spec->master_sw)
10028 return 0;
10029 spec->master_sw = val;
10030 alc262_hippo_master_update(codec);
10031 return 1;
10032}
10033
10034#define ALC262_HIPPO_MASTER_SWITCH \
10035 { \
10036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10037 .name = "Master Playback Switch", \
10038 .info = snd_ctl_boolean_mono_info, \
10039 .get = alc262_hippo_master_sw_get, \
10040 .put = alc262_hippo_master_sw_put, \
9680 } 10041 }
9681 return change; 10042
10043static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10044 ALC262_HIPPO_MASTER_SWITCH,
10045 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10046 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10047 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10053 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10054 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10055 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10056 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10057 { } /* end */
10058};
10059
10060static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10061 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10062 ALC262_HIPPO_MASTER_SWITCH,
10063 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10064 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10065 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10066 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10070 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10071 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10072 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10073 { } /* end */
10074};
10075
10076/* mute/unmute internal speaker according to the hp jack and mute state */
10077static void alc262_hippo_automute(struct hda_codec *codec)
10078{
10079 struct alc_spec *spec = codec->spec;
10080 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10081 unsigned int present;
10082
10083 /* need to execute and sync at first */
10084 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10085 present = snd_hda_codec_read(codec, hp_nid, 0,
10086 AC_VERB_GET_PIN_SENSE, 0);
10087 spec->jack_present = (present & 0x80000000) != 0;
10088 alc262_hippo_master_update(codec);
10089}
10090
10091static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10092{
10093 if ((res >> 26) != ALC880_HP_EVENT)
10094 return;
10095 alc262_hippo_automute(codec);
10096}
10097
10098static void alc262_hippo_init_hook(struct hda_codec *codec)
10099{
10100 struct alc_spec *spec = codec->spec;
10101
10102 spec->autocfg.hp_pins[0] = 0x15;
10103 spec->autocfg.speaker_pins[0] = 0x14;
10104 alc262_hippo_automute(codec);
10105}
10106
10107static void alc262_hippo1_init_hook(struct hda_codec *codec)
10108{
10109 struct alc_spec *spec = codec->spec;
10110
10111 spec->autocfg.hp_pins[0] = 0x1b;
10112 spec->autocfg.speaker_pins[0] = 0x14;
10113 alc262_hippo_automute(codec);
9682} 10114}
9683 10115
10116
9684static struct snd_kcontrol_new alc262_sony_mixer[] = { 10117static struct snd_kcontrol_new alc262_sony_mixer[] = {
9685 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 10118 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9686 { 10119 ALC262_HIPPO_MASTER_SWITCH,
9687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9688 .name = "Master Playback Switch",
9689 .info = snd_hda_mixer_amp_switch_info,
9690 .get = snd_hda_mixer_amp_switch_get,
9691 .put = alc262_sony_master_sw_put,
9692 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9693 },
9694 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 10120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9695 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 10121 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9696 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 10122 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
@@ -9699,8 +10125,8 @@ static struct snd_kcontrol_new alc262_sony_mixer[] = {
9699}; 10125};
9700 10126
9701static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { 10127static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9702 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 10128 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9703 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10129 ALC262_HIPPO_MASTER_SWITCH,
9704 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 10130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 10131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 10132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
@@ -9741,34 +10167,15 @@ static struct hda_verb alc262_tyan_verbs[] = {
9741}; 10167};
9742 10168
9743/* unsolicited event for HP jack sensing */ 10169/* unsolicited event for HP jack sensing */
9744static void alc262_tyan_automute(struct hda_codec *codec) 10170static void alc262_tyan_init_hook(struct hda_codec *codec)
9745{ 10171{
9746 unsigned int mute; 10172 struct alc_spec *spec = codec->spec;
9747 unsigned int present;
9748 10173
9749 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 10174 spec->autocfg.hp_pins[0] = 0x1b;
9750 present = snd_hda_codec_read(codec, 0x1b, 0, 10175 spec->autocfg.speaker_pins[0] = 0x15;
9751 AC_VERB_GET_PIN_SENSE, 0); 10176 alc_automute_amp(codec);
9752 present = (present & 0x80000000) != 0;
9753 if (present) {
9754 /* mute line output on ATX panel */
9755 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9756 HDA_AMP_MUTE, HDA_AMP_MUTE);
9757 } else {
9758 /* unmute line output if necessary */
9759 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9760 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9761 HDA_AMP_MUTE, mute);
9762 }
9763} 10177}
9764 10178
9765static void alc262_tyan_unsol_event(struct hda_codec *codec,
9766 unsigned int res)
9767{
9768 if ((res >> 26) != ALC880_HP_EVENT)
9769 return;
9770 alc262_tyan_automute(codec);
9771}
9772 10179
9773#define alc262_capture_mixer alc882_capture_mixer 10180#define alc262_capture_mixer alc882_capture_mixer
9774#define alc262_capture_alt_mixer alc882_capture_alt_mixer 10181#define alc262_capture_alt_mixer alc882_capture_alt_mixer
@@ -9923,99 +10330,25 @@ static void alc262_dmic_automute(struct hda_codec *codec)
9923 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); 10330 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9924} 10331}
9925 10332
9926/* toggle speaker-output according to the hp-jack state */
9927static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9928{
9929 unsigned int present;
9930 unsigned char bits;
9931
9932 present = snd_hda_codec_read(codec, 0x15, 0,
9933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9934 bits = present ? 0 : PIN_OUT;
9935 snd_hda_codec_write(codec, 0x14, 0,
9936 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9937}
9938
9939
9940 10333
9941/* unsolicited event for HP jack sensing */ 10334/* unsolicited event for HP jack sensing */
9942static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, 10335static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9943 unsigned int res) 10336 unsigned int res)
9944{ 10337{
9945 if ((res >> 26) == ALC880_HP_EVENT)
9946 alc262_toshiba_s06_speaker_automute(codec);
9947 if ((res >> 26) == ALC880_MIC_EVENT) 10338 if ((res >> 26) == ALC880_MIC_EVENT)
9948 alc262_dmic_automute(codec); 10339 alc262_dmic_automute(codec);
9949 10340 else
10341 alc_sku_unsol_event(codec, res);
9950} 10342}
9951 10343
9952static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) 10344static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9953{ 10345{
9954 alc262_toshiba_s06_speaker_automute(codec);
9955 alc262_dmic_automute(codec);
9956}
9957
9958/* mute/unmute internal speaker according to the hp jack and mute state */
9959static void alc262_hippo_automute(struct hda_codec *codec)
9960{
9961 struct alc_spec *spec = codec->spec; 10346 struct alc_spec *spec = codec->spec;
9962 unsigned int mute;
9963 unsigned int present;
9964
9965 /* need to execute and sync at first */
9966 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9967 present = snd_hda_codec_read(codec, 0x15, 0,
9968 AC_VERB_GET_PIN_SENSE, 0);
9969 spec->jack_present = (present & 0x80000000) != 0;
9970 if (spec->jack_present) {
9971 /* mute internal speaker */
9972 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9973 HDA_AMP_MUTE, HDA_AMP_MUTE);
9974 } else {
9975 /* unmute internal speaker if necessary */
9976 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9977 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9978 HDA_AMP_MUTE, mute);
9979 }
9980}
9981
9982/* unsolicited event for HP jack sensing */
9983static void alc262_hippo_unsol_event(struct hda_codec *codec,
9984 unsigned int res)
9985{
9986 if ((res >> 26) != ALC880_HP_EVENT)
9987 return;
9988 alc262_hippo_automute(codec);
9989}
9990
9991static void alc262_hippo1_automute(struct hda_codec *codec)
9992{
9993 unsigned int mute;
9994 unsigned int present;
9995 10347
9996 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 10348 spec->autocfg.hp_pins[0] = 0x15;
9997 present = snd_hda_codec_read(codec, 0x1b, 0, 10349 spec->autocfg.speaker_pins[0] = 0x14;
9998 AC_VERB_GET_PIN_SENSE, 0); 10350 alc_automute_pin(codec);
9999 present = (present & 0x80000000) != 0; 10351 alc262_dmic_automute(codec);
10000 if (present) {
10001 /* mute internal speaker */
10002 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10003 HDA_AMP_MUTE, HDA_AMP_MUTE);
10004 } else {
10005 /* unmute internal speaker if necessary */
10006 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10007 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10008 HDA_AMP_MUTE, mute);
10009 }
10010}
10011
10012/* unsolicited event for HP jack sensing */
10013static void alc262_hippo1_unsol_event(struct hda_codec *codec,
10014 unsigned int res)
10015{
10016 if ((res >> 26) != ALC880_HP_EVENT)
10017 return;
10018 alc262_hippo1_automute(codec);
10019} 10352}
10020 10353
10021/* 10354/*
@@ -10285,14 +10618,7 @@ static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10285 10618
10286static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = { 10619static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10287 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), 10620 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10288 { 10621 ALC262_HIPPO_MASTER_SWITCH,
10289 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10290 .name = "Master Playback Switch",
10291 .info = snd_hda_mixer_amp_switch_info,
10292 .get = snd_hda_mixer_amp_switch_get,
10293 .put = alc262_sony_master_sw_put,
10294 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10295 },
10296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 10622 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 10623 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10298 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10624 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
@@ -10639,31 +10965,46 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10640 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10966 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10641 10967
10642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, 10968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10969 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10644 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10970 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10645 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, 10971 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10646 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10972 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10647 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10973 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10648 10974
10649 10975
10650 /* FIXME: use matrix-type input source selection */ 10976 /* FIXME: use matrix-type input source selection */
10651 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 10977 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10652 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 10978 /* Input mixer1: only unmute Mic */
10653 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10654 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 10980 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 10981 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 10982 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
10657 /* Input mixer2 */ 10988 /* Input mixer2 */
10658 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10989 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10659 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 10990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 10991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 10992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
10662 /* Input mixer3 */ 10998 /* Input mixer3 */
10663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 11000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 11001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 11002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11005 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
10667 11008
10668 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 11009 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10669 11010
@@ -10843,6 +11184,8 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10843 if (err < 0) 11184 if (err < 0)
10844 return err; 11185 return err;
10845 11186
11187 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11188
10846 return 1; 11189 return 1;
10847} 11190}
10848 11191
@@ -10945,7 +11288,7 @@ static struct alc_config_preset alc262_presets[] = {
10945 .input_mux = &alc262_capture_source, 11288 .input_mux = &alc262_capture_source,
10946 }, 11289 },
10947 [ALC262_HIPPO] = { 11290 [ALC262_HIPPO] = {
10948 .mixers = { alc262_base_mixer }, 11291 .mixers = { alc262_hippo_mixer },
10949 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, 11292 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10950 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 11293 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10951 .dac_nids = alc262_dac_nids, 11294 .dac_nids = alc262_dac_nids,
@@ -10955,7 +11298,7 @@ static struct alc_config_preset alc262_presets[] = {
10955 .channel_mode = alc262_modes, 11298 .channel_mode = alc262_modes,
10956 .input_mux = &alc262_capture_source, 11299 .input_mux = &alc262_capture_source,
10957 .unsol_event = alc262_hippo_unsol_event, 11300 .unsol_event = alc262_hippo_unsol_event,
10958 .init_hook = alc262_hippo_automute, 11301 .init_hook = alc262_hippo_init_hook,
10959 }, 11302 },
10960 [ALC262_HIPPO_1] = { 11303 [ALC262_HIPPO_1] = {
10961 .mixers = { alc262_hippo1_mixer }, 11304 .mixers = { alc262_hippo1_mixer },
@@ -10967,8 +11310,8 @@ static struct alc_config_preset alc262_presets[] = {
10967 .num_channel_mode = ARRAY_SIZE(alc262_modes), 11310 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10968 .channel_mode = alc262_modes, 11311 .channel_mode = alc262_modes,
10969 .input_mux = &alc262_capture_source, 11312 .input_mux = &alc262_capture_source,
10970 .unsol_event = alc262_hippo1_unsol_event, 11313 .unsol_event = alc262_hippo_unsol_event,
10971 .init_hook = alc262_hippo1_automute, 11314 .init_hook = alc262_hippo1_init_hook,
10972 }, 11315 },
10973 [ALC262_FUJITSU] = { 11316 [ALC262_FUJITSU] = {
10974 .mixers = { alc262_fujitsu_mixer }, 11317 .mixers = { alc262_fujitsu_mixer },
@@ -11030,7 +11373,7 @@ static struct alc_config_preset alc262_presets[] = {
11030 .num_channel_mode = ARRAY_SIZE(alc262_modes), 11373 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11031 .channel_mode = alc262_modes, 11374 .channel_mode = alc262_modes,
11032 .input_mux = &alc262_capture_source, 11375 .input_mux = &alc262_capture_source,
11033 .unsol_event = alc262_hp_t5735_unsol_event, 11376 .unsol_event = alc_automute_amp_unsol_event,
11034 .init_hook = alc262_hp_t5735_init_hook, 11377 .init_hook = alc262_hp_t5735_init_hook,
11035 }, 11378 },
11036 [ALC262_HP_RP5700] = { 11379 [ALC262_HP_RP5700] = {
@@ -11062,7 +11405,7 @@ static struct alc_config_preset alc262_presets[] = {
11062 .channel_mode = alc262_modes, 11405 .channel_mode = alc262_modes,
11063 .input_mux = &alc262_capture_source, 11406 .input_mux = &alc262_capture_source,
11064 .unsol_event = alc262_hippo_unsol_event, 11407 .unsol_event = alc262_hippo_unsol_event,
11065 .init_hook = alc262_hippo_automute, 11408 .init_hook = alc262_hippo_init_hook,
11066 }, 11409 },
11067 [ALC262_BENQ_T31] = { 11410 [ALC262_BENQ_T31] = {
11068 .mixers = { alc262_benq_t31_mixer }, 11411 .mixers = { alc262_benq_t31_mixer },
@@ -11074,7 +11417,7 @@ static struct alc_config_preset alc262_presets[] = {
11074 .channel_mode = alc262_modes, 11417 .channel_mode = alc262_modes,
11075 .input_mux = &alc262_capture_source, 11418 .input_mux = &alc262_capture_source,
11076 .unsol_event = alc262_hippo_unsol_event, 11419 .unsol_event = alc262_hippo_unsol_event,
11077 .init_hook = alc262_hippo_automute, 11420 .init_hook = alc262_hippo_init_hook,
11078 }, 11421 },
11079 [ALC262_ULTRA] = { 11422 [ALC262_ULTRA] = {
11080 .mixers = { alc262_ultra_mixer }, 11423 .mixers = { alc262_ultra_mixer },
@@ -11139,7 +11482,7 @@ static struct alc_config_preset alc262_presets[] = {
11139 .channel_mode = alc262_modes, 11482 .channel_mode = alc262_modes,
11140 .input_mux = &alc262_capture_source, 11483 .input_mux = &alc262_capture_source,
11141 .unsol_event = alc262_hippo_unsol_event, 11484 .unsol_event = alc262_hippo_unsol_event,
11142 .init_hook = alc262_hippo_automute, 11485 .init_hook = alc262_hippo_init_hook,
11143 }, 11486 },
11144 [ALC262_TYAN] = { 11487 [ALC262_TYAN] = {
11145 .mixers = { alc262_tyan_mixer }, 11488 .mixers = { alc262_tyan_mixer },
@@ -11151,8 +11494,8 @@ static struct alc_config_preset alc262_presets[] = {
11151 .num_channel_mode = ARRAY_SIZE(alc262_modes), 11494 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11152 .channel_mode = alc262_modes, 11495 .channel_mode = alc262_modes,
11153 .input_mux = &alc262_capture_source, 11496 .input_mux = &alc262_capture_source,
11154 .unsol_event = alc262_tyan_unsol_event, 11497 .unsol_event = alc_automute_amp_unsol_event,
11155 .init_hook = alc262_tyan_automute, 11498 .init_hook = alc262_tyan_init_hook,
11156 }, 11499 },
11157}; 11500};
11158 11501
@@ -11187,8 +11530,8 @@ static int patch_alc262(struct hda_codec *codec)
11187 alc262_cfg_tbl); 11530 alc262_cfg_tbl);
11188 11531
11189 if (board_config < 0) { 11532 if (board_config < 0) {
11190 printk(KERN_INFO "hda_codec: Unknown model for ALC262, " 11533 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11191 "trying auto-probe from BIOS...\n"); 11534 "trying auto-probe from BIOS...\n", codec->chip_name);
11192 board_config = ALC262_AUTO; 11535 board_config = ALC262_AUTO;
11193 } 11536 }
11194 11537
@@ -11217,11 +11560,9 @@ static int patch_alc262(struct hda_codec *codec)
11217 if (board_config != ALC262_AUTO) 11560 if (board_config != ALC262_AUTO)
11218 setup_preset(spec, &alc262_presets[board_config]); 11561 setup_preset(spec, &alc262_presets[board_config]);
11219 11562
11220 spec->stream_name_analog = "ALC262 Analog";
11221 spec->stream_analog_playback = &alc262_pcm_analog_playback; 11563 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11222 spec->stream_analog_capture = &alc262_pcm_analog_capture; 11564 spec->stream_analog_capture = &alc262_pcm_analog_capture;
11223 11565
11224 spec->stream_name_digital = "ALC262 Digital";
11225 spec->stream_digital_playback = &alc262_pcm_digital_playback; 11566 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11226 spec->stream_digital_capture = &alc262_pcm_digital_capture; 11567 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11227 11568
@@ -11296,6 +11637,17 @@ static struct snd_kcontrol_new alc268_base_mixer[] = {
11296 { } 11637 { }
11297}; 11638};
11298 11639
11640static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11641 /* output mixer control */
11642 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11643 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11644 ALC262_HIPPO_MASTER_SWITCH,
11645 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11646 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11647 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11648 { }
11649};
11650
11299/* bind Beep switches of both NID 0x0f and 0x10 */ 11651/* bind Beep switches of both NID 0x0f and 0x10 */
11300static struct hda_bind_ctls alc268_bind_beep_sw = { 11652static struct hda_bind_ctls alc268_bind_beep_sw = {
11301 .ops = &snd_hda_bind_sw, 11653 .ops = &snd_hda_bind_sw,
@@ -11319,8 +11671,6 @@ static struct hda_verb alc268_eapd_verbs[] = {
11319}; 11671};
11320 11672
11321/* Toshiba specific */ 11673/* Toshiba specific */
11322#define alc268_toshiba_automute alc262_hippo_automute
11323
11324static struct hda_verb alc268_toshiba_verbs[] = { 11674static struct hda_verb alc268_toshiba_verbs[] = {
11325 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 11675 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11326 { } /* end */ 11676 { } /* end */
@@ -11456,13 +11806,8 @@ static struct hda_verb alc268_acer_verbs[] = {
11456}; 11806};
11457 11807
11458/* unsolicited event for HP jack sensing */ 11808/* unsolicited event for HP jack sensing */
11459static void alc268_toshiba_unsol_event(struct hda_codec *codec, 11809#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11460 unsigned int res) 11810#define alc268_toshiba_init_hook alc262_hippo_init_hook
11461{
11462 if ((res >> 26) != ALC880_HP_EVENT)
11463 return;
11464 alc268_toshiba_automute(codec);
11465}
11466 11811
11467static void alc268_acer_unsol_event(struct hda_codec *codec, 11812static void alc268_acer_unsol_event(struct hda_codec *codec,
11468 unsigned int res) 11813 unsigned int res)
@@ -11537,30 +11882,15 @@ static struct hda_verb alc268_dell_verbs[] = {
11537}; 11882};
11538 11883
11539/* mute/unmute internal speaker according to the hp jack and mute state */ 11884/* mute/unmute internal speaker according to the hp jack and mute state */
11540static void alc268_dell_automute(struct hda_codec *codec) 11885static void alc268_dell_init_hook(struct hda_codec *codec)
11541{ 11886{
11542 unsigned int present; 11887 struct alc_spec *spec = codec->spec;
11543 unsigned int mute;
11544
11545 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11546 if (present & 0x80000000)
11547 mute = HDA_AMP_MUTE;
11548 else
11549 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11550 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11551 HDA_AMP_MUTE, mute);
11552}
11553 11888
11554static void alc268_dell_unsol_event(struct hda_codec *codec, 11889 spec->autocfg.hp_pins[0] = 0x15;
11555 unsigned int res) 11890 spec->autocfg.speaker_pins[0] = 0x14;
11556{ 11891 alc_automute_pin(codec);
11557 if ((res >> 26) != ALC880_HP_EVENT)
11558 return;
11559 alc268_dell_automute(codec);
11560} 11892}
11561 11893
11562#define alc268_dell_init_hook alc268_dell_automute
11563
11564static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { 11894static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11565 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), 11895 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11566 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 11896 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
@@ -11579,16 +11909,6 @@ static struct hda_verb alc267_quanta_il1_verbs[] = {
11579 { } 11909 { }
11580}; 11910};
11581 11911
11582static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11583{
11584 unsigned int present;
11585
11586 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11587 & AC_PINSENSE_PRESENCE;
11588 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11589 present ? 0 : PIN_OUT);
11590}
11591
11592static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) 11912static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11593{ 11913{
11594 unsigned int present; 11914 unsigned int present;
@@ -11600,9 +11920,13 @@ static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11600 present ? 0x00 : 0x01); 11920 present ? 0x00 : 0x01);
11601} 11921}
11602 11922
11603static void alc267_quanta_il1_automute(struct hda_codec *codec) 11923static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
11604{ 11924{
11605 alc267_quanta_il1_hp_automute(codec); 11925 struct alc_spec *spec = codec->spec;
11926
11927 spec->autocfg.hp_pins[0] = 0x15;
11928 spec->autocfg.speaker_pins[0] = 0x14;
11929 alc_automute_pin(codec);
11606 alc267_quanta_il1_mic_automute(codec); 11930 alc267_quanta_il1_mic_automute(codec);
11607} 11931}
11608 11932
@@ -11610,12 +11934,12 @@ static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11610 unsigned int res) 11934 unsigned int res)
11611{ 11935{
11612 switch (res >> 26) { 11936 switch (res >> 26) {
11613 case ALC880_HP_EVENT:
11614 alc267_quanta_il1_hp_automute(codec);
11615 break;
11616 case ALC880_MIC_EVENT: 11937 case ALC880_MIC_EVENT:
11617 alc267_quanta_il1_mic_automute(codec); 11938 alc267_quanta_il1_mic_automute(codec);
11618 break; 11939 break;
11940 default:
11941 alc_sku_unsol_event(codec, res);
11942 break;
11619 } 11943 }
11620} 11944}
11621 11945
@@ -12063,16 +12387,16 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
12063 ALC268_ACER_ASPIRE_ONE), 12387 ALC268_ACER_ASPIRE_ONE),
12064 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), 12388 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
12065 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), 12389 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
12066 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), 12390 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12067 SND_PCI_QUIRK(0x103c, 0x30f1, "HP TX25xx series", ALC268_TOSHIBA), 12391 ALC268_TOSHIBA),
12068 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), 12392 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
12069 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), 12393 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12070 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), 12394 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12071 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA), 12395 ALC268_TOSHIBA),
12072 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), 12396 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
12073 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 12397 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
12074 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), 12398 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
12075 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), 12399 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
12076 {} 12400 {}
12077}; 12401};
12078 12402
@@ -12090,7 +12414,7 @@ static struct alc_config_preset alc268_presets[] = {
12090 .channel_mode = alc268_modes, 12414 .channel_mode = alc268_modes,
12091 .input_mux = &alc268_capture_source, 12415 .input_mux = &alc268_capture_source,
12092 .unsol_event = alc267_quanta_il1_unsol_event, 12416 .unsol_event = alc267_quanta_il1_unsol_event,
12093 .init_hook = alc267_quanta_il1_automute, 12417 .init_hook = alc267_quanta_il1_init_hook,
12094 }, 12418 },
12095 [ALC268_3ST] = { 12419 [ALC268_3ST] = {
12096 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 12420 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
@@ -12108,7 +12432,7 @@ static struct alc_config_preset alc268_presets[] = {
12108 .input_mux = &alc268_capture_source, 12432 .input_mux = &alc268_capture_source,
12109 }, 12433 },
12110 [ALC268_TOSHIBA] = { 12434 [ALC268_TOSHIBA] = {
12111 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 12435 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
12112 alc268_beep_mixer }, 12436 alc268_beep_mixer },
12113 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12437 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12114 alc268_toshiba_verbs }, 12438 alc268_toshiba_verbs },
@@ -12122,7 +12446,7 @@ static struct alc_config_preset alc268_presets[] = {
12122 .channel_mode = alc268_modes, 12446 .channel_mode = alc268_modes,
12123 .input_mux = &alc268_capture_source, 12447 .input_mux = &alc268_capture_source,
12124 .unsol_event = alc268_toshiba_unsol_event, 12448 .unsol_event = alc268_toshiba_unsol_event,
12125 .init_hook = alc268_toshiba_automute, 12449 .init_hook = alc268_toshiba_init_hook,
12126 }, 12450 },
12127 [ALC268_ACER] = { 12451 [ALC268_ACER] = {
12128 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, 12452 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
@@ -12185,7 +12509,7 @@ static struct alc_config_preset alc268_presets[] = {
12185 .hp_nid = 0x02, 12509 .hp_nid = 0x02,
12186 .num_channel_mode = ARRAY_SIZE(alc268_modes), 12510 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12187 .channel_mode = alc268_modes, 12511 .channel_mode = alc268_modes,
12188 .unsol_event = alc268_dell_unsol_event, 12512 .unsol_event = alc_sku_unsol_event,
12189 .init_hook = alc268_dell_init_hook, 12513 .init_hook = alc268_dell_init_hook,
12190 .input_mux = &alc268_capture_source, 12514 .input_mux = &alc268_capture_source,
12191 }, 12515 },
@@ -12205,7 +12529,7 @@ static struct alc_config_preset alc268_presets[] = {
12205 .channel_mode = alc268_modes, 12529 .channel_mode = alc268_modes,
12206 .input_mux = &alc268_capture_source, 12530 .input_mux = &alc268_capture_source,
12207 .unsol_event = alc268_toshiba_unsol_event, 12531 .unsol_event = alc268_toshiba_unsol_event,
12208 .init_hook = alc268_toshiba_automute 12532 .init_hook = alc268_toshiba_init_hook
12209 }, 12533 },
12210#ifdef CONFIG_SND_DEBUG 12534#ifdef CONFIG_SND_DEBUG
12211 [ALC268_TEST] = { 12535 [ALC268_TEST] = {
@@ -12243,8 +12567,8 @@ static int patch_alc268(struct hda_codec *codec)
12243 alc268_cfg_tbl); 12567 alc268_cfg_tbl);
12244 12568
12245 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { 12569 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12246 printk(KERN_INFO "hda_codec: Unknown model for ALC268, " 12570 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12247 "trying auto-probe from BIOS...\n"); 12571 "trying auto-probe from BIOS...\n", codec->chip_name);
12248 board_config = ALC268_AUTO; 12572 board_config = ALC268_AUTO;
12249 } 12573 }
12250 12574
@@ -12265,14 +12589,6 @@ static int patch_alc268(struct hda_codec *codec)
12265 if (board_config != ALC268_AUTO) 12589 if (board_config != ALC268_AUTO)
12266 setup_preset(spec, &alc268_presets[board_config]); 12590 setup_preset(spec, &alc268_presets[board_config]);
12267 12591
12268 if (codec->vendor_id == 0x10ec0267) {
12269 spec->stream_name_analog = "ALC267 Analog";
12270 spec->stream_name_digital = "ALC267 Digital";
12271 } else {
12272 spec->stream_name_analog = "ALC268 Analog";
12273 spec->stream_name_digital = "ALC268 Digital";
12274 }
12275
12276 spec->stream_analog_playback = &alc268_pcm_analog_playback; 12592 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12277 spec->stream_analog_capture = &alc268_pcm_analog_capture; 12593 spec->stream_analog_capture = &alc268_pcm_analog_capture;
12278 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; 12594 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
@@ -13099,8 +13415,8 @@ static int patch_alc269(struct hda_codec *codec)
13099 alc269_cfg_tbl); 13415 alc269_cfg_tbl);
13100 13416
13101 if (board_config < 0) { 13417 if (board_config < 0) {
13102 printk(KERN_INFO "hda_codec: Unknown model for ALC269, " 13418 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13103 "trying auto-probe from BIOS...\n"); 13419 "trying auto-probe from BIOS...\n", codec->chip_name);
13104 board_config = ALC269_AUTO; 13420 board_config = ALC269_AUTO;
13105 } 13421 }
13106 13422
@@ -13127,7 +13443,6 @@ static int patch_alc269(struct hda_codec *codec)
13127 if (board_config != ALC269_AUTO) 13443 if (board_config != ALC269_AUTO)
13128 setup_preset(spec, &alc269_presets[board_config]); 13444 setup_preset(spec, &alc269_presets[board_config]);
13129 13445
13130 spec->stream_name_analog = "ALC269 Analog";
13131 if (codec->subsystem_id == 0x17aa3bf8) { 13446 if (codec->subsystem_id == 0x17aa3bf8) {
13132 /* Due to a hardware problem on Lenovo Ideadpad, we need to 13447 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13133 * fix the sample rate of analog I/O to 44.1kHz 13448 * fix the sample rate of analog I/O to 44.1kHz
@@ -13138,7 +13453,6 @@ static int patch_alc269(struct hda_codec *codec)
13138 spec->stream_analog_playback = &alc269_pcm_analog_playback; 13453 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13139 spec->stream_analog_capture = &alc269_pcm_analog_capture; 13454 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13140 } 13455 }
13141 spec->stream_name_digital = "ALC269 Digital";
13142 spec->stream_digital_playback = &alc269_pcm_digital_playback; 13456 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13143 spec->stream_digital_capture = &alc269_pcm_digital_capture; 13457 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13144 13458
@@ -13927,7 +14241,6 @@ static void alc861_auto_init_multi_out(struct hda_codec *codec)
13927 struct alc_spec *spec = codec->spec; 14241 struct alc_spec *spec = codec->spec;
13928 int i; 14242 int i;
13929 14243
13930 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
13931 for (i = 0; i < spec->autocfg.line_outs; i++) { 14244 for (i = 0; i < spec->autocfg.line_outs; i++) {
13932 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 14245 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13933 int pin_type = get_pin_type(spec->autocfg.line_out_type); 14246 int pin_type = get_pin_type(spec->autocfg.line_out_type);
@@ -14010,6 +14323,8 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
14010 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 14323 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
14011 set_capture_mixer(spec); 14324 set_capture_mixer(spec);
14012 14325
14326 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14327
14013 return 1; 14328 return 1;
14014} 14329}
14015 14330
@@ -14199,8 +14514,8 @@ static int patch_alc861(struct hda_codec *codec)
14199 alc861_cfg_tbl); 14514 alc861_cfg_tbl);
14200 14515
14201 if (board_config < 0) { 14516 if (board_config < 0) {
14202 printk(KERN_INFO "hda_codec: Unknown model for ALC861, " 14517 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14203 "trying auto-probe from BIOS...\n"); 14518 "trying auto-probe from BIOS...\n", codec->chip_name);
14204 board_config = ALC861_AUTO; 14519 board_config = ALC861_AUTO;
14205 } 14520 }
14206 14521
@@ -14227,11 +14542,9 @@ static int patch_alc861(struct hda_codec *codec)
14227 if (board_config != ALC861_AUTO) 14542 if (board_config != ALC861_AUTO)
14228 setup_preset(spec, &alc861_presets[board_config]); 14543 setup_preset(spec, &alc861_presets[board_config]);
14229 14544
14230 spec->stream_name_analog = "ALC861 Analog";
14231 spec->stream_analog_playback = &alc861_pcm_analog_playback; 14545 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14232 spec->stream_analog_capture = &alc861_pcm_analog_capture; 14546 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14233 14547
14234 spec->stream_name_digital = "ALC861 Digital";
14235 spec->stream_digital_playback = &alc861_pcm_digital_playback; 14548 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14236 spec->stream_digital_capture = &alc861_pcm_digital_capture; 14549 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14237 14550
@@ -14618,19 +14931,6 @@ static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14618 {} 14931 {}
14619}; 14932};
14620 14933
14621/* toggle speaker-output according to the hp-jack state */
14622static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14623{
14624 unsigned int present;
14625 unsigned char bits;
14626
14627 present = snd_hda_codec_read(codec, 0x1b, 0,
14628 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14629 bits = present ? HDA_AMP_MUTE : 0;
14630 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14631 HDA_AMP_MUTE, bits);
14632}
14633
14634static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) 14934static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14635{ 14935{
14636 unsigned int present; 14936 unsigned int present;
@@ -14643,9 +14943,13 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14643 HDA_AMP_MUTE, bits); 14943 HDA_AMP_MUTE, bits);
14644} 14944}
14645 14945
14646static void alc861vd_lenovo_automute(struct hda_codec *codec) 14946static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
14647{ 14947{
14648 alc861vd_lenovo_hp_automute(codec); 14948 struct alc_spec *spec = codec->spec;
14949
14950 spec->autocfg.hp_pins[0] = 0x1b;
14951 spec->autocfg.speaker_pins[0] = 0x14;
14952 alc_automute_amp(codec);
14649 alc861vd_lenovo_mic_automute(codec); 14953 alc861vd_lenovo_mic_automute(codec);
14650} 14954}
14651 14955
@@ -14653,12 +14957,12 @@ static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14653 unsigned int res) 14957 unsigned int res)
14654{ 14958{
14655 switch (res >> 26) { 14959 switch (res >> 26) {
14656 case ALC880_HP_EVENT:
14657 alc861vd_lenovo_hp_automute(codec);
14658 break;
14659 case ALC880_MIC_EVENT: 14960 case ALC880_MIC_EVENT:
14660 alc861vd_lenovo_mic_automute(codec); 14961 alc861vd_lenovo_mic_automute(codec);
14661 break; 14962 break;
14963 default:
14964 alc_automute_amp_unsol_event(codec, res);
14965 break;
14662 } 14966 }
14663} 14967}
14664 14968
@@ -14708,20 +15012,13 @@ static struct hda_verb alc861vd_dallas_verbs[] = {
14708}; 15012};
14709 15013
14710/* toggle speaker-output according to the hp-jack state */ 15014/* toggle speaker-output according to the hp-jack state */
14711static void alc861vd_dallas_automute(struct hda_codec *codec) 15015static void alc861vd_dallas_init_hook(struct hda_codec *codec)
14712{ 15016{
14713 unsigned int present; 15017 struct alc_spec *spec = codec->spec;
14714
14715 present = snd_hda_codec_read(codec, 0x15, 0,
14716 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14717 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14718 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14719}
14720 15018
14721static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) 15019 spec->autocfg.hp_pins[0] = 0x15;
14722{ 15020 spec->autocfg.speaker_pins[0] = 0x14;
14723 if ((res >> 26) == ALC880_HP_EVENT) 15021 alc_automute_amp(codec);
14724 alc861vd_dallas_automute(codec);
14725} 15022}
14726 15023
14727#ifdef CONFIG_SND_HDA_POWER_SAVE 15024#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -14835,7 +15132,7 @@ static struct alc_config_preset alc861vd_presets[] = {
14835 .channel_mode = alc861vd_3stack_2ch_modes, 15132 .channel_mode = alc861vd_3stack_2ch_modes,
14836 .input_mux = &alc861vd_capture_source, 15133 .input_mux = &alc861vd_capture_source,
14837 .unsol_event = alc861vd_lenovo_unsol_event, 15134 .unsol_event = alc861vd_lenovo_unsol_event,
14838 .init_hook = alc861vd_lenovo_automute, 15135 .init_hook = alc861vd_lenovo_init_hook,
14839 }, 15136 },
14840 [ALC861VD_DALLAS] = { 15137 [ALC861VD_DALLAS] = {
14841 .mixers = { alc861vd_dallas_mixer }, 15138 .mixers = { alc861vd_dallas_mixer },
@@ -14845,8 +15142,8 @@ static struct alc_config_preset alc861vd_presets[] = {
14845 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 15142 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14846 .channel_mode = alc861vd_3stack_2ch_modes, 15143 .channel_mode = alc861vd_3stack_2ch_modes,
14847 .input_mux = &alc861vd_dallas_capture_source, 15144 .input_mux = &alc861vd_dallas_capture_source,
14848 .unsol_event = alc861vd_dallas_unsol_event, 15145 .unsol_event = alc_automute_amp_unsol_event,
14849 .init_hook = alc861vd_dallas_automute, 15146 .init_hook = alc861vd_dallas_init_hook,
14850 }, 15147 },
14851 [ALC861VD_HP] = { 15148 [ALC861VD_HP] = {
14852 .mixers = { alc861vd_hp_mixer }, 15149 .mixers = { alc861vd_hp_mixer },
@@ -14857,8 +15154,8 @@ static struct alc_config_preset alc861vd_presets[] = {
14857 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 15154 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14858 .channel_mode = alc861vd_3stack_2ch_modes, 15155 .channel_mode = alc861vd_3stack_2ch_modes,
14859 .input_mux = &alc861vd_hp_capture_source, 15156 .input_mux = &alc861vd_hp_capture_source,
14860 .unsol_event = alc861vd_dallas_unsol_event, 15157 .unsol_event = alc_automute_amp_unsol_event,
14861 .init_hook = alc861vd_dallas_automute, 15158 .init_hook = alc861vd_dallas_init_hook,
14862 }, 15159 },
14863 [ALC660VD_ASUS_V1S] = { 15160 [ALC660VD_ASUS_V1S] = {
14864 .mixers = { alc861vd_lenovo_mixer }, 15161 .mixers = { alc861vd_lenovo_mixer },
@@ -14873,7 +15170,7 @@ static struct alc_config_preset alc861vd_presets[] = {
14873 .channel_mode = alc861vd_3stack_2ch_modes, 15170 .channel_mode = alc861vd_3stack_2ch_modes,
14874 .input_mux = &alc861vd_capture_source, 15171 .input_mux = &alc861vd_capture_source,
14875 .unsol_event = alc861vd_lenovo_unsol_event, 15172 .unsol_event = alc861vd_lenovo_unsol_event,
14876 .init_hook = alc861vd_lenovo_automute, 15173 .init_hook = alc861vd_lenovo_init_hook,
14877 }, 15174 },
14878}; 15175};
14879 15176
@@ -14891,7 +15188,6 @@ static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14891 struct alc_spec *spec = codec->spec; 15188 struct alc_spec *spec = codec->spec;
14892 int i; 15189 int i;
14893 15190
14894 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
14895 for (i = 0; i <= HDA_SIDE; i++) { 15191 for (i = 0; i <= HDA_SIDE; i++) {
14896 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 15192 hda_nid_t nid = spec->autocfg.line_out_pins[i];
14897 int pin_type = get_pin_type(spec->autocfg.line_out_type); 15193 int pin_type = get_pin_type(spec->autocfg.line_out_type);
@@ -15109,6 +15405,8 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
15109 if (err < 0) 15405 if (err < 0)
15110 return err; 15406 return err;
15111 15407
15408 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15409
15112 return 1; 15410 return 1;
15113} 15411}
15114 15412
@@ -15140,8 +15438,8 @@ static int patch_alc861vd(struct hda_codec *codec)
15140 alc861vd_cfg_tbl); 15438 alc861vd_cfg_tbl);
15141 15439
15142 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { 15440 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15143 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" 15441 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15144 "ALC861VD, trying auto-probe from BIOS...\n"); 15442 "trying auto-probe from BIOS...\n", codec->chip_name);
15145 board_config = ALC861VD_AUTO; 15443 board_config = ALC861VD_AUTO;
15146 } 15444 }
15147 15445
@@ -15169,13 +15467,8 @@ static int patch_alc861vd(struct hda_codec *codec)
15169 setup_preset(spec, &alc861vd_presets[board_config]); 15467 setup_preset(spec, &alc861vd_presets[board_config]);
15170 15468
15171 if (codec->vendor_id == 0x10ec0660) { 15469 if (codec->vendor_id == 0x10ec0660) {
15172 spec->stream_name_analog = "ALC660-VD Analog";
15173 spec->stream_name_digital = "ALC660-VD Digital";
15174 /* always turn on EAPD */ 15470 /* always turn on EAPD */
15175 add_verb(spec, alc660vd_eapd_verbs); 15471 add_verb(spec, alc660vd_eapd_verbs);
15176 } else {
15177 spec->stream_name_analog = "ALC861VD Analog";
15178 spec->stream_name_digital = "ALC861VD Digital";
15179 } 15472 }
15180 15473
15181 spec->stream_analog_playback = &alc861vd_pcm_analog_playback; 15474 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
@@ -15289,6 +15582,38 @@ static struct hda_input_mux alc663_m51va_capture_source = {
15289 }, 15582 },
15290}; 15583};
15291 15584
15585#if 1 /* set to 0 for testing other input sources below */
15586static struct hda_input_mux alc272_nc10_capture_source = {
15587 .num_items = 2,
15588 .items = {
15589 { "Autoselect Mic", 0x0 },
15590 { "Internal Mic", 0x1 },
15591 },
15592};
15593#else
15594static struct hda_input_mux alc272_nc10_capture_source = {
15595 .num_items = 16,
15596 .items = {
15597 { "Autoselect Mic", 0x0 },
15598 { "Internal Mic", 0x1 },
15599 { "In-0x02", 0x2 },
15600 { "In-0x03", 0x3 },
15601 { "In-0x04", 0x4 },
15602 { "In-0x05", 0x5 },
15603 { "In-0x06", 0x6 },
15604 { "In-0x07", 0x7 },
15605 { "In-0x08", 0x8 },
15606 { "In-0x09", 0x9 },
15607 { "In-0x0a", 0x0a },
15608 { "In-0x0b", 0x0b },
15609 { "In-0x0c", 0x0c },
15610 { "In-0x0d", 0x0d },
15611 { "In-0x0e", 0x0e },
15612 { "In-0x0f", 0x0f },
15613 },
15614};
15615#endif
15616
15292/* 15617/*
15293 * 2ch mode 15618 * 2ch mode
15294 */ 15619 */
@@ -15428,10 +15753,8 @@ static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15428}; 15753};
15429 15754
15430static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { 15755static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
15431 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 15756 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15432 15757 ALC262_HIPPO_MASTER_SWITCH,
15433 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15434 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15435 15758
15436 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), 15759 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15437 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 15760 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
@@ -15444,15 +15767,11 @@ static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
15444}; 15767};
15445 15768
15446static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { 15769static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
15447 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), 15770 ALC262_HIPPO_MASTER_SWITCH,
15448 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 15771 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15449 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 15772 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15450 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15451 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 15773 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15452 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 15774 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15453 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15454 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
15455 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15456 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), 15775 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15457 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 15776 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15458 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 15777 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
@@ -15960,51 +16279,25 @@ static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15960static void alc662_eeepc_unsol_event(struct hda_codec *codec, 16279static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15961 unsigned int res) 16280 unsigned int res)
15962{ 16281{
15963 if ((res >> 26) == ALC880_HP_EVENT)
15964 alc262_hippo1_automute( codec );
15965
15966 if ((res >> 26) == ALC880_MIC_EVENT) 16282 if ((res >> 26) == ALC880_MIC_EVENT)
15967 alc662_eeepc_mic_automute(codec); 16283 alc662_eeepc_mic_automute(codec);
16284 else
16285 alc262_hippo_unsol_event(codec, res);
15968} 16286}
15969 16287
15970static void alc662_eeepc_inithook(struct hda_codec *codec) 16288static void alc662_eeepc_inithook(struct hda_codec *codec)
15971{ 16289{
15972 alc262_hippo1_automute( codec ); 16290 alc262_hippo1_init_hook(codec);
15973 alc662_eeepc_mic_automute(codec); 16291 alc662_eeepc_mic_automute(codec);
15974} 16292}
15975 16293
15976static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15977{
15978 unsigned int mute;
15979 unsigned int present;
15980
15981 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15982 present = snd_hda_codec_read(codec, 0x14, 0,
15983 AC_VERB_GET_PIN_SENSE, 0);
15984 present = (present & 0x80000000) != 0;
15985 if (present) {
15986 /* mute internal speaker */
15987 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
15988 HDA_AMP_MUTE, HDA_AMP_MUTE);
15989 } else {
15990 /* unmute internal speaker if necessary */
15991 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15992 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
15993 HDA_AMP_MUTE, mute);
15994 }
15995}
15996
15997/* unsolicited event for HP jack sensing */
15998static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15999 unsigned int res)
16000{
16001 if ((res >> 26) == ALC880_HP_EVENT)
16002 alc662_eeepc_ep20_automute(codec);
16003}
16004
16005static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) 16294static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16006{ 16295{
16007 alc662_eeepc_ep20_automute(codec); 16296 struct alc_spec *spec = codec->spec;
16297
16298 spec->autocfg.hp_pins[0] = 0x14;
16299 spec->autocfg.speaker_pins[0] = 0x1b;
16300 alc262_hippo_master_update(codec);
16008} 16301}
16009 16302
16010static void alc663_m51va_speaker_automute(struct hda_codec *codec) 16303static void alc663_m51va_speaker_automute(struct hda_codec *codec)
@@ -16338,35 +16631,9 @@ static void alc663_g50v_inithook(struct hda_codec *codec)
16338 alc662_eeepc_mic_automute(codec); 16631 alc662_eeepc_mic_automute(codec);
16339} 16632}
16340 16633
16341/* bind hp and internal speaker mute (with plug check) */
16342static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16343 struct snd_ctl_elem_value *ucontrol)
16344{
16345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16346 long *valp = ucontrol->value.integer.value;
16347 int change;
16348
16349 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16350 HDA_AMP_MUTE,
16351 valp[0] ? 0 : HDA_AMP_MUTE);
16352 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16353 HDA_AMP_MUTE,
16354 valp[1] ? 0 : HDA_AMP_MUTE);
16355 if (change)
16356 alc262_hippo1_automute(codec);
16357 return change;
16358}
16359
16360static struct snd_kcontrol_new alc662_ecs_mixer[] = { 16634static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16361 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), 16635 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16362 { 16636 ALC262_HIPPO_MASTER_SWITCH,
16363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16364 .name = "Master Playback Switch",
16365 .info = snd_hda_mixer_amp_switch_info,
16366 .get = snd_hda_mixer_amp_switch_get,
16367 .put = alc662_ecs_master_sw_put,
16368 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16369 },
16370 16637
16371 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), 16638 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16372 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), 16639 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
@@ -16378,6 +16645,23 @@ static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16378 { } /* end */ 16645 { } /* end */
16379}; 16646};
16380 16647
16648static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16649 /* Master Playback automatically created from Speaker and Headphone */
16650 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16651 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16652 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16654
16655 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16656 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16657 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16658
16659 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16660 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16661 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16662 { } /* end */
16663};
16664
16381#ifdef CONFIG_SND_HDA_POWER_SAVE 16665#ifdef CONFIG_SND_HDA_POWER_SAVE
16382#define alc662_loopbacks alc880_loopbacks 16666#define alc662_loopbacks alc880_loopbacks
16383#endif 16667#endif
@@ -16411,6 +16695,9 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
16411 [ALC663_ASUS_MODE4] = "asus-mode4", 16695 [ALC663_ASUS_MODE4] = "asus-mode4",
16412 [ALC663_ASUS_MODE5] = "asus-mode5", 16696 [ALC663_ASUS_MODE5] = "asus-mode5",
16413 [ALC663_ASUS_MODE6] = "asus-mode6", 16697 [ALC663_ASUS_MODE6] = "asus-mode6",
16698 [ALC272_DELL] = "dell",
16699 [ALC272_DELL_ZM1] = "dell-zm1",
16700 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
16414 [ALC662_AUTO] = "auto", 16701 [ALC662_AUTO] = "auto",
16415}; 16702};
16416 16703
@@ -16468,6 +16755,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
16468 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), 16755 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16469 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", 16756 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16470 ALC662_3ST_6ch_DIG), 16757 ALC662_3ST_6ch_DIG),
16758 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
16471 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", 16759 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16472 ALC662_3ST_6ch_DIG), 16760 ALC662_3ST_6ch_DIG),
16473 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), 16761 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
@@ -16558,7 +16846,7 @@ static struct alc_config_preset alc662_presets[] = {
16558 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 16846 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16559 .channel_mode = alc662_3ST_6ch_modes, 16847 .channel_mode = alc662_3ST_6ch_modes,
16560 .input_mux = &alc662_lenovo_101e_capture_source, 16848 .input_mux = &alc662_lenovo_101e_capture_source,
16561 .unsol_event = alc662_eeepc_ep20_unsol_event, 16849 .unsol_event = alc662_eeepc_unsol_event,
16562 .init_hook = alc662_eeepc_ep20_inithook, 16850 .init_hook = alc662_eeepc_ep20_inithook,
16563 }, 16851 },
16564 [ALC662_ECS] = { 16852 [ALC662_ECS] = {
@@ -16739,6 +17027,18 @@ static struct alc_config_preset alc662_presets[] = {
16739 .unsol_event = alc663_m51va_unsol_event, 17027 .unsol_event = alc663_m51va_unsol_event,
16740 .init_hook = alc663_m51va_inithook, 17028 .init_hook = alc663_m51va_inithook,
16741 }, 17029 },
17030 [ALC272_SAMSUNG_NC10] = {
17031 .mixers = { alc272_nc10_mixer },
17032 .init_verbs = { alc662_init_verbs,
17033 alc663_21jd_amic_init_verbs },
17034 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17035 .dac_nids = alc272_dac_nids,
17036 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17037 .channel_mode = alc662_3ST_2ch_modes,
17038 .input_mux = &alc272_nc10_capture_source,
17039 .unsol_event = alc663_mode4_unsol_event,
17040 .init_hook = alc663_mode4_inithook,
17041 },
16742}; 17042};
16743 17043
16744 17044
@@ -16933,7 +17233,6 @@ static void alc662_auto_init_multi_out(struct hda_codec *codec)
16933 struct alc_spec *spec = codec->spec; 17233 struct alc_spec *spec = codec->spec;
16934 int i; 17234 int i;
16935 17235
16936 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
16937 for (i = 0; i <= HDA_SIDE; i++) { 17236 for (i = 0; i <= HDA_SIDE; i++) {
16938 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 17237 hda_nid_t nid = spec->autocfg.line_out_pins[i];
16939 int pin_type = get_pin_type(spec->autocfg.line_out_type); 17238 int pin_type = get_pin_type(spec->autocfg.line_out_type);
@@ -17030,6 +17329,8 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
17030 if (err < 0) 17329 if (err < 0)
17031 return err; 17330 return err;
17032 17331
17332 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17333
17033 return 1; 17334 return 1;
17034} 17335}
17035 17336
@@ -17062,8 +17363,8 @@ static int patch_alc662(struct hda_codec *codec)
17062 alc662_models, 17363 alc662_models,
17063 alc662_cfg_tbl); 17364 alc662_cfg_tbl);
17064 if (board_config < 0) { 17365 if (board_config < 0) {
17065 printk(KERN_INFO "hda_codec: Unknown model for ALC662, " 17366 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17066 "trying auto-probe from BIOS...\n"); 17367 "trying auto-probe from BIOS...\n", codec->chip_name);
17067 board_config = ALC662_AUTO; 17368 board_config = ALC662_AUTO;
17068 } 17369 }
17069 17370
@@ -17090,17 +17391,6 @@ static int patch_alc662(struct hda_codec *codec)
17090 if (board_config != ALC662_AUTO) 17391 if (board_config != ALC662_AUTO)
17091 setup_preset(spec, &alc662_presets[board_config]); 17392 setup_preset(spec, &alc662_presets[board_config]);
17092 17393
17093 if (codec->vendor_id == 0x10ec0663) {
17094 spec->stream_name_analog = "ALC663 Analog";
17095 spec->stream_name_digital = "ALC663 Digital";
17096 } else if (codec->vendor_id == 0x10ec0272) {
17097 spec->stream_name_analog = "ALC272 Analog";
17098 spec->stream_name_digital = "ALC272 Digital";
17099 } else {
17100 spec->stream_name_analog = "ALC662 Analog";
17101 spec->stream_name_digital = "ALC662 Digital";
17102 }
17103
17104 spec->stream_analog_playback = &alc662_pcm_analog_playback; 17394 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17105 spec->stream_analog_capture = &alc662_pcm_analog_capture; 17395 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17106 17396