1 /*
2  * ALC882/ALC883/ALC888/ALC889 quirk models
3  * included by patch_realtek.c
4  */
5 
6 /* ALC882 models */
7 enum {
8 	ALC882_AUTO,
9 	ALC885_MBA21,
10 	ALC885_MBP3,
11 	ALC885_MB5,
12 	ALC885_MACMINI3,
13 	ALC885_IMAC91,
14 	ALC889A_MB31,
15 	ALC882_MODEL_LAST,
16 };
17 
18 #define ALC882_DIGOUT_NID	0x06
19 #define ALC882_DIGIN_NID	0x0a
20 #define ALC883_DIGOUT_NID	ALC882_DIGOUT_NID
21 #define ALC883_DIGIN_NID	ALC882_DIGIN_NID
22 #define ALC1200_DIGOUT_NID	0x10
23 
24 
25 static const struct hda_channel_mode alc882_ch_modes[1] = {
26 	{ 8, NULL }
27 };
28 
29 /* DACs */
30 static const hda_nid_t alc882_dac_nids[4] = {
31 	/* front, rear, clfe, rear_surr */
32 	0x02, 0x03, 0x04, 0x05
33 };
34 #define alc883_dac_nids		alc882_dac_nids
35 
36 /* ADCs */
37 #define alc882_adc_nids		alc880_adc_nids
38 #define alc882_adc_nids_alt	alc880_adc_nids_alt
39 #define alc883_adc_nids		alc882_adc_nids_alt
40 
41 static const hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
42 #define alc883_capsrc_nids	alc882_capsrc_nids_alt
43 
44 /* input MUX */
45 /* FIXME: should be a matrix-type input source selection */
46 
47 static const struct hda_input_mux alc882_capture_source = {
48 	.num_items = 4,
49 	.items = {
50 		{ "Mic", 0x0 },
51 		{ "Front Mic", 0x1 },
52 		{ "Line", 0x2 },
53 		{ "CD", 0x4 },
54 	},
55 };
56 
57 #define alc883_capture_source	alc882_capture_source
58 
59 static const struct hda_input_mux mb5_capture_source = {
60 	.num_items = 3,
61 	.items = {
62 		{ "Mic", 0x1 },
63 		{ "Line", 0x7 },
64 		{ "CD", 0x4 },
65 	},
66 };
67 
68 static const struct hda_input_mux macmini3_capture_source = {
69 	.num_items = 2,
70 	.items = {
71 		{ "Line", 0x2 },
72 		{ "CD", 0x4 },
73 	},
74 };
75 
76 static const struct hda_input_mux alc883_3stack_6ch_intel = {
77 	.num_items = 4,
78 	.items = {
79 		{ "Mic", 0x1 },
80 		{ "Front Mic", 0x0 },
81 		{ "Line", 0x2 },
82 		{ "CD", 0x4 },
83 	},
84 };
85 
86 static const struct hda_input_mux alc889A_mb31_capture_source = {
87 	.num_items = 2,
88 	.items = {
89 		{ "Mic", 0x0 },
90 		/* Front Mic (0x01) unused */
91 		{ "Line", 0x2 },
92 		/* Line 2 (0x03) unused */
93 		/* CD (0x04) unused? */
94 	},
95 };
96 
97 static const struct hda_input_mux alc889A_imac91_capture_source = {
98 	.num_items = 2,
99 	.items = {
100 		{ "Mic", 0x01 },
101 		{ "Line", 0x2 }, /* Not sure! */
102 	},
103 };
104 
105 /* Macbook Air 2,1 */
106 
107 static const struct hda_channel_mode alc885_mba21_ch_modes[1] = {
108       { 2, NULL },
109 };
110 
111 /*
112  * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
113  */
114 
115 /*
116  * 2ch mode
117  */
118 static const struct hda_verb alc885_mbp_ch2_init[] = {
119 	{ 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
120 	{ 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
121 	{ 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
122 	{ } /* end */
123 };
124 
125 /*
126  * 4ch mode
127  */
128 static const struct hda_verb alc885_mbp_ch4_init[] = {
129 	{ 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
130 	{ 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
131 	{ 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
132 	{ 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
133 	{ 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
134 	{ } /* end */
135 };
136 
137 static const struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
138 	{ 2, alc885_mbp_ch2_init },
139 	{ 4, alc885_mbp_ch4_init },
140 };
141 
142 /*
143  * 2ch
144  * Speakers/Woofer/HP = Front
145  * LineIn = Input
146  */
147 static const struct hda_verb alc885_mb5_ch2_init[] = {
148 	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
149 	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
150 	{ } /* end */
151 };
152 
153 /*
154  * 6ch mode
155  * Speakers/HP = Front
156  * Woofer = LFE
157  * LineIn = Surround
158  */
159 static const struct hda_verb alc885_mb5_ch6_init[] = {
160 	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
161 	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
162 	{0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
163 	{ } /* end */
164 };
165 
166 static const struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
167 	{ 2, alc885_mb5_ch2_init },
168 	{ 6, alc885_mb5_ch6_init },
169 };
170 
171 #define alc885_macmini3_6ch_modes	alc885_mb5_6ch_modes
172 
173 /* Macbook Air 2,1 same control for HP and internal Speaker */
174 
175 static const struct snd_kcontrol_new alc885_mba21_mixer[] = {
176       HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
177       HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
178      { }
179 };
180 
181 
182 static const struct snd_kcontrol_new alc885_mbp3_mixer[] = {
183 	HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
184 	HDA_BIND_MUTE   ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
185 	HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
186 	HDA_BIND_MUTE   ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
187 	HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
188 	HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
189 	HDA_CODEC_MUTE  ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
190 	HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
191 	HDA_CODEC_MUTE  ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
192 	HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
193 	HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
194 	{ } /* end */
195 };
196 
197 static const struct snd_kcontrol_new alc885_mb5_mixer[] = {
198 	HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
199 	HDA_BIND_MUTE   ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
200 	HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
201 	HDA_BIND_MUTE   ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
202 	HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
203 	HDA_BIND_MUTE   ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
204 	HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
205 	HDA_BIND_MUTE   ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
206 	HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
207 	HDA_CODEC_MUTE  ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
208 	HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
209 	HDA_CODEC_MUTE  ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
210 	HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
211 	HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
212 	{ } /* end */
213 };
214 
215 static const struct snd_kcontrol_new alc885_macmini3_mixer[] = {
216 	HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
217 	HDA_BIND_MUTE   ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
218 	HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
219 	HDA_BIND_MUTE   ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
220 	HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
221 	HDA_BIND_MUTE   ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
222 	HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
223 	HDA_BIND_MUTE   ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
224 	HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
225 	HDA_CODEC_MUTE  ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
226 	HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
227 	{ } /* end */
228 };
229 
230 static const struct snd_kcontrol_new alc885_imac91_mixer[] = {
231 	HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
232 	HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
233 	{ } /* end */
234 };
235 
236 
237 static const struct snd_kcontrol_new alc882_chmode_mixer[] = {
238 	{
239 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
240 		.name = "Channel Mode",
241 		.info = alc_ch_mode_info,
242 		.get = alc_ch_mode_get,
243 		.put = alc_ch_mode_put,
244 	},
245 	{ } /* end */
246 };
247 
248 static const struct hda_verb alc882_base_init_verbs[] = {
249 	/* Front mixer: unmute input/output amp left and right (volume = 0) */
250 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
251 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
252 	/* Rear mixer */
253 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
254 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
255 	/* CLFE mixer */
256 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
257 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
258 	/* Side mixer */
259 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
260 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
261 
262 	/* Front Pin: output 0 (0x0c) */
263 	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
264 	{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
265 	{0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
266 	/* Rear Pin: output 1 (0x0d) */
267 	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
268 	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
269 	{0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
270 	/* CLFE Pin: output 2 (0x0e) */
271 	{0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
272 	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
273 	{0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
274 	/* Side Pin: output 3 (0x0f) */
275 	{0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
276 	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
277 	{0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
278 	/* Mic (rear) pin: input vref at 80% */
279 	{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
280 	{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
281 	/* Front Mic pin: input vref at 80% */
282 	{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
283 	{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
284 	/* Line In pin: input */
285 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
286 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
287 	/* Line-2 In: Headphone output (output 0 - 0x0c) */
288 	{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
289 	{0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
290 	{0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
291 	/* CD pin widget for input */
292 	{0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
293 
294 	/* FIXME: use matrix-type input source selection */
295 	/* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
296 	/* Input mixer2 */
297 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
298 	/* Input mixer3 */
299 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
300 	/* ADC2: mute amp left and right */
301 	{0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
302 	{0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
303 	/* ADC3: mute amp left and right */
304 	{0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
305 	{0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
306 
307 	{ }
308 };
309 
310 #define alc883_init_verbs	alc882_base_init_verbs
311 
312 /* Macbook 5,1 */
313 static const struct hda_verb alc885_mb5_init_verbs[] = {
314 	/* DACs */
315 	{0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
316 	{0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
317 	{0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
318 	{0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
319 	/* Front mixer */
320 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
321 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
322 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
323 	/* Surround mixer */
324 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
325 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
326 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
327 	/* LFE mixer */
328 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
329 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
330 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
331 	/* HP mixer */
332 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
333 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
334 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
335 	/* Front Pin (0x0c) */
336 	{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
337 	{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
338 	{0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
339 	/* LFE Pin (0x0e) */
340 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
341 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
342 	{0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
343 	/* HP Pin (0x0f) */
344 	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
345 	{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
346 	{0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
347 	{0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
348 	/* Front Mic pin: input vref at 80% */
349 	{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
350 	{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
351 	/* Line In pin */
352 	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
353 	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
354 
355 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
356 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
357 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
358 	{ }
359 };
360 
361 /* Macmini 3,1 */
362 static const struct hda_verb alc885_macmini3_init_verbs[] = {
363 	/* DACs */
364 	{0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
365 	{0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
366 	{0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
367 	{0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
368 	/* Front mixer */
369 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
370 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
371 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
372 	/* Surround mixer */
373 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
374 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
375 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
376 	/* LFE mixer */
377 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
378 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
379 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
380 	/* HP mixer */
381 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
382 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
383 	{0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
384 	/* Front Pin (0x0c) */
385 	{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
386 	{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
387 	{0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
388 	/* LFE Pin (0x0e) */
389 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
390 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
391 	{0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
392 	/* HP Pin (0x0f) */
393 	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
394 	{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
395 	{0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
396 	{0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
397 	/* Line In pin */
398 	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
399 	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
400 
401 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
402 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
403 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
404 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
405 	{ }
406 };
407 
408 
409 static const struct hda_verb alc885_mba21_init_verbs[] = {
410 	/*Internal and HP Speaker Mixer*/
411 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
412 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
413 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
414 	/*Internal Speaker Pin (0x0c)*/
415 	{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
416 	{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
417 	{0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
418 	/* HP Pin: output 0 (0x0e) */
419 	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
420 	{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
421 	{0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
422 	{0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC_HP_EVENT | AC_USRSP_EN)},
423 	/* Line in (is hp when jack connected)*/
424 	{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
425 	{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
426 
427 	{ }
428  };
429 
430 
431 /* Macbook Pro rev3 */
432 static const struct hda_verb alc885_mbp3_init_verbs[] = {
433 	/* Front mixer: unmute input/output amp left and right (volume = 0) */
434 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
435 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
436 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
437 	/* Rear mixer */
438 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
439 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
440 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
441 	/* HP mixer */
442 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
443 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
444 	{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
445 	/* Front Pin: output 0 (0x0c) */
446 	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
447 	{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
448 	{0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
449 	/* HP Pin: output 0 (0x0e) */
450 	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
451 	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
452 	{0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
453 	{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
454 	/* Mic (rear) pin: input vref at 80% */
455 	{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
456 	{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
457 	/* Front Mic pin: input vref at 80% */
458 	{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
459 	{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
460 	/* Line In pin: use output 1 when in LineOut mode */
461 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
462 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
463 	{0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
464 
465 	/* FIXME: use matrix-type input source selection */
466 	/* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
467 	/* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
468 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
469 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
470 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
471 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
472 	/* Input mixer2 */
473 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
474 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
475 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
476 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
477 	/* Input mixer3 */
478 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
479 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
480 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
481 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
482 	/* ADC1: mute amp left and right */
483 	{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
484 	{0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
485 	/* ADC2: mute amp left and right */
486 	{0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
487 	{0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
488 	/* ADC3: mute amp left and right */
489 	{0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
490 	{0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
491 
492 	{ }
493 };
494 
495 /* iMac 9,1 */
496 static const struct hda_verb alc885_imac91_init_verbs[] = {
497 	/* Internal Speaker Pin (0x0c) */
498 	{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
499 	{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
500 	{0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
501 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
502 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
503 	{0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
504 	/* HP Pin: Rear */
505 	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
506 	{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
507 	{0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
508 	{0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC_HP_EVENT | AC_USRSP_EN)},
509 	/* Line in Rear */
510 	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
511 	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
512 	/* Front Mic pin: input vref at 80% */
513 	{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
514 	{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
515 	/* Rear mixer */
516 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
517 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
518 	{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
519 	/* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
520 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
521 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
522 	{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
523 	/* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
524 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
525 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
526 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
527 	{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
528 	/* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
529 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
530 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
531 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
532 	{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
533 	/* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
534 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
535 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
536 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
537 	{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
538 	/* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
539 	{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
540 	{0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
541 	/* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
542 	{0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
543 	{0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
544 	/* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
545 	{0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
546 	{0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
547 	{ }
548 };
549 
550 /* Toggle speaker-output according to the hp-jack state */
alc885_imac24_setup(struct hda_codec * codec)551 static void alc885_imac24_setup(struct hda_codec *codec)
552 {
553 	struct alc_spec *spec = codec->spec;
554 
555 	spec->autocfg.hp_pins[0] = 0x14;
556 	spec->autocfg.speaker_pins[0] = 0x18;
557 	spec->autocfg.speaker_pins[1] = 0x1a;
558 	alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
559 }
560 
561 #define alc885_mb5_setup	alc885_imac24_setup
562 #define alc885_macmini3_setup	alc885_imac24_setup
563 
564 /* Macbook Air 2,1 */
alc885_mba21_setup(struct hda_codec * codec)565 static void alc885_mba21_setup(struct hda_codec *codec)
566 {
567 	struct alc_spec *spec = codec->spec;
568 
569 	spec->autocfg.hp_pins[0] = 0x14;
570 	spec->autocfg.speaker_pins[0] = 0x18;
571 	alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
572 }
573 
574 
575 
alc885_mbp3_setup(struct hda_codec * codec)576 static void alc885_mbp3_setup(struct hda_codec *codec)
577 {
578 	struct alc_spec *spec = codec->spec;
579 
580 	spec->autocfg.hp_pins[0] = 0x15;
581 	spec->autocfg.speaker_pins[0] = 0x14;
582 	alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
583 }
584 
alc885_imac91_setup(struct hda_codec * codec)585 static void alc885_imac91_setup(struct hda_codec *codec)
586 {
587 	struct alc_spec *spec = codec->spec;
588 
589 	spec->autocfg.hp_pins[0] = 0x14;
590 	spec->autocfg.speaker_pins[0] = 0x18;
591 	spec->autocfg.speaker_pins[1] = 0x1a;
592 	alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
593 }
594 
595 /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
596 static const struct hda_verb alc889A_mb31_ch2_init[] = {
597 	{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},             /* HP as front */
598 	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
599 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},    /* Line as input */
600 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},   /* Line off */
601 	{ } /* end */
602 };
603 
604 /* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
605 static const struct hda_verb alc889A_mb31_ch4_init[] = {
606 	{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},             /* HP as front */
607 	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
608 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},   /* Line as output */
609 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
610 	{ } /* end */
611 };
612 
613 /* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
614 static const struct hda_verb alc889A_mb31_ch5_init[] = {
615 	{0x15, AC_VERB_SET_CONNECT_SEL, 0x01},             /* HP as rear */
616 	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
617 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},    /* Line as input */
618 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},   /* Line off */
619 	{ } /* end */
620 };
621 
622 /* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
623 static const struct hda_verb alc889A_mb31_ch6_init[] = {
624 	{0x15, AC_VERB_SET_CONNECT_SEL, 0x01},             /* HP as front */
625 	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},   /* Subwoofer off */
626 	{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},   /* Line as output */
627 	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
628 	{ } /* end */
629 };
630 
631 static const struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
632 	{ 2, alc889A_mb31_ch2_init },
633 	{ 4, alc889A_mb31_ch4_init },
634 	{ 5, alc889A_mb31_ch5_init },
635 	{ 6, alc889A_mb31_ch6_init },
636 };
637 
638 static const struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
639 	HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
640 	HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
641 	HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
642 	HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
643 	HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
644 	HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
645 	HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
646 	HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
647 	HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
648 	HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
649 	HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
650 	HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
651 	HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
652 	HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
653 	HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
654 	HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
655 	HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
656 	HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
657 	HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
658 	{ } /* end */
659 };
660 
661 static const struct snd_kcontrol_new alc889A_mb31_mixer[] = {
662 	/* Output mixers */
663 	HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
664 	HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
665 	HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
666 	HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
667 	HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
668 		HDA_OUTPUT),
669 	HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
670 	HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
671 	HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
672 	/* Output switches */
673 	HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
674 	HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
675 	HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
676 	/* Boost mixers */
677 	HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
678 	HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
679 	/* Input mixers */
680 	HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
681 	HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
682 	HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
683 	HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
684 	{ } /* end */
685 };
686 
687 static const struct snd_kcontrol_new alc883_chmode_mixer[] = {
688 	{
689 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
690 		.name = "Channel Mode",
691 		.info = alc_ch_mode_info,
692 		.get = alc_ch_mode_get,
693 		.put = alc_ch_mode_put,
694 	},
695 	{ } /* end */
696 };
697 
698 static const struct hda_verb alc889A_mb31_verbs[] = {
699 	/* Init rear pin (used as headphone output) */
700 	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},    /* Apple Headphones */
701 	{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},           /* Connect to front */
702 	{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
703 	/* Init line pin (used as output in 4ch and 6ch mode) */
704 	{0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},           /* Connect to CLFE */
705 	/* Init line 2 pin (used as headphone out by default) */
706 	{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},  /* Use as input */
707 	{0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
708 	{ } /* end */
709 };
710 
711 /* Mute speakers according to the headphone jack state */
alc889A_mb31_automute(struct hda_codec * codec)712 static void alc889A_mb31_automute(struct hda_codec *codec)
713 {
714 	unsigned int present;
715 
716 	/* Mute only in 2ch or 4ch mode */
717 	if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
718 	    == 0x00) {
719 		present = snd_hda_jack_detect(codec, 0x15);
720 		snd_hda_codec_amp_stereo(codec, 0x14,  HDA_OUTPUT, 0,
721 			HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
722 		snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
723 			HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
724 	}
725 }
726 
alc889A_mb31_unsol_event(struct hda_codec * codec,unsigned int res)727 static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
728 {
729 	if ((res >> 26) == ALC_HP_EVENT)
730 		alc889A_mb31_automute(codec);
731 }
732 
alc882_unsol_event(struct hda_codec * codec,unsigned int res)733 static void alc882_unsol_event(struct hda_codec *codec, unsigned int res)
734 {
735 	alc_exec_unsol_event(codec, res >> 26);
736 }
737 
738 /*
739  * configuration and preset
740  */
741 static const char * const alc882_models[ALC882_MODEL_LAST] = {
742 	[ALC885_MB5]		= "mb5",
743 	[ALC885_MACMINI3]	= "macmini3",
744 	[ALC885_MBA21]		= "mba21",
745 	[ALC885_MBP3]		= "mbp3",
746 	[ALC885_IMAC91]		= "imac91",
747 	[ALC889A_MB31]		= "mb31",
748 	[ALC882_AUTO]		= "auto",
749 };
750 
751 /* codec SSID table for Intel Mac */
752 static const struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
753 	SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
754 	SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
755 	SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
756 	SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
757 	SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
758 	SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
759 	SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
760 	SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
761 	SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
762 	SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
763 	SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
764 	SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
765 	/* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
766 	 * so apparently no perfect solution yet
767 	 */
768 	SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
769 	SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
770 	SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
771 	{} /* terminator */
772 };
773 
774 static const struct alc_config_preset alc882_presets[] = {
775 	   [ALC885_MBA21] = {
776 			.mixers = { alc885_mba21_mixer },
777 			.init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
778 			.num_dacs = 2,
779 			.dac_nids = alc882_dac_nids,
780 			.channel_mode = alc885_mba21_ch_modes,
781 			.num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
782 			.input_mux = &alc882_capture_source,
783 			.unsol_event = alc882_unsol_event,
784 			.setup = alc885_mba21_setup,
785 			.init_hook = alc_hp_automute,
786        },
787 	[ALC885_MBP3] = {
788 		.mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
789 		.init_verbs = { alc885_mbp3_init_verbs,
790 				alc880_gpio1_init_verbs },
791 		.num_dacs = 2,
792 		.dac_nids = alc882_dac_nids,
793 		.hp_nid = 0x04,
794 		.channel_mode = alc885_mbp_4ch_modes,
795 		.num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
796 		.input_mux = &alc882_capture_source,
797 		.dig_out_nid = ALC882_DIGOUT_NID,
798 		.dig_in_nid = ALC882_DIGIN_NID,
799 		.unsol_event = alc882_unsol_event,
800 		.setup = alc885_mbp3_setup,
801 		.init_hook = alc_hp_automute,
802 	},
803 	[ALC885_MB5] = {
804 		.mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
805 		.init_verbs = { alc885_mb5_init_verbs,
806 				alc880_gpio1_init_verbs },
807 		.num_dacs = ARRAY_SIZE(alc882_dac_nids),
808 		.dac_nids = alc882_dac_nids,
809 		.channel_mode = alc885_mb5_6ch_modes,
810 		.num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
811 		.input_mux = &mb5_capture_source,
812 		.dig_out_nid = ALC882_DIGOUT_NID,
813 		.dig_in_nid = ALC882_DIGIN_NID,
814 		.unsol_event = alc882_unsol_event,
815 		.setup = alc885_mb5_setup,
816 		.init_hook = alc_hp_automute,
817 	},
818 	[ALC885_MACMINI3] = {
819 		.mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
820 		.init_verbs = { alc885_macmini3_init_verbs,
821 				alc880_gpio1_init_verbs },
822 		.num_dacs = ARRAY_SIZE(alc882_dac_nids),
823 		.dac_nids = alc882_dac_nids,
824 		.channel_mode = alc885_macmini3_6ch_modes,
825 		.num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
826 		.input_mux = &macmini3_capture_source,
827 		.dig_out_nid = ALC882_DIGOUT_NID,
828 		.dig_in_nid = ALC882_DIGIN_NID,
829 		.unsol_event = alc882_unsol_event,
830 		.setup = alc885_macmini3_setup,
831 		.init_hook = alc_hp_automute,
832 	},
833 	[ALC885_IMAC91] = {
834 		.mixers = {alc885_imac91_mixer},
835 		.init_verbs = { alc885_imac91_init_verbs,
836 				alc880_gpio1_init_verbs },
837 		.num_dacs = ARRAY_SIZE(alc882_dac_nids),
838 		.dac_nids = alc882_dac_nids,
839 		.channel_mode = alc885_mba21_ch_modes,
840 		.num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
841 		.input_mux = &alc889A_imac91_capture_source,
842 		.dig_out_nid = ALC882_DIGOUT_NID,
843 		.dig_in_nid = ALC882_DIGIN_NID,
844 		.unsol_event = alc882_unsol_event,
845 		.setup = alc885_imac91_setup,
846 		.init_hook = alc_hp_automute,
847 	},
848 	[ALC889A_MB31] = {
849 		.mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
850 		.init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
851 			alc880_gpio1_init_verbs },
852 		.adc_nids = alc883_adc_nids,
853 		.num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
854 		.capsrc_nids = alc883_capsrc_nids,
855 		.dac_nids = alc883_dac_nids,
856 		.num_dacs = ARRAY_SIZE(alc883_dac_nids),
857 		.channel_mode = alc889A_mb31_6ch_modes,
858 		.num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
859 		.input_mux = &alc889A_mb31_capture_source,
860 		.dig_out_nid = ALC883_DIGOUT_NID,
861 		.unsol_event = alc889A_mb31_unsol_event,
862 		.init_hook = alc889A_mb31_automute,
863 	},
864 };
865 
866 
867