]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Universal Interface for Intel High Definition Audio Codec | |
3 | * | |
4 | * HD audio interface patch for ALC 260/880/882 codecs | |
5 | * | |
df694daa KY |
6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
7 | * PeiSen Hou <pshou@realtek.com.tw> | |
1da177e4 | 8 | * Takashi Iwai <tiwai@suse.de> |
7cf51e48 | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
1da177e4 LT |
10 | * |
11 | * This driver is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; either version 2 of the License, or | |
14 | * (at your option) any later version. | |
15 | * | |
16 | * This driver is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 | */ | |
25 | ||
1da177e4 LT |
26 | #include <linux/init.h> |
27 | #include <linux/delay.h> | |
28 | #include <linux/slab.h> | |
29 | #include <linux/pci.h> | |
30 | #include <sound/core.h> | |
31 | #include "hda_codec.h" | |
32 | #include "hda_local.h" | |
33 | ||
ccc656ce KY |
34 | #define ALC880_FRONT_EVENT 0x01 |
35 | #define ALC880_DCVOL_EVENT 0x02 | |
36 | #define ALC880_HP_EVENT 0x04 | |
37 | #define ALC880_MIC_EVENT 0x08 | |
1da177e4 LT |
38 | |
39 | /* ALC880 board config type */ | |
40 | enum { | |
1da177e4 LT |
41 | ALC880_3ST, |
42 | ALC880_3ST_DIG, | |
43 | ALC880_5ST, | |
44 | ALC880_5ST_DIG, | |
45 | ALC880_W810, | |
dfc0ff62 | 46 | ALC880_Z71V, |
b6482d48 | 47 | ALC880_6ST, |
16ded525 TI |
48 | ALC880_6ST_DIG, |
49 | ALC880_F1734, | |
50 | ALC880_ASUS, | |
51 | ALC880_ASUS_DIG, | |
52 | ALC880_ASUS_W1V, | |
df694daa | 53 | ALC880_ASUS_DIG2, |
2cf9f0fc | 54 | ALC880_FUJITSU, |
16ded525 | 55 | ALC880_UNIWILL_DIG, |
ccc656ce KY |
56 | ALC880_UNIWILL, |
57 | ALC880_UNIWILL_P53, | |
df694daa KY |
58 | ALC880_CLEVO, |
59 | ALC880_TCL_S700, | |
ae6b813a | 60 | ALC880_LG, |
d681518a | 61 | ALC880_LG_LW, |
e9edcee0 TI |
62 | #ifdef CONFIG_SND_DEBUG |
63 | ALC880_TEST, | |
64 | #endif | |
df694daa | 65 | ALC880_AUTO, |
16ded525 TI |
66 | ALC880_MODEL_LAST /* last tag */ |
67 | }; | |
68 | ||
69 | /* ALC260 models */ | |
70 | enum { | |
71 | ALC260_BASIC, | |
72 | ALC260_HP, | |
df694daa KY |
73 | ALC260_HP_3013, |
74 | ALC260_FUJITSU_S702X, | |
0bfc90e9 | 75 | ALC260_ACER, |
bc9f98a9 KY |
76 | ALC260_WILL, |
77 | ALC260_REPLACER_672V, | |
7cf51e48 JW |
78 | #ifdef CONFIG_SND_DEBUG |
79 | ALC260_TEST, | |
80 | #endif | |
df694daa | 81 | ALC260_AUTO, |
16ded525 | 82 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
83 | }; |
84 | ||
df694daa KY |
85 | /* ALC262 models */ |
86 | enum { | |
87 | ALC262_BASIC, | |
ccc656ce KY |
88 | ALC262_HIPPO, |
89 | ALC262_HIPPO_1, | |
834be88d | 90 | ALC262_FUJITSU, |
9c7f852e | 91 | ALC262_HP_BPC, |
cd7509a4 KY |
92 | ALC262_HP_BPC_D7000_WL, |
93 | ALC262_HP_BPC_D7000_WF, | |
66d2a9d6 | 94 | ALC262_HP_TC_T5735, |
8c427226 | 95 | ALC262_HP_RP5700, |
304dcaac | 96 | ALC262_BENQ_ED8, |
272a527c | 97 | ALC262_SONY_ASSAMD, |
83c34218 | 98 | ALC262_BENQ_T31, |
f651b50b | 99 | ALC262_ULTRA, |
df694daa KY |
100 | ALC262_AUTO, |
101 | ALC262_MODEL_LAST /* last tag */ | |
102 | }; | |
103 | ||
a361d84b KY |
104 | /* ALC268 models */ |
105 | enum { | |
106 | ALC268_3ST, | |
d1a991a6 | 107 | ALC268_TOSHIBA, |
d273809e | 108 | ALC268_ACER, |
3866f0b0 | 109 | ALC268_DELL, |
86c53bd2 JW |
110 | #ifdef CONFIG_SND_DEBUG |
111 | ALC268_TEST, | |
112 | #endif | |
a361d84b KY |
113 | ALC268_AUTO, |
114 | ALC268_MODEL_LAST /* last tag */ | |
115 | }; | |
116 | ||
f6a92248 KY |
117 | /* ALC269 models */ |
118 | enum { | |
119 | ALC269_BASIC, | |
120 | ALC269_AUTO, | |
121 | ALC269_MODEL_LAST /* last tag */ | |
122 | }; | |
123 | ||
df694daa KY |
124 | /* ALC861 models */ |
125 | enum { | |
126 | ALC861_3ST, | |
9c7f852e | 127 | ALC660_3ST, |
df694daa KY |
128 | ALC861_3ST_DIG, |
129 | ALC861_6ST_DIG, | |
22309c3e | 130 | ALC861_UNIWILL_M31, |
a53d1aec | 131 | ALC861_TOSHIBA, |
7cdbff94 | 132 | ALC861_ASUS, |
56bb0cab | 133 | ALC861_ASUS_LAPTOP, |
df694daa KY |
134 | ALC861_AUTO, |
135 | ALC861_MODEL_LAST, | |
136 | }; | |
137 | ||
f32610ed JS |
138 | /* ALC861-VD models */ |
139 | enum { | |
140 | ALC660VD_3ST, | |
6963f84c | 141 | ALC660VD_3ST_DIG, |
f32610ed JS |
142 | ALC861VD_3ST, |
143 | ALC861VD_3ST_DIG, | |
144 | ALC861VD_6ST_DIG, | |
bdd148a3 | 145 | ALC861VD_LENOVO, |
272a527c | 146 | ALC861VD_DALLAS, |
d1a991a6 | 147 | ALC861VD_HP, |
f32610ed JS |
148 | ALC861VD_AUTO, |
149 | ALC861VD_MODEL_LAST, | |
150 | }; | |
151 | ||
bc9f98a9 KY |
152 | /* ALC662 models */ |
153 | enum { | |
154 | ALC662_3ST_2ch_DIG, | |
155 | ALC662_3ST_6ch_DIG, | |
156 | ALC662_3ST_6ch, | |
157 | ALC662_5ST_DIG, | |
158 | ALC662_LENOVO_101E, | |
291702f0 | 159 | ALC662_ASUS_EEEPC_P701, |
8c427226 | 160 | ALC662_ASUS_EEEPC_EP20, |
bc9f98a9 KY |
161 | ALC662_AUTO, |
162 | ALC662_MODEL_LAST, | |
163 | }; | |
164 | ||
df694daa KY |
165 | /* ALC882 models */ |
166 | enum { | |
167 | ALC882_3ST_DIG, | |
168 | ALC882_6ST_DIG, | |
4b146cb0 | 169 | ALC882_ARIMA, |
bdd148a3 | 170 | ALC882_W2JC, |
272a527c KY |
171 | ALC882_TARGA, |
172 | ALC882_ASUS_A7J, | |
914759b7 | 173 | ALC882_ASUS_A7M, |
9102cd1c | 174 | ALC885_MACPRO, |
87350ad0 | 175 | ALC885_MBP3, |
c54728d8 | 176 | ALC885_IMAC24, |
272a527c | 177 | ALC882_AUTO, |
df694daa KY |
178 | ALC882_MODEL_LAST, |
179 | }; | |
180 | ||
9c7f852e TI |
181 | /* ALC883 models */ |
182 | enum { | |
183 | ALC883_3ST_2ch_DIG, | |
184 | ALC883_3ST_6ch_DIG, | |
185 | ALC883_3ST_6ch, | |
186 | ALC883_6ST_DIG, | |
ccc656ce KY |
187 | ALC883_TARGA_DIG, |
188 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 189 | ALC883_ACER, |
2880a867 | 190 | ALC883_ACER_ASPIRE, |
c07584c8 | 191 | ALC883_MEDION, |
272a527c | 192 | ALC883_MEDION_MD2, |
b373bdeb | 193 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 194 | ALC883_LENOVO_101E_2ch, |
272a527c | 195 | ALC883_LENOVO_NB0763, |
189609ae KY |
196 | ALC888_LENOVO_MS7195_DIG, |
197 | ALC883_HAIER_W66, | |
4723c022 CM |
198 | ALC888_6ST_HP, |
199 | ALC888_3ST_HP, | |
5795b9e6 | 200 | ALC888_6ST_DELL, |
a8848bd6 | 201 | ALC883_MITAC, |
9c7f852e TI |
202 | ALC883_AUTO, |
203 | ALC883_MODEL_LAST, | |
204 | }; | |
205 | ||
df694daa KY |
206 | /* for GPIO Poll */ |
207 | #define GPIO_MASK 0x03 | |
208 | ||
1da177e4 LT |
209 | struct alc_spec { |
210 | /* codec parameterization */ | |
df694daa | 211 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 LT |
212 | unsigned int num_mixers; |
213 | ||
df694daa | 214 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
215 | * don't forget NULL |
216 | * termination! | |
e9edcee0 TI |
217 | */ |
218 | unsigned int num_init_verbs; | |
1da177e4 | 219 | |
16ded525 | 220 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
221 | struct hda_pcm_stream *stream_analog_playback; |
222 | struct hda_pcm_stream *stream_analog_capture; | |
6330079f TI |
223 | struct hda_pcm_stream *stream_analog_alt_playback; |
224 | struct hda_pcm_stream *stream_analog_alt_capture; | |
1da177e4 | 225 | |
f12ab1e0 | 226 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
227 | struct hda_pcm_stream *stream_digital_playback; |
228 | struct hda_pcm_stream *stream_digital_capture; | |
229 | ||
230 | /* playback */ | |
16ded525 TI |
231 | struct hda_multi_out multiout; /* playback set-up |
232 | * max_channels, dacs must be set | |
233 | * dig_out_nid and hp_nid are optional | |
234 | */ | |
6330079f | 235 | hda_nid_t alt_dac_nid; |
1da177e4 LT |
236 | |
237 | /* capture */ | |
238 | unsigned int num_adc_nids; | |
239 | hda_nid_t *adc_nids; | |
16ded525 | 240 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
1da177e4 LT |
241 | |
242 | /* capture source */ | |
a1e8d2da | 243 | unsigned int num_mux_defs; |
1da177e4 LT |
244 | const struct hda_input_mux *input_mux; |
245 | unsigned int cur_mux[3]; | |
246 | ||
247 | /* channel model */ | |
d2a6d7dc | 248 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 249 | int num_channel_mode; |
4e195a7b | 250 | int need_dac_fix; |
1da177e4 LT |
251 | |
252 | /* PCM information */ | |
4c5186ed | 253 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 254 | |
e9edcee0 TI |
255 | /* dynamic controls, init_verbs and input_mux */ |
256 | struct auto_pin_cfg autocfg; | |
257 | unsigned int num_kctl_alloc, num_kctl_used; | |
c8b6bf9b | 258 | struct snd_kcontrol_new *kctl_alloc; |
e9edcee0 | 259 | struct hda_input_mux private_imux; |
41923e44 | 260 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
834be88d | 261 | |
ae6b813a TI |
262 | /* hooks */ |
263 | void (*init_hook)(struct hda_codec *codec); | |
264 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
265 | ||
834be88d TI |
266 | /* for pin sensing */ |
267 | unsigned int sense_updated: 1; | |
268 | unsigned int jack_present: 1; | |
bec15c3a | 269 | unsigned int master_sw: 1; |
cb53c626 | 270 | |
2134ea4f TI |
271 | /* for virtual master */ |
272 | hda_nid_t vmaster_nid; | |
273 | u32 vmaster_tlv[4]; | |
cb53c626 TI |
274 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
275 | struct hda_loopback_check loopback; | |
276 | #endif | |
df694daa KY |
277 | }; |
278 | ||
279 | /* | |
280 | * configuration template - to be copied to the spec instance | |
281 | */ | |
282 | struct alc_config_preset { | |
9c7f852e TI |
283 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
284 | * with spec | |
285 | */ | |
df694daa KY |
286 | const struct hda_verb *init_verbs[5]; |
287 | unsigned int num_dacs; | |
288 | hda_nid_t *dac_nids; | |
289 | hda_nid_t dig_out_nid; /* optional */ | |
290 | hda_nid_t hp_nid; /* optional */ | |
291 | unsigned int num_adc_nids; | |
292 | hda_nid_t *adc_nids; | |
293 | hda_nid_t dig_in_nid; | |
294 | unsigned int num_channel_mode; | |
295 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 296 | int need_dac_fix; |
a1e8d2da | 297 | unsigned int num_mux_defs; |
df694daa | 298 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
299 | void (*unsol_event)(struct hda_codec *, unsigned int); |
300 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
301 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
302 | struct hda_amp_list *loopbacks; | |
303 | #endif | |
1da177e4 LT |
304 | }; |
305 | ||
1da177e4 LT |
306 | |
307 | /* | |
308 | * input MUX handling | |
309 | */ | |
9c7f852e TI |
310 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
311 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
312 | { |
313 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
314 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
315 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
316 | if (mux_idx >= spec->num_mux_defs) | |
317 | mux_idx = 0; | |
318 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
319 | } |
320 | ||
9c7f852e TI |
321 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
322 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
323 | { |
324 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
325 | struct alc_spec *spec = codec->spec; | |
326 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
327 | ||
328 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
329 | return 0; | |
330 | } | |
331 | ||
9c7f852e TI |
332 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
333 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
334 | { |
335 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
336 | struct alc_spec *spec = codec->spec; | |
337 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
a1e8d2da JW |
338 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
339 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, | |
9c7f852e TI |
340 | spec->adc_nids[adc_idx], |
341 | &spec->cur_mux[adc_idx]); | |
1da177e4 LT |
342 | } |
343 | ||
e9edcee0 | 344 | |
1da177e4 LT |
345 | /* |
346 | * channel mode setting | |
347 | */ | |
9c7f852e TI |
348 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
349 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
350 | { |
351 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
352 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
353 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
354 | spec->num_channel_mode); | |
1da177e4 LT |
355 | } |
356 | ||
9c7f852e TI |
357 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
358 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
359 | { |
360 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
361 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 362 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
363 | spec->num_channel_mode, |
364 | spec->multiout.max_channels); | |
1da177e4 LT |
365 | } |
366 | ||
9c7f852e TI |
367 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
368 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
369 | { |
370 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
371 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
372 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
373 | spec->num_channel_mode, | |
374 | &spec->multiout.max_channels); | |
bd2033f2 | 375 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
376 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
377 | return err; | |
1da177e4 LT |
378 | } |
379 | ||
a9430dd8 | 380 | /* |
4c5186ed JW |
381 | * Control the mode of pin widget settings via the mixer. "pc" is used |
382 | * instead of "%" to avoid consequences of accidently treating the % as | |
383 | * being part of a format specifier. Maximum allowed length of a value is | |
384 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
385 | * |
386 | * Note: some retasking pin complexes seem to ignore requests for input | |
387 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
388 | * are requested. Therefore order this list so that this behaviour will not | |
389 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
390 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
391 | * March 2006. | |
4c5186ed JW |
392 | */ |
393 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
394 | "Mic 50pc bias", "Mic 80pc bias", |
395 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
396 | }; |
397 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 398 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
399 | }; |
400 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
401 | * in the pin being assumed to be exclusively an input or an output pin. In |
402 | * addition, "input" pins may or may not process the mic bias option | |
403 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
404 | * accept requests for bias as of chip versions up to March 2006) and/or | |
405 | * wiring in the computer. | |
a9430dd8 | 406 | */ |
a1e8d2da JW |
407 | #define ALC_PIN_DIR_IN 0x00 |
408 | #define ALC_PIN_DIR_OUT 0x01 | |
409 | #define ALC_PIN_DIR_INOUT 0x02 | |
410 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
411 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 412 | |
a1e8d2da | 413 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
414 | * For each direction the minimum and maximum values are given. |
415 | */ | |
a1e8d2da | 416 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
417 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
418 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
419 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
420 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
421 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
422 | }; |
423 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
424 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
425 | #define alc_pin_mode_n_items(_dir) \ | |
426 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
427 | ||
9c7f852e TI |
428 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
429 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 430 | { |
4c5186ed JW |
431 | unsigned int item_num = uinfo->value.enumerated.item; |
432 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
433 | ||
434 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 435 | uinfo->count = 1; |
4c5186ed JW |
436 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
437 | ||
438 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
439 | item_num = alc_pin_mode_min(dir); | |
440 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
441 | return 0; |
442 | } | |
443 | ||
9c7f852e TI |
444 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
445 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 446 | { |
4c5186ed | 447 | unsigned int i; |
a9430dd8 JW |
448 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
449 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 450 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 451 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
452 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
453 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
454 | 0x00); | |
a9430dd8 | 455 | |
4c5186ed JW |
456 | /* Find enumerated value for current pinctl setting */ |
457 | i = alc_pin_mode_min(dir); | |
9c7f852e | 458 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 459 | i++; |
9c7f852e | 460 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
461 | return 0; |
462 | } | |
463 | ||
9c7f852e TI |
464 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
465 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 466 | { |
4c5186ed | 467 | signed int change; |
a9430dd8 JW |
468 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
469 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
470 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
471 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
472 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
473 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
474 | 0x00); | |
a9430dd8 | 475 | |
f12ab1e0 | 476 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
477 | val = alc_pin_mode_min(dir); |
478 | ||
479 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
480 | if (change) { |
481 | /* Set pin mode to that requested */ | |
82beb8fd TI |
482 | snd_hda_codec_write_cache(codec, nid, 0, |
483 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
484 | alc_pin_mode_values[val]); | |
cdcd9268 JW |
485 | |
486 | /* Also enable the retasking pin's input/output as required | |
487 | * for the requested pin mode. Enum values of 2 or less are | |
488 | * input modes. | |
489 | * | |
490 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
491 | * reduces noise slightly (particularly on input) so we'll |
492 | * do it. However, having both input and output buffers | |
493 | * enabled simultaneously doesn't seem to be problematic if | |
494 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
495 | */ |
496 | if (val <= 2) { | |
47fd830a TI |
497 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
498 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
499 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
500 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 501 | } else { |
47fd830a TI |
502 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
503 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
504 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
505 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
506 | } |
507 | } | |
a9430dd8 JW |
508 | return change; |
509 | } | |
510 | ||
4c5186ed | 511 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 512 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
513 | .info = alc_pin_mode_info, \ |
514 | .get = alc_pin_mode_get, \ | |
515 | .put = alc_pin_mode_put, \ | |
516 | .private_value = nid | (dir<<16) } | |
df694daa | 517 | |
5c8f858d JW |
518 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
519 | * together using a mask with more than one bit set. This control is | |
520 | * currently used only by the ALC260 test model. At this stage they are not | |
521 | * needed for any "production" models. | |
522 | */ | |
523 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 524 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 525 | |
9c7f852e TI |
526 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
527 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
528 | { |
529 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
530 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
531 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
532 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
533 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
534 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
535 | |
536 | *valp = (val & mask) != 0; | |
537 | return 0; | |
538 | } | |
9c7f852e TI |
539 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
540 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
541 | { |
542 | signed int change; | |
543 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
544 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
545 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
546 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
547 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
548 | AC_VERB_GET_GPIO_DATA, | |
549 | 0x00); | |
5c8f858d JW |
550 | |
551 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
552 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
553 | if (val == 0) | |
5c8f858d JW |
554 | gpio_data &= ~mask; |
555 | else | |
556 | gpio_data |= mask; | |
82beb8fd TI |
557 | snd_hda_codec_write_cache(codec, nid, 0, |
558 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
559 | |
560 | return change; | |
561 | } | |
562 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
563 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
564 | .info = alc_gpio_data_info, \ | |
565 | .get = alc_gpio_data_get, \ | |
566 | .put = alc_gpio_data_put, \ | |
567 | .private_value = nid | (mask<<16) } | |
568 | #endif /* CONFIG_SND_DEBUG */ | |
569 | ||
92621f13 JW |
570 | /* A switch control to allow the enabling of the digital IO pins on the |
571 | * ALC260. This is incredibly simplistic; the intention of this control is | |
572 | * to provide something in the test model allowing digital outputs to be | |
573 | * identified if present. If models are found which can utilise these | |
574 | * outputs a more complete mixer control can be devised for those models if | |
575 | * necessary. | |
576 | */ | |
577 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 578 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 579 | |
9c7f852e TI |
580 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
581 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
582 | { |
583 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
584 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
585 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
586 | long *valp = ucontrol->value.integer.value; | |
9c7f852e | 587 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 588 | AC_VERB_GET_DIGI_CONVERT_1, 0x00); |
92621f13 JW |
589 | |
590 | *valp = (val & mask) != 0; | |
591 | return 0; | |
592 | } | |
9c7f852e TI |
593 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
594 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
595 | { |
596 | signed int change; | |
597 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
598 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
599 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
600 | long val = *ucontrol->value.integer.value; | |
9c7f852e | 601 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 602 | AC_VERB_GET_DIGI_CONVERT_1, |
9c7f852e | 603 | 0x00); |
92621f13 JW |
604 | |
605 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 606 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
607 | if (val==0) |
608 | ctrl_data &= ~mask; | |
609 | else | |
610 | ctrl_data |= mask; | |
82beb8fd TI |
611 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
612 | ctrl_data); | |
92621f13 JW |
613 | |
614 | return change; | |
615 | } | |
616 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
617 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
618 | .info = alc_spdif_ctrl_info, \ | |
619 | .get = alc_spdif_ctrl_get, \ | |
620 | .put = alc_spdif_ctrl_put, \ | |
621 | .private_value = nid | (mask<<16) } | |
622 | #endif /* CONFIG_SND_DEBUG */ | |
623 | ||
f8225f6d JW |
624 | /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. |
625 | * Again, this is only used in the ALC26x test models to help identify when | |
626 | * the EAPD line must be asserted for features to work. | |
627 | */ | |
628 | #ifdef CONFIG_SND_DEBUG | |
629 | #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info | |
630 | ||
631 | static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, | |
632 | struct snd_ctl_elem_value *ucontrol) | |
633 | { | |
634 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
635 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
636 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
637 | long *valp = ucontrol->value.integer.value; | |
638 | unsigned int val = snd_hda_codec_read(codec, nid, 0, | |
639 | AC_VERB_GET_EAPD_BTLENABLE, 0x00); | |
640 | ||
641 | *valp = (val & mask) != 0; | |
642 | return 0; | |
643 | } | |
644 | ||
645 | static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, | |
646 | struct snd_ctl_elem_value *ucontrol) | |
647 | { | |
648 | int change; | |
649 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
650 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
651 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
652 | long val = *ucontrol->value.integer.value; | |
653 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, | |
654 | AC_VERB_GET_EAPD_BTLENABLE, | |
655 | 0x00); | |
656 | ||
657 | /* Set/unset the masked control bit(s) as needed */ | |
658 | change = (!val ? 0 : mask) != (ctrl_data & mask); | |
659 | if (!val) | |
660 | ctrl_data &= ~mask; | |
661 | else | |
662 | ctrl_data |= mask; | |
663 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
664 | ctrl_data); | |
665 | ||
666 | return change; | |
667 | } | |
668 | ||
669 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ | |
670 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
671 | .info = alc_eapd_ctrl_info, \ | |
672 | .get = alc_eapd_ctrl_get, \ | |
673 | .put = alc_eapd_ctrl_put, \ | |
674 | .private_value = nid | (mask<<16) } | |
675 | #endif /* CONFIG_SND_DEBUG */ | |
676 | ||
df694daa KY |
677 | /* |
678 | * set up from the preset table | |
679 | */ | |
9c7f852e TI |
680 | static void setup_preset(struct alc_spec *spec, |
681 | const struct alc_config_preset *preset) | |
df694daa KY |
682 | { |
683 | int i; | |
684 | ||
685 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
686 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; | |
9c7f852e TI |
687 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
688 | i++) | |
689 | spec->init_verbs[spec->num_init_verbs++] = | |
690 | preset->init_verbs[i]; | |
df694daa KY |
691 | |
692 | spec->channel_mode = preset->channel_mode; | |
693 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 694 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
695 | |
696 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
697 | ||
698 | spec->multiout.num_dacs = preset->num_dacs; | |
699 | spec->multiout.dac_nids = preset->dac_nids; | |
700 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
701 | spec->multiout.hp_nid = preset->hp_nid; | |
702 | ||
a1e8d2da | 703 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 704 | if (!spec->num_mux_defs) |
a1e8d2da | 705 | spec->num_mux_defs = 1; |
df694daa KY |
706 | spec->input_mux = preset->input_mux; |
707 | ||
708 | spec->num_adc_nids = preset->num_adc_nids; | |
709 | spec->adc_nids = preset->adc_nids; | |
710 | spec->dig_in_nid = preset->dig_in_nid; | |
ae6b813a TI |
711 | |
712 | spec->unsol_event = preset->unsol_event; | |
713 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
714 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
715 | spec->loopback.amplist = preset->loopbacks; | |
716 | #endif | |
df694daa KY |
717 | } |
718 | ||
bc9f98a9 KY |
719 | /* Enable GPIO mask and set output */ |
720 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
721 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
722 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
723 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
724 | { } | |
725 | }; | |
726 | ||
727 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
728 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
729 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
730 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
731 | { } | |
732 | }; | |
733 | ||
bdd148a3 KY |
734 | static struct hda_verb alc_gpio3_init_verbs[] = { |
735 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
736 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
737 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
738 | { } | |
739 | }; | |
740 | ||
c9b58006 KY |
741 | static void alc_sku_automute(struct hda_codec *codec) |
742 | { | |
743 | struct alc_spec *spec = codec->spec; | |
744 | unsigned int mute; | |
745 | unsigned int present; | |
746 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | |
747 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | |
748 | ||
749 | /* need to execute and sync at first */ | |
750 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | |
751 | present = snd_hda_codec_read(codec, hp_nid, 0, | |
752 | AC_VERB_GET_PIN_SENSE, 0); | |
753 | spec->jack_present = (present & 0x80000000) != 0; | |
754 | if (spec->jack_present) { | |
755 | /* mute internal speaker */ | |
756 | snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0, | |
757 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
758 | } else { | |
759 | /* unmute internal speaker if necessary */ | |
760 | mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0); | |
761 | snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0, | |
762 | HDA_AMP_MUTE, mute); | |
763 | } | |
764 | } | |
765 | ||
766 | /* unsolicited event for HP jack sensing */ | |
767 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |
768 | { | |
769 | if (codec->vendor_id == 0x10ec0880) | |
770 | res >>= 28; | |
771 | else | |
772 | res >>= 26; | |
773 | if (res != ALC880_HP_EVENT) | |
774 | return; | |
775 | ||
776 | alc_sku_automute(codec); | |
777 | } | |
778 | ||
bc9f98a9 KY |
779 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
780 | * 31 ~ 16 : Manufacture ID | |
781 | * 15 ~ 8 : SKU ID | |
782 | * 7 ~ 0 : Assembly ID | |
783 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
784 | */ | |
785 | static void alc_subsystem_id(struct hda_codec *codec, | |
786 | unsigned int porta, unsigned int porte, | |
787 | unsigned int portd) | |
788 | { | |
c9b58006 KY |
789 | unsigned int ass, tmp, i; |
790 | unsigned nid; | |
791 | struct alc_spec *spec = codec->spec; | |
bc9f98a9 | 792 | |
c9b58006 KY |
793 | ass = codec->subsystem_id & 0xffff; |
794 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
795 | goto do_sku; | |
796 | ||
797 | /* | |
798 | * 31~30 : port conetcivity | |
799 | * 29~21 : reserve | |
800 | * 20 : PCBEEP input | |
801 | * 19~16 : Check sum (15:1) | |
802 | * 15~1 : Custom | |
803 | * 0 : override | |
804 | */ | |
805 | nid = 0x1d; | |
806 | if (codec->vendor_id == 0x10ec0260) | |
807 | nid = 0x17; | |
808 | ass = snd_hda_codec_read(codec, nid, 0, | |
809 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
810 | if (!(ass & 1) && !(ass & 0x100000)) | |
811 | return; | |
812 | if ((ass >> 30) != 1) /* no physical connection */ | |
bc9f98a9 KY |
813 | return; |
814 | ||
c9b58006 KY |
815 | /* check sum */ |
816 | tmp = 0; | |
817 | for (i = 1; i < 16; i++) { | |
8c427226 | 818 | if ((ass >> i) & 1) |
c9b58006 KY |
819 | tmp++; |
820 | } | |
821 | if (((ass >> 16) & 0xf) != tmp) | |
822 | return; | |
823 | do_sku: | |
824 | /* | |
825 | * 0 : override | |
826 | * 1 : Swap Jack | |
827 | * 2 : 0 --> Desktop, 1 --> Laptop | |
828 | * 3~5 : External Amplifier control | |
829 | * 7~6 : Reserved | |
830 | */ | |
bc9f98a9 KY |
831 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
832 | switch (tmp) { | |
833 | case 1: | |
834 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
835 | break; | |
836 | case 3: | |
837 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
838 | break; | |
bdd148a3 KY |
839 | case 7: |
840 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
841 | break; | |
c9b58006 | 842 | case 5: /* set EAPD output high */ |
bdd148a3 | 843 | switch (codec->vendor_id) { |
c9b58006 KY |
844 | case 0x10ec0260: |
845 | snd_hda_codec_write(codec, 0x0f, 0, | |
846 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
847 | snd_hda_codec_write(codec, 0x10, 0, | |
848 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
849 | break; | |
850 | case 0x10ec0262: | |
bdd148a3 KY |
851 | case 0x10ec0267: |
852 | case 0x10ec0268: | |
c9b58006 KY |
853 | case 0x10ec0269: |
854 | case 0x10ec0862: | |
855 | case 0x10ec0662: | |
bdd148a3 KY |
856 | snd_hda_codec_write(codec, 0x14, 0, |
857 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
858 | snd_hda_codec_write(codec, 0x15, 0, | |
859 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
c9b58006 | 860 | break; |
bdd148a3 | 861 | } |
c9b58006 KY |
862 | switch (codec->vendor_id) { |
863 | case 0x10ec0260: | |
864 | snd_hda_codec_write(codec, 0x1a, 0, | |
865 | AC_VERB_SET_COEF_INDEX, 7); | |
866 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
867 | AC_VERB_GET_PROC_COEF, 0); | |
868 | snd_hda_codec_write(codec, 0x1a, 0, | |
869 | AC_VERB_SET_COEF_INDEX, 7); | |
870 | snd_hda_codec_write(codec, 0x1a, 0, | |
871 | AC_VERB_SET_PROC_COEF, | |
872 | tmp | 0x2010); | |
873 | break; | |
874 | case 0x10ec0262: | |
875 | case 0x10ec0880: | |
876 | case 0x10ec0882: | |
877 | case 0x10ec0883: | |
878 | case 0x10ec0885: | |
879 | case 0x10ec0888: | |
880 | snd_hda_codec_write(codec, 0x20, 0, | |
881 | AC_VERB_SET_COEF_INDEX, 7); | |
882 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
883 | AC_VERB_GET_PROC_COEF, 0); | |
884 | snd_hda_codec_write(codec, 0x20, 0, | |
885 | AC_VERB_SET_COEF_INDEX, 7); | |
886 | snd_hda_codec_write(codec, 0x20, 0, | |
887 | AC_VERB_SET_PROC_COEF, | |
888 | tmp | 0x2010); | |
889 | break; | |
890 | case 0x10ec0267: | |
891 | case 0x10ec0268: | |
892 | snd_hda_codec_write(codec, 0x20, 0, | |
893 | AC_VERB_SET_COEF_INDEX, 7); | |
894 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
895 | AC_VERB_GET_PROC_COEF, 0); | |
896 | snd_hda_codec_write(codec, 0x20, 0, | |
897 | AC_VERB_SET_COEF_INDEX, 7); | |
898 | snd_hda_codec_write(codec, 0x20, 0, | |
899 | AC_VERB_SET_PROC_COEF, | |
900 | tmp | 0x3000); | |
901 | break; | |
bc9f98a9 | 902 | } |
c9b58006 | 903 | default: |
bc9f98a9 KY |
904 | break; |
905 | } | |
c9b58006 | 906 | |
8c427226 | 907 | /* is laptop or Desktop and enable the function "Mute internal speaker |
c9b58006 KY |
908 | * when the external headphone out jack is plugged" |
909 | */ | |
8c427226 | 910 | if (!(ass & 0x8000)) |
c9b58006 KY |
911 | return; |
912 | /* | |
913 | * 10~8 : Jack location | |
914 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
915 | * 14~13: Resvered | |
916 | * 15 : 1 --> enable the function "Mute internal speaker | |
917 | * when the external headphone out jack is plugged" | |
918 | */ | |
919 | if (!spec->autocfg.speaker_pins[0]) { | |
8c427226 | 920 | if (spec->autocfg.line_out_pins[0]) |
c9b58006 | 921 | spec->autocfg.speaker_pins[0] = |
8c427226 | 922 | spec->autocfg.line_out_pins[0]; |
c9b58006 KY |
923 | else |
924 | return; | |
925 | } | |
926 | ||
927 | if (!spec->autocfg.hp_pins[0]) { | |
928 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | |
929 | if (tmp == 0) | |
930 | spec->autocfg.hp_pins[0] = porta; | |
931 | else if (tmp == 1) | |
932 | spec->autocfg.hp_pins[0] = porte; | |
933 | else if (tmp == 2) | |
934 | spec->autocfg.hp_pins[0] = portd; | |
935 | else | |
936 | return; | |
937 | } | |
938 | ||
939 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | |
940 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
941 | AC_USRSP_EN | ALC880_HP_EVENT); | |
942 | spec->unsol_event = alc_sku_unsol_event; | |
943 | spec->init_hook = alc_sku_automute; | |
bc9f98a9 KY |
944 | } |
945 | ||
f95474ec TI |
946 | /* |
947 | * Fix-up pin default configurations | |
948 | */ | |
949 | ||
950 | struct alc_pincfg { | |
951 | hda_nid_t nid; | |
952 | u32 val; | |
953 | }; | |
954 | ||
955 | static void alc_fix_pincfg(struct hda_codec *codec, | |
956 | const struct snd_pci_quirk *quirk, | |
957 | const struct alc_pincfg **pinfix) | |
958 | { | |
959 | const struct alc_pincfg *cfg; | |
960 | ||
961 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
962 | if (!quirk) | |
963 | return; | |
964 | ||
965 | cfg = pinfix[quirk->value]; | |
966 | for (; cfg->nid; cfg++) { | |
967 | int i; | |
968 | u32 val = cfg->val; | |
969 | for (i = 0; i < 4; i++) { | |
970 | snd_hda_codec_write(codec, cfg->nid, 0, | |
971 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
972 | val & 0xff); | |
973 | val >>= 8; | |
974 | } | |
975 | } | |
976 | } | |
977 | ||
1da177e4 | 978 | /* |
e9edcee0 TI |
979 | * ALC880 3-stack model |
980 | * | |
981 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
982 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
983 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
984 | */ |
985 | ||
e9edcee0 TI |
986 | static hda_nid_t alc880_dac_nids[4] = { |
987 | /* front, rear, clfe, rear_surr */ | |
988 | 0x02, 0x05, 0x04, 0x03 | |
989 | }; | |
990 | ||
991 | static hda_nid_t alc880_adc_nids[3] = { | |
992 | /* ADC0-2 */ | |
993 | 0x07, 0x08, 0x09, | |
994 | }; | |
995 | ||
996 | /* The datasheet says the node 0x07 is connected from inputs, | |
997 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 998 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 999 | */ |
e9edcee0 TI |
1000 | static hda_nid_t alc880_adc_nids_alt[2] = { |
1001 | /* ADC1-2 */ | |
1002 | 0x08, 0x09, | |
1003 | }; | |
1004 | ||
1005 | #define ALC880_DIGOUT_NID 0x06 | |
1006 | #define ALC880_DIGIN_NID 0x0a | |
1007 | ||
1008 | static struct hda_input_mux alc880_capture_source = { | |
1009 | .num_items = 4, | |
1010 | .items = { | |
1011 | { "Mic", 0x0 }, | |
1012 | { "Front Mic", 0x3 }, | |
1013 | { "Line", 0x2 }, | |
1014 | { "CD", 0x4 }, | |
1015 | }, | |
1016 | }; | |
1017 | ||
1018 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
1019 | /* 2ch mode */ | |
1020 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
1021 | /* set line-in to input, mute it */ | |
1022 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1023 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1024 | /* set mic-in to input vref 80%, mute it */ | |
1025 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1026 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1027 | { } /* end */ | |
1028 | }; | |
1029 | ||
1030 | /* 6ch mode */ | |
1031 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
1032 | /* set line-in to output, unmute it */ | |
1033 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1034 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1035 | /* set mic-in to output, unmute it */ | |
1036 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1037 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1038 | { } /* end */ | |
1039 | }; | |
1040 | ||
d2a6d7dc | 1041 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
1042 | { 2, alc880_threestack_ch2_init }, |
1043 | { 6, alc880_threestack_ch6_init }, | |
1044 | }; | |
1045 | ||
c8b6bf9b | 1046 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 1047 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1048 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 1049 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1050 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
1051 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1052 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1053 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1054 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
1055 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1056 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1057 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1058 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1059 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1060 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1061 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
1062 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
1063 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1064 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
1065 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
1066 | { | |
1067 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1068 | .name = "Channel Mode", | |
df694daa KY |
1069 | .info = alc_ch_mode_info, |
1070 | .get = alc_ch_mode_get, | |
1071 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
1072 | }, |
1073 | { } /* end */ | |
1074 | }; | |
1075 | ||
1076 | /* capture mixer elements */ | |
c8b6bf9b | 1077 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
e9edcee0 TI |
1078 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
1079 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
1080 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
1081 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
1082 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
1083 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
1084 | { |
1085 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1086 | /* The multiple "Capture Source" controls confuse alsamixer | |
1087 | * So call somewhat different.. | |
1da177e4 LT |
1088 | */ |
1089 | /* .name = "Capture Source", */ | |
1090 | .name = "Input Source", | |
e9edcee0 | 1091 | .count = 3, |
1da177e4 LT |
1092 | .info = alc_mux_enum_info, |
1093 | .get = alc_mux_enum_get, | |
1094 | .put = alc_mux_enum_put, | |
1095 | }, | |
1da177e4 LT |
1096 | { } /* end */ |
1097 | }; | |
1098 | ||
e9edcee0 | 1099 | /* capture mixer elements (in case NID 0x07 not available) */ |
c8b6bf9b | 1100 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
71fe7b82 TI |
1101 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
1102 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1103 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
1104 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
1105 | { |
1106 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1107 | /* The multiple "Capture Source" controls confuse alsamixer | |
1108 | * So call somewhat different.. | |
1da177e4 LT |
1109 | */ |
1110 | /* .name = "Capture Source", */ | |
1111 | .name = "Input Source", | |
1112 | .count = 2, | |
1113 | .info = alc_mux_enum_info, | |
1114 | .get = alc_mux_enum_get, | |
1115 | .put = alc_mux_enum_put, | |
1116 | }, | |
1da177e4 LT |
1117 | { } /* end */ |
1118 | }; | |
1119 | ||
e9edcee0 TI |
1120 | |
1121 | ||
1122 | /* | |
1123 | * ALC880 5-stack model | |
1124 | * | |
9c7f852e TI |
1125 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
1126 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
1127 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
1128 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
1129 | */ | |
1130 | ||
1131 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 1132 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 1133 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1134 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
1135 | { } /* end */ |
1136 | }; | |
1137 | ||
e9edcee0 TI |
1138 | /* channel source setting (6/8 channel selection for 5-stack) */ |
1139 | /* 6ch mode */ | |
1140 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
1141 | /* set line-in to input, mute it */ | |
1142 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1143 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
1144 | { } /* end */ |
1145 | }; | |
1146 | ||
e9edcee0 TI |
1147 | /* 8ch mode */ |
1148 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
1149 | /* set line-in to output, unmute it */ | |
1150 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1151 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1152 | { } /* end */ | |
1153 | }; | |
1154 | ||
d2a6d7dc | 1155 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
1156 | { 6, alc880_fivestack_ch6_init }, |
1157 | { 8, alc880_fivestack_ch8_init }, | |
1158 | }; | |
1159 | ||
1160 | ||
1161 | /* | |
1162 | * ALC880 6-stack model | |
1163 | * | |
9c7f852e TI |
1164 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
1165 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
1166 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
1167 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
1168 | */ | |
1169 | ||
1170 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
1171 | /* front, rear, clfe, rear_surr */ | |
1172 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 1173 | }; |
e9edcee0 TI |
1174 | |
1175 | static struct hda_input_mux alc880_6stack_capture_source = { | |
1176 | .num_items = 4, | |
1177 | .items = { | |
1178 | { "Mic", 0x0 }, | |
1179 | { "Front Mic", 0x1 }, | |
1180 | { "Line", 0x2 }, | |
1181 | { "CD", 0x4 }, | |
1182 | }, | |
1183 | }; | |
1184 | ||
1185 | /* fixed 8-channels */ | |
d2a6d7dc | 1186 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
1187 | { 8, NULL }, |
1188 | }; | |
1189 | ||
c8b6bf9b | 1190 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 1191 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1192 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1193 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1194 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1195 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1196 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1197 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1198 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 1199 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1200 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
1201 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1202 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1203 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1204 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1205 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1206 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1207 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1208 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1209 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1210 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
1211 | { |
1212 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1213 | .name = "Channel Mode", | |
df694daa KY |
1214 | .info = alc_ch_mode_info, |
1215 | .get = alc_ch_mode_get, | |
1216 | .put = alc_ch_mode_put, | |
16ded525 TI |
1217 | }, |
1218 | { } /* end */ | |
1219 | }; | |
1220 | ||
e9edcee0 TI |
1221 | |
1222 | /* | |
1223 | * ALC880 W810 model | |
1224 | * | |
1225 | * W810 has rear IO for: | |
1226 | * Front (DAC 02) | |
1227 | * Surround (DAC 03) | |
1228 | * Center/LFE (DAC 04) | |
1229 | * Digital out (06) | |
1230 | * | |
1231 | * The system also has a pair of internal speakers, and a headphone jack. | |
1232 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
1233 | * | |
1234 | * There is a variable resistor to control the speaker or headphone | |
1235 | * volume. This is a hardware-only device without a software API. | |
1236 | * | |
1237 | * Plugging headphones in will disable the internal speakers. This is | |
1238 | * implemented in hardware, not via the driver using jack sense. In | |
1239 | * a similar fashion, plugging into the rear socket marked "front" will | |
1240 | * disable both the speakers and headphones. | |
1241 | * | |
1242 | * For input, there's a microphone jack, and an "audio in" jack. | |
1243 | * These may not do anything useful with this driver yet, because I | |
1244 | * haven't setup any initialization verbs for these yet... | |
1245 | */ | |
1246 | ||
1247 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1248 | /* front, rear/surround, clfe */ | |
1249 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1250 | }; |
1251 | ||
e9edcee0 | 1252 | /* fixed 6 channels */ |
d2a6d7dc | 1253 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1254 | { 6, NULL } |
1255 | }; | |
1256 | ||
1257 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1258 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1259 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1260 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1261 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1262 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1263 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1264 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1265 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1266 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1267 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1268 | { } /* end */ | |
1269 | }; | |
1270 | ||
1271 | ||
1272 | /* | |
1273 | * Z710V model | |
1274 | * | |
1275 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1276 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1277 | * Line = 0x1a | |
e9edcee0 TI |
1278 | */ |
1279 | ||
1280 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1281 | 0x02 | |
1282 | }; | |
1283 | #define ALC880_Z71V_HP_DAC 0x03 | |
1284 | ||
1285 | /* fixed 2 channels */ | |
d2a6d7dc | 1286 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1287 | { 2, NULL } |
1288 | }; | |
1289 | ||
c8b6bf9b | 1290 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1291 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1292 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1293 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1294 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1295 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1296 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1297 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1298 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1299 | { } /* end */ |
1300 | }; | |
1301 | ||
e9edcee0 | 1302 | |
e9edcee0 TI |
1303 | /* |
1304 | * ALC880 F1734 model | |
1305 | * | |
1306 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1307 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1308 | */ | |
1309 | ||
1310 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1311 | 0x03 | |
1312 | }; | |
1313 | #define ALC880_F1734_HP_DAC 0x02 | |
1314 | ||
c8b6bf9b | 1315 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1316 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1317 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
2134ea4f TI |
1318 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
1319 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
e9edcee0 TI |
1320 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1321 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1322 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1323 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1324 | { } /* end */ | |
1325 | }; | |
1326 | ||
1327 | ||
e9edcee0 TI |
1328 | /* |
1329 | * ALC880 ASUS model | |
1330 | * | |
1331 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1332 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1333 | * Mic = 0x18, Line = 0x1a | |
1334 | */ | |
1335 | ||
1336 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1337 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1338 | ||
c8b6bf9b | 1339 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1340 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1341 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1342 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1343 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1344 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1345 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1346 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1347 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1348 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1349 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1350 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1351 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1352 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1353 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1354 | { |
1355 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1356 | .name = "Channel Mode", | |
df694daa KY |
1357 | .info = alc_ch_mode_info, |
1358 | .get = alc_ch_mode_get, | |
1359 | .put = alc_ch_mode_put, | |
16ded525 TI |
1360 | }, |
1361 | { } /* end */ | |
1362 | }; | |
e9edcee0 | 1363 | |
e9edcee0 TI |
1364 | /* |
1365 | * ALC880 ASUS W1V model | |
1366 | * | |
1367 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1368 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1369 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1370 | */ | |
1371 | ||
1372 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1373 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1374 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1375 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1376 | { } /* end */ | |
1377 | }; | |
1378 | ||
3c10a9d9 | 1379 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1380 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1381 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1382 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1383 | { } /* end */ | |
1384 | }; | |
e9edcee0 | 1385 | |
df694daa KY |
1386 | /* TCL S700 */ |
1387 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1388 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1389 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1390 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1391 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1392 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1393 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1394 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1395 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1396 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1397 | { | |
1398 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1399 | /* The multiple "Capture Source" controls confuse alsamixer | |
1400 | * So call somewhat different.. | |
df694daa KY |
1401 | */ |
1402 | /* .name = "Capture Source", */ | |
1403 | .name = "Input Source", | |
1404 | .count = 1, | |
1405 | .info = alc_mux_enum_info, | |
1406 | .get = alc_mux_enum_get, | |
1407 | .put = alc_mux_enum_put, | |
1408 | }, | |
1409 | { } /* end */ | |
1410 | }; | |
1411 | ||
ccc656ce KY |
1412 | /* Uniwill */ |
1413 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
2134ea4f TI |
1414 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1415 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1416 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1417 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1418 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1419 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1420 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1421 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1422 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1423 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1424 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1425 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1426 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1427 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1428 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1429 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1430 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1431 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1432 | { | |
1433 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1434 | .name = "Channel Mode", | |
1435 | .info = alc_ch_mode_info, | |
1436 | .get = alc_ch_mode_get, | |
1437 | .put = alc_ch_mode_put, | |
1438 | }, | |
1439 | { } /* end */ | |
1440 | }; | |
1441 | ||
2cf9f0fc TD |
1442 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1443 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1444 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1445 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1446 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1447 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1448 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1449 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1450 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1451 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1452 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1453 | { } /* end */ | |
1454 | }; | |
1455 | ||
ccc656ce | 1456 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
2134ea4f TI |
1457 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1458 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1459 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1460 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1461 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1462 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1463 | { } /* end */ | |
1464 | }; | |
1465 | ||
2134ea4f TI |
1466 | /* |
1467 | * virtual master controls | |
1468 | */ | |
1469 | ||
1470 | /* | |
1471 | * slave controls for virtual master | |
1472 | */ | |
1473 | static const char *alc_slave_vols[] = { | |
1474 | "Front Playback Volume", | |
1475 | "Surround Playback Volume", | |
1476 | "Center Playback Volume", | |
1477 | "LFE Playback Volume", | |
1478 | "Side Playback Volume", | |
1479 | "Headphone Playback Volume", | |
1480 | "Speaker Playback Volume", | |
1481 | "Mono Playback Volume", | |
2134ea4f TI |
1482 | "Line-Out Playback Volume", |
1483 | NULL, | |
1484 | }; | |
1485 | ||
1486 | static const char *alc_slave_sws[] = { | |
1487 | "Front Playback Switch", | |
1488 | "Surround Playback Switch", | |
1489 | "Center Playback Switch", | |
1490 | "LFE Playback Switch", | |
1491 | "Side Playback Switch", | |
1492 | "Headphone Playback Switch", | |
1493 | "Speaker Playback Switch", | |
1494 | "Mono Playback Switch", | |
edb54a55 | 1495 | "IEC958 Playback Switch", |
2134ea4f TI |
1496 | NULL, |
1497 | }; | |
1498 | ||
1da177e4 | 1499 | /* |
e9edcee0 | 1500 | * build control elements |
1da177e4 LT |
1501 | */ |
1502 | static int alc_build_controls(struct hda_codec *codec) | |
1503 | { | |
1504 | struct alc_spec *spec = codec->spec; | |
1505 | int err; | |
1506 | int i; | |
1507 | ||
1508 | for (i = 0; i < spec->num_mixers; i++) { | |
1509 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1510 | if (err < 0) | |
1511 | return err; | |
1512 | } | |
1513 | ||
1514 | if (spec->multiout.dig_out_nid) { | |
9c7f852e TI |
1515 | err = snd_hda_create_spdif_out_ctls(codec, |
1516 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1517 | if (err < 0) |
1518 | return err; | |
1519 | } | |
1520 | if (spec->dig_in_nid) { | |
1521 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
1522 | if (err < 0) | |
1523 | return err; | |
1524 | } | |
2134ea4f TI |
1525 | |
1526 | /* if we have no master control, let's create it */ | |
1527 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
1528 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, | |
1529 | HDA_OUTPUT, spec->vmaster_tlv); | |
1530 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", | |
1531 | spec->vmaster_tlv, alc_slave_vols); | |
1532 | if (err < 0) | |
1533 | return err; | |
1534 | } | |
1535 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
1536 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
1537 | NULL, alc_slave_sws); | |
1538 | if (err < 0) | |
1539 | return err; | |
1540 | } | |
1541 | ||
1da177e4 LT |
1542 | return 0; |
1543 | } | |
1544 | ||
e9edcee0 | 1545 | |
1da177e4 LT |
1546 | /* |
1547 | * initialize the codec volumes, etc | |
1548 | */ | |
1549 | ||
e9edcee0 TI |
1550 | /* |
1551 | * generic initialization of ADC, input mixers and output mixers | |
1552 | */ | |
1553 | static struct hda_verb alc880_volume_init_verbs[] = { | |
1554 | /* | |
1555 | * Unmute ADC0-2 and set the default input to mic-in | |
1556 | */ | |
71fe7b82 | 1557 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1558 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1559 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1560 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1561 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1562 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 1563 | |
e9edcee0 TI |
1564 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
1565 | * mixer widget | |
9c7f852e TI |
1566 | * Note: PASD motherboards uses the Line In 2 as the input for front |
1567 | * panel mic (mic 2) | |
1da177e4 | 1568 | */ |
e9edcee0 | 1569 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
1570 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1571 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1572 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
1573 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
1574 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1575 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
1576 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 1577 | |
e9edcee0 TI |
1578 | /* |
1579 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 1580 | */ |
e9edcee0 TI |
1581 | /* set vol=0 to output mixers */ |
1582 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1583 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1584 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1585 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1586 | /* set up input amps for analog loopback */ | |
1587 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1588 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1589 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1590 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1591 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1592 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1593 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1594 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1595 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1596 | |
1597 | { } | |
1598 | }; | |
1599 | ||
e9edcee0 TI |
1600 | /* |
1601 | * 3-stack pin configuration: | |
1602 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1603 | */ | |
1604 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1605 | /* | |
1606 | * preset connection lists of input pins | |
1607 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1608 | */ | |
1609 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1610 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1611 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1612 | ||
1613 | /* | |
1614 | * Set pin mode and muting | |
1615 | */ | |
1616 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1617 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1618 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1619 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1620 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1621 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1622 | /* Mic2 (as headphone out) for HP output */ | |
1623 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1624 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1625 | /* Line In pin widget for input */ |
05acb863 | 1626 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1627 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1628 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1629 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1630 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1631 | /* CD pin widget for input */ |
05acb863 | 1632 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1633 | |
e9edcee0 TI |
1634 | { } |
1635 | }; | |
1da177e4 | 1636 | |
e9edcee0 TI |
1637 | /* |
1638 | * 5-stack pin configuration: | |
1639 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1640 | * line-in/side = 0x1a, f-mic = 0x1b | |
1641 | */ | |
1642 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1643 | /* | |
1644 | * preset connection lists of input pins | |
1645 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1646 | */ |
e9edcee0 TI |
1647 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1648 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1649 | |
e9edcee0 TI |
1650 | /* |
1651 | * Set pin mode and muting | |
1da177e4 | 1652 | */ |
e9edcee0 TI |
1653 | /* set pin widgets 0x14-0x17 for output */ |
1654 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1655 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1656 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1657 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1658 | /* unmute pins for output (no gain on this amp) */ | |
1659 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1660 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1661 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1662 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1663 | ||
1664 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1665 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1666 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1667 | /* Mic2 (as headphone out) for HP output */ | |
1668 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1669 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1670 | /* Line In pin widget for input */ | |
1671 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1672 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1673 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1674 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1675 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1676 | /* CD pin widget for input */ | |
1677 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1678 | |
1679 | { } | |
1680 | }; | |
1681 | ||
e9edcee0 TI |
1682 | /* |
1683 | * W810 pin configuration: | |
1684 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1685 | */ | |
1686 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1687 | /* hphone/speaker input selector: front DAC */ | |
1688 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1689 | |
05acb863 | 1690 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1691 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1692 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1693 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1694 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1695 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1696 | |
e9edcee0 | 1697 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1698 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1699 | |
1da177e4 LT |
1700 | { } |
1701 | }; | |
1702 | ||
e9edcee0 TI |
1703 | /* |
1704 | * Z71V pin configuration: | |
1705 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1706 | */ | |
1707 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1708 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1709 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1710 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1711 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1712 | |
16ded525 | 1713 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1714 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1715 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1716 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1717 | |
1718 | { } | |
1719 | }; | |
1720 | ||
e9edcee0 TI |
1721 | /* |
1722 | * 6-stack pin configuration: | |
9c7f852e TI |
1723 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
1724 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
1725 | */ |
1726 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1727 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1728 | ||
16ded525 | 1729 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1730 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1731 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1732 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1733 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1734 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1735 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1736 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1737 | ||
16ded525 | 1738 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1739 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1740 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1741 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1742 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 1743 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1744 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1745 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1746 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1747 | ||
e9edcee0 TI |
1748 | { } |
1749 | }; | |
1750 | ||
ccc656ce KY |
1751 | /* |
1752 | * Uniwill pin configuration: | |
1753 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
1754 | * line = 0x1a | |
1755 | */ | |
1756 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
1757 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1758 | ||
1759 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1760 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1761 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1762 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1763 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1764 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1765 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1766 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1767 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1768 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1769 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1770 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1771 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1772 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1773 | ||
1774 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1775 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1776 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1777 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1778 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1779 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1780 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
1781 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
1782 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1783 | ||
1784 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1785 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
1786 | ||
1787 | { } | |
1788 | }; | |
1789 | ||
1790 | /* | |
1791 | * Uniwill P53 | |
1792 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, | |
1793 | */ | |
1794 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
1795 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1796 | ||
1797 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1798 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1799 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1800 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1801 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1802 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1803 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1804 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1805 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1806 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1807 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1808 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1809 | ||
1810 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1811 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1812 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1813 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1814 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1815 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1816 | ||
1817 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1818 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
1819 | ||
1820 | { } | |
1821 | }; | |
1822 | ||
2cf9f0fc TD |
1823 | static struct hda_verb alc880_beep_init_verbs[] = { |
1824 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
1825 | { } | |
1826 | }; | |
1827 | ||
ccc656ce | 1828 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 1829 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
1830 | { |
1831 | unsigned int present; | |
f12ab1e0 | 1832 | unsigned char bits; |
ccc656ce KY |
1833 | |
1834 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1835 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1836 | bits = present ? HDA_AMP_MUTE : 0; |
1837 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
1838 | HDA_AMP_MUTE, bits); | |
1839 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
1840 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
1841 | } |
1842 | ||
1843 | /* auto-toggle front mic */ | |
1844 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
1845 | { | |
1846 | unsigned int present; | |
1847 | unsigned char bits; | |
ccc656ce KY |
1848 | |
1849 | present = snd_hda_codec_read(codec, 0x18, 0, | |
1850 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1851 | bits = present ? HDA_AMP_MUTE : 0; |
1852 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
1853 | } |
1854 | ||
1855 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
1856 | { | |
1857 | alc880_uniwill_hp_automute(codec); | |
1858 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
1859 | } |
1860 | ||
1861 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
1862 | unsigned int res) | |
1863 | { | |
1864 | /* Looks like the unsol event is incompatible with the standard | |
1865 | * definition. 4bit tag is placed at 28 bit! | |
1866 | */ | |
458a4fab TI |
1867 | switch (res >> 28) { |
1868 | case ALC880_HP_EVENT: | |
1869 | alc880_uniwill_hp_automute(codec); | |
1870 | break; | |
1871 | case ALC880_MIC_EVENT: | |
1872 | alc880_uniwill_mic_automute(codec); | |
1873 | break; | |
1874 | } | |
ccc656ce KY |
1875 | } |
1876 | ||
1877 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
1878 | { | |
1879 | unsigned int present; | |
f12ab1e0 | 1880 | unsigned char bits; |
ccc656ce KY |
1881 | |
1882 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1883 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1884 | bits = present ? HDA_AMP_MUTE : 0; |
1885 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits); | |
ccc656ce KY |
1886 | } |
1887 | ||
1888 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
1889 | { | |
1890 | unsigned int present; | |
1891 | ||
1892 | present = snd_hda_codec_read(codec, 0x21, 0, | |
47fd830a TI |
1893 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
1894 | present &= HDA_AMP_VOLMASK; | |
1895 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
1896 | HDA_AMP_VOLMASK, present); | |
1897 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
1898 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 1899 | } |
47fd830a | 1900 | |
ccc656ce KY |
1901 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
1902 | unsigned int res) | |
1903 | { | |
1904 | /* Looks like the unsol event is incompatible with the standard | |
1905 | * definition. 4bit tag is placed at 28 bit! | |
1906 | */ | |
1907 | if ((res >> 28) == ALC880_HP_EVENT) | |
1908 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 1909 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
1910 | alc880_uniwill_p53_dcvol_automute(codec); |
1911 | } | |
1912 | ||
e9edcee0 TI |
1913 | /* |
1914 | * F1734 pin configuration: | |
1915 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
1916 | */ | |
1917 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
16ded525 TI |
1918 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1919 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1920 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1921 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1922 | ||
e9edcee0 | 1923 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 1924 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 1925 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 1926 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1927 | |
e9edcee0 TI |
1928 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1929 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1930 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1931 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1932 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1933 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1934 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1935 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1936 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 TI |
1937 | |
1938 | { } | |
1939 | }; | |
1940 | ||
e9edcee0 TI |
1941 | /* |
1942 | * ASUS pin configuration: | |
1943 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
1944 | */ | |
1945 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
1946 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1947 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1948 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1949 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1950 | ||
1951 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 1952 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1953 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1954 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1955 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1956 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1957 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1958 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1959 | ||
1960 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1961 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1962 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1963 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1964 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1965 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1966 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1967 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1968 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1969 | ||
e9edcee0 TI |
1970 | { } |
1971 | }; | |
16ded525 | 1972 | |
e9edcee0 | 1973 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
1974 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
1975 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
1976 | |
1977 | /* Clevo m520g init */ | |
1978 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
1979 | /* headphone output */ | |
1980 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1981 | /* line-out */ | |
1982 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1983 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1984 | /* Line-in */ | |
1985 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1986 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1987 | /* CD */ | |
1988 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1989 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1990 | /* Mic1 (rear panel) */ | |
1991 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1992 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1993 | /* Mic2 (front panel) */ | |
1994 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1995 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1996 | /* headphone */ | |
1997 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1998 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1999 | /* change to EAPD mode */ | |
2000 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2001 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2002 | ||
2003 | { } | |
16ded525 TI |
2004 | }; |
2005 | ||
df694daa | 2006 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
2007 | /* change to EAPD mode */ |
2008 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2009 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2010 | ||
df694daa KY |
2011 | /* Headphone output */ |
2012 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2013 | /* Front output*/ | |
2014 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2015 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2016 | ||
2017 | /* Line In pin widget for input */ | |
2018 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2019 | /* CD pin widget for input */ | |
2020 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2021 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2022 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2023 | ||
2024 | /* change to EAPD mode */ | |
2025 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2026 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
2027 | ||
2028 | { } | |
2029 | }; | |
16ded525 | 2030 | |
e9edcee0 | 2031 | /* |
ae6b813a TI |
2032 | * LG m1 express dual |
2033 | * | |
2034 | * Pin assignment: | |
2035 | * Rear Line-In/Out (blue): 0x14 | |
2036 | * Build-in Mic-In: 0x15 | |
2037 | * Speaker-out: 0x17 | |
2038 | * HP-Out (green): 0x1b | |
2039 | * Mic-In/Out (red): 0x19 | |
2040 | * SPDIF-Out: 0x1e | |
2041 | */ | |
2042 | ||
2043 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
2044 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
2045 | 0x05, 0x02, 0x03 | |
2046 | }; | |
2047 | ||
2048 | /* seems analog CD is not working */ | |
2049 | static struct hda_input_mux alc880_lg_capture_source = { | |
2050 | .num_items = 3, | |
2051 | .items = { | |
2052 | { "Mic", 0x1 }, | |
2053 | { "Line", 0x5 }, | |
2054 | { "Internal Mic", 0x6 }, | |
2055 | }, | |
2056 | }; | |
2057 | ||
2058 | /* 2,4,6 channel modes */ | |
2059 | static struct hda_verb alc880_lg_ch2_init[] = { | |
2060 | /* set line-in and mic-in to input */ | |
2061 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
2062 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2063 | { } | |
2064 | }; | |
2065 | ||
2066 | static struct hda_verb alc880_lg_ch4_init[] = { | |
2067 | /* set line-in to out and mic-in to input */ | |
2068 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2069 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2070 | { } | |
2071 | }; | |
2072 | ||
2073 | static struct hda_verb alc880_lg_ch6_init[] = { | |
2074 | /* set line-in and mic-in to output */ | |
2075 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2076 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2077 | { } | |
2078 | }; | |
2079 | ||
2080 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
2081 | { 2, alc880_lg_ch2_init }, | |
2082 | { 4, alc880_lg_ch4_init }, | |
2083 | { 6, alc880_lg_ch6_init }, | |
2084 | }; | |
2085 | ||
2086 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
2134ea4f TI |
2087 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
2088 | HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), | |
ae6b813a TI |
2089 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2090 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
2091 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
2092 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
2093 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
2094 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
2095 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2096 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2097 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
2098 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
2099 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
2100 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
2101 | { | |
2102 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2103 | .name = "Channel Mode", | |
2104 | .info = alc_ch_mode_info, | |
2105 | .get = alc_ch_mode_get, | |
2106 | .put = alc_ch_mode_put, | |
2107 | }, | |
2108 | { } /* end */ | |
2109 | }; | |
2110 | ||
2111 | static struct hda_verb alc880_lg_init_verbs[] = { | |
2112 | /* set capture source to mic-in */ | |
2113 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2114 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2115 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2116 | /* mute all amp mixer inputs */ | |
2117 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
2118 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
2119 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
2120 | /* line-in to input */ |
2121 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2122 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2123 | /* built-in mic */ | |
2124 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2125 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2126 | /* speaker-out */ | |
2127 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2128 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2129 | /* mic-in to input */ | |
2130 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2131 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2132 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2133 | /* HP-out */ | |
2134 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
2135 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2136 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2137 | /* jack sense */ | |
2138 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2139 | { } | |
2140 | }; | |
2141 | ||
2142 | /* toggle speaker-output according to the hp-jack state */ | |
2143 | static void alc880_lg_automute(struct hda_codec *codec) | |
2144 | { | |
2145 | unsigned int present; | |
f12ab1e0 | 2146 | unsigned char bits; |
ae6b813a TI |
2147 | |
2148 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2149 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2150 | bits = present ? HDA_AMP_MUTE : 0; |
2151 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
2152 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
2153 | } |
2154 | ||
2155 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
2156 | { | |
2157 | /* Looks like the unsol event is incompatible with the standard | |
2158 | * definition. 4bit tag is placed at 28 bit! | |
2159 | */ | |
2160 | if ((res >> 28) == 0x01) | |
2161 | alc880_lg_automute(codec); | |
2162 | } | |
2163 | ||
d681518a TI |
2164 | /* |
2165 | * LG LW20 | |
2166 | * | |
2167 | * Pin assignment: | |
2168 | * Speaker-out: 0x14 | |
2169 | * Mic-In: 0x18 | |
e4f41da9 CM |
2170 | * Built-in Mic-In: 0x19 |
2171 | * Line-In: 0x1b | |
2172 | * HP-Out: 0x1a | |
d681518a TI |
2173 | * SPDIF-Out: 0x1e |
2174 | */ | |
2175 | ||
d681518a | 2176 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 2177 | .num_items = 3, |
d681518a TI |
2178 | .items = { |
2179 | { "Mic", 0x0 }, | |
2180 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 2181 | { "Line In", 0x2 }, |
d681518a TI |
2182 | }, |
2183 | }; | |
2184 | ||
0a8c5da3 CM |
2185 | #define alc880_lg_lw_modes alc880_threestack_modes |
2186 | ||
d681518a | 2187 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
2188 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2189 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2190 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
2191 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
2192 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
2193 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
2194 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
2195 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
2196 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
2197 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
2198 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
2199 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2200 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
2201 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
2202 | { |
2203 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2204 | .name = "Channel Mode", | |
2205 | .info = alc_ch_mode_info, | |
2206 | .get = alc_ch_mode_get, | |
2207 | .put = alc_ch_mode_put, | |
2208 | }, | |
d681518a TI |
2209 | { } /* end */ |
2210 | }; | |
2211 | ||
2212 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
2213 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2214 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2215 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2216 | ||
d681518a TI |
2217 | /* set capture source to mic-in */ |
2218 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2219 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2220 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 2221 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
2222 | /* speaker-out */ |
2223 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2224 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2225 | /* HP-out */ | |
d681518a TI |
2226 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2227 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2228 | /* mic-in to input */ | |
2229 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2230 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2231 | /* built-in mic */ | |
2232 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2233 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2234 | /* jack sense */ | |
2235 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2236 | { } | |
2237 | }; | |
2238 | ||
2239 | /* toggle speaker-output according to the hp-jack state */ | |
2240 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
2241 | { | |
2242 | unsigned int present; | |
f12ab1e0 | 2243 | unsigned char bits; |
d681518a TI |
2244 | |
2245 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2246 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2247 | bits = present ? HDA_AMP_MUTE : 0; |
2248 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
2249 | HDA_AMP_MUTE, bits); | |
d681518a TI |
2250 | } |
2251 | ||
2252 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
2253 | { | |
2254 | /* Looks like the unsol event is incompatible with the standard | |
2255 | * definition. 4bit tag is placed at 28 bit! | |
2256 | */ | |
2257 | if ((res >> 28) == 0x01) | |
2258 | alc880_lg_lw_automute(codec); | |
2259 | } | |
2260 | ||
cb53c626 TI |
2261 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2262 | static struct hda_amp_list alc880_loopbacks[] = { | |
2263 | { 0x0b, HDA_INPUT, 0 }, | |
2264 | { 0x0b, HDA_INPUT, 1 }, | |
2265 | { 0x0b, HDA_INPUT, 2 }, | |
2266 | { 0x0b, HDA_INPUT, 3 }, | |
2267 | { 0x0b, HDA_INPUT, 4 }, | |
2268 | { } /* end */ | |
2269 | }; | |
2270 | ||
2271 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2272 | { 0x0b, HDA_INPUT, 1 }, | |
2273 | { 0x0b, HDA_INPUT, 6 }, | |
2274 | { 0x0b, HDA_INPUT, 7 }, | |
2275 | { } /* end */ | |
2276 | }; | |
2277 | #endif | |
2278 | ||
ae6b813a TI |
2279 | /* |
2280 | * Common callbacks | |
e9edcee0 TI |
2281 | */ |
2282 | ||
1da177e4 LT |
2283 | static int alc_init(struct hda_codec *codec) |
2284 | { | |
2285 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2286 | unsigned int i; |
2287 | ||
2288 | for (i = 0; i < spec->num_init_verbs; i++) | |
2289 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2290 | |
2291 | if (spec->init_hook) | |
2292 | spec->init_hook(codec); | |
2293 | ||
1da177e4 LT |
2294 | return 0; |
2295 | } | |
2296 | ||
ae6b813a TI |
2297 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2298 | { | |
2299 | struct alc_spec *spec = codec->spec; | |
2300 | ||
2301 | if (spec->unsol_event) | |
2302 | spec->unsol_event(codec, res); | |
2303 | } | |
2304 | ||
cb53c626 TI |
2305 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2306 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2307 | { | |
2308 | struct alc_spec *spec = codec->spec; | |
2309 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2310 | } | |
2311 | #endif | |
2312 | ||
1da177e4 LT |
2313 | /* |
2314 | * Analog playback callbacks | |
2315 | */ | |
2316 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2317 | struct hda_codec *codec, | |
c8b6bf9b | 2318 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2319 | { |
2320 | struct alc_spec *spec = codec->spec; | |
2321 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | |
2322 | } | |
2323 | ||
2324 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2325 | struct hda_codec *codec, | |
2326 | unsigned int stream_tag, | |
2327 | unsigned int format, | |
c8b6bf9b | 2328 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2329 | { |
2330 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2331 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2332 | stream_tag, format, substream); | |
1da177e4 LT |
2333 | } |
2334 | ||
2335 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2336 | struct hda_codec *codec, | |
c8b6bf9b | 2337 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2338 | { |
2339 | struct alc_spec *spec = codec->spec; | |
2340 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2341 | } | |
2342 | ||
2343 | /* | |
2344 | * Digital out | |
2345 | */ | |
2346 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2347 | struct hda_codec *codec, | |
c8b6bf9b | 2348 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2349 | { |
2350 | struct alc_spec *spec = codec->spec; | |
2351 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2352 | } | |
2353 | ||
6b97eb45 TI |
2354 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2355 | struct hda_codec *codec, | |
2356 | unsigned int stream_tag, | |
2357 | unsigned int format, | |
2358 | struct snd_pcm_substream *substream) | |
2359 | { | |
2360 | struct alc_spec *spec = codec->spec; | |
2361 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2362 | stream_tag, format, substream); | |
2363 | } | |
2364 | ||
1da177e4 LT |
2365 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2366 | struct hda_codec *codec, | |
c8b6bf9b | 2367 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2368 | { |
2369 | struct alc_spec *spec = codec->spec; | |
2370 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2371 | } | |
2372 | ||
2373 | /* | |
2374 | * Analog capture | |
2375 | */ | |
6330079f | 2376 | static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
1da177e4 LT |
2377 | struct hda_codec *codec, |
2378 | unsigned int stream_tag, | |
2379 | unsigned int format, | |
c8b6bf9b | 2380 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2381 | { |
2382 | struct alc_spec *spec = codec->spec; | |
2383 | ||
6330079f | 2384 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
1da177e4 LT |
2385 | stream_tag, 0, format); |
2386 | return 0; | |
2387 | } | |
2388 | ||
6330079f | 2389 | static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
1da177e4 | 2390 | struct hda_codec *codec, |
c8b6bf9b | 2391 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2392 | { |
2393 | struct alc_spec *spec = codec->spec; | |
2394 | ||
6330079f | 2395 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
9c7f852e | 2396 | 0, 0, 0); |
1da177e4 LT |
2397 | return 0; |
2398 | } | |
2399 | ||
2400 | ||
2401 | /* | |
2402 | */ | |
2403 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2404 | .substreams = 1, | |
2405 | .channels_min = 2, | |
2406 | .channels_max = 8, | |
e9edcee0 | 2407 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2408 | .ops = { |
2409 | .open = alc880_playback_pcm_open, | |
2410 | .prepare = alc880_playback_pcm_prepare, | |
2411 | .cleanup = alc880_playback_pcm_cleanup | |
2412 | }, | |
2413 | }; | |
2414 | ||
2415 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
6330079f TI |
2416 | .substreams = 1, |
2417 | .channels_min = 2, | |
2418 | .channels_max = 2, | |
2419 | /* NID is set in alc_build_pcms */ | |
2420 | }; | |
2421 | ||
2422 | static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { | |
2423 | .substreams = 1, | |
2424 | .channels_min = 2, | |
2425 | .channels_max = 2, | |
2426 | /* NID is set in alc_build_pcms */ | |
2427 | }; | |
2428 | ||
2429 | static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { | |
2430 | .substreams = 2, /* can be overridden */ | |
1da177e4 LT |
2431 | .channels_min = 2, |
2432 | .channels_max = 2, | |
e9edcee0 | 2433 | /* NID is set in alc_build_pcms */ |
1da177e4 | 2434 | .ops = { |
6330079f TI |
2435 | .prepare = alc880_alt_capture_pcm_prepare, |
2436 | .cleanup = alc880_alt_capture_pcm_cleanup | |
1da177e4 LT |
2437 | }, |
2438 | }; | |
2439 | ||
2440 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
2441 | .substreams = 1, | |
2442 | .channels_min = 2, | |
2443 | .channels_max = 2, | |
2444 | /* NID is set in alc_build_pcms */ | |
2445 | .ops = { | |
2446 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
2447 | .close = alc880_dig_playback_pcm_close, |
2448 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
2449 | }, |
2450 | }; | |
2451 | ||
2452 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
2453 | .substreams = 1, | |
2454 | .channels_min = 2, | |
2455 | .channels_max = 2, | |
2456 | /* NID is set in alc_build_pcms */ | |
2457 | }; | |
2458 | ||
4c5186ed | 2459 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
6330079f | 2460 | static struct hda_pcm_stream alc_pcm_null_stream = { |
4c5186ed JW |
2461 | .substreams = 0, |
2462 | .channels_min = 0, | |
2463 | .channels_max = 0, | |
2464 | }; | |
2465 | ||
1da177e4 LT |
2466 | static int alc_build_pcms(struct hda_codec *codec) |
2467 | { | |
2468 | struct alc_spec *spec = codec->spec; | |
2469 | struct hda_pcm *info = spec->pcm_rec; | |
2470 | int i; | |
2471 | ||
2472 | codec->num_pcms = 1; | |
2473 | codec->pcm_info = info; | |
2474 | ||
2475 | info->name = spec->stream_name_analog; | |
4a471b7d TI |
2476 | if (spec->stream_analog_playback) { |
2477 | snd_assert(spec->multiout.dac_nids, return -EINVAL); | |
2478 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | |
2479 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
2480 | } | |
2481 | if (spec->stream_analog_capture) { | |
2482 | snd_assert(spec->adc_nids, return -EINVAL); | |
2483 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2484 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
2485 | } | |
2486 | ||
2487 | if (spec->channel_mode) { | |
2488 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
2489 | for (i = 0; i < spec->num_channel_mode; i++) { | |
2490 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
2491 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
2492 | } | |
1da177e4 LT |
2493 | } |
2494 | } | |
2495 | ||
e08a007d | 2496 | /* SPDIF for stream index #1 */ |
1da177e4 | 2497 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 2498 | codec->num_pcms = 2; |
c06134d7 | 2499 | info = spec->pcm_rec + 1; |
1da177e4 | 2500 | info->name = spec->stream_name_digital; |
4a471b7d TI |
2501 | if (spec->multiout.dig_out_nid && |
2502 | spec->stream_digital_playback) { | |
1da177e4 LT |
2503 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
2504 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2505 | } | |
4a471b7d TI |
2506 | if (spec->dig_in_nid && |
2507 | spec->stream_digital_capture) { | |
1da177e4 LT |
2508 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
2509 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2510 | } | |
2511 | } | |
2512 | ||
e08a007d TI |
2513 | /* If the use of more than one ADC is requested for the current |
2514 | * model, configure a second analog capture-only PCM. | |
2515 | */ | |
2516 | /* Additional Analaog capture for index #2 */ | |
6330079f TI |
2517 | if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || |
2518 | (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { | |
e08a007d | 2519 | codec->num_pcms = 3; |
c06134d7 | 2520 | info = spec->pcm_rec + 2; |
e08a007d | 2521 | info->name = spec->stream_name_analog; |
6330079f TI |
2522 | if (spec->alt_dac_nid) { |
2523 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
2524 | *spec->stream_analog_alt_playback; | |
2525 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
2526 | spec->alt_dac_nid; | |
2527 | } else { | |
2528 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
2529 | alc_pcm_null_stream; | |
2530 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
2531 | } | |
2532 | if (spec->num_adc_nids > 1) { | |
2533 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
2534 | *spec->stream_analog_alt_capture; | |
2535 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
2536 | spec->adc_nids[1]; | |
2537 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
2538 | spec->num_adc_nids - 1; | |
2539 | } else { | |
2540 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
2541 | alc_pcm_null_stream; | |
2542 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; | |
e08a007d TI |
2543 | } |
2544 | } | |
2545 | ||
1da177e4 LT |
2546 | return 0; |
2547 | } | |
2548 | ||
2549 | static void alc_free(struct hda_codec *codec) | |
2550 | { | |
e9edcee0 TI |
2551 | struct alc_spec *spec = codec->spec; |
2552 | unsigned int i; | |
2553 | ||
f12ab1e0 | 2554 | if (!spec) |
e9edcee0 TI |
2555 | return; |
2556 | ||
2557 | if (spec->kctl_alloc) { | |
2558 | for (i = 0; i < spec->num_kctl_used; i++) | |
2559 | kfree(spec->kctl_alloc[i].name); | |
2560 | kfree(spec->kctl_alloc); | |
2561 | } | |
2562 | kfree(spec); | |
1da177e4 LT |
2563 | } |
2564 | ||
2565 | /* | |
2566 | */ | |
2567 | static struct hda_codec_ops alc_patch_ops = { | |
2568 | .build_controls = alc_build_controls, | |
2569 | .build_pcms = alc_build_pcms, | |
2570 | .init = alc_init, | |
2571 | .free = alc_free, | |
ae6b813a | 2572 | .unsol_event = alc_unsol_event, |
cb53c626 TI |
2573 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2574 | .check_power_status = alc_check_power_status, | |
2575 | #endif | |
1da177e4 LT |
2576 | }; |
2577 | ||
2fa522be TI |
2578 | |
2579 | /* | |
2580 | * Test configuration for debugging | |
2581 | * | |
2582 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
2583 | * enum controls. | |
2584 | */ | |
2585 | #ifdef CONFIG_SND_DEBUG | |
2586 | static hda_nid_t alc880_test_dac_nids[4] = { | |
2587 | 0x02, 0x03, 0x04, 0x05 | |
2588 | }; | |
2589 | ||
2590 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 2591 | .num_items = 7, |
2fa522be TI |
2592 | .items = { |
2593 | { "In-1", 0x0 }, | |
2594 | { "In-2", 0x1 }, | |
2595 | { "In-3", 0x2 }, | |
2596 | { "In-4", 0x3 }, | |
2597 | { "CD", 0x4 }, | |
ae6b813a TI |
2598 | { "Front", 0x5 }, |
2599 | { "Surround", 0x6 }, | |
2fa522be TI |
2600 | }, |
2601 | }; | |
2602 | ||
d2a6d7dc | 2603 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 2604 | { 2, NULL }, |
fd2c326d | 2605 | { 4, NULL }, |
2fa522be | 2606 | { 6, NULL }, |
fd2c326d | 2607 | { 8, NULL }, |
2fa522be TI |
2608 | }; |
2609 | ||
9c7f852e TI |
2610 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
2611 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2612 | { |
2613 | static char *texts[] = { | |
2614 | "N/A", "Line Out", "HP Out", | |
2615 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
2616 | }; | |
2617 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2618 | uinfo->count = 1; | |
2619 | uinfo->value.enumerated.items = 8; | |
2620 | if (uinfo->value.enumerated.item >= 8) | |
2621 | uinfo->value.enumerated.item = 7; | |
2622 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2623 | return 0; | |
2624 | } | |
2625 | ||
9c7f852e TI |
2626 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
2627 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2628 | { |
2629 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2630 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2631 | unsigned int pin_ctl, item = 0; | |
2632 | ||
2633 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
2634 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2635 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
2636 | if (pin_ctl & AC_PINCTL_HP_EN) | |
2637 | item = 2; | |
2638 | else | |
2639 | item = 1; | |
2640 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
2641 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
2642 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
2643 | case AC_PINCTL_VREF_50: item = 4; break; | |
2644 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
2645 | case AC_PINCTL_VREF_80: item = 6; break; | |
2646 | case AC_PINCTL_VREF_100: item = 7; break; | |
2647 | } | |
2648 | } | |
2649 | ucontrol->value.enumerated.item[0] = item; | |
2650 | return 0; | |
2651 | } | |
2652 | ||
9c7f852e TI |
2653 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
2654 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2655 | { |
2656 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2657 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2658 | static unsigned int ctls[] = { | |
2659 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
2660 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
2661 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
2662 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
2663 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
2664 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
2665 | }; | |
2666 | unsigned int old_ctl, new_ctl; | |
2667 | ||
2668 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
2669 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2670 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
2671 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
2672 | int val; |
2673 | snd_hda_codec_write_cache(codec, nid, 0, | |
2674 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2675 | new_ctl); | |
47fd830a TI |
2676 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
2677 | HDA_AMP_MUTE : 0; | |
2678 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
2679 | HDA_AMP_MUTE, val); | |
2fa522be TI |
2680 | return 1; |
2681 | } | |
2682 | return 0; | |
2683 | } | |
2684 | ||
9c7f852e TI |
2685 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
2686 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2687 | { |
2688 | static char *texts[] = { | |
2689 | "Front", "Surround", "CLFE", "Side" | |
2690 | }; | |
2691 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2692 | uinfo->count = 1; | |
2693 | uinfo->value.enumerated.items = 4; | |
2694 | if (uinfo->value.enumerated.item >= 4) | |
2695 | uinfo->value.enumerated.item = 3; | |
2696 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2697 | return 0; | |
2698 | } | |
2699 | ||
9c7f852e TI |
2700 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
2701 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2702 | { |
2703 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2704 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2705 | unsigned int sel; | |
2706 | ||
2707 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
2708 | ucontrol->value.enumerated.item[0] = sel & 3; | |
2709 | return 0; | |
2710 | } | |
2711 | ||
9c7f852e TI |
2712 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
2713 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2714 | { |
2715 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2716 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2717 | unsigned int sel; | |
2718 | ||
2719 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
2720 | if (ucontrol->value.enumerated.item[0] != sel) { | |
2721 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
2722 | snd_hda_codec_write_cache(codec, nid, 0, |
2723 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
2724 | return 1; |
2725 | } | |
2726 | return 0; | |
2727 | } | |
2728 | ||
2729 | #define PIN_CTL_TEST(xname,nid) { \ | |
2730 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2731 | .name = xname, \ | |
2732 | .info = alc_test_pin_ctl_info, \ | |
2733 | .get = alc_test_pin_ctl_get, \ | |
2734 | .put = alc_test_pin_ctl_put, \ | |
2735 | .private_value = nid \ | |
2736 | } | |
2737 | ||
2738 | #define PIN_SRC_TEST(xname,nid) { \ | |
2739 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2740 | .name = xname, \ | |
2741 | .info = alc_test_pin_src_info, \ | |
2742 | .get = alc_test_pin_src_get, \ | |
2743 | .put = alc_test_pin_src_put, \ | |
2744 | .private_value = nid \ | |
2745 | } | |
2746 | ||
c8b6bf9b | 2747 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
2748 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2749 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
2750 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
2751 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
2752 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
2753 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
2754 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
2755 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
2756 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
2757 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
2758 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
2759 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
2760 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
2761 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
2762 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
2763 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
2764 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
2765 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
2766 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
2767 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
2768 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2769 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2770 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2771 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2772 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
2773 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
2774 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
2775 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
2776 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
2777 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
2778 | { |
2779 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2780 | .name = "Channel Mode", | |
df694daa KY |
2781 | .info = alc_ch_mode_info, |
2782 | .get = alc_ch_mode_get, | |
2783 | .put = alc_ch_mode_put, | |
2fa522be TI |
2784 | }, |
2785 | { } /* end */ | |
2786 | }; | |
2787 | ||
2788 | static struct hda_verb alc880_test_init_verbs[] = { | |
2789 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
2790 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
2791 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2792 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2793 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2794 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2795 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2796 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2797 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 2798 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
2799 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2800 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2801 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2802 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 2803 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
2804 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2805 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2806 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2807 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 2808 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
2809 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2810 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2811 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2812 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 2813 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
2814 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2815 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
2816 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2817 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2818 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 2819 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
2820 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2821 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2822 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2823 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 2824 | /* ADC set up */ |
05acb863 | 2825 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2826 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2827 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2828 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2829 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2830 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
2831 | /* Analog input/passthru */ |
2832 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2833 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2834 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2835 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2836 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
2837 | { } |
2838 | }; | |
2839 | #endif | |
2840 | ||
1da177e4 LT |
2841 | /* |
2842 | */ | |
2843 | ||
f5fcc13c TI |
2844 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
2845 | [ALC880_3ST] = "3stack", | |
2846 | [ALC880_TCL_S700] = "tcl", | |
2847 | [ALC880_3ST_DIG] = "3stack-digout", | |
2848 | [ALC880_CLEVO] = "clevo", | |
2849 | [ALC880_5ST] = "5stack", | |
2850 | [ALC880_5ST_DIG] = "5stack-digout", | |
2851 | [ALC880_W810] = "w810", | |
2852 | [ALC880_Z71V] = "z71v", | |
2853 | [ALC880_6ST] = "6stack", | |
2854 | [ALC880_6ST_DIG] = "6stack-digout", | |
2855 | [ALC880_ASUS] = "asus", | |
2856 | [ALC880_ASUS_W1V] = "asus-w1v", | |
2857 | [ALC880_ASUS_DIG] = "asus-dig", | |
2858 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
2859 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
2860 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
2861 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
2862 | [ALC880_F1734] = "F1734", |
2863 | [ALC880_LG] = "lg", | |
2864 | [ALC880_LG_LW] = "lg-lw", | |
2fa522be | 2865 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 2866 | [ALC880_TEST] = "test", |
2fa522be | 2867 | #endif |
f5fcc13c TI |
2868 | [ALC880_AUTO] = "auto", |
2869 | }; | |
2870 | ||
2871 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
ac3e3741 | 2872 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
2873 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), |
2874 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
2875 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), | |
2876 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
2877 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
2878 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
2879 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
2880 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
f5fcc13c TI |
2881 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), |
2882 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
f5fcc13c TI |
2883 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), |
2884 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
2885 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
2886 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
2887 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
2888 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
2889 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
2890 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
2891 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
2892 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
0e4ceb75 | 2893 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS), |
f5fcc13c TI |
2894 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
2895 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
2896 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
ac3e3741 | 2897 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ |
f5fcc13c | 2898 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), |
ac3e3741 TI |
2899 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), |
2900 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
2901 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), |
2902 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
2903 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), |
2904 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
2905 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
2906 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
ac3e3741 TI |
2907 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), |
2908 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
f5fcc13c | 2909 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), |
ac3e3741 | 2910 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), |
f5fcc13c | 2911 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), |
ac3e3741 | 2912 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), |
f5fcc13c TI |
2913 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), |
2914 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
ac3e3741 TI |
2915 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), |
2916 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), | |
f5fcc13c | 2917 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), |
f5fcc13c | 2918 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), |
ac3e3741 | 2919 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), |
2cf9f0fc | 2920 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
ac3e3741 | 2921 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), |
f5fcc13c TI |
2922 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), |
2923 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
f5fcc13c | 2924 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), |
ac3e3741 TI |
2925 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), |
2926 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ | |
2927 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
2928 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
f5fcc13c TI |
2929 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), |
2930 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 | 2931 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), |
f5fcc13c | 2932 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), |
ac3e3741 TI |
2933 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), |
2934 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
f5fcc13c TI |
2935 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), |
2936 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
2937 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 TI |
2938 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ |
2939 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
2940 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
1da177e4 LT |
2941 | {} |
2942 | }; | |
2943 | ||
16ded525 | 2944 | /* |
df694daa | 2945 | * ALC880 codec presets |
16ded525 | 2946 | */ |
16ded525 TI |
2947 | static struct alc_config_preset alc880_presets[] = { |
2948 | [ALC880_3ST] = { | |
e9edcee0 | 2949 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2950 | .init_verbs = { alc880_volume_init_verbs, |
2951 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2952 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 2953 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
2954 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2955 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2956 | .need_dac_fix = 1, |
16ded525 TI |
2957 | .input_mux = &alc880_capture_source, |
2958 | }, | |
2959 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 2960 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2961 | .init_verbs = { alc880_volume_init_verbs, |
2962 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2963 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
2964 | .dac_nids = alc880_dac_nids, |
2965 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2966 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2967 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2968 | .need_dac_fix = 1, |
16ded525 TI |
2969 | .input_mux = &alc880_capture_source, |
2970 | }, | |
df694daa KY |
2971 | [ALC880_TCL_S700] = { |
2972 | .mixers = { alc880_tcl_s700_mixer }, | |
2973 | .init_verbs = { alc880_volume_init_verbs, | |
2974 | alc880_pin_tcl_S700_init_verbs, | |
2975 | alc880_gpio2_init_verbs }, | |
2976 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2977 | .dac_nids = alc880_dac_nids, | |
2978 | .hp_nid = 0x03, | |
2979 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2980 | .channel_mode = alc880_2_jack_modes, | |
2981 | .input_mux = &alc880_capture_source, | |
2982 | }, | |
16ded525 | 2983 | [ALC880_5ST] = { |
f12ab1e0 TI |
2984 | .mixers = { alc880_three_stack_mixer, |
2985 | alc880_five_stack_mixer}, | |
2986 | .init_verbs = { alc880_volume_init_verbs, | |
2987 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2988 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2989 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
2990 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2991 | .channel_mode = alc880_fivestack_modes, | |
2992 | .input_mux = &alc880_capture_source, | |
2993 | }, | |
2994 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
2995 | .mixers = { alc880_three_stack_mixer, |
2996 | alc880_five_stack_mixer }, | |
2997 | .init_verbs = { alc880_volume_init_verbs, | |
2998 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2999 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3000 | .dac_nids = alc880_dac_nids, | |
3001 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3002 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3003 | .channel_mode = alc880_fivestack_modes, | |
3004 | .input_mux = &alc880_capture_source, | |
3005 | }, | |
b6482d48 TI |
3006 | [ALC880_6ST] = { |
3007 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
3008 | .init_verbs = { alc880_volume_init_verbs, |
3009 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
3010 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3011 | .dac_nids = alc880_6st_dac_nids, | |
3012 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
3013 | .channel_mode = alc880_sixstack_modes, | |
3014 | .input_mux = &alc880_6stack_capture_source, | |
3015 | }, | |
16ded525 | 3016 | [ALC880_6ST_DIG] = { |
e9edcee0 | 3017 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
3018 | .init_verbs = { alc880_volume_init_verbs, |
3019 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
3020 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3021 | .dac_nids = alc880_6st_dac_nids, | |
3022 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3023 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
3024 | .channel_mode = alc880_sixstack_modes, | |
3025 | .input_mux = &alc880_6stack_capture_source, | |
3026 | }, | |
3027 | [ALC880_W810] = { | |
e9edcee0 | 3028 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
3029 | .init_verbs = { alc880_volume_init_verbs, |
3030 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 3031 | alc880_gpio2_init_verbs }, |
16ded525 TI |
3032 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
3033 | .dac_nids = alc880_w810_dac_nids, | |
3034 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3035 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
3036 | .channel_mode = alc880_w810_modes, | |
3037 | .input_mux = &alc880_capture_source, | |
3038 | }, | |
3039 | [ALC880_Z71V] = { | |
e9edcee0 | 3040 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
3041 | .init_verbs = { alc880_volume_init_verbs, |
3042 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
3043 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
3044 | .dac_nids = alc880_z71v_dac_nids, | |
3045 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3046 | .hp_nid = 0x03, | |
e9edcee0 TI |
3047 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3048 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
3049 | .input_mux = &alc880_capture_source, |
3050 | }, | |
3051 | [ALC880_F1734] = { | |
e9edcee0 | 3052 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
3053 | .init_verbs = { alc880_volume_init_verbs, |
3054 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
3055 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
3056 | .dac_nids = alc880_f1734_dac_nids, | |
3057 | .hp_nid = 0x02, | |
3058 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3059 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
3060 | .input_mux = &alc880_capture_source, |
3061 | }, | |
3062 | [ALC880_ASUS] = { | |
e9edcee0 | 3063 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3064 | .init_verbs = { alc880_volume_init_verbs, |
3065 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3066 | alc880_gpio1_init_verbs }, |
3067 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3068 | .dac_nids = alc880_asus_dac_nids, | |
3069 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3070 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3071 | .need_dac_fix = 1, |
16ded525 TI |
3072 | .input_mux = &alc880_capture_source, |
3073 | }, | |
3074 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 3075 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3076 | .init_verbs = { alc880_volume_init_verbs, |
3077 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3078 | alc880_gpio1_init_verbs }, |
3079 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3080 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3081 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3082 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3083 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3084 | .need_dac_fix = 1, |
16ded525 TI |
3085 | .input_mux = &alc880_capture_source, |
3086 | }, | |
df694daa KY |
3087 | [ALC880_ASUS_DIG2] = { |
3088 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
3089 | .init_verbs = { alc880_volume_init_verbs, |
3090 | alc880_pin_asus_init_verbs, | |
df694daa KY |
3091 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
3092 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3093 | .dac_nids = alc880_asus_dac_nids, | |
3094 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3095 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3096 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3097 | .need_dac_fix = 1, |
df694daa KY |
3098 | .input_mux = &alc880_capture_source, |
3099 | }, | |
16ded525 | 3100 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 3101 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
3102 | .init_verbs = { alc880_volume_init_verbs, |
3103 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3104 | alc880_gpio1_init_verbs }, |
3105 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3106 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3107 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3108 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3109 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3110 | .need_dac_fix = 1, |
16ded525 TI |
3111 | .input_mux = &alc880_capture_source, |
3112 | }, | |
3113 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 3114 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
3115 | .init_verbs = { alc880_volume_init_verbs, |
3116 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
3117 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
3118 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3119 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3120 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3121 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3122 | .need_dac_fix = 1, |
16ded525 TI |
3123 | .input_mux = &alc880_capture_source, |
3124 | }, | |
ccc656ce KY |
3125 | [ALC880_UNIWILL] = { |
3126 | .mixers = { alc880_uniwill_mixer }, | |
3127 | .init_verbs = { alc880_volume_init_verbs, | |
3128 | alc880_uniwill_init_verbs }, | |
3129 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3130 | .dac_nids = alc880_asus_dac_nids, | |
3131 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3132 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3133 | .channel_mode = alc880_threestack_modes, | |
3134 | .need_dac_fix = 1, | |
3135 | .input_mux = &alc880_capture_source, | |
3136 | .unsol_event = alc880_uniwill_unsol_event, | |
3137 | .init_hook = alc880_uniwill_automute, | |
3138 | }, | |
3139 | [ALC880_UNIWILL_P53] = { | |
3140 | .mixers = { alc880_uniwill_p53_mixer }, | |
3141 | .init_verbs = { alc880_volume_init_verbs, | |
3142 | alc880_uniwill_p53_init_verbs }, | |
3143 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3144 | .dac_nids = alc880_asus_dac_nids, | |
3145 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
3146 | .channel_mode = alc880_threestack_modes, |
3147 | .input_mux = &alc880_capture_source, | |
3148 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3149 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3150 | }, | |
3151 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 3152 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
3153 | alc880_pcbeep_mixer, }, |
3154 | .init_verbs = { alc880_volume_init_verbs, | |
3155 | alc880_uniwill_p53_init_verbs, | |
3156 | alc880_beep_init_verbs }, | |
3157 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3158 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 3159 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
3160 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3161 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
3162 | .input_mux = &alc880_capture_source, |
3163 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3164 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3165 | }, | |
df694daa KY |
3166 | [ALC880_CLEVO] = { |
3167 | .mixers = { alc880_three_stack_mixer }, | |
3168 | .init_verbs = { alc880_volume_init_verbs, | |
3169 | alc880_pin_clevo_init_verbs }, | |
3170 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3171 | .dac_nids = alc880_dac_nids, | |
3172 | .hp_nid = 0x03, | |
3173 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3174 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3175 | .need_dac_fix = 1, |
df694daa KY |
3176 | .input_mux = &alc880_capture_source, |
3177 | }, | |
ae6b813a TI |
3178 | [ALC880_LG] = { |
3179 | .mixers = { alc880_lg_mixer }, | |
3180 | .init_verbs = { alc880_volume_init_verbs, | |
3181 | alc880_lg_init_verbs }, | |
3182 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
3183 | .dac_nids = alc880_lg_dac_nids, | |
3184 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3185 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
3186 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 3187 | .need_dac_fix = 1, |
ae6b813a TI |
3188 | .input_mux = &alc880_lg_capture_source, |
3189 | .unsol_event = alc880_lg_unsol_event, | |
3190 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
3191 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3192 | .loopbacks = alc880_lg_loopbacks, | |
3193 | #endif | |
ae6b813a | 3194 | }, |
d681518a TI |
3195 | [ALC880_LG_LW] = { |
3196 | .mixers = { alc880_lg_lw_mixer }, | |
3197 | .init_verbs = { alc880_volume_init_verbs, | |
3198 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 3199 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
3200 | .dac_nids = alc880_dac_nids, |
3201 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
3202 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3203 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
3204 | .input_mux = &alc880_lg_lw_capture_source, |
3205 | .unsol_event = alc880_lg_lw_unsol_event, | |
3206 | .init_hook = alc880_lg_lw_automute, | |
3207 | }, | |
16ded525 TI |
3208 | #ifdef CONFIG_SND_DEBUG |
3209 | [ALC880_TEST] = { | |
e9edcee0 TI |
3210 | .mixers = { alc880_test_mixer }, |
3211 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
3212 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
3213 | .dac_nids = alc880_test_dac_nids, | |
3214 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3215 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
3216 | .channel_mode = alc880_test_modes, | |
3217 | .input_mux = &alc880_test_capture_source, | |
3218 | }, | |
3219 | #endif | |
3220 | }; | |
3221 | ||
e9edcee0 TI |
3222 | /* |
3223 | * Automatic parse of I/O pins from the BIOS configuration | |
3224 | */ | |
3225 | ||
3226 | #define NUM_CONTROL_ALLOC 32 | |
3227 | #define NUM_VERB_ALLOC 32 | |
3228 | ||
3229 | enum { | |
3230 | ALC_CTL_WIDGET_VOL, | |
3231 | ALC_CTL_WIDGET_MUTE, | |
3232 | ALC_CTL_BIND_MUTE, | |
3233 | }; | |
c8b6bf9b | 3234 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
3235 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
3236 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 3237 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
3238 | }; |
3239 | ||
3240 | /* add dynamic controls */ | |
f12ab1e0 TI |
3241 | static int add_control(struct alc_spec *spec, int type, const char *name, |
3242 | unsigned long val) | |
e9edcee0 | 3243 | { |
c8b6bf9b | 3244 | struct snd_kcontrol_new *knew; |
e9edcee0 TI |
3245 | |
3246 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | |
3247 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | |
3248 | ||
f12ab1e0 TI |
3249 | /* array + terminator */ |
3250 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); | |
3251 | if (!knew) | |
e9edcee0 TI |
3252 | return -ENOMEM; |
3253 | if (spec->kctl_alloc) { | |
f12ab1e0 TI |
3254 | memcpy(knew, spec->kctl_alloc, |
3255 | sizeof(*knew) * spec->num_kctl_alloc); | |
e9edcee0 TI |
3256 | kfree(spec->kctl_alloc); |
3257 | } | |
3258 | spec->kctl_alloc = knew; | |
3259 | spec->num_kctl_alloc = num; | |
3260 | } | |
3261 | ||
3262 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | |
3263 | *knew = alc880_control_templates[type]; | |
543537bd | 3264 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 3265 | if (!knew->name) |
e9edcee0 TI |
3266 | return -ENOMEM; |
3267 | knew->private_value = val; | |
3268 | spec->num_kctl_used++; | |
3269 | return 0; | |
3270 | } | |
3271 | ||
3272 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
3273 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
3274 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
3275 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
3276 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
3277 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
3278 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
3279 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
3280 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3281 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3282 | #define ALC880_PIN_CD_NID 0x1c | |
3283 | ||
3284 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
3285 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
3286 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3287 | { |
3288 | hda_nid_t nid; | |
3289 | int assigned[4]; | |
3290 | int i, j; | |
3291 | ||
3292 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 3293 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
3294 | |
3295 | /* check the pins hardwired to audio widget */ | |
3296 | for (i = 0; i < cfg->line_outs; i++) { | |
3297 | nid = cfg->line_out_pins[i]; | |
3298 | if (alc880_is_fixed_pin(nid)) { | |
3299 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 3300 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
3301 | assigned[idx] = 1; |
3302 | } | |
3303 | } | |
3304 | /* left pins can be connect to any audio widget */ | |
3305 | for (i = 0; i < cfg->line_outs; i++) { | |
3306 | nid = cfg->line_out_pins[i]; | |
3307 | if (alc880_is_fixed_pin(nid)) | |
3308 | continue; | |
3309 | /* search for an empty channel */ | |
3310 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3311 | if (!assigned[j]) { |
3312 | spec->multiout.dac_nids[i] = | |
3313 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3314 | assigned[j] = 1; |
3315 | break; | |
3316 | } | |
3317 | } | |
3318 | } | |
3319 | spec->multiout.num_dacs = cfg->line_outs; | |
3320 | return 0; | |
3321 | } | |
3322 | ||
3323 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3324 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3325 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3326 | { |
3327 | char name[32]; | |
f12ab1e0 TI |
3328 | static const char *chname[4] = { |
3329 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3330 | }; | |
e9edcee0 TI |
3331 | hda_nid_t nid; |
3332 | int i, err; | |
3333 | ||
3334 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 3335 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
3336 | continue; |
3337 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
3338 | if (i == 2) { | |
3339 | /* Center/LFE */ | |
f12ab1e0 TI |
3340 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3341 | "Center Playback Volume", | |
3342 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
3343 | HDA_OUTPUT)); | |
3344 | if (err < 0) | |
e9edcee0 | 3345 | return err; |
f12ab1e0 TI |
3346 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3347 | "LFE Playback Volume", | |
3348 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
3349 | HDA_OUTPUT)); | |
3350 | if (err < 0) | |
e9edcee0 | 3351 | return err; |
f12ab1e0 TI |
3352 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3353 | "Center Playback Switch", | |
3354 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
3355 | HDA_INPUT)); | |
3356 | if (err < 0) | |
e9edcee0 | 3357 | return err; |
f12ab1e0 TI |
3358 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3359 | "LFE Playback Switch", | |
3360 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
3361 | HDA_INPUT)); | |
3362 | if (err < 0) | |
e9edcee0 TI |
3363 | return err; |
3364 | } else { | |
3365 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
3366 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3367 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
3368 | HDA_OUTPUT)); | |
3369 | if (err < 0) | |
e9edcee0 TI |
3370 | return err; |
3371 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
3372 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3373 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
3374 | HDA_INPUT)); | |
3375 | if (err < 0) | |
e9edcee0 TI |
3376 | return err; |
3377 | } | |
3378 | } | |
e9edcee0 TI |
3379 | return 0; |
3380 | } | |
3381 | ||
8d88bc3d TI |
3382 | /* add playback controls for speaker and HP outputs */ |
3383 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
3384 | const char *pfx) | |
e9edcee0 TI |
3385 | { |
3386 | hda_nid_t nid; | |
3387 | int err; | |
8d88bc3d | 3388 | char name[32]; |
e9edcee0 | 3389 | |
f12ab1e0 | 3390 | if (!pin) |
e9edcee0 TI |
3391 | return 0; |
3392 | ||
3393 | if (alc880_is_fixed_pin(pin)) { | |
3394 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 3395 | /* specify the DAC as the extra output */ |
f12ab1e0 | 3396 | if (!spec->multiout.hp_nid) |
e9edcee0 | 3397 | spec->multiout.hp_nid = nid; |
82bc955f TI |
3398 | else |
3399 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
3400 | /* control HP volume/switch on the output mixer amp */ |
3401 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 3402 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
3403 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3404 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3405 | if (err < 0) | |
e9edcee0 | 3406 | return err; |
8d88bc3d | 3407 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3408 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3409 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
3410 | if (err < 0) | |
e9edcee0 TI |
3411 | return err; |
3412 | } else if (alc880_is_multi_pin(pin)) { | |
3413 | /* set manual connection */ | |
e9edcee0 | 3414 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 3415 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3416 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3417 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
3418 | if (err < 0) | |
e9edcee0 TI |
3419 | return err; |
3420 | } | |
3421 | return 0; | |
3422 | } | |
3423 | ||
3424 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
3425 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
3426 | const char *ctlname, | |
df694daa | 3427 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
3428 | { |
3429 | char name[32]; | |
df694daa | 3430 | int err; |
e9edcee0 TI |
3431 | |
3432 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
3433 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3434 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3435 | if (err < 0) | |
e9edcee0 TI |
3436 | return err; |
3437 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
3438 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3439 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3440 | if (err < 0) | |
e9edcee0 TI |
3441 | return err; |
3442 | return 0; | |
3443 | } | |
3444 | ||
3445 | /* create playback/capture controls for input pins */ | |
df694daa KY |
3446 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
3447 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 3448 | { |
e9edcee0 | 3449 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 3450 | int i, err, idx; |
e9edcee0 TI |
3451 | |
3452 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3453 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 3454 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
3455 | err = new_analog_input(spec, cfg->input_pins[i], |
3456 | auto_pin_cfg_labels[i], | |
df694daa | 3457 | idx, 0x0b); |
e9edcee0 TI |
3458 | if (err < 0) |
3459 | return err; | |
f12ab1e0 TI |
3460 | imux->items[imux->num_items].label = |
3461 | auto_pin_cfg_labels[i]; | |
3462 | imux->items[imux->num_items].index = | |
3463 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
3464 | imux->num_items++; |
3465 | } | |
3466 | } | |
3467 | return 0; | |
3468 | } | |
3469 | ||
df694daa KY |
3470 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
3471 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
3472 | int dac_idx) |
3473 | { | |
3474 | /* set as output */ | |
f12ab1e0 TI |
3475 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
3476 | pin_type); | |
3477 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
3478 | AMP_OUT_UNMUTE); | |
e9edcee0 TI |
3479 | /* need the manual connection? */ |
3480 | if (alc880_is_multi_pin(nid)) { | |
3481 | struct alc_spec *spec = codec->spec; | |
3482 | int idx = alc880_multi_pin_idx(nid); | |
3483 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
3484 | AC_VERB_SET_CONNECT_SEL, | |
3485 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
3486 | } | |
3487 | } | |
3488 | ||
baba8ee9 TI |
3489 | static int get_pin_type(int line_out_type) |
3490 | { | |
3491 | if (line_out_type == AUTO_PIN_HP_OUT) | |
3492 | return PIN_HP; | |
3493 | else | |
3494 | return PIN_OUT; | |
3495 | } | |
3496 | ||
e9edcee0 TI |
3497 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
3498 | { | |
3499 | struct alc_spec *spec = codec->spec; | |
3500 | int i; | |
bc9f98a9 KY |
3501 | |
3502 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | |
e9edcee0 TI |
3503 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
3504 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
3505 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
3506 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
3507 | } |
3508 | } | |
3509 | ||
8d88bc3d | 3510 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
3511 | { |
3512 | struct alc_spec *spec = codec->spec; | |
3513 | hda_nid_t pin; | |
3514 | ||
82bc955f | 3515 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
3516 | if (pin) /* connect to front */ |
3517 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 3518 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
3519 | if (pin) /* connect to front */ |
3520 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
3521 | } | |
3522 | ||
3523 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
3524 | { | |
3525 | struct alc_spec *spec = codec->spec; | |
3526 | int i; | |
3527 | ||
3528 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3529 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3530 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
3531 | snd_hda_codec_write(codec, nid, 0, |
3532 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3533 | i <= AUTO_PIN_FRONT_MIC ? | |
3534 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 3535 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
3536 | snd_hda_codec_write(codec, nid, 0, |
3537 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
3538 | AMP_OUT_MUTE); |
3539 | } | |
3540 | } | |
3541 | } | |
3542 | ||
3543 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
3544 | /* return 1 if successful, 0 if the proper config is not found, |
3545 | * or a negative error code | |
3546 | */ | |
e9edcee0 TI |
3547 | static int alc880_parse_auto_config(struct hda_codec *codec) |
3548 | { | |
3549 | struct alc_spec *spec = codec->spec; | |
3550 | int err; | |
df694daa | 3551 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 3552 | |
f12ab1e0 TI |
3553 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
3554 | alc880_ignore); | |
3555 | if (err < 0) | |
e9edcee0 | 3556 | return err; |
f12ab1e0 | 3557 | if (!spec->autocfg.line_outs) |
e9edcee0 | 3558 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 3559 | |
f12ab1e0 TI |
3560 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
3561 | if (err < 0) | |
3562 | return err; | |
3563 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
3564 | if (err < 0) | |
3565 | return err; | |
3566 | err = alc880_auto_create_extra_out(spec, | |
3567 | spec->autocfg.speaker_pins[0], | |
3568 | "Speaker"); | |
3569 | if (err < 0) | |
3570 | return err; | |
3571 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
3572 | "Headphone"); | |
3573 | if (err < 0) | |
3574 | return err; | |
3575 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
3576 | if (err < 0) | |
e9edcee0 TI |
3577 | return err; |
3578 | ||
3579 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
3580 | ||
3581 | if (spec->autocfg.dig_out_pin) | |
3582 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
3583 | if (spec->autocfg.dig_in_pin) | |
3584 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
3585 | ||
3586 | if (spec->kctl_alloc) | |
3587 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
3588 | ||
3589 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | |
3590 | ||
a1e8d2da | 3591 | spec->num_mux_defs = 1; |
e9edcee0 TI |
3592 | spec->input_mux = &spec->private_imux; |
3593 | ||
3594 | return 1; | |
3595 | } | |
3596 | ||
ae6b813a TI |
3597 | /* additional initialization for auto-configuration model */ |
3598 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 3599 | { |
e9edcee0 | 3600 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 3601 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 3602 | alc880_auto_init_analog_input(codec); |
e9edcee0 TI |
3603 | } |
3604 | ||
3605 | /* | |
3606 | * OK, here we have finally the patch for ALC880 | |
3607 | */ | |
3608 | ||
1da177e4 LT |
3609 | static int patch_alc880(struct hda_codec *codec) |
3610 | { | |
3611 | struct alc_spec *spec; | |
3612 | int board_config; | |
df694daa | 3613 | int err; |
1da177e4 | 3614 | |
e560d8d8 | 3615 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
3616 | if (spec == NULL) |
3617 | return -ENOMEM; | |
3618 | ||
3619 | codec->spec = spec; | |
3620 | ||
f5fcc13c TI |
3621 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
3622 | alc880_models, | |
3623 | alc880_cfg_tbl); | |
3624 | if (board_config < 0) { | |
9c7f852e TI |
3625 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
3626 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 3627 | board_config = ALC880_AUTO; |
1da177e4 | 3628 | } |
1da177e4 | 3629 | |
e9edcee0 TI |
3630 | if (board_config == ALC880_AUTO) { |
3631 | /* automatic parse from the BIOS config */ | |
3632 | err = alc880_parse_auto_config(codec); | |
3633 | if (err < 0) { | |
3634 | alc_free(codec); | |
3635 | return err; | |
f12ab1e0 | 3636 | } else if (!err) { |
9c7f852e TI |
3637 | printk(KERN_INFO |
3638 | "hda_codec: Cannot set up configuration " | |
3639 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
3640 | board_config = ALC880_3ST; |
3641 | } | |
1da177e4 LT |
3642 | } |
3643 | ||
df694daa KY |
3644 | if (board_config != ALC880_AUTO) |
3645 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
3646 | |
3647 | spec->stream_name_analog = "ALC880 Analog"; | |
3648 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
3649 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
6330079f | 3650 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
1da177e4 LT |
3651 | |
3652 | spec->stream_name_digital = "ALC880 Digital"; | |
3653 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
3654 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
3655 | ||
f12ab1e0 | 3656 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 3657 | /* check whether NID 0x07 is valid */ |
54d17403 | 3658 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
3659 | /* get type */ |
3660 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
3661 | if (wcap != AC_WID_AUD_IN) { |
3662 | spec->adc_nids = alc880_adc_nids_alt; | |
3663 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
f12ab1e0 TI |
3664 | spec->mixers[spec->num_mixers] = |
3665 | alc880_capture_alt_mixer; | |
e9edcee0 TI |
3666 | spec->num_mixers++; |
3667 | } else { | |
3668 | spec->adc_nids = alc880_adc_nids; | |
3669 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
3670 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | |
3671 | spec->num_mixers++; | |
3672 | } | |
3673 | } | |
1da177e4 | 3674 | |
2134ea4f TI |
3675 | spec->vmaster_nid = 0x0c; |
3676 | ||
1da177e4 | 3677 | codec->patch_ops = alc_patch_ops; |
e9edcee0 | 3678 | if (board_config == ALC880_AUTO) |
ae6b813a | 3679 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
3680 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3681 | if (!spec->loopback.amplist) | |
3682 | spec->loopback.amplist = alc880_loopbacks; | |
3683 | #endif | |
1da177e4 LT |
3684 | |
3685 | return 0; | |
3686 | } | |
3687 | ||
e9edcee0 | 3688 | |
1da177e4 LT |
3689 | /* |
3690 | * ALC260 support | |
3691 | */ | |
3692 | ||
e9edcee0 TI |
3693 | static hda_nid_t alc260_dac_nids[1] = { |
3694 | /* front */ | |
3695 | 0x02, | |
3696 | }; | |
3697 | ||
3698 | static hda_nid_t alc260_adc_nids[1] = { | |
3699 | /* ADC0 */ | |
3700 | 0x04, | |
3701 | }; | |
3702 | ||
df694daa | 3703 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
3704 | /* ADC1 */ |
3705 | 0x05, | |
3706 | }; | |
3707 | ||
df694daa KY |
3708 | static hda_nid_t alc260_hp_adc_nids[2] = { |
3709 | /* ADC1, 0 */ | |
3710 | 0x05, 0x04 | |
3711 | }; | |
3712 | ||
d57fdac0 JW |
3713 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
3714 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
3715 | */ | |
3716 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
3717 | /* ADC0, ADC1 */ |
3718 | 0x04, 0x05 | |
3719 | }; | |
3720 | ||
e9edcee0 TI |
3721 | #define ALC260_DIGOUT_NID 0x03 |
3722 | #define ALC260_DIGIN_NID 0x06 | |
3723 | ||
3724 | static struct hda_input_mux alc260_capture_source = { | |
3725 | .num_items = 4, | |
3726 | .items = { | |
3727 | { "Mic", 0x0 }, | |
3728 | { "Front Mic", 0x1 }, | |
3729 | { "Line", 0x2 }, | |
3730 | { "CD", 0x4 }, | |
3731 | }, | |
3732 | }; | |
3733 | ||
17e7aec6 | 3734 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
3735 | * headphone jack and the internal CD lines since these are the only pins at |
3736 | * which audio can appear. For flexibility, also allow the option of | |
3737 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
3738 | * connection to the mixer output). | |
a9430dd8 | 3739 | */ |
a1e8d2da JW |
3740 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
3741 | { | |
3742 | .num_items = 3, | |
3743 | .items = { | |
3744 | { "Mic/Line", 0x0 }, | |
3745 | { "CD", 0x4 }, | |
3746 | { "Headphone", 0x2 }, | |
3747 | }, | |
a9430dd8 | 3748 | }, |
a1e8d2da JW |
3749 | { |
3750 | .num_items = 4, | |
3751 | .items = { | |
3752 | { "Mic/Line", 0x0 }, | |
3753 | { "CD", 0x4 }, | |
3754 | { "Headphone", 0x2 }, | |
3755 | { "Mixer", 0x5 }, | |
3756 | }, | |
3757 | }, | |
3758 | ||
a9430dd8 JW |
3759 | }; |
3760 | ||
a1e8d2da JW |
3761 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
3762 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 3763 | */ |
a1e8d2da JW |
3764 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
3765 | { | |
3766 | .num_items = 4, | |
3767 | .items = { | |
3768 | { "Mic", 0x0 }, | |
3769 | { "Line", 0x2 }, | |
3770 | { "CD", 0x4 }, | |
3771 | { "Headphone", 0x5 }, | |
3772 | }, | |
3773 | }, | |
3774 | { | |
3775 | .num_items = 5, | |
3776 | .items = { | |
3777 | { "Mic", 0x0 }, | |
3778 | { "Line", 0x2 }, | |
3779 | { "CD", 0x4 }, | |
3780 | { "Headphone", 0x6 }, | |
3781 | { "Mixer", 0x5 }, | |
3782 | }, | |
0bfc90e9 JW |
3783 | }, |
3784 | }; | |
1da177e4 LT |
3785 | /* |
3786 | * This is just place-holder, so there's something for alc_build_pcms to look | |
3787 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
3788 | * element which allows changing the channel mode, so the verb list is | |
3789 | * never used. | |
3790 | */ | |
d2a6d7dc | 3791 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
3792 | { 2, NULL }, |
3793 | }; | |
3794 | ||
df694daa KY |
3795 | |
3796 | /* Mixer combinations | |
3797 | * | |
3798 | * basic: base_output + input + pc_beep + capture | |
3799 | * HP: base_output + input + capture_alt | |
3800 | * HP_3013: hp_3013 + input + capture | |
3801 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 3802 | * acer: acer + capture |
df694daa KY |
3803 | */ |
3804 | ||
3805 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 3806 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3807 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 3808 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 3809 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 3810 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 3811 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 3812 | { } /* end */ |
f12ab1e0 | 3813 | }; |
1da177e4 | 3814 | |
df694daa | 3815 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
3816 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3817 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3818 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3819 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3820 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3821 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3822 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
3823 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
3824 | { } /* end */ |
3825 | }; | |
3826 | ||
3827 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
3828 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3829 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3830 | { } /* end */ | |
3831 | }; | |
3832 | ||
bec15c3a TI |
3833 | /* update HP, line and mono out pins according to the master switch */ |
3834 | static void alc260_hp_master_update(struct hda_codec *codec, | |
3835 | hda_nid_t hp, hda_nid_t line, | |
3836 | hda_nid_t mono) | |
3837 | { | |
3838 | struct alc_spec *spec = codec->spec; | |
3839 | unsigned int val = spec->master_sw ? PIN_HP : 0; | |
3840 | /* change HP and line-out pins */ | |
3841 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3842 | val); | |
3843 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3844 | val); | |
3845 | /* mono (speaker) depending on the HP jack sense */ | |
3846 | val = (val && !spec->jack_present) ? PIN_OUT : 0; | |
3847 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3848 | val); | |
3849 | } | |
3850 | ||
3851 | static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
3852 | struct snd_ctl_elem_value *ucontrol) | |
3853 | { | |
3854 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3855 | struct alc_spec *spec = codec->spec; | |
3856 | *ucontrol->value.integer.value = spec->master_sw; | |
3857 | return 0; | |
3858 | } | |
3859 | ||
3860 | static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
3861 | struct snd_ctl_elem_value *ucontrol) | |
3862 | { | |
3863 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3864 | struct alc_spec *spec = codec->spec; | |
3865 | int val = !!*ucontrol->value.integer.value; | |
3866 | hda_nid_t hp, line, mono; | |
3867 | ||
3868 | if (val == spec->master_sw) | |
3869 | return 0; | |
3870 | spec->master_sw = val; | |
3871 | hp = (kcontrol->private_value >> 16) & 0xff; | |
3872 | line = (kcontrol->private_value >> 8) & 0xff; | |
3873 | mono = kcontrol->private_value & 0xff; | |
3874 | alc260_hp_master_update(codec, hp, line, mono); | |
3875 | return 1; | |
3876 | } | |
3877 | ||
3878 | static struct snd_kcontrol_new alc260_hp_output_mixer[] = { | |
3879 | { | |
3880 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3881 | .name = "Master Playback Switch", | |
3882 | .info = snd_ctl_boolean_mono_info, | |
3883 | .get = alc260_hp_master_sw_get, | |
3884 | .put = alc260_hp_master_sw_put, | |
3885 | .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 | |
3886 | }, | |
3887 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3888 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), | |
3889 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
3890 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), | |
3891 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, | |
3892 | HDA_OUTPUT), | |
3893 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
3894 | { } /* end */ | |
3895 | }; | |
3896 | ||
3897 | static struct hda_verb alc260_hp_unsol_verbs[] = { | |
3898 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
3899 | {}, | |
3900 | }; | |
3901 | ||
3902 | static void alc260_hp_automute(struct hda_codec *codec) | |
3903 | { | |
3904 | struct alc_spec *spec = codec->spec; | |
3905 | unsigned int present; | |
3906 | ||
3907 | present = snd_hda_codec_read(codec, 0x10, 0, | |
3908 | AC_VERB_GET_PIN_SENSE, 0); | |
3909 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
3910 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | |
3911 | } | |
3912 | ||
3913 | static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) | |
3914 | { | |
3915 | if ((res >> 26) == ALC880_HP_EVENT) | |
3916 | alc260_hp_automute(codec); | |
3917 | } | |
3918 | ||
df694daa | 3919 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
bec15c3a TI |
3920 | { |
3921 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3922 | .name = "Master Playback Switch", | |
3923 | .info = snd_ctl_boolean_mono_info, | |
3924 | .get = alc260_hp_master_sw_get, | |
3925 | .put = alc260_hp_master_sw_put, | |
3926 | .private_value = (0x10 << 16) | (0x15 << 8) | 0x11 | |
3927 | }, | |
df694daa KY |
3928 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
3929 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
3930 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
3931 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
3932 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3933 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
3934 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
3935 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
3936 | { } /* end */ |
3937 | }; | |
3938 | ||
bec15c3a TI |
3939 | static struct hda_verb alc260_hp_3013_unsol_verbs[] = { |
3940 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
3941 | {}, | |
3942 | }; | |
3943 | ||
3944 | static void alc260_hp_3013_automute(struct hda_codec *codec) | |
3945 | { | |
3946 | struct alc_spec *spec = codec->spec; | |
3947 | unsigned int present; | |
3948 | ||
3949 | present = snd_hda_codec_read(codec, 0x15, 0, | |
3950 | AC_VERB_GET_PIN_SENSE, 0); | |
3951 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
3952 | alc260_hp_master_update(codec, 0x10, 0x15, 0x11); | |
3953 | } | |
3954 | ||
3955 | static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |
3956 | unsigned int res) | |
3957 | { | |
3958 | if ((res >> 26) == ALC880_HP_EVENT) | |
3959 | alc260_hp_3013_automute(codec); | |
3960 | } | |
3961 | ||
a1e8d2da JW |
3962 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, |
3963 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. | |
3964 | */ | |
c8b6bf9b | 3965 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 3966 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3967 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 3968 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
3969 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3970 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3971 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3972 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 3973 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
3974 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
3975 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3976 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
985be54b | 3977 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
df694daa KY |
3978 | { } /* end */ |
3979 | }; | |
3980 | ||
a1e8d2da JW |
3981 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
3982 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
3983 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
3984 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
3985 | * whether this behaviour is intentional or is a hardware bug in chip | |
3986 | * revisions available in early 2006. Therefore for now allow the | |
3987 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
3988 | * that the lack of mic bias for this NID is intentional we could change the | |
3989 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
3990 | * | |
3991 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
3992 | * don't appear to make the mic bias available from the "line" jack, even | |
3993 | * though the NID used for this jack (0x14) can supply it. The theory is | |
3994 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
3995 | * and the output jack. If this turns out to be the case for all such | |
3996 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
3997 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
3998 | * |
3999 | * The C20x Tablet series have a mono internal speaker which is controlled | |
4000 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
4001 | * controls for such models. On models without a "mono speaker" the control | |
4002 | * won't do anything. | |
a1e8d2da | 4003 | */ |
0bfc90e9 JW |
4004 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
4005 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4006 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 4007 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
bd869485 JW |
4008 | HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0, |
4009 | HDA_OUTPUT), | |
4010 | HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2, | |
4011 | HDA_INPUT), | |
0bfc90e9 JW |
4012 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4013 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4014 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4015 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4016 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4017 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4018 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4019 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4020 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4021 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4022 | { } /* end */ | |
4023 | }; | |
4024 | ||
bc9f98a9 KY |
4025 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
4026 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
4027 | */ | |
4028 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
4029 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4030 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4031 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4032 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4033 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4034 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4035 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4036 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4037 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4038 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4039 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4040 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4041 | { } /* end */ | |
4042 | }; | |
4043 | ||
4044 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
4045 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
4046 | */ | |
4047 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
4048 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4049 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4050 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4051 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4052 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4053 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
4054 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
4055 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4056 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4057 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4058 | { } /* end */ | |
4059 | }; | |
4060 | ||
df694daa KY |
4061 | /* capture mixer elements */ |
4062 | static struct snd_kcontrol_new alc260_capture_mixer[] = { | |
a9430dd8 JW |
4063 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
4064 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | |
df694daa KY |
4065 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
4066 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), | |
a9430dd8 JW |
4067 | { |
4068 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
df694daa KY |
4069 | /* The multiple "Capture Source" controls confuse alsamixer |
4070 | * So call somewhat different.. | |
df694daa KY |
4071 | */ |
4072 | /* .name = "Capture Source", */ | |
4073 | .name = "Input Source", | |
4074 | .count = 2, | |
4075 | .info = alc_mux_enum_info, | |
4076 | .get = alc_mux_enum_get, | |
4077 | .put = alc_mux_enum_put, | |
4078 | }, | |
4079 | { } /* end */ | |
4080 | }; | |
4081 | ||
4082 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { | |
4083 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | |
4084 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | |
4085 | { | |
4086 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4087 | /* The multiple "Capture Source" controls confuse alsamixer | |
4088 | * So call somewhat different.. | |
df694daa KY |
4089 | */ |
4090 | /* .name = "Capture Source", */ | |
4091 | .name = "Input Source", | |
4092 | .count = 1, | |
a9430dd8 JW |
4093 | .info = alc_mux_enum_info, |
4094 | .get = alc_mux_enum_get, | |
4095 | .put = alc_mux_enum_put, | |
4096 | }, | |
4097 | { } /* end */ | |
4098 | }; | |
4099 | ||
df694daa KY |
4100 | /* |
4101 | * initialization verbs | |
4102 | */ | |
1da177e4 LT |
4103 | static struct hda_verb alc260_init_verbs[] = { |
4104 | /* Line In pin widget for input */ | |
05acb863 | 4105 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4106 | /* CD pin widget for input */ |
05acb863 | 4107 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4108 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 4109 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4110 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 4111 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4112 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 4113 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4114 | /* select line-out */ |
fd56f2db | 4115 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 4116 | /* LINE-OUT pin */ |
05acb863 | 4117 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4118 | /* enable HP */ |
05acb863 | 4119 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 4120 | /* enable Mono */ |
05acb863 TI |
4121 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
4122 | /* mute capture amp left and right */ | |
16ded525 | 4123 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
4124 | /* set connection select to line in (default select for this ADC) */ |
4125 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
4126 | /* mute capture amp left and right */ |
4127 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4128 | /* set connection select to line in (default select for this ADC) */ | |
4129 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
4130 | /* set vol=0 Line-Out mixer amp left and right */ |
4131 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4132 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4133 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4134 | /* set vol=0 HP mixer amp left and right */ | |
4135 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4136 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4137 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4138 | /* set vol=0 Mono mixer amp left and right */ | |
4139 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4140 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4141 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4142 | /* unmute LINE-2 out pin */ | |
4143 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
4144 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4145 | * Line In 2 = 0x03 | |
4146 | */ | |
cb53c626 TI |
4147 | /* mute analog inputs */ |
4148 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4149 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4150 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4151 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4152 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4153 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
4154 | /* mute Front out path */ |
4155 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4156 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4157 | /* mute Headphone out path */ | |
4158 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4159 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4160 | /* mute Mono out path */ | |
4161 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4162 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
4163 | { } |
4164 | }; | |
4165 | ||
474167d6 | 4166 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
4167 | static struct hda_verb alc260_hp_init_verbs[] = { |
4168 | /* Headphone and output */ | |
4169 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4170 | /* mono output */ | |
4171 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4172 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4173 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4174 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4175 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4176 | /* Line In pin widget for input */ | |
4177 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4178 | /* Line-2 pin widget for output */ | |
4179 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4180 | /* CD pin widget for input */ | |
4181 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4182 | /* unmute amp left and right */ | |
4183 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4184 | /* set connection select to line in (default select for this ADC) */ | |
4185 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4186 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4187 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4188 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4189 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4190 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4191 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4192 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4193 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4194 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4195 | * Line In 2 = 0x03 | |
4196 | */ | |
cb53c626 TI |
4197 | /* mute analog inputs */ |
4198 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4199 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4200 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4201 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4202 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4203 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4204 | /* Unmute Front out path */ | |
4205 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4206 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4207 | /* Unmute Headphone out path */ | |
4208 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4209 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4210 | /* Unmute Mono out path */ | |
4211 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4212 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4213 | { } | |
4214 | }; | |
474167d6 | 4215 | #endif |
df694daa KY |
4216 | |
4217 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
4218 | /* Line out and output */ | |
4219 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4220 | /* mono output */ | |
4221 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4222 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4223 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4224 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4225 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4226 | /* Line In pin widget for input */ | |
4227 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4228 | /* Headphone pin widget for output */ | |
4229 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4230 | /* CD pin widget for input */ | |
4231 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4232 | /* unmute amp left and right */ | |
4233 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4234 | /* set connection select to line in (default select for this ADC) */ | |
4235 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4236 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4237 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4238 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4239 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4240 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4241 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4242 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4243 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4244 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4245 | * Line In 2 = 0x03 | |
4246 | */ | |
cb53c626 TI |
4247 | /* mute analog inputs */ |
4248 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4249 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4250 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4251 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4252 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4253 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4254 | /* Unmute Front out path */ | |
4255 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4256 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4257 | /* Unmute Headphone out path */ | |
4258 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4259 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4260 | /* Unmute Mono out path */ | |
4261 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4262 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4263 | { } | |
4264 | }; | |
4265 | ||
a9430dd8 | 4266 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
4267 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
4268 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
4269 | */ |
4270 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
4271 | /* Disable all GPIOs */ | |
4272 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
4273 | /* Internal speaker is connected to headphone pin */ | |
4274 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4275 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
4276 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
4277 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
4278 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
4279 | /* Ensure all other unused pins are disabled and muted. */ | |
4280 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4281 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 4282 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 4283 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 4284 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
4285 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4286 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4287 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4288 | ||
4289 | /* Disable digital (SPDIF) pins */ | |
4290 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4291 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 4292 | |
f7ace40d JW |
4293 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
4294 | * when acting as an output. | |
4295 | */ | |
4296 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 4297 | |
f7ace40d | 4298 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
4299 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4300 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4301 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4302 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4303 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4304 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4305 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4306 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4307 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 4308 | |
f7ace40d JW |
4309 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
4310 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4311 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
4312 | * If the pin mode is changed by the user the pin mode control will | |
4313 | * take care of enabling the pin's input/output buffers as needed. | |
4314 | * Therefore there's no need to enable the input buffer at this | |
4315 | * stage. | |
cdcd9268 | 4316 | */ |
f7ace40d | 4317 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
cdcd9268 JW |
4318 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
4319 | * mixer ctrl) | |
4320 | */ | |
f7ace40d JW |
4321 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4322 | ||
4323 | /* Mute capture amp left and right */ | |
4324 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4325 | /* Set ADC connection select to match default mixer setting - line | |
4326 | * in (on mic1 pin) | |
4327 | */ | |
4328 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4329 | ||
4330 | /* Do the same for the second ADC: mute capture input amp and | |
4331 | * set ADC connection to line in (on mic1 pin) | |
4332 | */ | |
4333 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4334 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4335 | ||
4336 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4337 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4338 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4339 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4340 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4341 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4342 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4343 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4344 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
4345 | |
4346 | { } | |
a9430dd8 JW |
4347 | }; |
4348 | ||
0bfc90e9 JW |
4349 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
4350 | * similar laptops (adapted from Fujitsu init verbs). | |
4351 | */ | |
4352 | static struct hda_verb alc260_acer_init_verbs[] = { | |
4353 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
4354 | * the headphone jack. Turn this on and rely on the standard mute | |
4355 | * methods whenever the user wants to turn these outputs off. | |
4356 | */ | |
4357 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4358 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4359 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
4360 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
4361 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4362 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
4363 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
4364 | /* Line In jack is connected to Line1 pin */ | |
4365 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
4366 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
4367 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
4368 | /* Ensure all other unused pins are disabled and muted. */ |
4369 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4370 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
4371 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
4372 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4373 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4374 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4375 | /* Disable digital (SPDIF) pins */ | |
4376 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4377 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4378 | ||
4379 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum | |
4380 | * bus when acting as outputs. | |
4381 | */ | |
4382 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4383 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4384 | ||
4385 | /* Start with output sum widgets muted and their output gains at min */ | |
4386 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4387 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4388 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4389 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4390 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4391 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4392 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4393 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4394 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4395 | ||
f12ab1e0 TI |
4396 | /* Unmute Line-out pin widget amp left and right |
4397 | * (no equiv mixer ctrl) | |
4398 | */ | |
0bfc90e9 | 4399 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
4400 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
4401 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
4402 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
4403 | * inputs. If the pin mode is changed by the user the pin mode control | |
4404 | * will take care of enabling the pin's input/output buffers as needed. | |
4405 | * Therefore there's no need to enable the input buffer at this | |
4406 | * stage. | |
4407 | */ | |
4408 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4409 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4410 | ||
4411 | /* Mute capture amp left and right */ | |
4412 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4413 | /* Set ADC connection select to match default mixer setting - mic | |
4414 | * (on mic1 pin) | |
4415 | */ | |
4416 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4417 | ||
4418 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 4419 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
4420 | */ |
4421 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 4422 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
4423 | |
4424 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4425 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4426 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4427 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4428 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4429 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4430 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4431 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4432 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4433 | ||
4434 | { } | |
4435 | }; | |
4436 | ||
bc9f98a9 KY |
4437 | static struct hda_verb alc260_will_verbs[] = { |
4438 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4439 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4440 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4441 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4442 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4443 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
4444 | {} | |
4445 | }; | |
4446 | ||
4447 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
4448 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4449 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4450 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
4451 | ||
4452 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4453 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4454 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4455 | ||
4456 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4457 | {} | |
4458 | }; | |
4459 | ||
4460 | /* toggle speaker-output according to the hp-jack state */ | |
4461 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
4462 | { | |
4463 | unsigned int present; | |
4464 | ||
4465 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
4466 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
4467 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
4468 | if (present) { | |
82beb8fd TI |
4469 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4470 | AC_VERB_SET_GPIO_DATA, 1); | |
4471 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4472 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4473 | PIN_HP); | |
bc9f98a9 | 4474 | } else { |
82beb8fd TI |
4475 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4476 | AC_VERB_SET_GPIO_DATA, 0); | |
4477 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4478 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4479 | PIN_OUT); | |
bc9f98a9 KY |
4480 | } |
4481 | } | |
4482 | ||
4483 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
4484 | unsigned int res) | |
4485 | { | |
4486 | if ((res >> 26) == ALC880_HP_EVENT) | |
4487 | alc260_replacer_672v_automute(codec); | |
4488 | } | |
4489 | ||
7cf51e48 JW |
4490 | /* Test configuration for debugging, modelled after the ALC880 test |
4491 | * configuration. | |
4492 | */ | |
4493 | #ifdef CONFIG_SND_DEBUG | |
4494 | static hda_nid_t alc260_test_dac_nids[1] = { | |
4495 | 0x02, | |
4496 | }; | |
4497 | static hda_nid_t alc260_test_adc_nids[2] = { | |
4498 | 0x04, 0x05, | |
4499 | }; | |
a1e8d2da JW |
4500 | /* For testing the ALC260, each input MUX needs its own definition since |
4501 | * the signal assignments are different. This assumes that the first ADC | |
4502 | * is NID 0x04. | |
17e7aec6 | 4503 | */ |
a1e8d2da JW |
4504 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
4505 | { | |
4506 | .num_items = 7, | |
4507 | .items = { | |
4508 | { "MIC1 pin", 0x0 }, | |
4509 | { "MIC2 pin", 0x1 }, | |
4510 | { "LINE1 pin", 0x2 }, | |
4511 | { "LINE2 pin", 0x3 }, | |
4512 | { "CD pin", 0x4 }, | |
4513 | { "LINE-OUT pin", 0x5 }, | |
4514 | { "HP-OUT pin", 0x6 }, | |
4515 | }, | |
4516 | }, | |
4517 | { | |
4518 | .num_items = 8, | |
4519 | .items = { | |
4520 | { "MIC1 pin", 0x0 }, | |
4521 | { "MIC2 pin", 0x1 }, | |
4522 | { "LINE1 pin", 0x2 }, | |
4523 | { "LINE2 pin", 0x3 }, | |
4524 | { "CD pin", 0x4 }, | |
4525 | { "Mixer", 0x5 }, | |
4526 | { "LINE-OUT pin", 0x6 }, | |
4527 | { "HP-OUT pin", 0x7 }, | |
4528 | }, | |
7cf51e48 JW |
4529 | }, |
4530 | }; | |
4531 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
4532 | /* Output driver widgets */ | |
4533 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
4534 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4535 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4536 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
4537 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4538 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
4539 | ||
a1e8d2da JW |
4540 | /* Modes for retasking pin widgets |
4541 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
4542 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
4543 | * mention this restriction. At this stage it's not clear whether | |
4544 | * this behaviour is intentional or is a hardware bug in chip | |
4545 | * revisions available at least up until early 2006. Therefore for | |
4546 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
4547 | * choices, but if it turns out that the lack of mic bias for these | |
4548 | * NIDs is intentional we could change their modes from | |
4549 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4550 | */ | |
7cf51e48 JW |
4551 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
4552 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
4553 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
4554 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
4555 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
4556 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
4557 | ||
4558 | /* Loopback mixer controls */ | |
4559 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
4560 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
4561 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4562 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
4563 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4564 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4565 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
4566 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
4567 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4568 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4569 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4570 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4571 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4572 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4573 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
4574 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
4575 | |
4576 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
4577 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
4578 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
4579 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
4580 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
4581 | ||
92621f13 JW |
4582 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
4583 | * is ambigious as to which NID is which; testing on laptops which | |
4584 | * make this output available should provide clarification. | |
4585 | */ | |
4586 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
4587 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
4588 | ||
f8225f6d JW |
4589 | /* A switch allowing EAPD to be enabled. Some laptops seem to use |
4590 | * this output to turn on an external amplifier. | |
4591 | */ | |
4592 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
4593 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
4594 | ||
7cf51e48 JW |
4595 | { } /* end */ |
4596 | }; | |
4597 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
4598 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
4599 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
4600 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4601 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
4602 | ||
7cf51e48 JW |
4603 | /* Enable retasking pins as output, initially without power amp */ |
4604 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4605 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4606 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4607 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4608 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4609 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4610 | ||
92621f13 JW |
4611 | /* Disable digital (SPDIF) pins initially, but users can enable |
4612 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
4613 | * payload also sets the generation to 0, output to be in "consumer" | |
4614 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
4615 | * control. | |
4616 | */ | |
7cf51e48 JW |
4617 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
4618 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4619 | ||
f7ace40d | 4620 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
4621 | * OUT1 sum bus when acting as an output. |
4622 | */ | |
4623 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4624 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
4625 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4626 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
4627 | ||
4628 | /* Start with output sum widgets muted and their output gains at min */ | |
4629 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4630 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4631 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4632 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4633 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4634 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4635 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4636 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4637 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4638 | ||
cdcd9268 JW |
4639 | /* Unmute retasking pin widget output buffers since the default |
4640 | * state appears to be output. As the pin mode is changed by the | |
4641 | * user the pin mode control will take care of enabling the pin's | |
4642 | * input/output buffers as needed. | |
4643 | */ | |
7cf51e48 JW |
4644 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
4645 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4646 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4647 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4648 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4649 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4650 | /* Also unmute the mono-out pin widget */ | |
4651 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4652 | ||
7cf51e48 JW |
4653 | /* Mute capture amp left and right */ |
4654 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
4655 | /* Set ADC connection select to match default mixer setting (mic1 |
4656 | * pin) | |
7cf51e48 JW |
4657 | */ |
4658 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4659 | ||
4660 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 4661 | * set ADC connection to mic1 pin |
7cf51e48 JW |
4662 | */ |
4663 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4664 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4665 | ||
4666 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4667 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4668 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4669 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4670 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4671 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4672 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4673 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4674 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4675 | ||
4676 | { } | |
4677 | }; | |
4678 | #endif | |
4679 | ||
6330079f TI |
4680 | #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback |
4681 | #define alc260_pcm_analog_capture alc880_pcm_analog_capture | |
1da177e4 | 4682 | |
a3bcba38 TI |
4683 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
4684 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
4685 | ||
df694daa KY |
4686 | /* |
4687 | * for BIOS auto-configuration | |
4688 | */ | |
16ded525 | 4689 | |
df694daa KY |
4690 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
4691 | const char *pfx) | |
4692 | { | |
4693 | hda_nid_t nid_vol; | |
4694 | unsigned long vol_val, sw_val; | |
4695 | char name[32]; | |
4696 | int err; | |
4697 | ||
4698 | if (nid >= 0x0f && nid < 0x11) { | |
4699 | nid_vol = nid - 0x7; | |
4700 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4701 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4702 | } else if (nid == 0x11) { | |
4703 | nid_vol = nid - 0x7; | |
4704 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
4705 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
4706 | } else if (nid >= 0x12 && nid <= 0x15) { | |
4707 | nid_vol = 0x08; | |
4708 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4709 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4710 | } else | |
4711 | return 0; /* N/A */ | |
4712 | ||
4713 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
f12ab1e0 TI |
4714 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); |
4715 | if (err < 0) | |
df694daa KY |
4716 | return err; |
4717 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | |
f12ab1e0 TI |
4718 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
4719 | if (err < 0) | |
df694daa KY |
4720 | return err; |
4721 | return 1; | |
4722 | } | |
4723 | ||
4724 | /* add playback controls from the parsed DAC table */ | |
4725 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
4726 | const struct auto_pin_cfg *cfg) | |
4727 | { | |
4728 | hda_nid_t nid; | |
4729 | int err; | |
4730 | ||
4731 | spec->multiout.num_dacs = 1; | |
4732 | spec->multiout.dac_nids = spec->private_dac_nids; | |
4733 | spec->multiout.dac_nids[0] = 0x02; | |
4734 | ||
4735 | nid = cfg->line_out_pins[0]; | |
4736 | if (nid) { | |
4737 | err = alc260_add_playback_controls(spec, nid, "Front"); | |
4738 | if (err < 0) | |
4739 | return err; | |
4740 | } | |
4741 | ||
82bc955f | 4742 | nid = cfg->speaker_pins[0]; |
df694daa KY |
4743 | if (nid) { |
4744 | err = alc260_add_playback_controls(spec, nid, "Speaker"); | |
4745 | if (err < 0) | |
4746 | return err; | |
4747 | } | |
4748 | ||
eb06ed8f | 4749 | nid = cfg->hp_pins[0]; |
df694daa KY |
4750 | if (nid) { |
4751 | err = alc260_add_playback_controls(spec, nid, "Headphone"); | |
4752 | if (err < 0) | |
4753 | return err; | |
4754 | } | |
f12ab1e0 | 4755 | return 0; |
df694daa KY |
4756 | } |
4757 | ||
4758 | /* create playback/capture controls for input pins */ | |
4759 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
4760 | const struct auto_pin_cfg *cfg) | |
4761 | { | |
df694daa KY |
4762 | struct hda_input_mux *imux = &spec->private_imux; |
4763 | int i, err, idx; | |
4764 | ||
4765 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4766 | if (cfg->input_pins[i] >= 0x12) { | |
4767 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 4768 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4769 | auto_pin_cfg_labels[i], idx, |
4770 | 0x07); | |
df694daa KY |
4771 | if (err < 0) |
4772 | return err; | |
f12ab1e0 TI |
4773 | imux->items[imux->num_items].label = |
4774 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4775 | imux->items[imux->num_items].index = idx; |
4776 | imux->num_items++; | |
4777 | } | |
f12ab1e0 | 4778 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 4779 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 4780 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4781 | auto_pin_cfg_labels[i], idx, |
4782 | 0x07); | |
df694daa KY |
4783 | if (err < 0) |
4784 | return err; | |
f12ab1e0 TI |
4785 | imux->items[imux->num_items].label = |
4786 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4787 | imux->items[imux->num_items].index = idx; |
4788 | imux->num_items++; | |
4789 | } | |
4790 | } | |
4791 | return 0; | |
4792 | } | |
4793 | ||
4794 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
4795 | hda_nid_t nid, int pin_type, | |
4796 | int sel_idx) | |
4797 | { | |
4798 | /* set as output */ | |
f12ab1e0 TI |
4799 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
4800 | pin_type); | |
4801 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4802 | AMP_OUT_UNMUTE); | |
df694daa KY |
4803 | /* need the manual connection? */ |
4804 | if (nid >= 0x12) { | |
4805 | int idx = nid - 0x12; | |
4806 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
4807 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
4808 | } |
4809 | } | |
4810 | ||
4811 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
4812 | { | |
4813 | struct alc_spec *spec = codec->spec; | |
4814 | hda_nid_t nid; | |
4815 | ||
bc9f98a9 | 4816 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 4817 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
4818 | if (nid) { |
4819 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
4820 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
4821 | } | |
df694daa | 4822 | |
82bc955f | 4823 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
4824 | if (nid) |
4825 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
4826 | ||
eb06ed8f | 4827 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 4828 | if (nid) |
baba8ee9 | 4829 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 4830 | } |
df694daa KY |
4831 | |
4832 | #define ALC260_PIN_CD_NID 0x16 | |
4833 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
4834 | { | |
4835 | struct alc_spec *spec = codec->spec; | |
4836 | int i; | |
4837 | ||
4838 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4839 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4840 | if (nid >= 0x12) { | |
f12ab1e0 TI |
4841 | snd_hda_codec_write(codec, nid, 0, |
4842 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4843 | i <= AUTO_PIN_FRONT_MIC ? | |
4844 | PIN_VREF80 : PIN_IN); | |
df694daa | 4845 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
4846 | snd_hda_codec_write(codec, nid, 0, |
4847 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
4848 | AMP_OUT_MUTE); |
4849 | } | |
4850 | } | |
4851 | } | |
4852 | ||
4853 | /* | |
4854 | * generic initialization of ADC, input mixers and output mixers | |
4855 | */ | |
4856 | static struct hda_verb alc260_volume_init_verbs[] = { | |
4857 | /* | |
4858 | * Unmute ADC0-1 and set the default input to mic-in | |
4859 | */ | |
4860 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4861 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4862 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4863 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4864 | ||
4865 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
4866 | * mixer widget | |
f12ab1e0 TI |
4867 | * Note: PASD motherboards uses the Line In 2 as the input for |
4868 | * front panel mic (mic 2) | |
df694daa KY |
4869 | */ |
4870 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
4871 | /* mute analog inputs */ |
4872 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4873 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4874 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4875 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4876 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4877 | |
4878 | /* | |
4879 | * Set up output mixers (0x08 - 0x0a) | |
4880 | */ | |
4881 | /* set vol=0 to output mixers */ | |
4882 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4883 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4884 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4885 | /* set up input amps for analog loopback */ | |
4886 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4887 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4888 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4889 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4890 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4891 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4892 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4893 | ||
4894 | { } | |
4895 | }; | |
4896 | ||
4897 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
4898 | { | |
4899 | struct alc_spec *spec = codec->spec; | |
4900 | unsigned int wcap; | |
4901 | int err; | |
4902 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
4903 | ||
f12ab1e0 TI |
4904 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
4905 | alc260_ignore); | |
4906 | if (err < 0) | |
df694daa | 4907 | return err; |
f12ab1e0 TI |
4908 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
4909 | if (err < 0) | |
4a471b7d | 4910 | return err; |
f12ab1e0 | 4911 | if (!spec->kctl_alloc) |
df694daa | 4912 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
4913 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
4914 | if (err < 0) | |
df694daa KY |
4915 | return err; |
4916 | ||
4917 | spec->multiout.max_channels = 2; | |
4918 | ||
4919 | if (spec->autocfg.dig_out_pin) | |
4920 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
4921 | if (spec->kctl_alloc) | |
4922 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
4923 | ||
4924 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; | |
4925 | ||
a1e8d2da | 4926 | spec->num_mux_defs = 1; |
df694daa KY |
4927 | spec->input_mux = &spec->private_imux; |
4928 | ||
4929 | /* check whether NID 0x04 is valid */ | |
4a471b7d | 4930 | wcap = get_wcaps(codec, 0x04); |
df694daa KY |
4931 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
4932 | if (wcap != AC_WID_AUD_IN) { | |
4933 | spec->adc_nids = alc260_adc_nids_alt; | |
4934 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
4935 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; | |
df694daa KY |
4936 | } else { |
4937 | spec->adc_nids = alc260_adc_nids; | |
4938 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
4939 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; | |
df694daa | 4940 | } |
4a471b7d | 4941 | spec->num_mixers++; |
df694daa KY |
4942 | |
4943 | return 1; | |
4944 | } | |
4945 | ||
ae6b813a TI |
4946 | /* additional initialization for auto-configuration model */ |
4947 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 4948 | { |
df694daa KY |
4949 | alc260_auto_init_multi_out(codec); |
4950 | alc260_auto_init_analog_input(codec); | |
df694daa KY |
4951 | } |
4952 | ||
cb53c626 TI |
4953 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4954 | static struct hda_amp_list alc260_loopbacks[] = { | |
4955 | { 0x07, HDA_INPUT, 0 }, | |
4956 | { 0x07, HDA_INPUT, 1 }, | |
4957 | { 0x07, HDA_INPUT, 2 }, | |
4958 | { 0x07, HDA_INPUT, 3 }, | |
4959 | { 0x07, HDA_INPUT, 4 }, | |
4960 | { } /* end */ | |
4961 | }; | |
4962 | #endif | |
4963 | ||
df694daa KY |
4964 | /* |
4965 | * ALC260 configurations | |
4966 | */ | |
f5fcc13c TI |
4967 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
4968 | [ALC260_BASIC] = "basic", | |
4969 | [ALC260_HP] = "hp", | |
4970 | [ALC260_HP_3013] = "hp-3013", | |
4971 | [ALC260_FUJITSU_S702X] = "fujitsu", | |
4972 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
4973 | [ALC260_WILL] = "will", |
4974 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 4975 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 4976 | [ALC260_TEST] = "test", |
7cf51e48 | 4977 | #endif |
f5fcc13c TI |
4978 | [ALC260_AUTO] = "auto", |
4979 | }; | |
4980 | ||
4981 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 4982 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 4983 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 4984 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 4985 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c TI |
4986 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
4987 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP), | |
4988 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013), | |
4989 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), | |
4990 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
4991 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
4992 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
4993 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
4994 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
4995 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
4996 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
4997 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 | 4998 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), |
ac3e3741 | 4999 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
df694daa KY |
5000 | {} |
5001 | }; | |
5002 | ||
5003 | static struct alc_config_preset alc260_presets[] = { | |
5004 | [ALC260_BASIC] = { | |
5005 | .mixers = { alc260_base_output_mixer, | |
5006 | alc260_input_mixer, | |
5007 | alc260_pc_beep_mixer, | |
5008 | alc260_capture_mixer }, | |
5009 | .init_verbs = { alc260_init_verbs }, | |
5010 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5011 | .dac_nids = alc260_dac_nids, | |
5012 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5013 | .adc_nids = alc260_adc_nids, | |
5014 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5015 | .channel_mode = alc260_modes, | |
5016 | .input_mux = &alc260_capture_source, | |
5017 | }, | |
5018 | [ALC260_HP] = { | |
bec15c3a | 5019 | .mixers = { alc260_hp_output_mixer, |
df694daa KY |
5020 | alc260_input_mixer, |
5021 | alc260_capture_alt_mixer }, | |
bec15c3a TI |
5022 | .init_verbs = { alc260_init_verbs, |
5023 | alc260_hp_unsol_verbs }, | |
df694daa KY |
5024 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5025 | .dac_nids = alc260_dac_nids, | |
5026 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
5027 | .adc_nids = alc260_hp_adc_nids, | |
5028 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5029 | .channel_mode = alc260_modes, | |
5030 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5031 | .unsol_event = alc260_hp_unsol_event, |
5032 | .init_hook = alc260_hp_automute, | |
df694daa KY |
5033 | }, |
5034 | [ALC260_HP_3013] = { | |
5035 | .mixers = { alc260_hp_3013_mixer, | |
5036 | alc260_input_mixer, | |
5037 | alc260_capture_alt_mixer }, | |
bec15c3a TI |
5038 | .init_verbs = { alc260_hp_3013_init_verbs, |
5039 | alc260_hp_3013_unsol_verbs }, | |
df694daa KY |
5040 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5041 | .dac_nids = alc260_dac_nids, | |
5042 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
5043 | .adc_nids = alc260_hp_adc_nids, | |
5044 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5045 | .channel_mode = alc260_modes, | |
5046 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5047 | .unsol_event = alc260_hp_3013_unsol_event, |
5048 | .init_hook = alc260_hp_3013_automute, | |
df694daa KY |
5049 | }, |
5050 | [ALC260_FUJITSU_S702X] = { | |
5051 | .mixers = { alc260_fujitsu_mixer, | |
5052 | alc260_capture_mixer }, | |
5053 | .init_verbs = { alc260_fujitsu_init_verbs }, | |
5054 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5055 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
5056 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
5057 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
5058 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5059 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5060 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
5061 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 5062 | }, |
0bfc90e9 JW |
5063 | [ALC260_ACER] = { |
5064 | .mixers = { alc260_acer_mixer, | |
5065 | alc260_capture_mixer }, | |
5066 | .init_verbs = { alc260_acer_init_verbs }, | |
5067 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5068 | .dac_nids = alc260_dac_nids, | |
5069 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
5070 | .adc_nids = alc260_dual_adc_nids, | |
5071 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5072 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5073 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
5074 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 5075 | }, |
bc9f98a9 KY |
5076 | [ALC260_WILL] = { |
5077 | .mixers = { alc260_will_mixer, | |
5078 | alc260_capture_mixer }, | |
5079 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, | |
5080 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5081 | .dac_nids = alc260_dac_nids, | |
5082 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5083 | .adc_nids = alc260_adc_nids, | |
5084 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5085 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5086 | .channel_mode = alc260_modes, | |
5087 | .input_mux = &alc260_capture_source, | |
5088 | }, | |
5089 | [ALC260_REPLACER_672V] = { | |
5090 | .mixers = { alc260_replacer_672v_mixer, | |
5091 | alc260_capture_mixer }, | |
5092 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, | |
5093 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5094 | .dac_nids = alc260_dac_nids, | |
5095 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5096 | .adc_nids = alc260_adc_nids, | |
5097 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5098 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5099 | .channel_mode = alc260_modes, | |
5100 | .input_mux = &alc260_capture_source, | |
5101 | .unsol_event = alc260_replacer_672v_unsol_event, | |
5102 | .init_hook = alc260_replacer_672v_automute, | |
5103 | }, | |
7cf51e48 JW |
5104 | #ifdef CONFIG_SND_DEBUG |
5105 | [ALC260_TEST] = { | |
5106 | .mixers = { alc260_test_mixer, | |
5107 | alc260_capture_mixer }, | |
5108 | .init_verbs = { alc260_test_init_verbs }, | |
5109 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
5110 | .dac_nids = alc260_test_dac_nids, | |
5111 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
5112 | .adc_nids = alc260_test_adc_nids, | |
5113 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5114 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5115 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
5116 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
5117 | }, |
5118 | #endif | |
df694daa KY |
5119 | }; |
5120 | ||
5121 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
5122 | { |
5123 | struct alc_spec *spec; | |
df694daa | 5124 | int err, board_config; |
1da177e4 | 5125 | |
e560d8d8 | 5126 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
5127 | if (spec == NULL) |
5128 | return -ENOMEM; | |
5129 | ||
5130 | codec->spec = spec; | |
5131 | ||
f5fcc13c TI |
5132 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
5133 | alc260_models, | |
5134 | alc260_cfg_tbl); | |
5135 | if (board_config < 0) { | |
9c7f852e TI |
5136 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
5137 | "trying auto-probe from BIOS...\n"); | |
df694daa | 5138 | board_config = ALC260_AUTO; |
16ded525 | 5139 | } |
1da177e4 | 5140 | |
df694daa KY |
5141 | if (board_config == ALC260_AUTO) { |
5142 | /* automatic parse from the BIOS config */ | |
5143 | err = alc260_parse_auto_config(codec); | |
5144 | if (err < 0) { | |
5145 | alc_free(codec); | |
5146 | return err; | |
f12ab1e0 | 5147 | } else if (!err) { |
9c7f852e TI |
5148 | printk(KERN_INFO |
5149 | "hda_codec: Cannot set up configuration " | |
5150 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5151 | board_config = ALC260_BASIC; |
5152 | } | |
a9430dd8 | 5153 | } |
e9edcee0 | 5154 | |
df694daa KY |
5155 | if (board_config != ALC260_AUTO) |
5156 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
5157 | |
5158 | spec->stream_name_analog = "ALC260 Analog"; | |
5159 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
5160 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
5161 | ||
a3bcba38 TI |
5162 | spec->stream_name_digital = "ALC260 Digital"; |
5163 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
5164 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
5165 | ||
2134ea4f TI |
5166 | spec->vmaster_nid = 0x08; |
5167 | ||
1da177e4 | 5168 | codec->patch_ops = alc_patch_ops; |
df694daa | 5169 | if (board_config == ALC260_AUTO) |
ae6b813a | 5170 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
5171 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5172 | if (!spec->loopback.amplist) | |
5173 | spec->loopback.amplist = alc260_loopbacks; | |
5174 | #endif | |
1da177e4 LT |
5175 | |
5176 | return 0; | |
5177 | } | |
5178 | ||
e9edcee0 | 5179 | |
1da177e4 LT |
5180 | /* |
5181 | * ALC882 support | |
5182 | * | |
5183 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
5184 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5185 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5186 | * 6-channel independent captures. | |
5187 | * | |
5188 | * In addition, an independent DAC for the multi-playback (not used in this | |
5189 | * driver yet). | |
5190 | */ | |
df694daa KY |
5191 | #define ALC882_DIGOUT_NID 0x06 |
5192 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 5193 | |
d2a6d7dc | 5194 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
5195 | { 8, NULL } |
5196 | }; | |
5197 | ||
5198 | static hda_nid_t alc882_dac_nids[4] = { | |
5199 | /* front, rear, clfe, rear_surr */ | |
5200 | 0x02, 0x03, 0x04, 0x05 | |
5201 | }; | |
5202 | ||
df694daa KY |
5203 | /* identical with ALC880 */ |
5204 | #define alc882_adc_nids alc880_adc_nids | |
5205 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 LT |
5206 | |
5207 | /* input MUX */ | |
5208 | /* FIXME: should be a matrix-type input source selection */ | |
5209 | ||
5210 | static struct hda_input_mux alc882_capture_source = { | |
5211 | .num_items = 4, | |
5212 | .items = { | |
5213 | { "Mic", 0x0 }, | |
5214 | { "Front Mic", 0x1 }, | |
5215 | { "Line", 0x2 }, | |
5216 | { "CD", 0x4 }, | |
5217 | }, | |
5218 | }; | |
1da177e4 LT |
5219 | #define alc882_mux_enum_info alc_mux_enum_info |
5220 | #define alc882_mux_enum_get alc_mux_enum_get | |
5221 | ||
f12ab1e0 TI |
5222 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, |
5223 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
5224 | { |
5225 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
5226 | struct alc_spec *spec = codec->spec; | |
5227 | const struct hda_input_mux *imux = spec->input_mux; | |
5228 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
5229 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
5230 | hda_nid_t nid = capture_mixers[adc_idx]; | |
5231 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
5232 | unsigned int i, idx; | |
5233 | ||
5234 | idx = ucontrol->value.enumerated.item[0]; | |
5235 | if (idx >= imux->num_items) | |
5236 | idx = imux->num_items - 1; | |
82beb8fd | 5237 | if (*cur_val == idx) |
1da177e4 LT |
5238 | return 0; |
5239 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
5240 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
5241 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
82beb8fd | 5242 | imux->items[i].index, |
47fd830a | 5243 | HDA_AMP_MUTE, v); |
1da177e4 LT |
5244 | } |
5245 | *cur_val = idx; | |
5246 | return 1; | |
5247 | } | |
5248 | ||
272a527c KY |
5249 | /* |
5250 | * 2ch mode | |
5251 | */ | |
5252 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
5253 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5254 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5255 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5256 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5257 | { } /* end */ | |
5258 | }; | |
5259 | ||
5260 | /* | |
5261 | * 6ch mode | |
5262 | */ | |
5263 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
5264 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5265 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5266 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5267 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5268 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5269 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5270 | { } /* end */ | |
5271 | }; | |
5272 | ||
5273 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
5274 | { 2, alc882_3ST_ch2_init }, | |
5275 | { 6, alc882_3ST_ch6_init }, | |
5276 | }; | |
5277 | ||
df694daa KY |
5278 | /* |
5279 | * 6ch mode | |
5280 | */ | |
5281 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
5282 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5283 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5284 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5285 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5286 | { } /* end */ | |
5287 | }; | |
5288 | ||
5289 | /* | |
5290 | * 8ch mode | |
5291 | */ | |
5292 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
5293 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5294 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5295 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5296 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5297 | { } /* end */ | |
5298 | }; | |
5299 | ||
5300 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
5301 | { 6, alc882_sixstack_ch6_init }, | |
5302 | { 8, alc882_sixstack_ch8_init }, | |
5303 | }; | |
5304 | ||
87350ad0 TI |
5305 | /* |
5306 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
5307 | */ | |
5308 | ||
5309 | /* | |
5310 | * 2ch mode | |
5311 | */ | |
5312 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
5313 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5314 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5315 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5316 | { } /* end */ | |
5317 | }; | |
5318 | ||
5319 | /* | |
5320 | * 6ch mode | |
5321 | */ | |
5322 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
5323 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5324 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5325 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5326 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5327 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5328 | { } /* end */ | |
5329 | }; | |
5330 | ||
5331 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
5332 | { 2, alc885_mbp_ch2_init }, | |
5333 | { 6, alc885_mbp_ch6_init }, | |
5334 | }; | |
5335 | ||
5336 | ||
1da177e4 LT |
5337 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
5338 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
5339 | */ | |
c8b6bf9b | 5340 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 5341 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 5342 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 5343 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 5344 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
5345 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
5346 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
5347 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
5348 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 5349 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 5350 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
5351 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
5352 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5353 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5354 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5355 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5356 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5357 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
5358 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5359 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5360 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
5361 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5362 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5363 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
5364 | { } /* end */ |
5365 | }; | |
5366 | ||
87350ad0 | 5367 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
2134ea4f TI |
5368 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
5369 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | |
5370 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | |
5371 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | |
5372 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5373 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
87350ad0 TI |
5374 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
5375 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
2134ea4f | 5376 | HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), |
87350ad0 TI |
5377 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), |
5378 | { } /* end */ | |
5379 | }; | |
bdd148a3 KY |
5380 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
5381 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5382 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5383 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5384 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5385 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5386 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5387 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5388 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5389 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5390 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5391 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5392 | { } /* end */ | |
5393 | }; | |
5394 | ||
272a527c KY |
5395 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
5396 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5397 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5398 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5399 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5400 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5401 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5402 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5403 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5404 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5405 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5406 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
5407 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
96fe7cc8 | 5408 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
272a527c KY |
5409 | { } /* end */ |
5410 | }; | |
5411 | ||
5412 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
5413 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
5414 | */ | |
5415 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
5416 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5417 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5418 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5419 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
5420 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5421 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5422 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5423 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5424 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
5425 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
5426 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5427 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5428 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5429 | { } /* end */ |
5430 | }; | |
5431 | ||
914759b7 TI |
5432 | static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { |
5433 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5434 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5435 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5436 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5437 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5438 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5439 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5440 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5441 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5442 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5443 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5444 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5445 | { } /* end */ | |
5446 | }; | |
5447 | ||
df694daa KY |
5448 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
5449 | { | |
5450 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5451 | .name = "Channel Mode", | |
5452 | .info = alc_ch_mode_info, | |
5453 | .get = alc_ch_mode_get, | |
5454 | .put = alc_ch_mode_put, | |
5455 | }, | |
5456 | { } /* end */ | |
5457 | }; | |
5458 | ||
1da177e4 LT |
5459 | static struct hda_verb alc882_init_verbs[] = { |
5460 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
5461 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5462 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5463 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5464 | /* Rear mixer */ |
05acb863 TI |
5465 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5466 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5467 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5468 | /* CLFE mixer */ |
05acb863 TI |
5469 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5470 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5471 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5472 | /* Side mixer */ |
05acb863 TI |
5473 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5474 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5475 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5476 | |
e9edcee0 | 5477 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 5478 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5479 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5480 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 5481 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 5482 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5483 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5484 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 5485 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 5486 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5487 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5488 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 5489 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 5490 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5491 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5492 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 5493 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 5494 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5495 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5496 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 5497 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5498 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5499 | /* Line In pin: input */ | |
05acb863 | 5500 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
5501 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5502 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
5503 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5504 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5505 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 5506 | /* CD pin widget for input */ |
05acb863 | 5507 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
5508 | |
5509 | /* FIXME: use matrix-type input source selection */ | |
5510 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5511 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
5512 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5513 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5514 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5515 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5516 | /* Input mixer2 */ |
05acb863 TI |
5517 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5518 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5519 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5520 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5521 | /* Input mixer3 */ |
05acb863 TI |
5522 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5523 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5524 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5525 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5526 | /* ADC1: mute amp left and right */ | |
5527 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5528 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5529 | /* ADC2: mute amp left and right */ |
5530 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5531 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5532 | /* ADC3: mute amp left and right */ |
5533 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5534 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
5535 | |
5536 | { } | |
5537 | }; | |
5538 | ||
4b146cb0 TI |
5539 | static struct hda_verb alc882_eapd_verbs[] = { |
5540 | /* change to EAPD mode */ | |
5541 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 5542 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 5543 | { } |
4b146cb0 TI |
5544 | }; |
5545 | ||
9102cd1c TD |
5546 | /* Mac Pro test */ |
5547 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
5548 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5549 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5550 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
5551 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
5552 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
5553 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5554 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5555 | { } /* end */ | |
5556 | }; | |
5557 | ||
5558 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
5559 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5560 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5561 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5562 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5563 | /* Front Pin: output 0 (0x0c) */ | |
5564 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5565 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5566 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5567 | /* Front Mic pin: input vref at 80% */ | |
5568 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5569 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5570 | /* Speaker: output */ | |
5571 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5572 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5573 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
5574 | /* Headphone output (output 0 - 0x0c) */ | |
5575 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5576 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5577 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5578 | ||
5579 | /* FIXME: use matrix-type input source selection */ | |
5580 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5581 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5582 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5583 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5584 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5585 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5586 | /* Input mixer2 */ | |
5587 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5588 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5589 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5590 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5591 | /* Input mixer3 */ | |
5592 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5593 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5594 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5595 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5596 | /* ADC1: mute amp left and right */ | |
5597 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5598 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5599 | /* ADC2: mute amp left and right */ | |
5600 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5601 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5602 | /* ADC3: mute amp left and right */ | |
5603 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5604 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5605 | ||
5606 | { } | |
5607 | }; | |
f12ab1e0 | 5608 | |
87350ad0 TI |
5609 | /* Macbook Pro rev3 */ |
5610 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
5611 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5612 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5613 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5614 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5615 | /* Rear mixer */ | |
5616 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5617 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5618 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5619 | /* Front Pin: output 0 (0x0c) */ | |
5620 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5621 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5622 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5623 | /* HP Pin: output 0 (0x0d) */ | |
5624 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
5625 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5626 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5627 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5628 | /* Mic (rear) pin: input vref at 80% */ | |
5629 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5630 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5631 | /* Front Mic pin: input vref at 80% */ | |
5632 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5633 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5634 | /* Line In pin: use output 1 when in LineOut mode */ | |
5635 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
5636 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5637 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5638 | ||
5639 | /* FIXME: use matrix-type input source selection */ | |
5640 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5641 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5642 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5643 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5644 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5645 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5646 | /* Input mixer2 */ | |
5647 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5648 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5649 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5650 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5651 | /* Input mixer3 */ | |
5652 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5653 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5654 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5655 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5656 | /* ADC1: mute amp left and right */ | |
5657 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5658 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5659 | /* ADC2: mute amp left and right */ | |
5660 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5661 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5662 | /* ADC3: mute amp left and right */ | |
5663 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5664 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5665 | ||
5666 | { } | |
5667 | }; | |
5668 | ||
c54728d8 NF |
5669 | /* iMac 24 mixer. */ |
5670 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
5671 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
5672 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
5673 | { } /* end */ | |
5674 | }; | |
5675 | ||
5676 | /* iMac 24 init verbs. */ | |
5677 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
5678 | /* Internal speakers: output 0 (0x0c) */ | |
5679 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5680 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5681 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5682 | /* Internal speakers: output 0 (0x0c) */ | |
5683 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5684 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5685 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5686 | /* Headphone: output 0 (0x0c) */ | |
5687 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5688 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5689 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5690 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5691 | /* Front Mic: input vref at 80% */ | |
5692 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5693 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5694 | { } | |
5695 | }; | |
5696 | ||
5697 | /* Toggle speaker-output according to the hp-jack state */ | |
5698 | static void alc885_imac24_automute(struct hda_codec *codec) | |
5699 | { | |
5700 | unsigned int present; | |
5701 | ||
5702 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5703 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5704 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
5705 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5706 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
5707 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
5708 | } |
5709 | ||
5710 | /* Processes unsolicited events. */ | |
5711 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
5712 | unsigned int res) | |
5713 | { | |
5714 | /* Headphone insertion or removal. */ | |
5715 | if ((res >> 26) == ALC880_HP_EVENT) | |
5716 | alc885_imac24_automute(codec); | |
5717 | } | |
5718 | ||
87350ad0 TI |
5719 | static void alc885_mbp3_automute(struct hda_codec *codec) |
5720 | { | |
5721 | unsigned int present; | |
5722 | ||
5723 | present = snd_hda_codec_read(codec, 0x15, 0, | |
5724 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
5725 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
5726 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5727 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
5728 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
5729 | ||
5730 | } | |
5731 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
5732 | unsigned int res) | |
5733 | { | |
5734 | /* Headphone insertion or removal. */ | |
5735 | if ((res >> 26) == ALC880_HP_EVENT) | |
5736 | alc885_mbp3_automute(codec); | |
5737 | } | |
5738 | ||
5739 | ||
272a527c KY |
5740 | static struct hda_verb alc882_targa_verbs[] = { |
5741 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5742 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5743 | ||
5744 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5745 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5746 | ||
5747 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5748 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5749 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5750 | ||
5751 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5752 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
5753 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
5754 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
5755 | { } /* end */ | |
5756 | }; | |
5757 | ||
5758 | /* toggle speaker-output according to the hp-jack state */ | |
5759 | static void alc882_targa_automute(struct hda_codec *codec) | |
5760 | { | |
5761 | unsigned int present; | |
5762 | ||
5763 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5764 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5765 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
5766 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
5767 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
5768 | present ? 1 : 3); | |
272a527c KY |
5769 | } |
5770 | ||
5771 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
5772 | { | |
5773 | /* Looks like the unsol event is incompatible with the standard | |
5774 | * definition. 4bit tag is placed at 26 bit! | |
5775 | */ | |
5776 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
5777 | alc882_targa_automute(codec); | |
5778 | } | |
5779 | } | |
5780 | ||
5781 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
5782 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5783 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5784 | ||
5785 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5786 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5787 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5788 | ||
5789 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5790 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5791 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5792 | ||
5793 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5794 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5795 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5796 | { } /* end */ | |
5797 | }; | |
5798 | ||
914759b7 TI |
5799 | static struct hda_verb alc882_asus_a7m_verbs[] = { |
5800 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5801 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5802 | ||
5803 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5804 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5805 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5806 | ||
5807 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5808 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5809 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5810 | ||
5811 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5812 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5813 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5814 | { } /* end */ | |
5815 | }; | |
5816 | ||
9102cd1c TD |
5817 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
5818 | { | |
5819 | unsigned int gpiostate, gpiomask, gpiodir; | |
5820 | ||
5821 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
5822 | AC_VERB_GET_GPIO_DATA, 0); | |
5823 | ||
5824 | if (!muted) | |
5825 | gpiostate |= (1 << pin); | |
5826 | else | |
5827 | gpiostate &= ~(1 << pin); | |
5828 | ||
5829 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
5830 | AC_VERB_GET_GPIO_MASK, 0); | |
5831 | gpiomask |= (1 << pin); | |
5832 | ||
5833 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
5834 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
5835 | gpiodir |= (1 << pin); | |
5836 | ||
5837 | ||
5838 | snd_hda_codec_write(codec, codec->afg, 0, | |
5839 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
5840 | snd_hda_codec_write(codec, codec->afg, 0, | |
5841 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
5842 | ||
5843 | msleep(1); | |
5844 | ||
5845 | snd_hda_codec_write(codec, codec->afg, 0, | |
5846 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
5847 | } | |
5848 | ||
7debbe51 TI |
5849 | /* set up GPIO at initialization */ |
5850 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
5851 | { | |
5852 | alc882_gpio_mute(codec, 0, 0); | |
5853 | alc882_gpio_mute(codec, 1, 0); | |
5854 | } | |
5855 | ||
5856 | /* set up GPIO and update auto-muting at initialization */ | |
5857 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
5858 | { | |
5859 | alc885_macpro_init_hook(codec); | |
5860 | alc885_imac24_automute(codec); | |
5861 | } | |
5862 | ||
df694daa KY |
5863 | /* |
5864 | * generic initialization of ADC, input mixers and output mixers | |
5865 | */ | |
5866 | static struct hda_verb alc882_auto_init_verbs[] = { | |
5867 | /* | |
5868 | * Unmute ADC0-2 and set the default input to mic-in | |
5869 | */ | |
5870 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5871 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5872 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5873 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5874 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5875 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 5876 | |
cb53c626 | 5877 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 5878 | * mixer widget |
f12ab1e0 TI |
5879 | * Note: PASD motherboards uses the Line In 2 as the input for |
5880 | * front panel mic (mic 2) | |
df694daa KY |
5881 | */ |
5882 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5883 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
5884 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5885 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5886 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5887 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 5888 | |
df694daa KY |
5889 | /* |
5890 | * Set up output mixers (0x0c - 0x0f) | |
5891 | */ | |
5892 | /* set vol=0 to output mixers */ | |
5893 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5894 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5895 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5896 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5897 | /* set up input amps for analog loopback */ | |
5898 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5899 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5900 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5901 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5902 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5903 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5904 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5905 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5906 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5907 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5908 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5909 | ||
5910 | /* FIXME: use matrix-type input source selection */ | |
5911 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5912 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5913 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5914 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5915 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5916 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5917 | /* Input mixer2 */ | |
5918 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5919 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5920 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5921 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5922 | /* Input mixer3 */ | |
5923 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5924 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5925 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5926 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5927 | ||
5928 | { } | |
5929 | }; | |
5930 | ||
5931 | /* capture mixer elements */ | |
5932 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { | |
5933 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5934 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5935 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5936 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5937 | { | |
5938 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5939 | /* The multiple "Capture Source" controls confuse alsamixer | |
5940 | * So call somewhat different.. | |
df694daa KY |
5941 | */ |
5942 | /* .name = "Capture Source", */ | |
5943 | .name = "Input Source", | |
5944 | .count = 2, | |
5945 | .info = alc882_mux_enum_info, | |
5946 | .get = alc882_mux_enum_get, | |
5947 | .put = alc882_mux_enum_put, | |
5948 | }, | |
5949 | { } /* end */ | |
5950 | }; | |
5951 | ||
5952 | static struct snd_kcontrol_new alc882_capture_mixer[] = { | |
5953 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
5954 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
5955 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
5956 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
5957 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
5958 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
5959 | { | |
5960 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5961 | /* The multiple "Capture Source" controls confuse alsamixer | |
5962 | * So call somewhat different.. | |
df694daa KY |
5963 | */ |
5964 | /* .name = "Capture Source", */ | |
5965 | .name = "Input Source", | |
5966 | .count = 3, | |
5967 | .info = alc882_mux_enum_info, | |
5968 | .get = alc882_mux_enum_get, | |
5969 | .put = alc882_mux_enum_put, | |
5970 | }, | |
5971 | { } /* end */ | |
5972 | }; | |
5973 | ||
cb53c626 TI |
5974 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5975 | #define alc882_loopbacks alc880_loopbacks | |
5976 | #endif | |
5977 | ||
df694daa KY |
5978 | /* pcm configuration: identiacal with ALC880 */ |
5979 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
5980 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
5981 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
5982 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
5983 | ||
5984 | /* | |
5985 | * configuration and preset | |
5986 | */ | |
f5fcc13c TI |
5987 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
5988 | [ALC882_3ST_DIG] = "3stack-dig", | |
5989 | [ALC882_6ST_DIG] = "6stack-dig", | |
5990 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 5991 | [ALC882_W2JC] = "w2jc", |
0438a00e TI |
5992 | [ALC882_TARGA] = "targa", |
5993 | [ALC882_ASUS_A7J] = "asus-a7j", | |
5994 | [ALC882_ASUS_A7M] = "asus-a7m", | |
9102cd1c | 5995 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 5996 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 5997 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
5998 | [ALC882_AUTO] = "auto", |
5999 | }; | |
6000 | ||
6001 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
6002 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
272a527c | 6003 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
ac8842a0 | 6004 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), |
914759b7 | 6005 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), |
ac3e3741 | 6006 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
c5d9f1cd | 6007 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 6008 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
ac3e3741 | 6009 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
4444704c | 6010 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
ac3e3741 TI |
6011 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
6012 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
6013 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | |
df694daa KY |
6014 | {} |
6015 | }; | |
6016 | ||
6017 | static struct alc_config_preset alc882_presets[] = { | |
6018 | [ALC882_3ST_DIG] = { | |
6019 | .mixers = { alc882_base_mixer }, | |
6020 | .init_verbs = { alc882_init_verbs }, | |
6021 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6022 | .dac_nids = alc882_dac_nids, | |
6023 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6024 | .dig_in_nid = ALC882_DIGIN_NID, |
6025 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6026 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 6027 | .need_dac_fix = 1, |
df694daa KY |
6028 | .input_mux = &alc882_capture_source, |
6029 | }, | |
6030 | [ALC882_6ST_DIG] = { | |
6031 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6032 | .init_verbs = { alc882_init_verbs }, | |
6033 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6034 | .dac_nids = alc882_dac_nids, | |
6035 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6036 | .dig_in_nid = ALC882_DIGIN_NID, |
6037 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6038 | .channel_mode = alc882_sixstack_modes, | |
6039 | .input_mux = &alc882_capture_source, | |
6040 | }, | |
4b146cb0 TI |
6041 | [ALC882_ARIMA] = { |
6042 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6043 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
6044 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6045 | .dac_nids = alc882_dac_nids, | |
6046 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6047 | .channel_mode = alc882_sixstack_modes, | |
6048 | .input_mux = &alc882_capture_source, | |
6049 | }, | |
bdd148a3 KY |
6050 | [ALC882_W2JC] = { |
6051 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
6052 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6053 | alc880_gpio1_init_verbs }, | |
6054 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6055 | .dac_nids = alc882_dac_nids, | |
6056 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6057 | .channel_mode = alc880_threestack_modes, | |
6058 | .need_dac_fix = 1, | |
6059 | .input_mux = &alc882_capture_source, | |
6060 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6061 | }, | |
87350ad0 TI |
6062 | [ALC885_MBP3] = { |
6063 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
6064 | .init_verbs = { alc885_mbp3_init_verbs, | |
6065 | alc880_gpio1_init_verbs }, | |
6066 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6067 | .dac_nids = alc882_dac_nids, | |
6068 | .channel_mode = alc885_mbp_6ch_modes, | |
6069 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
6070 | .input_mux = &alc882_capture_source, | |
6071 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6072 | .dig_in_nid = ALC882_DIGIN_NID, | |
6073 | .unsol_event = alc885_mbp3_unsol_event, | |
6074 | .init_hook = alc885_mbp3_automute, | |
6075 | }, | |
9102cd1c TD |
6076 | [ALC885_MACPRO] = { |
6077 | .mixers = { alc882_macpro_mixer }, | |
6078 | .init_verbs = { alc882_macpro_init_verbs }, | |
6079 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6080 | .dac_nids = alc882_dac_nids, | |
6081 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6082 | .dig_in_nid = ALC882_DIGIN_NID, | |
6083 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6084 | .channel_mode = alc882_ch_modes, | |
6085 | .input_mux = &alc882_capture_source, | |
7debbe51 | 6086 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 6087 | }, |
c54728d8 NF |
6088 | [ALC885_IMAC24] = { |
6089 | .mixers = { alc885_imac24_mixer }, | |
6090 | .init_verbs = { alc885_imac24_init_verbs }, | |
6091 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6092 | .dac_nids = alc882_dac_nids, | |
6093 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6094 | .dig_in_nid = ALC882_DIGIN_NID, | |
6095 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6096 | .channel_mode = alc882_ch_modes, | |
6097 | .input_mux = &alc882_capture_source, | |
6098 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 6099 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 6100 | }, |
272a527c KY |
6101 | [ALC882_TARGA] = { |
6102 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer, | |
6103 | alc882_capture_mixer }, | |
6104 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, | |
6105 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6106 | .dac_nids = alc882_dac_nids, | |
6107 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6108 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6109 | .adc_nids = alc882_adc_nids, | |
6110 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | |
6111 | .channel_mode = alc882_3ST_6ch_modes, | |
6112 | .need_dac_fix = 1, | |
6113 | .input_mux = &alc882_capture_source, | |
6114 | .unsol_event = alc882_targa_unsol_event, | |
6115 | .init_hook = alc882_targa_automute, | |
6116 | }, | |
6117 | [ALC882_ASUS_A7J] = { | |
6118 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, | |
6119 | alc882_capture_mixer }, | |
6120 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, | |
6121 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6122 | .dac_nids = alc882_dac_nids, | |
6123 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6124 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6125 | .adc_nids = alc882_adc_nids, | |
6126 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | |
6127 | .channel_mode = alc882_3ST_6ch_modes, | |
6128 | .need_dac_fix = 1, | |
6129 | .input_mux = &alc882_capture_source, | |
6130 | }, | |
914759b7 TI |
6131 | [ALC882_ASUS_A7M] = { |
6132 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | |
6133 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6134 | alc880_gpio1_init_verbs, | |
6135 | alc882_asus_a7m_verbs }, | |
6136 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6137 | .dac_nids = alc882_dac_nids, | |
6138 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6139 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6140 | .channel_mode = alc880_threestack_modes, | |
6141 | .need_dac_fix = 1, | |
6142 | .input_mux = &alc882_capture_source, | |
6143 | }, | |
df694daa KY |
6144 | }; |
6145 | ||
6146 | ||
f95474ec TI |
6147 | /* |
6148 | * Pin config fixes | |
6149 | */ | |
6150 | enum { | |
6151 | PINFIX_ABIT_AW9D_MAX | |
6152 | }; | |
6153 | ||
6154 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
6155 | { 0x15, 0x01080104 }, /* side */ | |
6156 | { 0x16, 0x01011012 }, /* rear */ | |
6157 | { 0x17, 0x01016011 }, /* clfe */ | |
6158 | { } | |
6159 | }; | |
6160 | ||
6161 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
6162 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
6163 | }; | |
6164 | ||
6165 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
6166 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
6167 | {} | |
6168 | }; | |
6169 | ||
df694daa KY |
6170 | /* |
6171 | * BIOS auto configuration | |
6172 | */ | |
6173 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
6174 | hda_nid_t nid, int pin_type, | |
6175 | int dac_idx) | |
6176 | { | |
6177 | /* set as output */ | |
6178 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6179 | int idx; |
6180 | ||
df694daa KY |
6181 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6182 | idx = 4; | |
6183 | else | |
6184 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
6185 | ||
f12ab1e0 TI |
6186 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
6187 | pin_type); | |
6188 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
6189 | AMP_OUT_UNMUTE); | |
df694daa KY |
6190 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
6191 | ||
6192 | } | |
6193 | ||
6194 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
6195 | { | |
6196 | struct alc_spec *spec = codec->spec; | |
6197 | int i; | |
6198 | ||
bc9f98a9 | 6199 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 6200 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6201 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6202 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 6203 | if (nid) |
baba8ee9 | 6204 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6205 | i); |
df694daa KY |
6206 | } |
6207 | } | |
6208 | ||
6209 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
6210 | { | |
6211 | struct alc_spec *spec = codec->spec; | |
6212 | hda_nid_t pin; | |
6213 | ||
eb06ed8f | 6214 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 6215 | if (pin) /* connect to front */ |
f12ab1e0 TI |
6216 | /* use dac 0 */ |
6217 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
df694daa KY |
6218 | } |
6219 | ||
6220 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
6221 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
6222 | ||
6223 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
6224 | { | |
6225 | struct alc_spec *spec = codec->spec; | |
6226 | int i; | |
6227 | ||
6228 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6229 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
6230 | if (alc882_is_input_pin(nid)) { | |
f12ab1e0 TI |
6231 | snd_hda_codec_write(codec, nid, 0, |
6232 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
6233 | i <= AUTO_PIN_FRONT_MIC ? | |
6234 | PIN_VREF80 : PIN_IN); | |
df694daa | 6235 | if (nid != ALC882_PIN_CD_NID) |
f12ab1e0 TI |
6236 | snd_hda_codec_write(codec, nid, 0, |
6237 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
6238 | AMP_OUT_MUTE); |
6239 | } | |
6240 | } | |
6241 | } | |
6242 | ||
776e184e TI |
6243 | /* add mic boosts if needed */ |
6244 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | |
6245 | { | |
6246 | struct alc_spec *spec = codec->spec; | |
6247 | int err; | |
6248 | hda_nid_t nid; | |
6249 | ||
6250 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
ce22e03e | 6251 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6252 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6253 | "Mic Boost", | |
6254 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6255 | if (err < 0) | |
6256 | return err; | |
6257 | } | |
6258 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
ce22e03e | 6259 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6260 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6261 | "Front Mic Boost", | |
6262 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6263 | if (err < 0) | |
6264 | return err; | |
6265 | } | |
6266 | return 0; | |
6267 | } | |
6268 | ||
df694daa KY |
6269 | /* almost identical with ALC880 parser... */ |
6270 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
6271 | { | |
6272 | struct alc_spec *spec = codec->spec; | |
6273 | int err = alc880_parse_auto_config(codec); | |
6274 | ||
6275 | if (err < 0) | |
6276 | return err; | |
776e184e TI |
6277 | else if (!err) |
6278 | return 0; /* no config found */ | |
6279 | ||
6280 | err = alc_auto_add_mic_boost(codec); | |
6281 | if (err < 0) | |
6282 | return err; | |
6283 | ||
6284 | /* hack - override the init verbs */ | |
6285 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
6286 | ||
6287 | return 1; /* config found */ | |
df694daa KY |
6288 | } |
6289 | ||
ae6b813a TI |
6290 | /* additional initialization for auto-configuration model */ |
6291 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 6292 | { |
df694daa KY |
6293 | alc882_auto_init_multi_out(codec); |
6294 | alc882_auto_init_hp_out(codec); | |
6295 | alc882_auto_init_analog_input(codec); | |
df694daa KY |
6296 | } |
6297 | ||
df694daa KY |
6298 | static int patch_alc882(struct hda_codec *codec) |
6299 | { | |
6300 | struct alc_spec *spec; | |
6301 | int err, board_config; | |
6302 | ||
6303 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6304 | if (spec == NULL) | |
6305 | return -ENOMEM; | |
6306 | ||
6307 | codec->spec = spec; | |
6308 | ||
f5fcc13c TI |
6309 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
6310 | alc882_models, | |
6311 | alc882_cfg_tbl); | |
df694daa KY |
6312 | |
6313 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
6314 | /* Pick up systems that don't supply PCI SSID */ |
6315 | switch (codec->subsystem_id) { | |
6316 | case 0x106b0c00: /* Mac Pro */ | |
6317 | board_config = ALC885_MACPRO; | |
6318 | break; | |
c54728d8 NF |
6319 | case 0x106b1000: /* iMac 24 */ |
6320 | board_config = ALC885_IMAC24; | |
6321 | break; | |
3d5fa2e5 | 6322 | case 0x106b00a1: /* Macbook */ |
87350ad0 TI |
6323 | case 0x106b2c00: /* Macbook Pro rev3 */ |
6324 | board_config = ALC885_MBP3; | |
6325 | break; | |
081d17c4 TD |
6326 | default: |
6327 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " | |
6328 | "trying auto-probe from BIOS...\n"); | |
6329 | board_config = ALC882_AUTO; | |
6330 | } | |
df694daa KY |
6331 | } |
6332 | ||
f95474ec TI |
6333 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
6334 | ||
df694daa KY |
6335 | if (board_config == ALC882_AUTO) { |
6336 | /* automatic parse from the BIOS config */ | |
6337 | err = alc882_parse_auto_config(codec); | |
6338 | if (err < 0) { | |
6339 | alc_free(codec); | |
6340 | return err; | |
f12ab1e0 | 6341 | } else if (!err) { |
9c7f852e TI |
6342 | printk(KERN_INFO |
6343 | "hda_codec: Cannot set up configuration " | |
6344 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
6345 | board_config = ALC882_3ST_DIG; |
6346 | } | |
6347 | } | |
6348 | ||
6349 | if (board_config != ALC882_AUTO) | |
6350 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 LT |
6351 | |
6352 | spec->stream_name_analog = "ALC882 Analog"; | |
df694daa KY |
6353 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
6354 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
6330079f TI |
6355 | /* FIXME: setup DAC5 */ |
6356 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | |
6357 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | |
1da177e4 LT |
6358 | |
6359 | spec->stream_name_digital = "ALC882 Digital"; | |
df694daa KY |
6360 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
6361 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 6362 | |
f12ab1e0 | 6363 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 6364 | /* check whether NID 0x07 is valid */ |
4a471b7d | 6365 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
6366 | /* get type */ |
6367 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
6368 | if (wcap != AC_WID_AUD_IN) { |
6369 | spec->adc_nids = alc882_adc_nids_alt; | |
6370 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
f12ab1e0 TI |
6371 | spec->mixers[spec->num_mixers] = |
6372 | alc882_capture_alt_mixer; | |
df694daa KY |
6373 | spec->num_mixers++; |
6374 | } else { | |
6375 | spec->adc_nids = alc882_adc_nids; | |
6376 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
6377 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; | |
6378 | spec->num_mixers++; | |
6379 | } | |
6380 | } | |
1da177e4 | 6381 | |
2134ea4f TI |
6382 | spec->vmaster_nid = 0x0c; |
6383 | ||
1da177e4 | 6384 | codec->patch_ops = alc_patch_ops; |
df694daa | 6385 | if (board_config == ALC882_AUTO) |
ae6b813a | 6386 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
6387 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6388 | if (!spec->loopback.amplist) | |
6389 | spec->loopback.amplist = alc882_loopbacks; | |
6390 | #endif | |
df694daa KY |
6391 | |
6392 | return 0; | |
6393 | } | |
6394 | ||
6395 | /* | |
9c7f852e TI |
6396 | * ALC883 support |
6397 | * | |
6398 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
6399 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
6400 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
6401 | * 6-channel independent captures. | |
6402 | * | |
6403 | * In addition, an independent DAC for the multi-playback (not used in this | |
6404 | * driver yet). | |
df694daa | 6405 | */ |
9c7f852e TI |
6406 | #define ALC883_DIGOUT_NID 0x06 |
6407 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 6408 | |
9c7f852e TI |
6409 | static hda_nid_t alc883_dac_nids[4] = { |
6410 | /* front, rear, clfe, rear_surr */ | |
6411 | 0x02, 0x04, 0x03, 0x05 | |
6412 | }; | |
df694daa | 6413 | |
9c7f852e TI |
6414 | static hda_nid_t alc883_adc_nids[2] = { |
6415 | /* ADC1-2 */ | |
6416 | 0x08, 0x09, | |
6417 | }; | |
f12ab1e0 | 6418 | |
9c7f852e TI |
6419 | /* input MUX */ |
6420 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 6421 | |
9c7f852e TI |
6422 | static struct hda_input_mux alc883_capture_source = { |
6423 | .num_items = 4, | |
6424 | .items = { | |
6425 | { "Mic", 0x0 }, | |
6426 | { "Front Mic", 0x1 }, | |
6427 | { "Line", 0x2 }, | |
6428 | { "CD", 0x4 }, | |
6429 | }, | |
6430 | }; | |
bc9f98a9 KY |
6431 | |
6432 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | |
6433 | .num_items = 2, | |
6434 | .items = { | |
6435 | { "Mic", 0x1 }, | |
6436 | { "Line", 0x2 }, | |
6437 | }, | |
6438 | }; | |
6439 | ||
272a527c KY |
6440 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
6441 | .num_items = 4, | |
6442 | .items = { | |
6443 | { "Mic", 0x0 }, | |
6444 | { "iMic", 0x1 }, | |
6445 | { "Line", 0x2 }, | |
6446 | { "CD", 0x4 }, | |
6447 | }, | |
6448 | }; | |
6449 | ||
9c7f852e TI |
6450 | #define alc883_mux_enum_info alc_mux_enum_info |
6451 | #define alc883_mux_enum_get alc_mux_enum_get | |
df694daa | 6452 | |
9c7f852e TI |
6453 | static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, |
6454 | struct snd_ctl_elem_value *ucontrol) | |
6455 | { | |
6456 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
6457 | struct alc_spec *spec = codec->spec; | |
6458 | const struct hda_input_mux *imux = spec->input_mux; | |
6459 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
6460 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
6461 | hda_nid_t nid = capture_mixers[adc_idx]; | |
6462 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
6463 | unsigned int i, idx; | |
6464 | ||
6465 | idx = ucontrol->value.enumerated.item[0]; | |
6466 | if (idx >= imux->num_items) | |
6467 | idx = imux->num_items - 1; | |
82beb8fd | 6468 | if (*cur_val == idx) |
9c7f852e TI |
6469 | return 0; |
6470 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
6471 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
6472 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
82beb8fd | 6473 | imux->items[i].index, |
47fd830a | 6474 | HDA_AMP_MUTE, v); |
9c7f852e TI |
6475 | } |
6476 | *cur_val = idx; | |
6477 | return 1; | |
6478 | } | |
f12ab1e0 | 6479 | |
9c7f852e TI |
6480 | /* |
6481 | * 2ch mode | |
6482 | */ | |
6483 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
6484 | { 2, NULL } | |
6485 | }; | |
6486 | ||
6487 | /* | |
6488 | * 2ch mode | |
6489 | */ | |
6490 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
6491 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6492 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6493 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6494 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6495 | { } /* end */ | |
6496 | }; | |
6497 | ||
b201131c TD |
6498 | /* |
6499 | * 4ch mode | |
6500 | */ | |
6501 | static struct hda_verb alc883_3ST_ch4_init[] = { | |
6502 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6503 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6504 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6505 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6506 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6507 | { } /* end */ | |
6508 | }; | |
6509 | ||
9c7f852e TI |
6510 | /* |
6511 | * 6ch mode | |
6512 | */ | |
6513 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
6514 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6515 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6516 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6517 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6518 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6519 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6520 | { } /* end */ | |
6521 | }; | |
6522 | ||
b201131c | 6523 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { |
9c7f852e | 6524 | { 2, alc883_3ST_ch2_init }, |
b201131c | 6525 | { 4, alc883_3ST_ch4_init }, |
9c7f852e TI |
6526 | { 6, alc883_3ST_ch6_init }, |
6527 | }; | |
6528 | ||
6529 | /* | |
6530 | * 6ch mode | |
6531 | */ | |
6532 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
6533 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
6534 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6535 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6536 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6537 | { } /* end */ | |
6538 | }; | |
6539 | ||
6540 | /* | |
6541 | * 8ch mode | |
6542 | */ | |
6543 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
6544 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6545 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6546 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6547 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6548 | { } /* end */ | |
6549 | }; | |
6550 | ||
6551 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
6552 | { 6, alc883_sixstack_ch6_init }, | |
6553 | { 8, alc883_sixstack_ch8_init }, | |
6554 | }; | |
6555 | ||
b373bdeb AN |
6556 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
6557 | /* eanable EAPD on medion laptop */ | |
6558 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
6559 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
6560 | { } | |
6561 | }; | |
6562 | ||
9c7f852e TI |
6563 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6564 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
6565 | */ | |
6566 | ||
6567 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 6568 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
6569 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
6570 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6571 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6572 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6573 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6574 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6575 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6576 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6577 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6578 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
6579 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
6580 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6581 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6582 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6583 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6584 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 6585 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 6586 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 6587 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6588 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6589 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6590 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6591 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6592 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6593 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6594 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6595 | { | |
6596 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6597 | /* .name = "Capture Source", */ | |
6598 | .name = "Input Source", | |
6599 | .count = 2, | |
6600 | .info = alc883_mux_enum_info, | |
6601 | .get = alc883_mux_enum_get, | |
6602 | .put = alc883_mux_enum_put, | |
6603 | }, | |
df694daa | 6604 | { } /* end */ |
834be88d TI |
6605 | }; |
6606 | ||
a8848bd6 AS |
6607 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
6608 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6609 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6610 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6611 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6612 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6613 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6614 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6615 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6616 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6617 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6618 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6619 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6620 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6621 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6622 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6623 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6624 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6625 | { | |
6626 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6627 | /* .name = "Capture Source", */ | |
6628 | .name = "Input Source", | |
6629 | .count = 2, | |
6630 | .info = alc883_mux_enum_info, | |
6631 | .get = alc883_mux_enum_get, | |
6632 | .put = alc883_mux_enum_put, | |
6633 | }, | |
6634 | { } /* end */ | |
6635 | }; | |
6636 | ||
9c7f852e TI |
6637 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
6638 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6639 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6640 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6641 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6642 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6643 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6644 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6645 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6646 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6647 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6648 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6649 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6650 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6651 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6652 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6653 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6654 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6655 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6656 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6657 | { | |
6658 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6659 | /* .name = "Capture Source", */ | |
6660 | .name = "Input Source", | |
6661 | .count = 2, | |
6662 | .info = alc883_mux_enum_info, | |
6663 | .get = alc883_mux_enum_get, | |
6664 | .put = alc883_mux_enum_put, | |
6665 | }, | |
6666 | { } /* end */ | |
6667 | }; | |
df694daa | 6668 | |
9c7f852e TI |
6669 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
6670 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6671 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6672 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6673 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6674 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6675 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6676 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6677 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6678 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6679 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6680 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6681 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6682 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6683 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6684 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6685 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6686 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6687 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6688 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6689 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6690 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6691 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6692 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6693 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6694 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6695 | { | |
6696 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6697 | /* .name = "Capture Source", */ | |
6698 | .name = "Input Source", | |
6699 | .count = 2, | |
6700 | .info = alc883_mux_enum_info, | |
6701 | .get = alc883_mux_enum_get, | |
6702 | .put = alc883_mux_enum_put, | |
6703 | }, | |
6704 | { } /* end */ | |
6705 | }; | |
6706 | ||
d1d985f0 | 6707 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 TD |
6708 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6709 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6710 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6711 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6712 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6713 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6714 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), | |
6715 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6716 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6717 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6718 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6719 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6720 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6721 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6722 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
6723 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6724 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6725 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
6726 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6727 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6728 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6729 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6730 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6731 | ||
6732 | { | |
6733 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6734 | /* .name = "Capture Source", */ | |
6735 | .name = "Input Source", | |
6736 | .count = 1, | |
6737 | .info = alc883_mux_enum_info, | |
6738 | .get = alc883_mux_enum_get, | |
6739 | .put = alc883_mux_enum_put, | |
6740 | }, | |
6741 | { } /* end */ | |
6742 | }; | |
6743 | ||
ccc656ce KY |
6744 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
6745 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6746 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6747 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6748 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6749 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6750 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6751 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6752 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6753 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6754 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6755 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6756 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6757 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6758 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6759 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
6760 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6761 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6762 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6763 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6764 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6765 | { | |
6766 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6767 | /* .name = "Capture Source", */ | |
6768 | .name = "Input Source", | |
6769 | .count = 2, | |
6770 | .info = alc883_mux_enum_info, | |
6771 | .get = alc883_mux_enum_get, | |
6772 | .put = alc883_mux_enum_put, | |
6773 | }, | |
6774 | { } /* end */ | |
f12ab1e0 | 6775 | }; |
ccc656ce KY |
6776 | |
6777 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
6778 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6779 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6780 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6781 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6782 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6783 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6784 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
6785 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6786 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6787 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6788 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6789 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6790 | { | |
6791 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6792 | /* .name = "Capture Source", */ | |
6793 | .name = "Input Source", | |
6794 | .count = 2, | |
6795 | .info = alc883_mux_enum_info, | |
6796 | .get = alc883_mux_enum_get, | |
6797 | .put = alc883_mux_enum_put, | |
6798 | }, | |
6799 | { } /* end */ | |
f12ab1e0 | 6800 | }; |
ccc656ce | 6801 | |
bc9f98a9 KY |
6802 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
6803 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6804 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
86cd9298 TI |
6805 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
6806 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
bc9f98a9 KY |
6807 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
6808 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6809 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6810 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6811 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6812 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6813 | { | |
6814 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6815 | /* .name = "Capture Source", */ | |
6816 | .name = "Input Source", | |
6817 | .count = 1, | |
6818 | .info = alc883_mux_enum_info, | |
6819 | .get = alc883_mux_enum_get, | |
6820 | .put = alc883_mux_enum_put, | |
6821 | }, | |
6822 | { } /* end */ | |
f12ab1e0 | 6823 | }; |
bc9f98a9 | 6824 | |
272a527c KY |
6825 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
6826 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6827 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
6828 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6829 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6830 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6831 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6832 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6833 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6834 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6835 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6836 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6837 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6838 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6839 | { | |
6840 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6841 | /* .name = "Capture Source", */ | |
6842 | .name = "Input Source", | |
6843 | .count = 2, | |
6844 | .info = alc883_mux_enum_info, | |
6845 | .get = alc883_mux_enum_get, | |
6846 | .put = alc883_mux_enum_put, | |
6847 | }, | |
6848 | { } /* end */ | |
6849 | }; | |
6850 | ||
6851 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
6852 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6853 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6854 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6855 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6856 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6857 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6858 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6859 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6860 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6861 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6862 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6863 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6864 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6865 | { | |
6866 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6867 | /* .name = "Capture Source", */ | |
6868 | .name = "Input Source", | |
6869 | .count = 2, | |
6870 | .info = alc883_mux_enum_info, | |
6871 | .get = alc883_mux_enum_get, | |
6872 | .put = alc883_mux_enum_put, | |
6873 | }, | |
6874 | { } /* end */ | |
6875 | }; | |
6876 | ||
4723c022 | 6877 | static struct snd_kcontrol_new alc888_6st_hp_mixer[] = { |
cd1e3b40 CM |
6878 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6879 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6880 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
6881 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
6882 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
6883 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
6884 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
6885 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
6886 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6887 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6888 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6889 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6890 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6891 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6892 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6893 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6894 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6895 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6896 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6897 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6898 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6899 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6900 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6901 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6902 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6903 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6904 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6905 | { | |
6906 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6907 | /* .name = "Capture Source", */ | |
6908 | .name = "Input Source", | |
6909 | .count = 2, | |
6910 | .info = alc883_mux_enum_info, | |
6911 | .get = alc883_mux_enum_get, | |
6912 | .put = alc883_mux_enum_put, | |
6913 | }, | |
6914 | { } /* end */ | |
6915 | }; | |
6916 | ||
4723c022 | 6917 | static struct snd_kcontrol_new alc888_3st_hp_mixer[] = { |
8341de60 CM |
6918 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6919 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6920 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
6921 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
6922 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
6923 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
6924 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
6925 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
6926 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6927 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6928 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6929 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6930 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6931 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6932 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6933 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6934 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6935 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6936 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6937 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6938 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6939 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6940 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6941 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6942 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6943 | { | |
6944 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6945 | /* .name = "Capture Source", */ | |
6946 | .name = "Input Source", | |
6947 | .count = 2, | |
6948 | .info = alc883_mux_enum_info, | |
6949 | .get = alc883_mux_enum_get, | |
6950 | .put = alc883_mux_enum_put, | |
6951 | }, | |
6952 | { } /* end */ | |
6953 | }; | |
6954 | ||
5795b9e6 CM |
6955 | static struct snd_kcontrol_new alc888_6st_dell_mixer[] = { |
6956 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6957 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6958 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
6959 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
6960 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
6961 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
6962 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
6963 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
6964 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6965 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6966 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6967 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6968 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6969 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6970 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6971 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6972 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6973 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6974 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6975 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6976 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6977 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6978 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6979 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6980 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6981 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6982 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6983 | { | |
6984 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6985 | /* .name = "Capture Source", */ | |
6986 | .name = "Input Source", | |
6987 | .count = 2, | |
6988 | .info = alc883_mux_enum_info, | |
6989 | .get = alc883_mux_enum_get, | |
6990 | .put = alc883_mux_enum_put, | |
6991 | }, | |
6992 | { } /* end */ | |
6993 | }; | |
6994 | ||
2880a867 | 6995 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
6996 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6997 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 6998 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
6999 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7000 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
7001 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7002 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7003 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 TD |
7004 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
7005 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7006 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7007 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7008 | { | |
7009 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7010 | /* .name = "Capture Source", */ | |
7011 | .name = "Input Source", | |
7012 | .count = 2, | |
7013 | .info = alc883_mux_enum_info, | |
7014 | .get = alc883_mux_enum_get, | |
7015 | .put = alc883_mux_enum_put, | |
7016 | }, | |
7017 | { } /* end */ | |
d1a991a6 | 7018 | }; |
2880a867 | 7019 | |
9c7f852e TI |
7020 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
7021 | { | |
7022 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7023 | .name = "Channel Mode", | |
7024 | .info = alc_ch_mode_info, | |
7025 | .get = alc_ch_mode_get, | |
7026 | .put = alc_ch_mode_put, | |
7027 | }, | |
7028 | { } /* end */ | |
7029 | }; | |
7030 | ||
7031 | static struct hda_verb alc883_init_verbs[] = { | |
7032 | /* ADC1: mute amp left and right */ | |
7033 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7034 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7035 | /* ADC2: mute amp left and right */ |
7036 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7037 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7038 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7039 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7040 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7041 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7042 | /* Rear mixer */ | |
7043 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7044 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7045 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7046 | /* CLFE mixer */ | |
7047 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7048 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7049 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7050 | /* Side mixer */ | |
7051 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7052 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7053 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 7054 | |
cb53c626 TI |
7055 | /* mute analog input loopbacks */ |
7056 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7057 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7058 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7059 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7060 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 7061 | |
9c7f852e TI |
7062 | /* Front Pin: output 0 (0x0c) */ |
7063 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7064 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7065 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7066 | /* Rear Pin: output 1 (0x0d) */ | |
7067 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7068 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7069 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7070 | /* CLFE Pin: output 2 (0x0e) */ | |
7071 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7072 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7073 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7074 | /* Side Pin: output 3 (0x0f) */ | |
7075 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7076 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7077 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
7078 | /* Mic (rear) pin: input vref at 80% */ | |
7079 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7080 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7081 | /* Front Mic pin: input vref at 80% */ | |
7082 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7083 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7084 | /* Line In pin: input */ | |
7085 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7086 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7087 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
7088 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7089 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7090 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7091 | /* CD pin widget for input */ | |
7092 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7093 | ||
7094 | /* FIXME: use matrix-type input source selection */ | |
7095 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7096 | /* Input mixer2 */ | |
7097 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7098 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7099 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7100 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
7101 | /* Input mixer3 */ | |
7102 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7103 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7104 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7105 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
7106 | { } | |
7107 | }; | |
7108 | ||
a8848bd6 AS |
7109 | /* toggle speaker-output according to the hp-jack state */ |
7110 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | |
7111 | { | |
7112 | unsigned int present; | |
7113 | ||
7114 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7115 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7116 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7117 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7118 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7119 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7120 | } | |
7121 | ||
7122 | /* auto-toggle front mic */ | |
7123 | /* | |
7124 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | |
7125 | { | |
7126 | unsigned int present; | |
7127 | unsigned char bits; | |
7128 | ||
7129 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7130 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7131 | bits = present ? HDA_AMP_MUTE : 0; | |
7132 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
7133 | } | |
7134 | */ | |
7135 | ||
7136 | static void alc883_mitac_automute(struct hda_codec *codec) | |
7137 | { | |
7138 | alc883_mitac_hp_automute(codec); | |
7139 | /* alc883_mitac_mic_automute(codec); */ | |
7140 | } | |
7141 | ||
7142 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | |
7143 | unsigned int res) | |
7144 | { | |
7145 | switch (res >> 26) { | |
7146 | case ALC880_HP_EVENT: | |
7147 | alc883_mitac_hp_automute(codec); | |
7148 | break; | |
7149 | case ALC880_MIC_EVENT: | |
7150 | /* alc883_mitac_mic_automute(codec); */ | |
7151 | break; | |
7152 | } | |
7153 | } | |
7154 | ||
7155 | static struct hda_verb alc883_mitac_verbs[] = { | |
7156 | /* HP */ | |
7157 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7158 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7159 | /* Subwoofer */ | |
7160 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7161 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7162 | ||
7163 | /* enable unsolicited event */ | |
7164 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7165 | /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ | |
7166 | ||
7167 | { } /* end */ | |
7168 | }; | |
7169 | ||
ccc656ce KY |
7170 | static struct hda_verb alc883_tagra_verbs[] = { |
7171 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7172 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7173 | ||
7174 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7175 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7176 | ||
7177 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
7178 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
7179 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
7180 | ||
7181 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
7182 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
7183 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
7184 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
7185 | |
7186 | { } /* end */ | |
7187 | }; | |
7188 | ||
bc9f98a9 KY |
7189 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
7190 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7191 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
7192 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
7193 | { } /* end */ | |
7194 | }; | |
7195 | ||
272a527c KY |
7196 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
7197 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7198 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7199 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7200 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7201 | { } /* end */ | |
7202 | }; | |
7203 | ||
7204 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
7205 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7206 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7207 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7208 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
7209 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7210 | { } /* end */ | |
7211 | }; | |
7212 | ||
189609ae KY |
7213 | static struct hda_verb alc883_haier_w66_verbs[] = { |
7214 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7215 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7216 | ||
7217 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7218 | ||
7219 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7220 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7221 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7222 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7223 | { } /* end */ | |
7224 | }; | |
7225 | ||
4723c022 | 7226 | static struct hda_verb alc888_6st_hp_verbs[] = { |
cd1e3b40 CM |
7227 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
7228 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */ | |
7229 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */ | |
7230 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */ | |
7231 | { } | |
7232 | }; | |
7233 | ||
4723c022 | 7234 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 CM |
7235 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
7236 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ | |
7237 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
7238 | { } | |
7239 | }; | |
7240 | ||
5795b9e6 CM |
7241 | static struct hda_verb alc888_6st_dell_verbs[] = { |
7242 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ | |
7243 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */ | |
7244 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */ | |
7245 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */ | |
7246 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7247 | { } | |
7248 | }; | |
7249 | ||
4723c022 | 7250 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
7251 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
7252 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7253 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7254 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7255 | { } | |
7256 | }; | |
7257 | ||
4723c022 | 7258 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
7259 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
7260 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7261 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7262 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7263 | { } | |
7264 | }; | |
7265 | ||
4723c022 CM |
7266 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
7267 | { 2, alc888_3st_hp_2ch_init }, | |
7268 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
7269 | }; |
7270 | ||
272a527c KY |
7271 | /* toggle front-jack and RCA according to the hp-jack state */ |
7272 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
7273 | { | |
7274 | unsigned int present; | |
7275 | ||
7276 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7277 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7278 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7279 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7280 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7281 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7282 | } |
7283 | ||
7284 | /* toggle RCA according to the front-jack state */ | |
7285 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
7286 | { | |
7287 | unsigned int present; | |
7288 | ||
7289 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7290 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7291 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7292 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 7293 | } |
47fd830a | 7294 | |
272a527c KY |
7295 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
7296 | unsigned int res) | |
7297 | { | |
7298 | if ((res >> 26) == ALC880_HP_EVENT) | |
7299 | alc888_lenovo_ms7195_front_automute(codec); | |
7300 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7301 | alc888_lenovo_ms7195_rca_automute(codec); | |
7302 | } | |
7303 | ||
7304 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
7305 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7306 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7307 | ||
7308 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7309 | ||
7310 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7311 | { } /* end */ | |
7312 | }; | |
7313 | ||
7314 | /* toggle speaker-output according to the hp-jack state */ | |
7315 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
7316 | { | |
7317 | unsigned int present; | |
7318 | ||
7319 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7320 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7321 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7322 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7323 | } |
7324 | ||
7325 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
7326 | unsigned int res) | |
7327 | { | |
7328 | if ((res >> 26) == ALC880_HP_EVENT) | |
7329 | alc883_medion_md2_automute(codec); | |
7330 | } | |
7331 | ||
ccc656ce KY |
7332 | /* toggle speaker-output according to the hp-jack state */ |
7333 | static void alc883_tagra_automute(struct hda_codec *codec) | |
7334 | { | |
7335 | unsigned int present; | |
f12ab1e0 | 7336 | unsigned char bits; |
ccc656ce KY |
7337 | |
7338 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7339 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7340 | bits = present ? HDA_AMP_MUTE : 0; |
7341 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
7342 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
7343 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
7344 | present ? 1 : 3); | |
ccc656ce KY |
7345 | } |
7346 | ||
7347 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
7348 | { | |
7349 | if ((res >> 26) == ALC880_HP_EVENT) | |
7350 | alc883_tagra_automute(codec); | |
7351 | } | |
7352 | ||
189609ae KY |
7353 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
7354 | { | |
7355 | unsigned int present; | |
7356 | unsigned char bits; | |
7357 | ||
7358 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7359 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7360 | bits = present ? 0x80 : 0; | |
7361 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7362 | 0x80, bits); | |
7363 | } | |
7364 | ||
7365 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
7366 | unsigned int res) | |
7367 | { | |
7368 | if ((res >> 26) == ALC880_HP_EVENT) | |
7369 | alc883_haier_w66_automute(codec); | |
7370 | } | |
7371 | ||
bc9f98a9 KY |
7372 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
7373 | { | |
7374 | unsigned int present; | |
f12ab1e0 | 7375 | unsigned char bits; |
bc9f98a9 KY |
7376 | |
7377 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7378 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7379 | bits = present ? HDA_AMP_MUTE : 0; |
7380 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7381 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
7382 | } |
7383 | ||
7384 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
7385 | { | |
7386 | unsigned int present; | |
f12ab1e0 | 7387 | unsigned char bits; |
bc9f98a9 KY |
7388 | |
7389 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7390 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7391 | bits = present ? HDA_AMP_MUTE : 0; |
7392 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7393 | HDA_AMP_MUTE, bits); | |
7394 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7395 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
7396 | } |
7397 | ||
7398 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
7399 | unsigned int res) | |
7400 | { | |
7401 | if ((res >> 26) == ALC880_HP_EVENT) | |
7402 | alc883_lenovo_101e_all_automute(codec); | |
7403 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7404 | alc883_lenovo_101e_ispeaker_automute(codec); | |
7405 | } | |
7406 | ||
676a9b53 TI |
7407 | /* toggle speaker-output according to the hp-jack state */ |
7408 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
7409 | { | |
7410 | unsigned int present; | |
7411 | ||
7412 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7413 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7414 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7415 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7416 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7417 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7418 | } | |
7419 | ||
7420 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
7421 | unsigned int res) | |
7422 | { | |
7423 | if ((res >> 26) == ALC880_HP_EVENT) | |
7424 | alc883_acer_aspire_automute(codec); | |
7425 | } | |
7426 | ||
d1a991a6 KY |
7427 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
7428 | /* HP Pin: output 0 (0x0c) */ | |
7429 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7430 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7431 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7432 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
7433 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
7434 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 7435 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
7436 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
7437 | /* eanable EAPD on medion laptop */ | |
7438 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7439 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
7440 | /* enable unsolicited event */ |
7441 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
7442 | { } |
7443 | }; | |
7444 | ||
5795b9e6 CM |
7445 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) |
7446 | { | |
7447 | unsigned int present; | |
7448 | ||
7449 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7450 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7451 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7452 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7453 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7454 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7455 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7456 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7457 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7458 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7459 | } | |
7460 | ||
7461 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | |
7462 | unsigned int res) | |
7463 | { | |
7464 | switch (res >> 26) { | |
7465 | case ALC880_HP_EVENT: | |
7466 | printk("hp_event\n"); | |
7467 | alc888_6st_dell_front_automute(codec); | |
7468 | break; | |
7469 | } | |
7470 | } | |
7471 | ||
9c7f852e TI |
7472 | /* |
7473 | * generic initialization of ADC, input mixers and output mixers | |
7474 | */ | |
7475 | static struct hda_verb alc883_auto_init_verbs[] = { | |
7476 | /* | |
7477 | * Unmute ADC0-2 and set the default input to mic-in | |
7478 | */ | |
7479 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7480 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7481 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7482 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7483 | ||
cb53c626 | 7484 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 7485 | * mixer widget |
f12ab1e0 TI |
7486 | * Note: PASD motherboards uses the Line In 2 as the input for |
7487 | * front panel mic (mic 2) | |
9c7f852e TI |
7488 | */ |
7489 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
7490 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7491 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7492 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7493 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7494 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7495 | |
7496 | /* | |
7497 | * Set up output mixers (0x0c - 0x0f) | |
7498 | */ | |
7499 | /* set vol=0 to output mixers */ | |
7500 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7501 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7502 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7503 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7504 | /* set up input amps for analog loopback */ | |
7505 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7506 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7507 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7508 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7509 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7510 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7511 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7512 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7513 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7514 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7515 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7516 | ||
7517 | /* FIXME: use matrix-type input source selection */ | |
7518 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7519 | /* Input mixer1 */ | |
7520 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7521 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7522 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7523 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
7524 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
7525 | /* Input mixer2 */ | |
7526 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7527 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7528 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7529 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
e3cde64a | 7530 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
9c7f852e TI |
7531 | |
7532 | { } | |
7533 | }; | |
7534 | ||
7535 | /* capture mixer elements */ | |
7536 | static struct snd_kcontrol_new alc883_capture_mixer[] = { | |
7537 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7538 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7539 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7540 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7541 | { | |
7542 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7543 | /* The multiple "Capture Source" controls confuse alsamixer | |
7544 | * So call somewhat different.. | |
9c7f852e TI |
7545 | */ |
7546 | /* .name = "Capture Source", */ | |
7547 | .name = "Input Source", | |
7548 | .count = 2, | |
7549 | .info = alc882_mux_enum_info, | |
7550 | .get = alc882_mux_enum_get, | |
7551 | .put = alc882_mux_enum_put, | |
7552 | }, | |
7553 | { } /* end */ | |
7554 | }; | |
7555 | ||
cb53c626 TI |
7556 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
7557 | #define alc883_loopbacks alc880_loopbacks | |
7558 | #endif | |
7559 | ||
9c7f852e TI |
7560 | /* pcm configuration: identiacal with ALC880 */ |
7561 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
7562 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 7563 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
9c7f852e TI |
7564 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback |
7565 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
7566 | ||
7567 | /* | |
7568 | * configuration and preset | |
7569 | */ | |
f5fcc13c TI |
7570 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
7571 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
7572 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
7573 | [ALC883_3ST_6ch] = "3stack-6ch", | |
7574 | [ALC883_6ST_DIG] = "6stack-dig", | |
7575 | [ALC883_TARGA_DIG] = "targa-dig", | |
7576 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 7577 | [ALC883_ACER] = "acer", |
2880a867 | 7578 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
f5fcc13c | 7579 | [ALC883_MEDION] = "medion", |
272a527c | 7580 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 7581 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 7582 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
7583 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
7584 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
189609ae | 7585 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 CM |
7586 | [ALC888_6ST_HP] = "6stack-hp", |
7587 | [ALC888_3ST_HP] = "3stack-hp", | |
5795b9e6 | 7588 | [ALC888_6ST_DELL] = "6stack-dell", |
a8848bd6 | 7589 | [ALC883_MITAC] = "mitac", |
f5fcc13c TI |
7590 | [ALC883_AUTO] = "auto", |
7591 | }; | |
7592 | ||
7593 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
7594 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
ac3e3741 TI |
7595 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
7596 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), | |
7597 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), | |
7598 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ | |
5795b9e6 | 7599 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
febe3375 | 7600 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
ac3e3741 TI |
7601 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
7602 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
7603 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP), | |
7604 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), | |
f5fcc13c | 7605 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), |
ac3e3741 TI |
7606 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
7607 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
7608 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), | |
57b14f24 | 7609 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 7610 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
bba8dee7 | 7611 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 7612 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 7613 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
f5fcc13c | 7614 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 7615 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
7616 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), |
7617 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 | 7618 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
64ca1c29 | 7619 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
7620 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
7621 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
7622 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 TI |
7623 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
7624 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
7625 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), | |
7626 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), | |
7627 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | |
f5fcc13c | 7628 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 TI |
7629 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
7630 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), | |
e60623b4 | 7631 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c | 7632 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
272a527c | 7633 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
272a527c | 7634 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
ac3e3741 TI |
7635 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
7636 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
272a527c | 7637 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
189609ae | 7638 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
ac3e3741 | 7639 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9c7f852e TI |
7640 | {} |
7641 | }; | |
7642 | ||
7643 | static struct alc_config_preset alc883_presets[] = { | |
7644 | [ALC883_3ST_2ch_DIG] = { | |
7645 | .mixers = { alc883_3ST_2ch_mixer }, | |
7646 | .init_verbs = { alc883_init_verbs }, | |
7647 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7648 | .dac_nids = alc883_dac_nids, | |
7649 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7650 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7651 | .adc_nids = alc883_adc_nids, | |
7652 | .dig_in_nid = ALC883_DIGIN_NID, | |
7653 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7654 | .channel_mode = alc883_3ST_2ch_modes, | |
7655 | .input_mux = &alc883_capture_source, | |
7656 | }, | |
7657 | [ALC883_3ST_6ch_DIG] = { | |
7658 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7659 | .init_verbs = { alc883_init_verbs }, | |
7660 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7661 | .dac_nids = alc883_dac_nids, | |
7662 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7663 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7664 | .adc_nids = alc883_adc_nids, | |
7665 | .dig_in_nid = ALC883_DIGIN_NID, | |
7666 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7667 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 7668 | .need_dac_fix = 1, |
9c7f852e | 7669 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 7670 | }, |
9c7f852e TI |
7671 | [ALC883_3ST_6ch] = { |
7672 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7673 | .init_verbs = { alc883_init_verbs }, | |
7674 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7675 | .dac_nids = alc883_dac_nids, | |
7676 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7677 | .adc_nids = alc883_adc_nids, | |
7678 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7679 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 7680 | .need_dac_fix = 1, |
9c7f852e | 7681 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 7682 | }, |
9c7f852e TI |
7683 | [ALC883_6ST_DIG] = { |
7684 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
7685 | .init_verbs = { alc883_init_verbs }, | |
7686 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7687 | .dac_nids = alc883_dac_nids, | |
7688 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7689 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7690 | .adc_nids = alc883_adc_nids, | |
7691 | .dig_in_nid = ALC883_DIGIN_NID, | |
7692 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7693 | .channel_mode = alc883_sixstack_modes, | |
7694 | .input_mux = &alc883_capture_source, | |
7695 | }, | |
ccc656ce KY |
7696 | [ALC883_TARGA_DIG] = { |
7697 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
7698 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
7699 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7700 | .dac_nids = alc883_dac_nids, | |
7701 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7702 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7703 | .adc_nids = alc883_adc_nids, | |
7704 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7705 | .channel_mode = alc883_3ST_6ch_modes, | |
7706 | .need_dac_fix = 1, | |
7707 | .input_mux = &alc883_capture_source, | |
7708 | .unsol_event = alc883_tagra_unsol_event, | |
7709 | .init_hook = alc883_tagra_automute, | |
7710 | }, | |
7711 | [ALC883_TARGA_2ch_DIG] = { | |
7712 | .mixers = { alc883_tagra_2ch_mixer}, | |
7713 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
7714 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7715 | .dac_nids = alc883_dac_nids, | |
7716 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7717 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7718 | .adc_nids = alc883_adc_nids, | |
7719 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7720 | .channel_mode = alc883_3ST_2ch_modes, | |
7721 | .input_mux = &alc883_capture_source, | |
7722 | .unsol_event = alc883_tagra_unsol_event, | |
7723 | .init_hook = alc883_tagra_automute, | |
7724 | }, | |
bab282b9 | 7725 | [ALC883_ACER] = { |
676a9b53 | 7726 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
7727 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
7728 | * and the headphone jack. Turn this on and rely on the | |
7729 | * standard mute methods whenever the user wants to turn | |
7730 | * these outputs off. | |
7731 | */ | |
7732 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
7733 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7734 | .dac_nids = alc883_dac_nids, | |
7735 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7736 | .adc_nids = alc883_adc_nids, | |
7737 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7738 | .channel_mode = alc883_3ST_2ch_modes, | |
7739 | .input_mux = &alc883_capture_source, | |
7740 | }, | |
2880a867 | 7741 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 7742 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 7743 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
7744 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7745 | .dac_nids = alc883_dac_nids, | |
7746 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7747 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7748 | .adc_nids = alc883_adc_nids, | |
7749 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7750 | .channel_mode = alc883_3ST_2ch_modes, | |
7751 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
7752 | .unsol_event = alc883_acer_aspire_unsol_event, |
7753 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 7754 | }, |
c07584c8 TD |
7755 | [ALC883_MEDION] = { |
7756 | .mixers = { alc883_fivestack_mixer, | |
7757 | alc883_chmode_mixer }, | |
7758 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 7759 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
7760 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7761 | .dac_nids = alc883_dac_nids, | |
7762 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7763 | .adc_nids = alc883_adc_nids, | |
7764 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7765 | .channel_mode = alc883_sixstack_modes, | |
7766 | .input_mux = &alc883_capture_source, | |
b373bdeb | 7767 | }, |
272a527c KY |
7768 | [ALC883_MEDION_MD2] = { |
7769 | .mixers = { alc883_medion_md2_mixer}, | |
7770 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
7771 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7772 | .dac_nids = alc883_dac_nids, | |
7773 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7774 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7775 | .adc_nids = alc883_adc_nids, | |
7776 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7777 | .channel_mode = alc883_3ST_2ch_modes, | |
7778 | .input_mux = &alc883_capture_source, | |
7779 | .unsol_event = alc883_medion_md2_unsol_event, | |
7780 | .init_hook = alc883_medion_md2_automute, | |
7781 | }, | |
b373bdeb | 7782 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 7783 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
7784 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
7785 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7786 | .dac_nids = alc883_dac_nids, | |
7787 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7788 | .adc_nids = alc883_adc_nids, | |
7789 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7790 | .channel_mode = alc883_3ST_2ch_modes, | |
7791 | .input_mux = &alc883_capture_source, | |
7792 | }, | |
bc9f98a9 KY |
7793 | [ALC883_LENOVO_101E_2ch] = { |
7794 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
7795 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
7796 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7797 | .dac_nids = alc883_dac_nids, | |
7798 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7799 | .adc_nids = alc883_adc_nids, | |
7800 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7801 | .channel_mode = alc883_3ST_2ch_modes, | |
7802 | .input_mux = &alc883_lenovo_101e_capture_source, | |
7803 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
7804 | .init_hook = alc883_lenovo_101e_all_automute, | |
7805 | }, | |
272a527c KY |
7806 | [ALC883_LENOVO_NB0763] = { |
7807 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
7808 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
7809 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7810 | .dac_nids = alc883_dac_nids, | |
7811 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7812 | .adc_nids = alc883_adc_nids, | |
7813 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7814 | .channel_mode = alc883_3ST_2ch_modes, | |
7815 | .need_dac_fix = 1, | |
7816 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
7817 | .unsol_event = alc883_medion_md2_unsol_event, | |
7818 | .init_hook = alc883_medion_md2_automute, | |
7819 | }, | |
7820 | [ALC888_LENOVO_MS7195_DIG] = { | |
7821 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7822 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
7823 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7824 | .dac_nids = alc883_dac_nids, | |
7825 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7826 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7827 | .adc_nids = alc883_adc_nids, | |
7828 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7829 | .channel_mode = alc883_3ST_6ch_modes, | |
7830 | .need_dac_fix = 1, | |
7831 | .input_mux = &alc883_capture_source, | |
7832 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
7833 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
7834 | }, |
7835 | [ALC883_HAIER_W66] = { | |
7836 | .mixers = { alc883_tagra_2ch_mixer}, | |
7837 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
7838 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7839 | .dac_nids = alc883_dac_nids, | |
7840 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7841 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7842 | .adc_nids = alc883_adc_nids, | |
7843 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7844 | .channel_mode = alc883_3ST_2ch_modes, | |
7845 | .input_mux = &alc883_capture_source, | |
7846 | .unsol_event = alc883_haier_w66_unsol_event, | |
7847 | .init_hook = alc883_haier_w66_automute, | |
272a527c | 7848 | }, |
4723c022 CM |
7849 | [ALC888_6ST_HP] = { |
7850 | .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer }, | |
7851 | .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs }, | |
cd1e3b40 CM |
7852 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7853 | .dac_nids = alc883_dac_nids, | |
7854 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7855 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7856 | .adc_nids = alc883_adc_nids, | |
7857 | .dig_in_nid = ALC883_DIGIN_NID, | |
7858 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7859 | .channel_mode = alc883_sixstack_modes, | |
7860 | .input_mux = &alc883_capture_source, | |
7861 | }, | |
4723c022 CM |
7862 | [ALC888_3ST_HP] = { |
7863 | .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer }, | |
7864 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, | |
8341de60 CM |
7865 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7866 | .dac_nids = alc883_dac_nids, | |
7867 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7868 | .adc_nids = alc883_adc_nids, | |
4723c022 CM |
7869 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
7870 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
7871 | .need_dac_fix = 1, |
7872 | .input_mux = &alc883_capture_source, | |
7873 | }, | |
5795b9e6 CM |
7874 | [ALC888_6ST_DELL] = { |
7875 | .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer }, | |
7876 | .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, | |
7877 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7878 | .dac_nids = alc883_dac_nids, | |
7879 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7880 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7881 | .adc_nids = alc883_adc_nids, | |
7882 | .dig_in_nid = ALC883_DIGIN_NID, | |
7883 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7884 | .channel_mode = alc883_sixstack_modes, | |
7885 | .input_mux = &alc883_capture_source, | |
7886 | .unsol_event = alc888_6st_dell_unsol_event, | |
7887 | .init_hook = alc888_6st_dell_front_automute, | |
7888 | }, | |
a8848bd6 AS |
7889 | [ALC883_MITAC] = { |
7890 | .mixers = { alc883_mitac_mixer }, | |
7891 | .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, | |
7892 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7893 | .dac_nids = alc883_dac_nids, | |
7894 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7895 | .adc_nids = alc883_adc_nids, | |
7896 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7897 | .channel_mode = alc883_3ST_2ch_modes, | |
7898 | .input_mux = &alc883_capture_source, | |
7899 | .unsol_event = alc883_mitac_unsol_event, | |
7900 | .init_hook = alc883_mitac_automute, | |
7901 | }, | |
9c7f852e TI |
7902 | }; |
7903 | ||
7904 | ||
7905 | /* | |
7906 | * BIOS auto configuration | |
7907 | */ | |
7908 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
7909 | hda_nid_t nid, int pin_type, | |
7910 | int dac_idx) | |
7911 | { | |
7912 | /* set as output */ | |
7913 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
7914 | int idx; |
7915 | ||
9c7f852e TI |
7916 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
7917 | idx = 4; | |
7918 | else | |
7919 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
7920 | ||
7921 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
7922 | pin_type); | |
7923 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
7924 | AMP_OUT_UNMUTE); | |
7925 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); | |
7926 | ||
7927 | } | |
7928 | ||
7929 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
7930 | { | |
7931 | struct alc_spec *spec = codec->spec; | |
7932 | int i; | |
7933 | ||
bc9f98a9 | 7934 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 7935 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 7936 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 7937 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 7938 | if (nid) |
baba8ee9 | 7939 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 7940 | i); |
9c7f852e TI |
7941 | } |
7942 | } | |
7943 | ||
7944 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
7945 | { | |
7946 | struct alc_spec *spec = codec->spec; | |
7947 | hda_nid_t pin; | |
7948 | ||
eb06ed8f | 7949 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
7950 | if (pin) /* connect to front */ |
7951 | /* use dac 0 */ | |
7952 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
7953 | } | |
7954 | ||
7955 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
7956 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
7957 | ||
7958 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
7959 | { | |
7960 | struct alc_spec *spec = codec->spec; | |
7961 | int i; | |
7962 | ||
7963 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
7964 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7965 | if (alc883_is_input_pin(nid)) { | |
7966 | snd_hda_codec_write(codec, nid, 0, | |
7967 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
7968 | (i <= AUTO_PIN_FRONT_MIC ? | |
7969 | PIN_VREF80 : PIN_IN)); | |
7970 | if (nid != ALC883_PIN_CD_NID) | |
7971 | snd_hda_codec_write(codec, nid, 0, | |
7972 | AC_VERB_SET_AMP_GAIN_MUTE, | |
7973 | AMP_OUT_MUTE); | |
7974 | } | |
7975 | } | |
7976 | } | |
7977 | ||
7978 | /* almost identical with ALC880 parser... */ | |
7979 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
7980 | { | |
7981 | struct alc_spec *spec = codec->spec; | |
7982 | int err = alc880_parse_auto_config(codec); | |
7983 | ||
7984 | if (err < 0) | |
7985 | return err; | |
776e184e TI |
7986 | else if (!err) |
7987 | return 0; /* no config found */ | |
7988 | ||
7989 | err = alc_auto_add_mic_boost(codec); | |
7990 | if (err < 0) | |
7991 | return err; | |
7992 | ||
7993 | /* hack - override the init verbs */ | |
7994 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
bc9f98a9 KY |
7995 | spec->mixers[spec->num_mixers] = alc883_capture_mixer; |
7996 | spec->num_mixers++; | |
776e184e TI |
7997 | |
7998 | return 1; /* config found */ | |
9c7f852e TI |
7999 | } |
8000 | ||
8001 | /* additional initialization for auto-configuration model */ | |
8002 | static void alc883_auto_init(struct hda_codec *codec) | |
8003 | { | |
8004 | alc883_auto_init_multi_out(codec); | |
8005 | alc883_auto_init_hp_out(codec); | |
8006 | alc883_auto_init_analog_input(codec); | |
8007 | } | |
8008 | ||
8009 | static int patch_alc883(struct hda_codec *codec) | |
8010 | { | |
8011 | struct alc_spec *spec; | |
8012 | int err, board_config; | |
8013 | ||
8014 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
8015 | if (spec == NULL) | |
8016 | return -ENOMEM; | |
8017 | ||
8018 | codec->spec = spec; | |
8019 | ||
f5fcc13c TI |
8020 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
8021 | alc883_models, | |
8022 | alc883_cfg_tbl); | |
8023 | if (board_config < 0) { | |
9c7f852e TI |
8024 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
8025 | "trying auto-probe from BIOS...\n"); | |
8026 | board_config = ALC883_AUTO; | |
8027 | } | |
8028 | ||
8029 | if (board_config == ALC883_AUTO) { | |
8030 | /* automatic parse from the BIOS config */ | |
8031 | err = alc883_parse_auto_config(codec); | |
8032 | if (err < 0) { | |
8033 | alc_free(codec); | |
8034 | return err; | |
f12ab1e0 | 8035 | } else if (!err) { |
9c7f852e TI |
8036 | printk(KERN_INFO |
8037 | "hda_codec: Cannot set up configuration " | |
8038 | "from BIOS. Using base mode...\n"); | |
8039 | board_config = ALC883_3ST_2ch_DIG; | |
8040 | } | |
8041 | } | |
8042 | ||
8043 | if (board_config != ALC883_AUTO) | |
8044 | setup_preset(spec, &alc883_presets[board_config]); | |
8045 | ||
8046 | spec->stream_name_analog = "ALC883 Analog"; | |
8047 | spec->stream_analog_playback = &alc883_pcm_analog_playback; | |
8048 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6330079f | 8049 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; |
9c7f852e TI |
8050 | |
8051 | spec->stream_name_digital = "ALC883 Digital"; | |
8052 | spec->stream_digital_playback = &alc883_pcm_digital_playback; | |
8053 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
8054 | ||
f12ab1e0 | 8055 | if (!spec->adc_nids && spec->input_mux) { |
4b146cb0 TI |
8056 | spec->adc_nids = alc883_adc_nids; |
8057 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
8058 | } | |
9c7f852e | 8059 | |
2134ea4f TI |
8060 | spec->vmaster_nid = 0x0c; |
8061 | ||
9c7f852e TI |
8062 | codec->patch_ops = alc_patch_ops; |
8063 | if (board_config == ALC883_AUTO) | |
8064 | spec->init_hook = alc883_auto_init; | |
cb53c626 TI |
8065 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8066 | if (!spec->loopback.amplist) | |
8067 | spec->loopback.amplist = alc883_loopbacks; | |
8068 | #endif | |
9c7f852e TI |
8069 | |
8070 | return 0; | |
8071 | } | |
8072 | ||
8073 | /* | |
8074 | * ALC262 support | |
8075 | */ | |
8076 | ||
8077 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
8078 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
8079 | ||
8080 | #define alc262_dac_nids alc260_dac_nids | |
8081 | #define alc262_adc_nids alc882_adc_nids | |
8082 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
8083 | ||
8084 | #define alc262_modes alc260_modes | |
8085 | #define alc262_capture_source alc882_capture_source | |
8086 | ||
8087 | static struct snd_kcontrol_new alc262_base_mixer[] = { | |
8088 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8089 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8090 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8091 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8092 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8093 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8094 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8095 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8096 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
8097 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8098 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8099 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
8100 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
8101 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
8102 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), | |
8103 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8104 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
8105 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
8106 | { } /* end */ | |
8107 | }; | |
8108 | ||
ccc656ce KY |
8109 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
8110 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8111 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8112 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8113 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8114 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8115 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8116 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8117 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8118 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
8119 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8120 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8121 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce KY |
8122 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
8123 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
8124 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ | |
8125 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8126 | { } /* end */ | |
8127 | }; | |
8128 | ||
ce875f07 TI |
8129 | /* update HP, line and mono-out pins according to the master switch */ |
8130 | static void alc262_hp_master_update(struct hda_codec *codec) | |
8131 | { | |
8132 | struct alc_spec *spec = codec->spec; | |
8133 | int val = spec->master_sw; | |
8134 | ||
8135 | /* HP & line-out */ | |
8136 | snd_hda_codec_write_cache(codec, 0x1b, 0, | |
8137 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8138 | val ? PIN_HP : 0); | |
8139 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
8140 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8141 | val ? PIN_HP : 0); | |
8142 | /* mono (speaker) depending on the HP jack sense */ | |
8143 | val = val && !spec->jack_present; | |
8144 | snd_hda_codec_write_cache(codec, 0x16, 0, | |
8145 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8146 | val ? PIN_OUT : 0); | |
8147 | } | |
8148 | ||
8149 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | |
8150 | { | |
8151 | struct alc_spec *spec = codec->spec; | |
8152 | unsigned int presence; | |
8153 | presence = snd_hda_codec_read(codec, 0x1b, 0, | |
8154 | AC_VERB_GET_PIN_SENSE, 0); | |
8155 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
8156 | alc262_hp_master_update(codec); | |
8157 | } | |
8158 | ||
8159 | static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |
8160 | { | |
8161 | if ((res >> 26) != ALC880_HP_EVENT) | |
8162 | return; | |
8163 | alc262_hp_bpc_automute(codec); | |
8164 | } | |
8165 | ||
8166 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | |
8167 | { | |
8168 | struct alc_spec *spec = codec->spec; | |
8169 | unsigned int presence; | |
8170 | presence = snd_hda_codec_read(codec, 0x15, 0, | |
8171 | AC_VERB_GET_PIN_SENSE, 0); | |
8172 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
8173 | alc262_hp_master_update(codec); | |
8174 | } | |
8175 | ||
8176 | static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, | |
8177 | unsigned int res) | |
8178 | { | |
8179 | if ((res >> 26) != ALC880_HP_EVENT) | |
8180 | return; | |
8181 | alc262_hp_wildwest_automute(codec); | |
8182 | } | |
8183 | ||
8184 | static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
8185 | struct snd_ctl_elem_value *ucontrol) | |
8186 | { | |
8187 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8188 | struct alc_spec *spec = codec->spec; | |
8189 | *ucontrol->value.integer.value = spec->master_sw; | |
8190 | return 0; | |
8191 | } | |
8192 | ||
8193 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
8194 | struct snd_ctl_elem_value *ucontrol) | |
8195 | { | |
8196 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8197 | struct alc_spec *spec = codec->spec; | |
8198 | int val = !!*ucontrol->value.integer.value; | |
8199 | ||
8200 | if (val == spec->master_sw) | |
8201 | return 0; | |
8202 | spec->master_sw = val; | |
8203 | alc262_hp_master_update(codec); | |
8204 | return 1; | |
8205 | } | |
8206 | ||
9c7f852e | 8207 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
ce875f07 TI |
8208 | { |
8209 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8210 | .name = "Master Playback Switch", | |
8211 | .info = snd_ctl_boolean_mono_info, | |
8212 | .get = alc262_hp_master_sw_get, | |
8213 | .put = alc262_hp_master_sw_put, | |
8214 | }, | |
9c7f852e TI |
8215 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8216 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8217 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
8218 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
8219 | HDA_OUTPUT), | |
8220 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
8221 | HDA_OUTPUT), | |
9c7f852e TI |
8222 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
8223 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8224 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
8225 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8226 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8227 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
8228 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
8229 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8230 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8231 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8232 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
8233 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
8234 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
8235 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
8236 | { } /* end */ | |
8237 | }; | |
8238 | ||
cd7509a4 | 8239 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
ce875f07 TI |
8240 | { |
8241 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8242 | .name = "Master Playback Switch", | |
8243 | .info = snd_ctl_boolean_mono_info, | |
8244 | .get = alc262_hp_master_sw_get, | |
8245 | .put = alc262_hp_master_sw_put, | |
8246 | }, | |
cd7509a4 KY |
8247 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8248 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8249 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
8250 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
8251 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
8252 | HDA_OUTPUT), | |
8253 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
8254 | HDA_OUTPUT), | |
cd7509a4 KY |
8255 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), |
8256 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 8257 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
8258 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8259 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8260 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8261 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8262 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
8263 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
8264 | { } /* end */ | |
8265 | }; | |
8266 | ||
8267 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
8268 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8269 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8270 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
8271 | { } /* end */ |
8272 | }; | |
8273 | ||
66d2a9d6 KY |
8274 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
8275 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | |
8276 | { | |
8277 | struct alc_spec *spec = codec->spec; | |
66d2a9d6 KY |
8278 | |
8279 | if (force || !spec->sense_updated) { | |
8280 | unsigned int present; | |
8281 | present = snd_hda_codec_read(codec, 0x15, 0, | |
8282 | AC_VERB_GET_PIN_SENSE, 0); | |
4bb26130 | 8283 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
66d2a9d6 KY |
8284 | spec->sense_updated = 1; |
8285 | } | |
4bb26130 TI |
8286 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
8287 | spec->jack_present ? HDA_AMP_MUTE : 0); | |
66d2a9d6 KY |
8288 | } |
8289 | ||
8290 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | |
8291 | unsigned int res) | |
8292 | { | |
8293 | if ((res >> 26) != ALC880_HP_EVENT) | |
8294 | return; | |
8295 | alc262_hp_t5735_automute(codec, 1); | |
8296 | } | |
8297 | ||
8298 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | |
8299 | { | |
8300 | alc262_hp_t5735_automute(codec, 1); | |
8301 | } | |
8302 | ||
8303 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | |
86cd9298 TI |
8304 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8305 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
66d2a9d6 KY |
8306 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
8307 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8308 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8309 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8310 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
8311 | { } /* end */ | |
8312 | }; | |
8313 | ||
8314 | static struct hda_verb alc262_hp_t5735_verbs[] = { | |
8315 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8316 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8317 | ||
8318 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8319 | { } | |
8320 | }; | |
8321 | ||
8c427226 | 8322 | static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { |
f2f48e18 TI |
8323 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8324 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
8325 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
8326 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
8c427226 KY |
8327 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8328 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8329 | { } /* end */ | |
8330 | }; | |
8331 | ||
8332 | static struct hda_verb alc262_hp_rp5700_verbs[] = { | |
8333 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8334 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8335 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8336 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8337 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
8338 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8339 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8340 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8341 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
8342 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
8343 | {} | |
8344 | }; | |
8345 | ||
8346 | static struct hda_input_mux alc262_hp_rp5700_capture_source = { | |
8347 | .num_items = 1, | |
8348 | .items = { | |
8349 | { "Line", 0x1 }, | |
8350 | }, | |
8351 | }; | |
8352 | ||
0724ea2a TI |
8353 | /* bind hp and internal speaker mute (with plug check) */ |
8354 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | |
8355 | struct snd_ctl_elem_value *ucontrol) | |
8356 | { | |
8357 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8358 | long *valp = ucontrol->value.integer.value; | |
8359 | int change; | |
8360 | ||
8361 | /* change hp mute */ | |
8362 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
8363 | HDA_AMP_MUTE, | |
8364 | valp[0] ? 0 : HDA_AMP_MUTE); | |
8365 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
8366 | HDA_AMP_MUTE, | |
8367 | valp[1] ? 0 : HDA_AMP_MUTE); | |
8368 | if (change) { | |
8369 | /* change speaker according to HP jack state */ | |
8370 | struct alc_spec *spec = codec->spec; | |
8371 | unsigned int mute; | |
8372 | if (spec->jack_present) | |
8373 | mute = HDA_AMP_MUTE; | |
8374 | else | |
8375 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | |
8376 | HDA_OUTPUT, 0); | |
8377 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8378 | HDA_AMP_MUTE, mute); | |
8379 | } | |
8380 | return change; | |
8381 | } | |
5b31954e | 8382 | |
272a527c | 8383 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
0724ea2a TI |
8384 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8385 | { | |
8386 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8387 | .name = "Master Playback Switch", | |
8388 | .info = snd_hda_mixer_amp_switch_info, | |
8389 | .get = snd_hda_mixer_amp_switch_get, | |
8390 | .put = alc262_sony_master_sw_put, | |
8391 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
8392 | }, | |
272a527c KY |
8393 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
8394 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8395 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
8396 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8397 | { } /* end */ | |
8398 | }; | |
8399 | ||
83c34218 KY |
8400 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
8401 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8402 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8403 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8404 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8405 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8406 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
8407 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8408 | { } /* end */ | |
8409 | }; | |
272a527c | 8410 | |
9c7f852e TI |
8411 | #define alc262_capture_mixer alc882_capture_mixer |
8412 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
8413 | ||
8414 | /* | |
8415 | * generic initialization of ADC, input mixers and output mixers | |
8416 | */ | |
8417 | static struct hda_verb alc262_init_verbs[] = { | |
8418 | /* | |
8419 | * Unmute ADC0-2 and set the default input to mic-in | |
8420 | */ | |
8421 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8422 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8423 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8424 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8425 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8426 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8427 | ||
cb53c626 | 8428 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 8429 | * mixer widget |
f12ab1e0 TI |
8430 | * Note: PASD motherboards uses the Line In 2 as the input for |
8431 | * front panel mic (mic 2) | |
9c7f852e TI |
8432 | */ |
8433 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8434 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8435 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8436 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8437 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8438 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
8439 | |
8440 | /* | |
df694daa KY |
8441 | * Set up output mixers (0x0c - 0x0e) |
8442 | */ | |
8443 | /* set vol=0 to output mixers */ | |
8444 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8445 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8446 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8447 | /* set up input amps for analog loopback */ | |
8448 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8449 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8450 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8451 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8452 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8453 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8454 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8455 | ||
8456 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
8457 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
8458 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
8459 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8460 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8461 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8462 | ||
8463 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8464 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8465 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8466 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8467 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8468 | ||
8469 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8470 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8471 | ||
8472 | /* FIXME: use matrix-type input source selection */ | |
8473 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8474 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8475 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8476 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8477 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8478 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8479 | /* Input mixer2 */ | |
8480 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8481 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8482 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8483 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8484 | /* Input mixer3 */ | |
8485 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8486 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8487 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 8488 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
8489 | |
8490 | { } | |
8491 | }; | |
1da177e4 | 8492 | |
ccc656ce KY |
8493 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
8494 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
8495 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8496 | {} | |
8497 | }; | |
8498 | ||
8499 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
8500 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
8501 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8502 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8503 | ||
8504 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
8505 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8506 | {} | |
8507 | }; | |
8508 | ||
272a527c KY |
8509 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
8510 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
8511 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8512 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
8513 | ||
8514 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
8515 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8516 | }; | |
8517 | ||
ccc656ce | 8518 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 8519 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
8520 | { |
8521 | struct alc_spec *spec = codec->spec; | |
8522 | unsigned int mute; | |
5b31954e | 8523 | unsigned int present; |
ccc656ce | 8524 | |
5b31954e TI |
8525 | /* need to execute and sync at first */ |
8526 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8527 | present = snd_hda_codec_read(codec, 0x15, 0, | |
8528 | AC_VERB_GET_PIN_SENSE, 0); | |
8529 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
8530 | if (spec->jack_present) { |
8531 | /* mute internal speaker */ | |
47fd830a TI |
8532 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8533 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
8534 | } else { |
8535 | /* unmute internal speaker if necessary */ | |
8536 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
8537 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8538 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
8539 | } |
8540 | } | |
8541 | ||
8542 | /* unsolicited event for HP jack sensing */ | |
8543 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
8544 | unsigned int res) | |
8545 | { | |
8546 | if ((res >> 26) != ALC880_HP_EVENT) | |
8547 | return; | |
5b31954e | 8548 | alc262_hippo_automute(codec); |
ccc656ce KY |
8549 | } |
8550 | ||
5b31954e | 8551 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 8552 | { |
ccc656ce | 8553 | unsigned int mute; |
5b31954e | 8554 | unsigned int present; |
ccc656ce | 8555 | |
5b31954e TI |
8556 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
8557 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8558 | AC_VERB_GET_PIN_SENSE, 0); | |
8559 | present = (present & 0x80000000) != 0; | |
8560 | if (present) { | |
ccc656ce | 8561 | /* mute internal speaker */ |
47fd830a TI |
8562 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8563 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
8564 | } else { |
8565 | /* unmute internal speaker if necessary */ | |
8566 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
8567 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8568 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
8569 | } |
8570 | } | |
8571 | ||
8572 | /* unsolicited event for HP jack sensing */ | |
8573 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
8574 | unsigned int res) | |
8575 | { | |
8576 | if ((res >> 26) != ALC880_HP_EVENT) | |
8577 | return; | |
5b31954e | 8578 | alc262_hippo1_automute(codec); |
ccc656ce KY |
8579 | } |
8580 | ||
834be88d TI |
8581 | /* |
8582 | * fujitsu model | |
8583 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker | |
8584 | */ | |
8585 | ||
8586 | #define ALC_HP_EVENT 0x37 | |
8587 | ||
8588 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
8589 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
8590 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8591 | {} | |
8592 | }; | |
8593 | ||
8594 | static struct hda_input_mux alc262_fujitsu_capture_source = { | |
39d3ed38 | 8595 | .num_items = 3, |
834be88d TI |
8596 | .items = { |
8597 | { "Mic", 0x0 }, | |
39d3ed38 | 8598 | { "Int Mic", 0x1 }, |
834be88d TI |
8599 | { "CD", 0x4 }, |
8600 | }, | |
8601 | }; | |
8602 | ||
9c7f852e TI |
8603 | static struct hda_input_mux alc262_HP_capture_source = { |
8604 | .num_items = 5, | |
8605 | .items = { | |
8606 | { "Mic", 0x0 }, | |
accbe498 | 8607 | { "Front Mic", 0x1 }, |
9c7f852e TI |
8608 | { "Line", 0x2 }, |
8609 | { "CD", 0x4 }, | |
8610 | { "AUX IN", 0x6 }, | |
8611 | }, | |
8612 | }; | |
8613 | ||
accbe498 | 8614 | static struct hda_input_mux alc262_HP_D7000_capture_source = { |
8615 | .num_items = 4, | |
8616 | .items = { | |
8617 | { "Mic", 0x0 }, | |
8618 | { "Front Mic", 0x2 }, | |
8619 | { "Line", 0x1 }, | |
8620 | { "CD", 0x4 }, | |
8621 | }, | |
8622 | }; | |
8623 | ||
834be88d TI |
8624 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
8625 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | |
8626 | { | |
8627 | struct alc_spec *spec = codec->spec; | |
8628 | unsigned int mute; | |
8629 | ||
f12ab1e0 | 8630 | if (force || !spec->sense_updated) { |
834be88d TI |
8631 | unsigned int present; |
8632 | /* need to execute and sync at first */ | |
8633 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8634 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8635 | AC_VERB_GET_PIN_SENSE, 0); | |
8636 | spec->jack_present = (present & 0x80000000) != 0; | |
8637 | spec->sense_updated = 1; | |
8638 | } | |
8639 | if (spec->jack_present) { | |
8640 | /* mute internal speaker */ | |
47fd830a TI |
8641 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8642 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
834be88d TI |
8643 | } else { |
8644 | /* unmute internal speaker if necessary */ | |
8645 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
8646 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8647 | HDA_AMP_MUTE, mute); | |
834be88d TI |
8648 | } |
8649 | } | |
8650 | ||
8651 | /* unsolicited event for HP jack sensing */ | |
8652 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
8653 | unsigned int res) | |
8654 | { | |
8655 | if ((res >> 26) != ALC_HP_EVENT) | |
8656 | return; | |
8657 | alc262_fujitsu_automute(codec, 1); | |
8658 | } | |
8659 | ||
8660 | /* bind volumes of both NID 0x0c and 0x0d */ | |
cca3b371 TI |
8661 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
8662 | .ops = &snd_hda_bind_vol, | |
8663 | .values = { | |
8664 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
8665 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
8666 | 0 | |
8667 | }, | |
8668 | }; | |
834be88d TI |
8669 | |
8670 | /* bind hp and internal speaker mute (with plug check) */ | |
8671 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
8672 | struct snd_ctl_elem_value *ucontrol) | |
8673 | { | |
8674 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8675 | long *valp = ucontrol->value.integer.value; | |
8676 | int change; | |
8677 | ||
8678 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
47fd830a TI |
8679 | HDA_AMP_MUTE, |
8680 | valp[0] ? 0 : HDA_AMP_MUTE); | |
834be88d | 8681 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
47fd830a TI |
8682 | HDA_AMP_MUTE, |
8683 | valp[1] ? 0 : HDA_AMP_MUTE); | |
82beb8fd TI |
8684 | if (change) |
8685 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
8686 | return change; |
8687 | } | |
8688 | ||
8689 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 8690 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
8691 | { |
8692 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8693 | .name = "Master Playback Switch", | |
8694 | .info = snd_hda_mixer_amp_switch_info, | |
8695 | .get = snd_hda_mixer_amp_switch_get, | |
8696 | .put = alc262_fujitsu_master_sw_put, | |
8697 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
8698 | }, | |
8699 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8700 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8701 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
8702 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8703 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
39d3ed38 TI |
8704 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), |
8705 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
8706 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
834be88d TI |
8707 | { } /* end */ |
8708 | }; | |
8709 | ||
304dcaac TI |
8710 | /* additional init verbs for Benq laptops */ |
8711 | static struct hda_verb alc262_EAPD_verbs[] = { | |
8712 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
8713 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
8714 | {} | |
8715 | }; | |
8716 | ||
83c34218 KY |
8717 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
8718 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8719 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8720 | ||
8721 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
8722 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
8723 | {} | |
8724 | }; | |
8725 | ||
f651b50b TD |
8726 | /* Samsung Q1 Ultra Vista model setup */ |
8727 | static struct snd_kcontrol_new alc262_ultra_mixer[] = { | |
8728 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8729 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8730 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8731 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
8732 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8733 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
8734 | { } /* end */ | |
8735 | }; | |
8736 | ||
8737 | static struct hda_verb alc262_ultra_verbs[] = { | |
8738 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
8739 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8740 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
8741 | /* Mic is on Node 0x19 */ | |
8742 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8743 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8744 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8745 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8746 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8747 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8748 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8749 | {} | |
8750 | }; | |
8751 | ||
8752 | static struct hda_input_mux alc262_ultra_capture_source = { | |
8753 | .num_items = 1, | |
8754 | .items = { | |
8755 | { "Mic", 0x1 }, | |
8756 | }, | |
8757 | }; | |
8758 | ||
8759 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
8760 | static void alc262_ultra_automute(struct hda_codec *codec) | |
8761 | { | |
8762 | struct alc_spec *spec = codec->spec; | |
8763 | unsigned int mute; | |
8764 | unsigned int present; | |
8765 | ||
8766 | /* need to execute and sync at first */ | |
8767 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8768 | present = snd_hda_codec_read(codec, 0x15, 0, | |
8769 | AC_VERB_GET_PIN_SENSE, 0); | |
8770 | spec->jack_present = (present & 0x80000000) != 0; | |
8771 | if (spec->jack_present) { | |
8772 | /* mute internal speaker */ | |
8773 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8774 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8775 | } else { | |
8776 | /* unmute internal speaker if necessary */ | |
8777 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
8778 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8779 | HDA_AMP_MUTE, mute); | |
8780 | } | |
8781 | } | |
8782 | ||
8783 | /* unsolicited event for HP jack sensing */ | |
8784 | static void alc262_ultra_unsol_event(struct hda_codec *codec, | |
8785 | unsigned int res) | |
8786 | { | |
8787 | if ((res >> 26) != ALC880_HP_EVENT) | |
8788 | return; | |
8789 | alc262_ultra_automute(codec); | |
8790 | } | |
8791 | ||
df694daa | 8792 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
8793 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
8794 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
8795 | { |
8796 | hda_nid_t nid; | |
8797 | int err; | |
8798 | ||
8799 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
8800 | spec->multiout.dac_nids = spec->private_dac_nids; | |
8801 | spec->multiout.dac_nids[0] = 2; | |
8802 | ||
8803 | nid = cfg->line_out_pins[0]; | |
8804 | if (nid) { | |
f12ab1e0 TI |
8805 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
8806 | "Front Playback Volume", | |
8807 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
8808 | if (err < 0) | |
df694daa | 8809 | return err; |
f12ab1e0 TI |
8810 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8811 | "Front Playback Switch", | |
8812 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
8813 | if (err < 0) | |
df694daa KY |
8814 | return err; |
8815 | } | |
8816 | ||
82bc955f | 8817 | nid = cfg->speaker_pins[0]; |
df694daa KY |
8818 | if (nid) { |
8819 | if (nid == 0x16) { | |
f12ab1e0 TI |
8820 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
8821 | "Speaker Playback Volume", | |
8822 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
8823 | HDA_OUTPUT)); | |
8824 | if (err < 0) | |
df694daa | 8825 | return err; |
f12ab1e0 TI |
8826 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8827 | "Speaker Playback Switch", | |
8828 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
8829 | HDA_OUTPUT)); | |
8830 | if (err < 0) | |
df694daa KY |
8831 | return err; |
8832 | } else { | |
f12ab1e0 TI |
8833 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8834 | "Speaker Playback Switch", | |
8835 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
8836 | HDA_OUTPUT)); | |
8837 | if (err < 0) | |
df694daa KY |
8838 | return err; |
8839 | } | |
8840 | } | |
eb06ed8f | 8841 | nid = cfg->hp_pins[0]; |
df694daa KY |
8842 | if (nid) { |
8843 | /* spec->multiout.hp_nid = 2; */ | |
8844 | if (nid == 0x16) { | |
f12ab1e0 TI |
8845 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
8846 | "Headphone Playback Volume", | |
8847 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
8848 | HDA_OUTPUT)); | |
8849 | if (err < 0) | |
df694daa | 8850 | return err; |
f12ab1e0 TI |
8851 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8852 | "Headphone Playback Switch", | |
8853 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
8854 | HDA_OUTPUT)); | |
8855 | if (err < 0) | |
df694daa KY |
8856 | return err; |
8857 | } else { | |
f12ab1e0 TI |
8858 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8859 | "Headphone Playback Switch", | |
8860 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
8861 | HDA_OUTPUT)); | |
8862 | if (err < 0) | |
df694daa KY |
8863 | return err; |
8864 | } | |
8865 | } | |
f12ab1e0 | 8866 | return 0; |
df694daa KY |
8867 | } |
8868 | ||
8869 | /* identical with ALC880 */ | |
f12ab1e0 TI |
8870 | #define alc262_auto_create_analog_input_ctls \ |
8871 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
8872 | |
8873 | /* | |
8874 | * generic initialization of ADC, input mixers and output mixers | |
8875 | */ | |
8876 | static struct hda_verb alc262_volume_init_verbs[] = { | |
8877 | /* | |
8878 | * Unmute ADC0-2 and set the default input to mic-in | |
8879 | */ | |
8880 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8881 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8882 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8883 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8884 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8885 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8886 | ||
cb53c626 | 8887 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 8888 | * mixer widget |
f12ab1e0 TI |
8889 | * Note: PASD motherboards uses the Line In 2 as the input for |
8890 | * front panel mic (mic 2) | |
df694daa KY |
8891 | */ |
8892 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8893 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8894 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8895 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8896 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8897 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
8898 | |
8899 | /* | |
8900 | * Set up output mixers (0x0c - 0x0f) | |
8901 | */ | |
8902 | /* set vol=0 to output mixers */ | |
8903 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8904 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8905 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8906 | ||
8907 | /* set up input amps for analog loopback */ | |
8908 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8909 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8910 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8911 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8912 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8913 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8914 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8915 | ||
8916 | /* FIXME: use matrix-type input source selection */ | |
8917 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8918 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8919 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8920 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8921 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8922 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8923 | /* Input mixer2 */ | |
8924 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8925 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8926 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8927 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8928 | /* Input mixer3 */ | |
8929 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8930 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8931 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8932 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8933 | ||
8934 | { } | |
8935 | }; | |
8936 | ||
9c7f852e TI |
8937 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
8938 | /* | |
8939 | * Unmute ADC0-2 and set the default input to mic-in | |
8940 | */ | |
8941 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8942 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8943 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8944 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8945 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8946 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8947 | ||
cb53c626 | 8948 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 8949 | * mixer widget |
f12ab1e0 TI |
8950 | * Note: PASD motherboards uses the Line In 2 as the input for |
8951 | * front panel mic (mic 2) | |
9c7f852e TI |
8952 | */ |
8953 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8954 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8955 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8956 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8957 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8958 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
8959 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
8960 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9c7f852e TI |
8961 | |
8962 | /* | |
8963 | * Set up output mixers (0x0c - 0x0e) | |
8964 | */ | |
8965 | /* set vol=0 to output mixers */ | |
8966 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8967 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8968 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8969 | ||
8970 | /* set up input amps for analog loopback */ | |
8971 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8972 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8973 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8974 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8975 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8976 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8977 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8978 | ||
ce875f07 | 8979 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
9c7f852e TI |
8980 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
8981 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8982 | ||
8983 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8984 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8985 | ||
8986 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8987 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8988 | ||
8989 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8990 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8991 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8992 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8993 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8994 | ||
8995 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
8996 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8997 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8998 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
8999 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9000 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9001 | ||
9002 | ||
9003 | /* FIXME: use matrix-type input source selection */ | |
9004 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9005 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9006 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9007 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9008 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9009 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9010 | /* Input mixer2 */ | |
9011 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9012 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9013 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9014 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9015 | /* Input mixer3 */ | |
9016 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9017 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9018 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9019 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9020 | ||
ce875f07 TI |
9021 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
9022 | ||
9c7f852e TI |
9023 | { } |
9024 | }; | |
9025 | ||
cd7509a4 KY |
9026 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
9027 | /* | |
9028 | * Unmute ADC0-2 and set the default input to mic-in | |
9029 | */ | |
9030 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9031 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9032 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9033 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9034 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9035 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9036 | ||
cb53c626 | 9037 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
9038 | * mixer widget |
9039 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
9040 | * panel mic (mic 2) | |
9041 | */ | |
9042 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9043 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9044 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9045 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9046 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9047 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9048 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9049 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9050 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
9051 | /* |
9052 | * Set up output mixers (0x0c - 0x0e) | |
9053 | */ | |
9054 | /* set vol=0 to output mixers */ | |
9055 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9056 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9057 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9058 | ||
9059 | /* set up input amps for analog loopback */ | |
9060 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9061 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9062 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9063 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9064 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9065 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9066 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9067 | ||
9068 | ||
9069 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
9070 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
9071 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
9072 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
9073 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
9074 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
9075 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
9076 | ||
9077 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9078 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9079 | ||
9080 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9081 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
9082 | ||
9083 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
9084 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9085 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9086 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
9087 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9088 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9089 | ||
9090 | /* FIXME: use matrix-type input source selection */ | |
9091 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9092 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9093 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
9094 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
9095 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
9096 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
9097 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
9098 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
9099 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
9100 | /* Input mixer2 */ | |
9101 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9102 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9103 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9104 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9105 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9106 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
9107 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
9108 | /* Input mixer3 */ | |
9109 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9110 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9111 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9112 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9113 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9114 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
9115 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
9116 | ||
ce875f07 TI |
9117 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
9118 | ||
cd7509a4 KY |
9119 | { } |
9120 | }; | |
9121 | ||
cb53c626 TI |
9122 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9123 | #define alc262_loopbacks alc880_loopbacks | |
9124 | #endif | |
9125 | ||
df694daa KY |
9126 | /* pcm configuration: identiacal with ALC880 */ |
9127 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
9128 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
9129 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
9130 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
9131 | ||
9132 | /* | |
9133 | * BIOS auto configuration | |
9134 | */ | |
9135 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
9136 | { | |
9137 | struct alc_spec *spec = codec->spec; | |
9138 | int err; | |
9139 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
9140 | ||
f12ab1e0 TI |
9141 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
9142 | alc262_ignore); | |
9143 | if (err < 0) | |
df694daa | 9144 | return err; |
f12ab1e0 | 9145 | if (!spec->autocfg.line_outs) |
df694daa | 9146 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
9147 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
9148 | if (err < 0) | |
9149 | return err; | |
9150 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
9151 | if (err < 0) | |
df694daa KY |
9152 | return err; |
9153 | ||
9154 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
9155 | ||
9156 | if (spec->autocfg.dig_out_pin) | |
9157 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
9158 | if (spec->autocfg.dig_in_pin) | |
9159 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
9160 | ||
9161 | if (spec->kctl_alloc) | |
9162 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
9163 | ||
9164 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; | |
a1e8d2da | 9165 | spec->num_mux_defs = 1; |
df694daa KY |
9166 | spec->input_mux = &spec->private_imux; |
9167 | ||
776e184e TI |
9168 | err = alc_auto_add_mic_boost(codec); |
9169 | if (err < 0) | |
9170 | return err; | |
9171 | ||
df694daa KY |
9172 | return 1; |
9173 | } | |
9174 | ||
9175 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
9176 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
9177 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
9178 | ||
9179 | ||
9180 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 9181 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 9182 | { |
df694daa KY |
9183 | alc262_auto_init_multi_out(codec); |
9184 | alc262_auto_init_hp_out(codec); | |
9185 | alc262_auto_init_analog_input(codec); | |
df694daa KY |
9186 | } |
9187 | ||
9188 | /* | |
9189 | * configuration and preset | |
9190 | */ | |
f5fcc13c TI |
9191 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
9192 | [ALC262_BASIC] = "basic", | |
9193 | [ALC262_HIPPO] = "hippo", | |
9194 | [ALC262_HIPPO_1] = "hippo_1", | |
9195 | [ALC262_FUJITSU] = "fujitsu", | |
9196 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 9197 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
61dc35de | 9198 | [ALC262_HP_TC_T5735] = "hp-tc-t5735", |
8c427226 | 9199 | [ALC262_HP_RP5700] = "hp-rp5700", |
f5fcc13c | 9200 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
9201 | [ALC262_BENQ_T31] = "benq-t31", |
9202 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
f651b50b | 9203 | [ALC262_ULTRA] = "ultra", |
f5fcc13c TI |
9204 | [ALC262_AUTO] = "auto", |
9205 | }; | |
9206 | ||
9207 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
9208 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
9209 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), | |
7d87de2d | 9210 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
ac3e3741 TI |
9211 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
9212 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), | |
7d87de2d | 9213 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), |
b98f9334 | 9214 | SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), |
b98f9334 | 9215 | SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), |
b98f9334 | 9216 | SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), |
cd7509a4 | 9217 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 9218 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 9219 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 9220 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 9221 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 9222 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 9223 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 9224 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 TI |
9225 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), |
9226 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), | |
9227 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), | |
66d2a9d6 KY |
9228 | SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", |
9229 | ALC262_HP_TC_T5735), | |
8c427226 | 9230 | SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), |
ac3e3741 | 9231 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
f5fcc13c | 9232 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
5b31954e | 9233 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c | 9234 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
ac3e3741 TI |
9235 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
9236 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), | |
f651b50b | 9237 | SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), |
ac3e3741 TI |
9238 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), |
9239 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), | |
9240 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
df694daa KY |
9241 | {} |
9242 | }; | |
9243 | ||
9244 | static struct alc_config_preset alc262_presets[] = { | |
9245 | [ALC262_BASIC] = { | |
9246 | .mixers = { alc262_base_mixer }, | |
9247 | .init_verbs = { alc262_init_verbs }, | |
9248 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9249 | .dac_nids = alc262_dac_nids, | |
9250 | .hp_nid = 0x03, | |
9251 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9252 | .channel_mode = alc262_modes, | |
a3bcba38 | 9253 | .input_mux = &alc262_capture_source, |
df694daa | 9254 | }, |
ccc656ce KY |
9255 | [ALC262_HIPPO] = { |
9256 | .mixers = { alc262_base_mixer }, | |
9257 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
9258 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9259 | .dac_nids = alc262_dac_nids, | |
9260 | .hp_nid = 0x03, | |
9261 | .dig_out_nid = ALC262_DIGOUT_NID, | |
9262 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9263 | .channel_mode = alc262_modes, | |
9264 | .input_mux = &alc262_capture_source, | |
9265 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 9266 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
9267 | }, |
9268 | [ALC262_HIPPO_1] = { | |
9269 | .mixers = { alc262_hippo1_mixer }, | |
9270 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
9271 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9272 | .dac_nids = alc262_dac_nids, | |
9273 | .hp_nid = 0x02, | |
9274 | .dig_out_nid = ALC262_DIGOUT_NID, | |
9275 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9276 | .channel_mode = alc262_modes, | |
9277 | .input_mux = &alc262_capture_source, | |
9278 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 9279 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 9280 | }, |
834be88d TI |
9281 | [ALC262_FUJITSU] = { |
9282 | .mixers = { alc262_fujitsu_mixer }, | |
39d3ed38 TI |
9283 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
9284 | alc262_fujitsu_unsol_verbs }, | |
834be88d TI |
9285 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
9286 | .dac_nids = alc262_dac_nids, | |
9287 | .hp_nid = 0x03, | |
9288 | .dig_out_nid = ALC262_DIGOUT_NID, | |
9289 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9290 | .channel_mode = alc262_modes, | |
9291 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 9292 | .unsol_event = alc262_fujitsu_unsol_event, |
834be88d | 9293 | }, |
9c7f852e TI |
9294 | [ALC262_HP_BPC] = { |
9295 | .mixers = { alc262_HP_BPC_mixer }, | |
9296 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
9297 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9298 | .dac_nids = alc262_dac_nids, | |
9299 | .hp_nid = 0x03, | |
9300 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9301 | .channel_mode = alc262_modes, | |
9302 | .input_mux = &alc262_HP_capture_source, | |
ce875f07 TI |
9303 | .unsol_event = alc262_hp_bpc_unsol_event, |
9304 | .init_hook = alc262_hp_bpc_automute, | |
f12ab1e0 | 9305 | }, |
cd7509a4 KY |
9306 | [ALC262_HP_BPC_D7000_WF] = { |
9307 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
9308 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
9309 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9310 | .dac_nids = alc262_dac_nids, | |
9311 | .hp_nid = 0x03, | |
9312 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9313 | .channel_mode = alc262_modes, | |
accbe498 | 9314 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
9315 | .unsol_event = alc262_hp_wildwest_unsol_event, |
9316 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 9317 | }, |
cd7509a4 KY |
9318 | [ALC262_HP_BPC_D7000_WL] = { |
9319 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
9320 | alc262_HP_BPC_WildWest_option_mixer }, | |
9321 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
9322 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9323 | .dac_nids = alc262_dac_nids, | |
9324 | .hp_nid = 0x03, | |
9325 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9326 | .channel_mode = alc262_modes, | |
accbe498 | 9327 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
9328 | .unsol_event = alc262_hp_wildwest_unsol_event, |
9329 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 9330 | }, |
66d2a9d6 KY |
9331 | [ALC262_HP_TC_T5735] = { |
9332 | .mixers = { alc262_hp_t5735_mixer }, | |
9333 | .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, | |
9334 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9335 | .dac_nids = alc262_dac_nids, | |
9336 | .hp_nid = 0x03, | |
9337 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9338 | .channel_mode = alc262_modes, | |
9339 | .input_mux = &alc262_capture_source, | |
9340 | .unsol_event = alc262_hp_t5735_unsol_event, | |
9341 | .init_hook = alc262_hp_t5735_init_hook, | |
8c427226 KY |
9342 | }, |
9343 | [ALC262_HP_RP5700] = { | |
9344 | .mixers = { alc262_hp_rp5700_mixer }, | |
9345 | .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, | |
9346 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9347 | .dac_nids = alc262_dac_nids, | |
9348 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9349 | .channel_mode = alc262_modes, | |
9350 | .input_mux = &alc262_hp_rp5700_capture_source, | |
66d2a9d6 | 9351 | }, |
304dcaac TI |
9352 | [ALC262_BENQ_ED8] = { |
9353 | .mixers = { alc262_base_mixer }, | |
9354 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
9355 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9356 | .dac_nids = alc262_dac_nids, | |
9357 | .hp_nid = 0x03, | |
9358 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9359 | .channel_mode = alc262_modes, | |
9360 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 9361 | }, |
272a527c KY |
9362 | [ALC262_SONY_ASSAMD] = { |
9363 | .mixers = { alc262_sony_mixer }, | |
9364 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
9365 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9366 | .dac_nids = alc262_dac_nids, | |
9367 | .hp_nid = 0x02, | |
9368 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9369 | .channel_mode = alc262_modes, | |
9370 | .input_mux = &alc262_capture_source, | |
9371 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 9372 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
9373 | }, |
9374 | [ALC262_BENQ_T31] = { | |
9375 | .mixers = { alc262_benq_t31_mixer }, | |
9376 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
9377 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9378 | .dac_nids = alc262_dac_nids, | |
9379 | .hp_nid = 0x03, | |
9380 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9381 | .channel_mode = alc262_modes, | |
9382 | .input_mux = &alc262_capture_source, | |
9383 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 9384 | .init_hook = alc262_hippo_automute, |
272a527c | 9385 | }, |
f651b50b TD |
9386 | [ALC262_ULTRA] = { |
9387 | .mixers = { alc262_ultra_mixer }, | |
9388 | .init_verbs = { alc262_init_verbs, alc262_ultra_verbs }, | |
9389 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9390 | .dac_nids = alc262_dac_nids, | |
9391 | .hp_nid = 0x03, | |
9392 | .dig_out_nid = ALC262_DIGOUT_NID, | |
9393 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9394 | .channel_mode = alc262_modes, | |
9395 | .input_mux = &alc262_ultra_capture_source, | |
9396 | .unsol_event = alc262_ultra_unsol_event, | |
9397 | .init_hook = alc262_ultra_automute, | |
9398 | }, | |
df694daa KY |
9399 | }; |
9400 | ||
9401 | static int patch_alc262(struct hda_codec *codec) | |
9402 | { | |
9403 | struct alc_spec *spec; | |
9404 | int board_config; | |
9405 | int err; | |
9406 | ||
dc041e0b | 9407 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
9408 | if (spec == NULL) |
9409 | return -ENOMEM; | |
9410 | ||
9411 | codec->spec = spec; | |
9412 | #if 0 | |
f12ab1e0 TI |
9413 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
9414 | * under-run | |
9415 | */ | |
df694daa KY |
9416 | { |
9417 | int tmp; | |
9418 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
9419 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
9420 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
9421 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
9422 | } | |
9423 | #endif | |
9424 | ||
f5fcc13c TI |
9425 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
9426 | alc262_models, | |
9427 | alc262_cfg_tbl); | |
cd7509a4 | 9428 | |
f5fcc13c | 9429 | if (board_config < 0) { |
9c7f852e TI |
9430 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
9431 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
9432 | board_config = ALC262_AUTO; |
9433 | } | |
9434 | ||
9435 | if (board_config == ALC262_AUTO) { | |
9436 | /* automatic parse from the BIOS config */ | |
9437 | err = alc262_parse_auto_config(codec); | |
9438 | if (err < 0) { | |
9439 | alc_free(codec); | |
9440 | return err; | |
f12ab1e0 | 9441 | } else if (!err) { |
9c7f852e TI |
9442 | printk(KERN_INFO |
9443 | "hda_codec: Cannot set up configuration " | |
9444 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
9445 | board_config = ALC262_BASIC; |
9446 | } | |
9447 | } | |
9448 | ||
9449 | if (board_config != ALC262_AUTO) | |
9450 | setup_preset(spec, &alc262_presets[board_config]); | |
9451 | ||
9452 | spec->stream_name_analog = "ALC262 Analog"; | |
9453 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
9454 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
9455 | ||
9456 | spec->stream_name_digital = "ALC262 Digital"; | |
9457 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
9458 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
9459 | ||
f12ab1e0 | 9460 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 9461 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
9462 | unsigned int wcap = get_wcaps(codec, 0x07); |
9463 | ||
f12ab1e0 TI |
9464 | /* get type */ |
9465 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
9466 | if (wcap != AC_WID_AUD_IN) { |
9467 | spec->adc_nids = alc262_adc_nids_alt; | |
9468 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
f12ab1e0 TI |
9469 | spec->mixers[spec->num_mixers] = |
9470 | alc262_capture_alt_mixer; | |
df694daa KY |
9471 | spec->num_mixers++; |
9472 | } else { | |
9473 | spec->adc_nids = alc262_adc_nids; | |
9474 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
9475 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; | |
9476 | spec->num_mixers++; | |
9477 | } | |
9478 | } | |
9479 | ||
2134ea4f TI |
9480 | spec->vmaster_nid = 0x0c; |
9481 | ||
df694daa KY |
9482 | codec->patch_ops = alc_patch_ops; |
9483 | if (board_config == ALC262_AUTO) | |
ae6b813a | 9484 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
9485 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9486 | if (!spec->loopback.amplist) | |
9487 | spec->loopback.amplist = alc262_loopbacks; | |
9488 | #endif | |
834be88d | 9489 | |
df694daa KY |
9490 | return 0; |
9491 | } | |
9492 | ||
a361d84b KY |
9493 | /* |
9494 | * ALC268 channel source setting (2 channel) | |
9495 | */ | |
9496 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
9497 | #define alc268_modes alc260_modes | |
9498 | ||
9499 | static hda_nid_t alc268_dac_nids[2] = { | |
9500 | /* front, hp */ | |
9501 | 0x02, 0x03 | |
9502 | }; | |
9503 | ||
9504 | static hda_nid_t alc268_adc_nids[2] = { | |
9505 | /* ADC0-1 */ | |
9506 | 0x08, 0x07 | |
9507 | }; | |
9508 | ||
9509 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
9510 | /* ADC0 */ | |
9511 | 0x08 | |
9512 | }; | |
9513 | ||
9514 | static struct snd_kcontrol_new alc268_base_mixer[] = { | |
9515 | /* output mixer control */ | |
9516 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
9517 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9518 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
9519 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
9520 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9521 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
9522 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
9523 | { } |
9524 | }; | |
9525 | ||
d1a991a6 KY |
9526 | static struct hda_verb alc268_eapd_verbs[] = { |
9527 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9528 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9529 | { } | |
9530 | }; | |
9531 | ||
d273809e TI |
9532 | /* Toshiba specific */ |
9533 | #define alc268_toshiba_automute alc262_hippo_automute | |
9534 | ||
9535 | static struct hda_verb alc268_toshiba_verbs[] = { | |
9536 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
9537 | { } /* end */ | |
9538 | }; | |
9539 | ||
9540 | /* Acer specific */ | |
889c4395 | 9541 | /* bind volumes of both NID 0x02 and 0x03 */ |
6bc96857 TI |
9542 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
9543 | .ops = &snd_hda_bind_vol, | |
9544 | .values = { | |
9545 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
9546 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
9547 | 0 | |
9548 | }, | |
9549 | }; | |
9550 | ||
889c4395 TI |
9551 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9552 | static void alc268_acer_automute(struct hda_codec *codec, int force) | |
9553 | { | |
9554 | struct alc_spec *spec = codec->spec; | |
9555 | unsigned int mute; | |
9556 | ||
9557 | if (force || !spec->sense_updated) { | |
9558 | unsigned int present; | |
9559 | present = snd_hda_codec_read(codec, 0x14, 0, | |
9560 | AC_VERB_GET_PIN_SENSE, 0); | |
9561 | spec->jack_present = (present & 0x80000000) != 0; | |
9562 | spec->sense_updated = 1; | |
9563 | } | |
9564 | if (spec->jack_present) | |
9565 | mute = HDA_AMP_MUTE; /* mute internal speaker */ | |
9566 | else /* unmute internal speaker if necessary */ | |
9567 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
9568 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
9569 | HDA_AMP_MUTE, mute); | |
9570 | } | |
9571 | ||
9572 | ||
9573 | /* bind hp and internal speaker mute (with plug check) */ | |
9574 | static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |
9575 | struct snd_ctl_elem_value *ucontrol) | |
9576 | { | |
9577 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9578 | long *valp = ucontrol->value.integer.value; | |
9579 | int change; | |
9580 | ||
9581 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
9582 | HDA_AMP_MUTE, | |
9583 | valp[0] ? 0 : HDA_AMP_MUTE); | |
9584 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
9585 | HDA_AMP_MUTE, | |
9586 | valp[1] ? 0 : HDA_AMP_MUTE); | |
9587 | if (change) | |
9588 | alc268_acer_automute(codec, 0); | |
9589 | return change; | |
9590 | } | |
d273809e TI |
9591 | |
9592 | static struct snd_kcontrol_new alc268_acer_mixer[] = { | |
9593 | /* output mixer control */ | |
9594 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
9595 | { | |
9596 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9597 | .name = "Master Playback Switch", | |
9598 | .info = snd_hda_mixer_amp_switch_info, | |
9599 | .get = snd_hda_mixer_amp_switch_get, | |
9600 | .put = alc268_acer_master_sw_put, | |
9601 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
9602 | }, | |
33bf17ab TI |
9603 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9604 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
9605 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
9606 | { } |
9607 | }; | |
9608 | ||
9609 | static struct hda_verb alc268_acer_verbs[] = { | |
9610 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9611 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9612 | ||
9613 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
9614 | { } | |
9615 | }; | |
9616 | ||
9617 | /* unsolicited event for HP jack sensing */ | |
9618 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
9619 | unsigned int res) | |
9620 | { | |
889c4395 | 9621 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
9622 | return; |
9623 | alc268_toshiba_automute(codec); | |
9624 | } | |
9625 | ||
9626 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
9627 | unsigned int res) | |
9628 | { | |
889c4395 | 9629 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
9630 | return; |
9631 | alc268_acer_automute(codec, 1); | |
9632 | } | |
9633 | ||
889c4395 TI |
9634 | static void alc268_acer_init_hook(struct hda_codec *codec) |
9635 | { | |
9636 | alc268_acer_automute(codec, 1); | |
9637 | } | |
9638 | ||
3866f0b0 TI |
9639 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
9640 | /* output mixer control */ | |
9641 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9642 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9643 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
9644 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9645 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9646 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
9647 | { } | |
9648 | }; | |
9649 | ||
9650 | static struct hda_verb alc268_dell_verbs[] = { | |
9651 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9652 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9653 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
9654 | { } | |
9655 | }; | |
9656 | ||
9657 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
9658 | static void alc268_dell_automute(struct hda_codec *codec) | |
9659 | { | |
9660 | unsigned int present; | |
9661 | unsigned int mute; | |
9662 | ||
9663 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | |
9664 | if (present & 0x80000000) | |
9665 | mute = HDA_AMP_MUTE; | |
9666 | else | |
9667 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
9668 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9669 | HDA_AMP_MUTE, mute); | |
9670 | } | |
9671 | ||
9672 | static void alc268_dell_unsol_event(struct hda_codec *codec, | |
9673 | unsigned int res) | |
9674 | { | |
9675 | if ((res >> 26) != ALC880_HP_EVENT) | |
9676 | return; | |
9677 | alc268_dell_automute(codec); | |
9678 | } | |
9679 | ||
9680 | #define alc268_dell_init_hook alc268_dell_automute | |
9681 | ||
a361d84b KY |
9682 | /* |
9683 | * generic initialization of ADC, input mixers and output mixers | |
9684 | */ | |
9685 | static struct hda_verb alc268_base_init_verbs[] = { | |
9686 | /* Unmute DAC0-1 and set vol = 0 */ | |
9687 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9688 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9689 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9690 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9691 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9692 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9693 | ||
9694 | /* | |
9695 | * Set up output mixers (0x0c - 0x0e) | |
9696 | */ | |
9697 | /* set vol=0 to output mixers */ | |
9698 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9699 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9700 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9701 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9702 | ||
9703 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9704 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9705 | ||
9706 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9707 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9708 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9709 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9710 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9711 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9712 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9713 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9714 | ||
9715 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9716 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9717 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9718 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9719 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9720 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9721 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9722 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9723 | ||
a9b3aa8a JZ |
9724 | /* Unmute Selector 23h,24h and set the default input to mic-in */ |
9725 | ||
9726 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9727 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9728 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9729 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
a361d84b | 9730 | |
a361d84b KY |
9731 | { } |
9732 | }; | |
9733 | ||
9734 | /* | |
9735 | * generic initialization of ADC, input mixers and output mixers | |
9736 | */ | |
9737 | static struct hda_verb alc268_volume_init_verbs[] = { | |
9738 | /* set output DAC */ | |
9739 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9740 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9741 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9742 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9743 | ||
9744 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9745 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9746 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9747 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9748 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9749 | ||
9750 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9751 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9752 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9753 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9754 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9755 | ||
9756 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9757 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9758 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9759 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9760 | ||
9761 | /* set PCBEEP vol = 0 */ | |
9762 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))}, | |
9763 | ||
9764 | { } | |
9765 | }; | |
9766 | ||
9767 | #define alc268_mux_enum_info alc_mux_enum_info | |
9768 | #define alc268_mux_enum_get alc_mux_enum_get | |
9769 | ||
9770 | static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol, | |
9771 | struct snd_ctl_elem_value *ucontrol) | |
9772 | { | |
9773 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9774 | struct alc_spec *spec = codec->spec; | |
a9b3aa8a | 9775 | |
a361d84b KY |
9776 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
9777 | static hda_nid_t capture_mixers[3] = { 0x23, 0x24 }; | |
9778 | hda_nid_t nid = capture_mixers[adc_idx]; | |
a361d84b | 9779 | |
a9b3aa8a JZ |
9780 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
9781 | nid, | |
9782 | &spec->cur_mux[adc_idx]); | |
a361d84b KY |
9783 | } |
9784 | ||
9785 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { | |
9786 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
9787 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
9788 | { | |
9789 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9790 | /* The multiple "Capture Source" controls confuse alsamixer | |
9791 | * So call somewhat different.. | |
a361d84b KY |
9792 | */ |
9793 | /* .name = "Capture Source", */ | |
9794 | .name = "Input Source", | |
9795 | .count = 1, | |
9796 | .info = alc268_mux_enum_info, | |
9797 | .get = alc268_mux_enum_get, | |
9798 | .put = alc268_mux_enum_put, | |
9799 | }, | |
9800 | { } /* end */ | |
9801 | }; | |
9802 | ||
9803 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
9804 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
9805 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
9806 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
9807 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
9808 | { | |
9809 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9810 | /* The multiple "Capture Source" controls confuse alsamixer | |
9811 | * So call somewhat different.. | |
a361d84b KY |
9812 | */ |
9813 | /* .name = "Capture Source", */ | |
9814 | .name = "Input Source", | |
9815 | .count = 2, | |
9816 | .info = alc268_mux_enum_info, | |
9817 | .get = alc268_mux_enum_get, | |
9818 | .put = alc268_mux_enum_put, | |
9819 | }, | |
9820 | { } /* end */ | |
9821 | }; | |
9822 | ||
9823 | static struct hda_input_mux alc268_capture_source = { | |
9824 | .num_items = 4, | |
9825 | .items = { | |
9826 | { "Mic", 0x0 }, | |
9827 | { "Front Mic", 0x1 }, | |
9828 | { "Line", 0x2 }, | |
9829 | { "CD", 0x3 }, | |
9830 | }, | |
9831 | }; | |
9832 | ||
86c53bd2 JW |
9833 | #ifdef CONFIG_SND_DEBUG |
9834 | static struct snd_kcontrol_new alc268_test_mixer[] = { | |
9835 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
9836 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9837 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
9838 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9839 | ||
9840 | /* Volume widgets */ | |
9841 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9842 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
9843 | HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
9844 | HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), | |
9845 | HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), | |
9846 | HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), | |
9847 | HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), | |
9848 | HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), | |
9849 | HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), | |
9850 | HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), | |
9851 | HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), | |
9852 | HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), | |
9853 | HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), | |
f0747ee6 TI |
9854 | /* The below appears problematic on some hardwares */ |
9855 | /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ | |
86c53bd2 JW |
9856 | HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
9857 | HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), | |
9858 | HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), | |
9859 | HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), | |
9860 | ||
9861 | /* Modes for retasking pin widgets */ | |
9862 | ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
9863 | ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
9864 | ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), | |
9865 | ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), | |
9866 | ||
9867 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
9868 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
9869 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
9870 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
9871 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
9872 | ||
9873 | /* Switches to allow the digital SPDIF output pin to be enabled. | |
9874 | * The ALC268 does not have an SPDIF input. | |
9875 | */ | |
9876 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), | |
9877 | ||
9878 | /* A switch allowing EAPD to be enabled. Some laptops seem to use | |
9879 | * this output to turn on an external amplifier. | |
9880 | */ | |
9881 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
9882 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
9883 | ||
9884 | { } /* end */ | |
9885 | }; | |
9886 | #endif | |
9887 | ||
a361d84b KY |
9888 | /* create input playback/capture controls for the given pin */ |
9889 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
9890 | const char *ctlname, int idx) | |
9891 | { | |
9892 | char name[32]; | |
9893 | int err; | |
9894 | ||
9895 | sprintf(name, "%s Playback Volume", ctlname); | |
9896 | if (nid == 0x14) { | |
9897 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
9898 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
9899 | HDA_OUTPUT)); | |
9900 | if (err < 0) | |
9901 | return err; | |
9902 | } else if (nid == 0x15) { | |
9903 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
9904 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
9905 | HDA_OUTPUT)); | |
9906 | if (err < 0) | |
9907 | return err; | |
9908 | } else | |
9909 | return -1; | |
9910 | sprintf(name, "%s Playback Switch", ctlname); | |
9911 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
9912 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
9913 | if (err < 0) | |
9914 | return err; | |
9915 | return 0; | |
9916 | } | |
9917 | ||
9918 | /* add playback controls from the parsed DAC table */ | |
9919 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
9920 | const struct auto_pin_cfg *cfg) | |
9921 | { | |
9922 | hda_nid_t nid; | |
9923 | int err; | |
9924 | ||
9925 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
9926 | spec->multiout.dac_nids = spec->private_dac_nids; | |
9927 | spec->multiout.dac_nids[0] = 2; | |
9928 | spec->multiout.dac_nids[1] = 3; | |
9929 | ||
9930 | nid = cfg->line_out_pins[0]; | |
9931 | if (nid) | |
9932 | alc268_new_analog_output(spec, nid, "Front", 0); | |
9933 | ||
9934 | nid = cfg->speaker_pins[0]; | |
9935 | if (nid == 0x1d) { | |
9936 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
9937 | "Speaker Playback Volume", | |
9938 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
9939 | if (err < 0) | |
9940 | return err; | |
9941 | } | |
9942 | nid = cfg->hp_pins[0]; | |
9943 | if (nid) | |
9944 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
9945 | ||
9946 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
9947 | if (nid == 0x16) { | |
9948 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
9949 | "Mono Playback Switch", | |
9950 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
9951 | if (err < 0) | |
9952 | return err; | |
9953 | } | |
9954 | return 0; | |
9955 | } | |
9956 | ||
9957 | /* create playback/capture controls for input pins */ | |
9958 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
9959 | const struct auto_pin_cfg *cfg) | |
9960 | { | |
9961 | struct hda_input_mux *imux = &spec->private_imux; | |
9962 | int i, idx1; | |
9963 | ||
9964 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
9965 | switch(cfg->input_pins[i]) { | |
9966 | case 0x18: | |
9967 | idx1 = 0; /* Mic 1 */ | |
9968 | break; | |
9969 | case 0x19: | |
9970 | idx1 = 1; /* Mic 2 */ | |
9971 | break; | |
9972 | case 0x1a: | |
9973 | idx1 = 2; /* Line In */ | |
9974 | break; | |
9975 | case 0x1c: | |
9976 | idx1 = 3; /* CD */ | |
9977 | break; | |
9978 | default: | |
9979 | continue; | |
9980 | } | |
9981 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
9982 | imux->items[imux->num_items].index = idx1; | |
9983 | imux->num_items++; | |
9984 | } | |
9985 | return 0; | |
9986 | } | |
9987 | ||
9988 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
9989 | { | |
9990 | struct alc_spec *spec = codec->spec; | |
9991 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
9992 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
9993 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
9994 | unsigned int dac_vol1, dac_vol2; | |
9995 | ||
9996 | if (speaker_nid) { | |
9997 | snd_hda_codec_write(codec, speaker_nid, 0, | |
9998 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
9999 | snd_hda_codec_write(codec, 0x0f, 0, | |
10000 | AC_VERB_SET_AMP_GAIN_MUTE, | |
10001 | AMP_IN_UNMUTE(1)); | |
10002 | snd_hda_codec_write(codec, 0x10, 0, | |
10003 | AC_VERB_SET_AMP_GAIN_MUTE, | |
10004 | AMP_IN_UNMUTE(1)); | |
10005 | } else { | |
10006 | snd_hda_codec_write(codec, 0x0f, 0, | |
10007 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
10008 | snd_hda_codec_write(codec, 0x10, 0, | |
10009 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
10010 | } | |
10011 | ||
10012 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
10013 | if (line_nid == 0x14) | |
10014 | dac_vol2 = AMP_OUT_ZERO; | |
10015 | else if (line_nid == 0x15) | |
10016 | dac_vol1 = AMP_OUT_ZERO; | |
10017 | if (hp_nid == 0x14) | |
10018 | dac_vol2 = AMP_OUT_ZERO; | |
10019 | else if (hp_nid == 0x15) | |
10020 | dac_vol1 = AMP_OUT_ZERO; | |
10021 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
10022 | spec->autocfg.line_out_pins[1] != 0x16 || | |
10023 | spec->autocfg.line_out_pins[2] != 0x16) | |
10024 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
10025 | ||
10026 | snd_hda_codec_write(codec, 0x02, 0, | |
10027 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
10028 | snd_hda_codec_write(codec, 0x03, 0, | |
10029 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
10030 | } | |
10031 | ||
10032 | /* pcm configuration: identiacal with ALC880 */ | |
10033 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
10034 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 10035 | #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
a361d84b KY |
10036 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback |
10037 | ||
10038 | /* | |
10039 | * BIOS auto configuration | |
10040 | */ | |
10041 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
10042 | { | |
10043 | struct alc_spec *spec = codec->spec; | |
10044 | int err; | |
10045 | static hda_nid_t alc268_ignore[] = { 0 }; | |
10046 | ||
10047 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
10048 | alc268_ignore); | |
10049 | if (err < 0) | |
10050 | return err; | |
10051 | if (!spec->autocfg.line_outs) | |
10052 | return 0; /* can't find valid BIOS pin config */ | |
10053 | ||
10054 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
10055 | if (err < 0) | |
10056 | return err; | |
10057 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10058 | if (err < 0) | |
10059 | return err; | |
10060 | ||
10061 | spec->multiout.max_channels = 2; | |
10062 | ||
10063 | /* digital only support output */ | |
10064 | if (spec->autocfg.dig_out_pin) | |
10065 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
10066 | ||
10067 | if (spec->kctl_alloc) | |
10068 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
10069 | ||
10070 | spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; | |
10071 | spec->num_mux_defs = 1; | |
10072 | spec->input_mux = &spec->private_imux; | |
10073 | ||
776e184e TI |
10074 | err = alc_auto_add_mic_boost(codec); |
10075 | if (err < 0) | |
10076 | return err; | |
10077 | ||
a361d84b KY |
10078 | return 1; |
10079 | } | |
10080 | ||
10081 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
10082 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
10083 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
10084 | ||
10085 | /* init callback for auto-configuration model -- overriding the default init */ | |
10086 | static void alc268_auto_init(struct hda_codec *codec) | |
10087 | { | |
10088 | alc268_auto_init_multi_out(codec); | |
10089 | alc268_auto_init_hp_out(codec); | |
10090 | alc268_auto_init_mono_speaker_out(codec); | |
10091 | alc268_auto_init_analog_input(codec); | |
10092 | } | |
10093 | ||
10094 | /* | |
10095 | * configuration and preset | |
10096 | */ | |
10097 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
10098 | [ALC268_3ST] = "3stack", | |
983f8ae4 | 10099 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 10100 | [ALC268_ACER] = "acer", |
3866f0b0 | 10101 | [ALC268_DELL] = "dell", |
86c53bd2 JW |
10102 | #ifdef CONFIG_SND_DEBUG |
10103 | [ALC268_TEST] = "test", | |
10104 | #endif | |
a361d84b KY |
10105 | [ALC268_AUTO] = "auto", |
10106 | }; | |
10107 | ||
10108 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
ac3e3741 | 10109 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), |
dafc8357 | 10110 | SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), |
ac3e3741 | 10111 | SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), |
29a52c24 | 10112 | SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), |
3866f0b0 | 10113 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
ac3e3741 | 10114 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
a361d84b | 10115 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
d1a991a6 | 10116 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
8e7f00f9 | 10117 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), |
b875bf3a | 10118 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
a361d84b KY |
10119 | {} |
10120 | }; | |
10121 | ||
10122 | static struct alc_config_preset alc268_presets[] = { | |
10123 | [ALC268_3ST] = { | |
10124 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, | |
10125 | .init_verbs = { alc268_base_init_verbs }, | |
10126 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10127 | .dac_nids = alc268_dac_nids, | |
10128 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10129 | .adc_nids = alc268_adc_nids_alt, | |
10130 | .hp_nid = 0x03, | |
10131 | .dig_out_nid = ALC268_DIGOUT_NID, | |
10132 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10133 | .channel_mode = alc268_modes, | |
10134 | .input_mux = &alc268_capture_source, | |
10135 | }, | |
d1a991a6 KY |
10136 | [ALC268_TOSHIBA] = { |
10137 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, | |
d273809e TI |
10138 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
10139 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
10140 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
10141 | .dac_nids = alc268_dac_nids, | |
10142 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10143 | .adc_nids = alc268_adc_nids_alt, | |
10144 | .hp_nid = 0x03, | |
10145 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10146 | .channel_mode = alc268_modes, | |
10147 | .input_mux = &alc268_capture_source, | |
d273809e TI |
10148 | .unsol_event = alc268_toshiba_unsol_event, |
10149 | .init_hook = alc268_toshiba_automute, | |
10150 | }, | |
10151 | [ALC268_ACER] = { | |
10152 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer }, | |
10153 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
10154 | alc268_acer_verbs }, | |
10155 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10156 | .dac_nids = alc268_dac_nids, | |
10157 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10158 | .adc_nids = alc268_adc_nids_alt, | |
10159 | .hp_nid = 0x02, | |
10160 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10161 | .channel_mode = alc268_modes, | |
10162 | .input_mux = &alc268_capture_source, | |
10163 | .unsol_event = alc268_acer_unsol_event, | |
889c4395 | 10164 | .init_hook = alc268_acer_init_hook, |
d1a991a6 | 10165 | }, |
3866f0b0 TI |
10166 | [ALC268_DELL] = { |
10167 | .mixers = { alc268_dell_mixer }, | |
10168 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
10169 | alc268_dell_verbs }, | |
10170 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10171 | .dac_nids = alc268_dac_nids, | |
10172 | .hp_nid = 0x02, | |
10173 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10174 | .channel_mode = alc268_modes, | |
10175 | .unsol_event = alc268_dell_unsol_event, | |
10176 | .init_hook = alc268_dell_init_hook, | |
10177 | .input_mux = &alc268_capture_source, | |
10178 | }, | |
86c53bd2 JW |
10179 | #ifdef CONFIG_SND_DEBUG |
10180 | [ALC268_TEST] = { | |
10181 | .mixers = { alc268_test_mixer, alc268_capture_mixer }, | |
10182 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
10183 | alc268_volume_init_verbs }, | |
10184 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10185 | .dac_nids = alc268_dac_nids, | |
10186 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10187 | .adc_nids = alc268_adc_nids_alt, | |
10188 | .hp_nid = 0x03, | |
10189 | .dig_out_nid = ALC268_DIGOUT_NID, | |
10190 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10191 | .channel_mode = alc268_modes, | |
10192 | .input_mux = &alc268_capture_source, | |
10193 | }, | |
10194 | #endif | |
a361d84b KY |
10195 | }; |
10196 | ||
10197 | static int patch_alc268(struct hda_codec *codec) | |
10198 | { | |
10199 | struct alc_spec *spec; | |
10200 | int board_config; | |
10201 | int err; | |
10202 | ||
10203 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
10204 | if (spec == NULL) | |
10205 | return -ENOMEM; | |
10206 | ||
10207 | codec->spec = spec; | |
10208 | ||
10209 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
10210 | alc268_models, | |
10211 | alc268_cfg_tbl); | |
10212 | ||
10213 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
10214 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
10215 | "trying auto-probe from BIOS...\n"); | |
10216 | board_config = ALC268_AUTO; | |
10217 | } | |
10218 | ||
10219 | if (board_config == ALC268_AUTO) { | |
10220 | /* automatic parse from the BIOS config */ | |
10221 | err = alc268_parse_auto_config(codec); | |
10222 | if (err < 0) { | |
10223 | alc_free(codec); | |
10224 | return err; | |
10225 | } else if (!err) { | |
10226 | printk(KERN_INFO | |
10227 | "hda_codec: Cannot set up configuration " | |
10228 | "from BIOS. Using base mode...\n"); | |
10229 | board_config = ALC268_3ST; | |
10230 | } | |
10231 | } | |
10232 | ||
10233 | if (board_config != ALC268_AUTO) | |
10234 | setup_preset(spec, &alc268_presets[board_config]); | |
10235 | ||
10236 | spec->stream_name_analog = "ALC268 Analog"; | |
10237 | spec->stream_analog_playback = &alc268_pcm_analog_playback; | |
10238 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
6330079f | 10239 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; |
a361d84b KY |
10240 | |
10241 | spec->stream_name_digital = "ALC268 Digital"; | |
10242 | spec->stream_digital_playback = &alc268_pcm_digital_playback; | |
10243 | ||
3866f0b0 TI |
10244 | if (!spec->adc_nids && spec->input_mux) { |
10245 | /* check whether NID 0x07 is valid */ | |
10246 | unsigned int wcap = get_wcaps(codec, 0x07); | |
10247 | ||
10248 | /* get type */ | |
10249 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
10250 | if (wcap != AC_WID_AUD_IN) { | |
10251 | spec->adc_nids = alc268_adc_nids_alt; | |
10252 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | |
10253 | spec->mixers[spec->num_mixers] = | |
a361d84b | 10254 | alc268_capture_alt_mixer; |
3866f0b0 TI |
10255 | spec->num_mixers++; |
10256 | } else { | |
10257 | spec->adc_nids = alc268_adc_nids; | |
10258 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | |
10259 | spec->mixers[spec->num_mixers] = | |
10260 | alc268_capture_mixer; | |
10261 | spec->num_mixers++; | |
a361d84b KY |
10262 | } |
10263 | } | |
2134ea4f TI |
10264 | |
10265 | spec->vmaster_nid = 0x02; | |
10266 | ||
a361d84b KY |
10267 | codec->patch_ops = alc_patch_ops; |
10268 | if (board_config == ALC268_AUTO) | |
10269 | spec->init_hook = alc268_auto_init; | |
10270 | ||
10271 | return 0; | |
10272 | } | |
10273 | ||
f6a92248 KY |
10274 | /* |
10275 | * ALC269 channel source setting (2 channel) | |
10276 | */ | |
10277 | #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID | |
10278 | ||
10279 | #define alc269_dac_nids alc260_dac_nids | |
10280 | ||
10281 | static hda_nid_t alc269_adc_nids[1] = { | |
10282 | /* ADC1 */ | |
10283 | 0x07, | |
10284 | }; | |
10285 | ||
10286 | #define alc269_modes alc260_modes | |
10287 | #define alc269_capture_source alc880_lg_lw_capture_source | |
10288 | ||
10289 | static struct snd_kcontrol_new alc269_base_mixer[] = { | |
10290 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10291 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10292 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10293 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10294 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10295 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10296 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10297 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
10298 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
10299 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10300 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10301 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
10302 | { } /* end */ | |
10303 | }; | |
10304 | ||
10305 | /* capture mixer elements */ | |
10306 | static struct snd_kcontrol_new alc269_capture_mixer[] = { | |
10307 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
10308 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
10309 | { | |
10310 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10311 | /* The multiple "Capture Source" controls confuse alsamixer | |
10312 | * So call somewhat different.. | |
f6a92248 KY |
10313 | */ |
10314 | /* .name = "Capture Source", */ | |
10315 | .name = "Input Source", | |
10316 | .count = 1, | |
10317 | .info = alc_mux_enum_info, | |
10318 | .get = alc_mux_enum_get, | |
10319 | .put = alc_mux_enum_put, | |
10320 | }, | |
10321 | { } /* end */ | |
10322 | }; | |
10323 | ||
10324 | /* | |
10325 | * generic initialization of ADC, input mixers and output mixers | |
10326 | */ | |
10327 | static struct hda_verb alc269_init_verbs[] = { | |
10328 | /* | |
10329 | * Unmute ADC0 and set the default input to mic-in | |
10330 | */ | |
10331 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10332 | ||
10333 | /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the | |
10334 | * analog-loopback mixer widget | |
10335 | * Note: PASD motherboards uses the Line In 2 as the input for | |
10336 | * front panel mic (mic 2) | |
10337 | */ | |
10338 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
10339 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10340 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10341 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10342 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10343 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10344 | ||
10345 | /* | |
10346 | * Set up output mixers (0x0c - 0x0e) | |
10347 | */ | |
10348 | /* set vol=0 to output mixers */ | |
10349 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10350 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10351 | ||
10352 | /* set up input amps for analog loopback */ | |
10353 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10354 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10355 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10356 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10357 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10358 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10359 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10360 | ||
10361 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10362 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10363 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10364 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10365 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10366 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10367 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10368 | ||
10369 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10370 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10371 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10372 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10373 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10374 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10375 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10376 | ||
10377 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10378 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10379 | ||
10380 | /* FIXME: use matrix-type input source selection */ | |
10381 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ | |
10382 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10383 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10384 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10385 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10386 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10387 | ||
10388 | /* set EAPD */ | |
10389 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10390 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10391 | { } | |
10392 | }; | |
10393 | ||
10394 | /* add playback controls from the parsed DAC table */ | |
10395 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | |
10396 | const struct auto_pin_cfg *cfg) | |
10397 | { | |
10398 | hda_nid_t nid; | |
10399 | int err; | |
10400 | ||
10401 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
10402 | spec->multiout.dac_nids = spec->private_dac_nids; | |
10403 | spec->multiout.dac_nids[0] = 2; | |
10404 | ||
10405 | nid = cfg->line_out_pins[0]; | |
10406 | if (nid) { | |
10407 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
10408 | "Front Playback Volume", | |
10409 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | |
10410 | if (err < 0) | |
10411 | return err; | |
10412 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
10413 | "Front Playback Switch", | |
10414 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
10415 | if (err < 0) | |
10416 | return err; | |
10417 | } | |
10418 | ||
10419 | nid = cfg->speaker_pins[0]; | |
10420 | if (nid) { | |
10421 | if (!cfg->line_out_pins[0]) { | |
10422 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
10423 | "Speaker Playback Volume", | |
10424 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
10425 | HDA_OUTPUT)); | |
10426 | if (err < 0) | |
10427 | return err; | |
10428 | } | |
10429 | if (nid == 0x16) { | |
10430 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
10431 | "Speaker Playback Switch", | |
10432 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10433 | HDA_OUTPUT)); | |
10434 | if (err < 0) | |
10435 | return err; | |
10436 | } else { | |
10437 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
10438 | "Speaker Playback Switch", | |
10439 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10440 | HDA_OUTPUT)); | |
10441 | if (err < 0) | |
10442 | return err; | |
10443 | } | |
10444 | } | |
10445 | nid = cfg->hp_pins[0]; | |
10446 | if (nid) { | |
10447 | /* spec->multiout.hp_nid = 2; */ | |
10448 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | |
10449 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
10450 | "Headphone Playback Volume", | |
10451 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
10452 | HDA_OUTPUT)); | |
10453 | if (err < 0) | |
10454 | return err; | |
10455 | } | |
10456 | if (nid == 0x16) { | |
10457 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
10458 | "Headphone Playback Switch", | |
10459 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10460 | HDA_OUTPUT)); | |
10461 | if (err < 0) | |
10462 | return err; | |
10463 | } else { | |
10464 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
10465 | "Headphone Playback Switch", | |
10466 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10467 | HDA_OUTPUT)); | |
10468 | if (err < 0) | |
10469 | return err; | |
10470 | } | |
10471 | } | |
10472 | return 0; | |
10473 | } | |
10474 | ||
10475 | #define alc269_auto_create_analog_input_ctls \ | |
10476 | alc880_auto_create_analog_input_ctls | |
10477 | ||
10478 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
10479 | #define alc269_loopbacks alc880_loopbacks | |
10480 | #endif | |
10481 | ||
10482 | /* pcm configuration: identiacal with ALC880 */ | |
10483 | #define alc269_pcm_analog_playback alc880_pcm_analog_playback | |
10484 | #define alc269_pcm_analog_capture alc880_pcm_analog_capture | |
10485 | #define alc269_pcm_digital_playback alc880_pcm_digital_playback | |
10486 | #define alc269_pcm_digital_capture alc880_pcm_digital_capture | |
10487 | ||
10488 | /* | |
10489 | * BIOS auto configuration | |
10490 | */ | |
10491 | static int alc269_parse_auto_config(struct hda_codec *codec) | |
10492 | { | |
10493 | struct alc_spec *spec = codec->spec; | |
10494 | int err; | |
10495 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; | |
10496 | ||
10497 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
10498 | alc269_ignore); | |
10499 | if (err < 0) | |
10500 | return err; | |
10501 | ||
10502 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
10503 | if (err < 0) | |
10504 | return err; | |
10505 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10506 | if (err < 0) | |
10507 | return err; | |
10508 | ||
10509 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
10510 | ||
10511 | if (spec->autocfg.dig_out_pin) | |
10512 | spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; | |
10513 | ||
10514 | if (spec->kctl_alloc) | |
10515 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
10516 | ||
10517 | spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs; | |
10518 | spec->num_mux_defs = 1; | |
10519 | spec->input_mux = &spec->private_imux; | |
10520 | ||
10521 | err = alc_auto_add_mic_boost(codec); | |
10522 | if (err < 0) | |
10523 | return err; | |
10524 | ||
10525 | return 1; | |
10526 | } | |
10527 | ||
10528 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | |
10529 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | |
10530 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | |
10531 | ||
10532 | ||
10533 | /* init callback for auto-configuration model -- overriding the default init */ | |
10534 | static void alc269_auto_init(struct hda_codec *codec) | |
10535 | { | |
10536 | alc269_auto_init_multi_out(codec); | |
10537 | alc269_auto_init_hp_out(codec); | |
10538 | alc269_auto_init_analog_input(codec); | |
10539 | } | |
10540 | ||
10541 | /* | |
10542 | * configuration and preset | |
10543 | */ | |
10544 | static const char *alc269_models[ALC269_MODEL_LAST] = { | |
10545 | [ALC269_BASIC] = "basic", | |
10546 | }; | |
10547 | ||
10548 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | |
10549 | {} | |
10550 | }; | |
10551 | ||
10552 | static struct alc_config_preset alc269_presets[] = { | |
10553 | [ALC269_BASIC] = { | |
10554 | .mixers = { alc269_base_mixer }, | |
10555 | .init_verbs = { alc269_init_verbs }, | |
10556 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
10557 | .dac_nids = alc269_dac_nids, | |
10558 | .hp_nid = 0x03, | |
10559 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
10560 | .channel_mode = alc269_modes, | |
10561 | .input_mux = &alc269_capture_source, | |
10562 | }, | |
10563 | }; | |
10564 | ||
10565 | static int patch_alc269(struct hda_codec *codec) | |
10566 | { | |
10567 | struct alc_spec *spec; | |
10568 | int board_config; | |
10569 | int err; | |
10570 | ||
10571 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
10572 | if (spec == NULL) | |
10573 | return -ENOMEM; | |
10574 | ||
10575 | codec->spec = spec; | |
10576 | ||
10577 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, | |
10578 | alc269_models, | |
10579 | alc269_cfg_tbl); | |
10580 | ||
10581 | if (board_config < 0) { | |
10582 | printk(KERN_INFO "hda_codec: Unknown model for ALC269, " | |
10583 | "trying auto-probe from BIOS...\n"); | |
10584 | board_config = ALC269_AUTO; | |
10585 | } | |
10586 | ||
10587 | if (board_config == ALC269_AUTO) { | |
10588 | /* automatic parse from the BIOS config */ | |
10589 | err = alc269_parse_auto_config(codec); | |
10590 | if (err < 0) { | |
10591 | alc_free(codec); | |
10592 | return err; | |
10593 | } else if (!err) { | |
10594 | printk(KERN_INFO | |
10595 | "hda_codec: Cannot set up configuration " | |
10596 | "from BIOS. Using base mode...\n"); | |
10597 | board_config = ALC269_BASIC; | |
10598 | } | |
10599 | } | |
10600 | ||
10601 | if (board_config != ALC269_AUTO) | |
10602 | setup_preset(spec, &alc269_presets[board_config]); | |
10603 | ||
10604 | spec->stream_name_analog = "ALC269 Analog"; | |
10605 | spec->stream_analog_playback = &alc269_pcm_analog_playback; | |
10606 | spec->stream_analog_capture = &alc269_pcm_analog_capture; | |
10607 | ||
10608 | spec->stream_name_digital = "ALC269 Digital"; | |
10609 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | |
10610 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | |
10611 | ||
10612 | spec->adc_nids = alc269_adc_nids; | |
10613 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | |
10614 | spec->mixers[spec->num_mixers] = alc269_capture_mixer; | |
10615 | spec->num_mixers++; | |
10616 | ||
10617 | codec->patch_ops = alc_patch_ops; | |
10618 | if (board_config == ALC269_AUTO) | |
10619 | spec->init_hook = alc269_auto_init; | |
10620 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
10621 | if (!spec->loopback.amplist) | |
10622 | spec->loopback.amplist = alc269_loopbacks; | |
10623 | #endif | |
10624 | ||
10625 | return 0; | |
10626 | } | |
10627 | ||
df694daa KY |
10628 | /* |
10629 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
10630 | */ | |
10631 | ||
10632 | /* | |
10633 | * set the path ways for 2 channel output | |
10634 | * need to set the codec line out and mic 1 pin widgets to inputs | |
10635 | */ | |
10636 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
10637 | /* set pin widget 1Ah (line in) for input */ | |
10638 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
10639 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
10640 | * the vref | |
10641 | */ | |
df694daa KY |
10642 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
10643 | ||
9c7f852e TI |
10644 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
10645 | #if 0 | |
10646 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
10647 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
10648 | #endif | |
df694daa KY |
10649 | { } /* end */ |
10650 | }; | |
10651 | /* | |
10652 | * 6ch mode | |
10653 | * need to set the codec line out and mic 1 pin widgets to outputs | |
10654 | */ | |
10655 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
10656 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
10657 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10658 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
10659 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10660 | ||
10661 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 10662 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 10663 | |
9c7f852e TI |
10664 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
10665 | #if 0 | |
10666 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
10667 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
10668 | #endif | |
df694daa KY |
10669 | { } /* end */ |
10670 | }; | |
10671 | ||
10672 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
10673 | { 2, alc861_threestack_ch2_init }, | |
10674 | { 6, alc861_threestack_ch6_init }, | |
10675 | }; | |
22309c3e TI |
10676 | /* Set mic1 as input and unmute the mixer */ |
10677 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
10678 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
10679 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
10680 | { } /* end */ | |
10681 | }; | |
10682 | /* Set mic1 as output and mute mixer */ | |
10683 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
10684 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10685 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
10686 | { } /* end */ | |
10687 | }; | |
10688 | ||
10689 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
10690 | { 2, alc861_uniwill_m31_ch2_init }, | |
10691 | { 4, alc861_uniwill_m31_ch4_init }, | |
10692 | }; | |
df694daa | 10693 | |
7cdbff94 MD |
10694 | /* Set mic1 and line-in as input and unmute the mixer */ |
10695 | static struct hda_verb alc861_asus_ch2_init[] = { | |
10696 | /* set pin widget 1Ah (line in) for input */ | |
10697 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
10698 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
10699 | * the vref | |
10700 | */ | |
7cdbff94 MD |
10701 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
10702 | ||
10703 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
10704 | #if 0 | |
10705 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
10706 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
10707 | #endif | |
10708 | { } /* end */ | |
10709 | }; | |
10710 | /* Set mic1 nad line-in as output and mute mixer */ | |
10711 | static struct hda_verb alc861_asus_ch6_init[] = { | |
10712 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
10713 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10714 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
10715 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
10716 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10717 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
10718 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
10719 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
10720 | ||
10721 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
10722 | #if 0 | |
10723 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
10724 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
10725 | #endif | |
10726 | { } /* end */ | |
10727 | }; | |
10728 | ||
10729 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
10730 | { 2, alc861_asus_ch2_init }, | |
10731 | { 6, alc861_asus_ch6_init }, | |
10732 | }; | |
10733 | ||
df694daa KY |
10734 | /* patch-ALC861 */ |
10735 | ||
10736 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
10737 | /* output mixer control */ | |
10738 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
10739 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
10740 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
10741 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
10742 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
10743 | ||
10744 | /*Input mixer control */ | |
10745 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
10746 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
10747 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
10748 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
10749 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
10750 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
10751 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
10752 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
10753 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
10754 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 10755 | |
df694daa KY |
10756 | /* Capture mixer control */ |
10757 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
10758 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
10759 | { | |
10760 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10761 | .name = "Capture Source", | |
10762 | .count = 1, | |
10763 | .info = alc_mux_enum_info, | |
10764 | .get = alc_mux_enum_get, | |
10765 | .put = alc_mux_enum_put, | |
10766 | }, | |
10767 | { } /* end */ | |
10768 | }; | |
10769 | ||
10770 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
10771 | /* output mixer control */ | |
10772 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
10773 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
10774 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
10775 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
10776 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
10777 | ||
10778 | /* Input mixer control */ | |
10779 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
10780 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
10781 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
10782 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
10783 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
10784 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
10785 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
10786 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
10787 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
10788 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 10789 | |
df694daa KY |
10790 | /* Capture mixer control */ |
10791 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
10792 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
10793 | { | |
10794 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10795 | .name = "Capture Source", | |
10796 | .count = 1, | |
10797 | .info = alc_mux_enum_info, | |
10798 | .get = alc_mux_enum_get, | |
10799 | .put = alc_mux_enum_put, | |
10800 | }, | |
10801 | { | |
10802 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10803 | .name = "Channel Mode", | |
10804 | .info = alc_ch_mode_info, | |
10805 | .get = alc_ch_mode_get, | |
10806 | .put = alc_ch_mode_put, | |
10807 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
10808 | }, | |
10809 | { } /* end */ | |
a53d1aec TD |
10810 | }; |
10811 | ||
d1d985f0 | 10812 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
10813 | /* output mixer control */ |
10814 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
10815 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
10816 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
10817 | ||
10818 | /*Capture mixer control */ | |
10819 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
10820 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
10821 | { | |
10822 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10823 | .name = "Capture Source", | |
10824 | .count = 1, | |
10825 | .info = alc_mux_enum_info, | |
10826 | .get = alc_mux_enum_get, | |
10827 | .put = alc_mux_enum_put, | |
10828 | }, | |
10829 | ||
10830 | { } /* end */ | |
f12ab1e0 | 10831 | }; |
a53d1aec | 10832 | |
22309c3e TI |
10833 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
10834 | /* output mixer control */ | |
10835 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
10836 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
10837 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
10838 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
10839 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
10840 | ||
10841 | /* Input mixer control */ | |
10842 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
10843 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
10844 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
10845 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
10846 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
10847 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
10848 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
10849 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
10850 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
10851 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 10852 | |
22309c3e TI |
10853 | /* Capture mixer control */ |
10854 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
10855 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
10856 | { | |
10857 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10858 | .name = "Capture Source", | |
10859 | .count = 1, | |
10860 | .info = alc_mux_enum_info, | |
10861 | .get = alc_mux_enum_get, | |
10862 | .put = alc_mux_enum_put, | |
10863 | }, | |
10864 | { | |
10865 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10866 | .name = "Channel Mode", | |
10867 | .info = alc_ch_mode_info, | |
10868 | .get = alc_ch_mode_get, | |
10869 | .put = alc_ch_mode_put, | |
10870 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
10871 | }, | |
10872 | { } /* end */ | |
f12ab1e0 | 10873 | }; |
7cdbff94 MD |
10874 | |
10875 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
10876 | /* output mixer control */ | |
10877 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
10878 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
10879 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
10880 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
10881 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
10882 | ||
10883 | /* Input mixer control */ | |
10884 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
10885 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10886 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
10887 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
10888 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
10889 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
10890 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
10891 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
10892 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
10893 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
10894 | ||
7cdbff94 MD |
10895 | /* Capture mixer control */ |
10896 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
10897 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
10898 | { | |
10899 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10900 | .name = "Capture Source", | |
10901 | .count = 1, | |
10902 | .info = alc_mux_enum_info, | |
10903 | .get = alc_mux_enum_get, | |
10904 | .put = alc_mux_enum_put, | |
10905 | }, | |
10906 | { | |
10907 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10908 | .name = "Channel Mode", | |
10909 | .info = alc_ch_mode_info, | |
10910 | .get = alc_ch_mode_get, | |
10911 | .put = alc_ch_mode_put, | |
10912 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
10913 | }, | |
10914 | { } | |
56bb0cab TI |
10915 | }; |
10916 | ||
10917 | /* additional mixer */ | |
d1d985f0 | 10918 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
10919 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
10920 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
10921 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
10922 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
10923 | { } | |
10924 | }; | |
7cdbff94 | 10925 | |
df694daa KY |
10926 | /* |
10927 | * generic initialization of ADC, input mixers and output mixers | |
10928 | */ | |
10929 | static struct hda_verb alc861_base_init_verbs[] = { | |
10930 | /* | |
10931 | * Unmute ADC0 and set the default input to mic-in | |
10932 | */ | |
10933 | /* port-A for surround (rear panel) */ | |
10934 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10935 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
10936 | /* port-B for mic-in (rear panel) with vref */ | |
10937 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
10938 | /* port-C for line-in (rear panel) */ | |
10939 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
10940 | /* port-D for Front */ | |
10941 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10942 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
10943 | /* port-E for HP out (front panel) */ | |
10944 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
10945 | /* route front PCM to HP */ | |
9dece1d7 | 10946 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
10947 | /* port-F for mic-in (front panel) with vref */ |
10948 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
10949 | /* port-G for CLFE (rear panel) */ | |
10950 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10951 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
10952 | /* port-H for side (rear panel) */ | |
10953 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10954 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
10955 | /* CD-in */ | |
10956 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
10957 | /* route front mic to ADC1*/ | |
10958 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10959 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10960 | ||
10961 | /* Unmute DAC0~3 & spdif out*/ | |
10962 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10963 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10964 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10965 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10966 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10967 | ||
10968 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
10969 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10970 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10971 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10972 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10973 | ||
10974 | /* Unmute Stereo Mixer 15 */ | |
10975 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10976 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10977 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 10978 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
10979 | |
10980 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10981 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10982 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10983 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10984 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10985 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10986 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10987 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
10988 | /* hp used DAC 3 (Front) */ |
10989 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
10990 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
10991 | ||
10992 | { } | |
10993 | }; | |
10994 | ||
10995 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
10996 | /* | |
10997 | * Unmute ADC0 and set the default input to mic-in | |
10998 | */ | |
10999 | /* port-A for surround (rear panel) */ | |
11000 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11001 | /* port-B for mic-in (rear panel) with vref */ | |
11002 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11003 | /* port-C for line-in (rear panel) */ | |
11004 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11005 | /* port-D for Front */ | |
11006 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11007 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11008 | /* port-E for HP out (front panel) */ | |
11009 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
11010 | /* route front PCM to HP */ | |
9dece1d7 | 11011 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
11012 | /* port-F for mic-in (front panel) with vref */ |
11013 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11014 | /* port-G for CLFE (rear panel) */ | |
11015 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11016 | /* port-H for side (rear panel) */ | |
11017 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11018 | /* CD-in */ | |
11019 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11020 | /* route front mic to ADC1*/ | |
11021 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11022 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11023 | /* Unmute DAC0~3 & spdif out*/ | |
11024 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11025 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11026 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11027 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11028 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11029 | ||
11030 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
11031 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11032 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11033 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11034 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11035 | ||
11036 | /* Unmute Stereo Mixer 15 */ | |
11037 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11038 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11039 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 11040 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
11041 | |
11042 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11043 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11044 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11045 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11046 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11047 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11048 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11049 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
11050 | /* hp used DAC 3 (Front) */ |
11051 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
11052 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
11053 | { } | |
11054 | }; | |
22309c3e TI |
11055 | |
11056 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
11057 | /* | |
11058 | * Unmute ADC0 and set the default input to mic-in | |
11059 | */ | |
11060 | /* port-A for surround (rear panel) */ | |
11061 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11062 | /* port-B for mic-in (rear panel) with vref */ | |
11063 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11064 | /* port-C for line-in (rear panel) */ | |
11065 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11066 | /* port-D for Front */ | |
11067 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11068 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11069 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
11070 | /* this has to be set to VREF80 */ |
11071 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 11072 | /* route front PCM to HP */ |
9dece1d7 | 11073 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
11074 | /* port-F for mic-in (front panel) with vref */ |
11075 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11076 | /* port-G for CLFE (rear panel) */ | |
11077 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11078 | /* port-H for side (rear panel) */ | |
11079 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11080 | /* CD-in */ | |
11081 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11082 | /* route front mic to ADC1*/ | |
11083 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11084 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11085 | /* Unmute DAC0~3 & spdif out*/ | |
11086 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11087 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11088 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11089 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11090 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11091 | ||
11092 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
11093 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11094 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11095 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11096 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11097 | ||
11098 | /* Unmute Stereo Mixer 15 */ | |
11099 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11100 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11101 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 11102 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
11103 | |
11104 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11105 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11106 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11107 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11108 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11109 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11110 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11111 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
11112 | /* hp used DAC 3 (Front) */ |
11113 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
11114 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
11115 | { } | |
11116 | }; | |
11117 | ||
7cdbff94 MD |
11118 | static struct hda_verb alc861_asus_init_verbs[] = { |
11119 | /* | |
11120 | * Unmute ADC0 and set the default input to mic-in | |
11121 | */ | |
f12ab1e0 TI |
11122 | /* port-A for surround (rear panel) |
11123 | * according to codec#0 this is the HP jack | |
11124 | */ | |
7cdbff94 MD |
11125 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
11126 | /* route front PCM to HP */ | |
11127 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
11128 | /* port-B for mic-in (rear panel) with vref */ | |
11129 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11130 | /* port-C for line-in (rear panel) */ | |
11131 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11132 | /* port-D for Front */ | |
11133 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11134 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11135 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
11136 | /* this has to be set to VREF80 */ |
11137 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 11138 | /* route front PCM to HP */ |
9dece1d7 | 11139 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
11140 | /* port-F for mic-in (front panel) with vref */ |
11141 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11142 | /* port-G for CLFE (rear panel) */ | |
11143 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11144 | /* port-H for side (rear panel) */ | |
11145 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11146 | /* CD-in */ | |
11147 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11148 | /* route front mic to ADC1*/ | |
11149 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11150 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11151 | /* Unmute DAC0~3 & spdif out*/ | |
11152 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11153 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11154 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11155 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11156 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11157 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
11158 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11159 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11160 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11161 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11162 | ||
11163 | /* Unmute Stereo Mixer 15 */ | |
11164 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11165 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11166 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 11167 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
11168 | |
11169 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11170 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11171 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11172 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11173 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11174 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11175 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11176 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
11177 | /* hp used DAC 3 (Front) */ |
11178 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
11179 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
11180 | { } | |
11181 | }; | |
11182 | ||
56bb0cab TI |
11183 | /* additional init verbs for ASUS laptops */ |
11184 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
11185 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
11186 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
11187 | { } | |
11188 | }; | |
7cdbff94 | 11189 | |
df694daa KY |
11190 | /* |
11191 | * generic initialization of ADC, input mixers and output mixers | |
11192 | */ | |
11193 | static struct hda_verb alc861_auto_init_verbs[] = { | |
11194 | /* | |
11195 | * Unmute ADC0 and set the default input to mic-in | |
11196 | */ | |
f12ab1e0 | 11197 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa KY |
11198 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
11199 | ||
11200 | /* Unmute DAC0~3 & spdif out*/ | |
11201 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11202 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11203 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11204 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11205 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11206 | ||
11207 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
11208 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11209 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11210 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11211 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11212 | ||
11213 | /* Unmute Stereo Mixer 15 */ | |
11214 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11215 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11216 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
11217 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
11218 | ||
11219 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11220 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11221 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11222 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11223 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11224 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11225 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11226 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11227 | ||
11228 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11229 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
11230 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
11231 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
11232 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
11233 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
11234 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
11235 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 11236 | |
f12ab1e0 | 11237 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
11238 | |
11239 | { } | |
11240 | }; | |
11241 | ||
a53d1aec TD |
11242 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
11243 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 11244 | |
a53d1aec TD |
11245 | { } |
11246 | }; | |
11247 | ||
11248 | /* toggle speaker-output according to the hp-jack state */ | |
11249 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
11250 | { | |
11251 | unsigned int present; | |
11252 | ||
11253 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
11254 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
11255 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
11256 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
11257 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
11258 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
11259 | } |
11260 | ||
11261 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
11262 | unsigned int res) | |
11263 | { | |
a53d1aec TD |
11264 | if ((res >> 26) == ALC880_HP_EVENT) |
11265 | alc861_toshiba_automute(codec); | |
11266 | } | |
11267 | ||
df694daa KY |
11268 | /* pcm configuration: identiacal with ALC880 */ |
11269 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
11270 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
11271 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
11272 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
11273 | ||
11274 | ||
11275 | #define ALC861_DIGOUT_NID 0x07 | |
11276 | ||
11277 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
11278 | { 8, NULL } | |
11279 | }; | |
11280 | ||
11281 | static hda_nid_t alc861_dac_nids[4] = { | |
11282 | /* front, surround, clfe, side */ | |
11283 | 0x03, 0x06, 0x05, 0x04 | |
11284 | }; | |
11285 | ||
9c7f852e TI |
11286 | static hda_nid_t alc660_dac_nids[3] = { |
11287 | /* front, clfe, surround */ | |
11288 | 0x03, 0x05, 0x06 | |
11289 | }; | |
11290 | ||
df694daa KY |
11291 | static hda_nid_t alc861_adc_nids[1] = { |
11292 | /* ADC0-2 */ | |
11293 | 0x08, | |
11294 | }; | |
11295 | ||
11296 | static struct hda_input_mux alc861_capture_source = { | |
11297 | .num_items = 5, | |
11298 | .items = { | |
11299 | { "Mic", 0x0 }, | |
11300 | { "Front Mic", 0x3 }, | |
11301 | { "Line", 0x1 }, | |
11302 | { "CD", 0x4 }, | |
11303 | { "Mixer", 0x5 }, | |
11304 | }, | |
11305 | }; | |
11306 | ||
11307 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
11308 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
11309 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
11310 | { |
11311 | int i; | |
11312 | hda_nid_t nid; | |
11313 | ||
11314 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11315 | for (i = 0; i < cfg->line_outs; i++) { | |
11316 | nid = cfg->line_out_pins[i]; | |
11317 | if (nid) { | |
11318 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
11319 | continue; | |
11320 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
11321 | } | |
11322 | } | |
11323 | spec->multiout.num_dacs = cfg->line_outs; | |
11324 | return 0; | |
11325 | } | |
11326 | ||
11327 | /* add playback controls from the parsed DAC table */ | |
11328 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11329 | const struct auto_pin_cfg *cfg) | |
11330 | { | |
11331 | char name[32]; | |
f12ab1e0 TI |
11332 | static const char *chname[4] = { |
11333 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
11334 | }; | |
df694daa KY |
11335 | hda_nid_t nid; |
11336 | int i, idx, err; | |
11337 | ||
11338 | for (i = 0; i < cfg->line_outs; i++) { | |
11339 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 11340 | if (!nid) |
df694daa KY |
11341 | continue; |
11342 | if (nid == 0x05) { | |
11343 | /* Center/LFE */ | |
f12ab1e0 TI |
11344 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
11345 | "Center Playback Switch", | |
11346 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
11347 | HDA_OUTPUT)); | |
11348 | if (err < 0) | |
df694daa | 11349 | return err; |
f12ab1e0 TI |
11350 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
11351 | "LFE Playback Switch", | |
11352 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
11353 | HDA_OUTPUT)); | |
11354 | if (err < 0) | |
df694daa KY |
11355 | return err; |
11356 | } else { | |
f12ab1e0 TI |
11357 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
11358 | idx++) | |
df694daa KY |
11359 | if (nid == alc861_dac_nids[idx]) |
11360 | break; | |
11361 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
11362 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
11363 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
11364 | HDA_OUTPUT)); | |
11365 | if (err < 0) | |
df694daa KY |
11366 | return err; |
11367 | } | |
11368 | } | |
11369 | return 0; | |
11370 | } | |
11371 | ||
11372 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
11373 | { | |
11374 | int err; | |
11375 | hda_nid_t nid; | |
11376 | ||
f12ab1e0 | 11377 | if (!pin) |
df694daa KY |
11378 | return 0; |
11379 | ||
11380 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
11381 | nid = 0x03; | |
f12ab1e0 TI |
11382 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
11383 | "Headphone Playback Switch", | |
11384 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
11385 | if (err < 0) | |
df694daa KY |
11386 | return err; |
11387 | spec->multiout.hp_nid = nid; | |
11388 | } | |
11389 | return 0; | |
11390 | } | |
11391 | ||
11392 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
11393 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
11394 | const struct auto_pin_cfg *cfg) | |
df694daa | 11395 | { |
df694daa KY |
11396 | struct hda_input_mux *imux = &spec->private_imux; |
11397 | int i, err, idx, idx1; | |
11398 | ||
11399 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 11400 | switch (cfg->input_pins[i]) { |
df694daa KY |
11401 | case 0x0c: |
11402 | idx1 = 1; | |
f12ab1e0 | 11403 | idx = 2; /* Line In */ |
df694daa KY |
11404 | break; |
11405 | case 0x0f: | |
11406 | idx1 = 2; | |
f12ab1e0 | 11407 | idx = 2; /* Line In */ |
df694daa KY |
11408 | break; |
11409 | case 0x0d: | |
11410 | idx1 = 0; | |
f12ab1e0 | 11411 | idx = 1; /* Mic In */ |
df694daa | 11412 | break; |
f12ab1e0 | 11413 | case 0x10: |
df694daa | 11414 | idx1 = 3; |
f12ab1e0 | 11415 | idx = 1; /* Mic In */ |
df694daa KY |
11416 | break; |
11417 | case 0x11: | |
11418 | idx1 = 4; | |
f12ab1e0 | 11419 | idx = 0; /* CD */ |
df694daa KY |
11420 | break; |
11421 | default: | |
11422 | continue; | |
11423 | } | |
11424 | ||
4a471b7d TI |
11425 | err = new_analog_input(spec, cfg->input_pins[i], |
11426 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
11427 | if (err < 0) |
11428 | return err; | |
11429 | ||
4a471b7d | 11430 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 11431 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 11432 | imux->num_items++; |
df694daa KY |
11433 | } |
11434 | return 0; | |
11435 | } | |
11436 | ||
11437 | static struct snd_kcontrol_new alc861_capture_mixer[] = { | |
11438 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11439 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11440 | ||
11441 | { | |
11442 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11443 | /* The multiple "Capture Source" controls confuse alsamixer | |
11444 | * So call somewhat different.. | |
df694daa KY |
11445 | */ |
11446 | /* .name = "Capture Source", */ | |
11447 | .name = "Input Source", | |
11448 | .count = 1, | |
11449 | .info = alc_mux_enum_info, | |
11450 | .get = alc_mux_enum_get, | |
11451 | .put = alc_mux_enum_put, | |
11452 | }, | |
11453 | { } /* end */ | |
11454 | }; | |
11455 | ||
f12ab1e0 TI |
11456 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
11457 | hda_nid_t nid, | |
df694daa KY |
11458 | int pin_type, int dac_idx) |
11459 | { | |
11460 | /* set as output */ | |
11461 | ||
f12ab1e0 TI |
11462 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
11463 | pin_type); | |
11464 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
11465 | AMP_OUT_UNMUTE); | |
df694daa KY |
11466 | |
11467 | } | |
11468 | ||
11469 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
11470 | { | |
11471 | struct alc_spec *spec = codec->spec; | |
11472 | int i; | |
11473 | ||
bc9f98a9 | 11474 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
11475 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
11476 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 11477 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 11478 | if (nid) |
baba8ee9 | 11479 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 11480 | spec->multiout.dac_nids[i]); |
df694daa KY |
11481 | } |
11482 | } | |
11483 | ||
11484 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
11485 | { | |
11486 | struct alc_spec *spec = codec->spec; | |
11487 | hda_nid_t pin; | |
11488 | ||
eb06ed8f | 11489 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 11490 | if (pin) /* connect to front */ |
f12ab1e0 TI |
11491 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
11492 | spec->multiout.dac_nids[0]); | |
df694daa KY |
11493 | } |
11494 | ||
11495 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
11496 | { | |
11497 | struct alc_spec *spec = codec->spec; | |
11498 | int i; | |
11499 | ||
11500 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11501 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
11502 | if (nid >= 0x0c && nid <= 0x11) { |
11503 | snd_hda_codec_write(codec, nid, 0, | |
11504 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
11505 | i <= AUTO_PIN_FRONT_MIC ? | |
11506 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
11507 | } |
11508 | } | |
11509 | } | |
11510 | ||
11511 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
11512 | /* return 1 if successful, 0 if the proper config is not found, |
11513 | * or a negative error code | |
11514 | */ | |
df694daa KY |
11515 | static int alc861_parse_auto_config(struct hda_codec *codec) |
11516 | { | |
11517 | struct alc_spec *spec = codec->spec; | |
11518 | int err; | |
11519 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
11520 | ||
f12ab1e0 TI |
11521 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
11522 | alc861_ignore); | |
11523 | if (err < 0) | |
df694daa | 11524 | return err; |
f12ab1e0 | 11525 | if (!spec->autocfg.line_outs) |
df694daa KY |
11526 | return 0; /* can't find valid BIOS pin config */ |
11527 | ||
f12ab1e0 TI |
11528 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
11529 | if (err < 0) | |
11530 | return err; | |
11531 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11532 | if (err < 0) | |
11533 | return err; | |
11534 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
11535 | if (err < 0) | |
11536 | return err; | |
11537 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11538 | if (err < 0) | |
df694daa KY |
11539 | return err; |
11540 | ||
11541 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
11542 | ||
11543 | if (spec->autocfg.dig_out_pin) | |
11544 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
11545 | ||
11546 | if (spec->kctl_alloc) | |
11547 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
11548 | ||
11549 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; | |
11550 | ||
a1e8d2da | 11551 | spec->num_mux_defs = 1; |
df694daa KY |
11552 | spec->input_mux = &spec->private_imux; |
11553 | ||
11554 | spec->adc_nids = alc861_adc_nids; | |
11555 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
11556 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; | |
11557 | spec->num_mixers++; | |
11558 | ||
11559 | return 1; | |
11560 | } | |
11561 | ||
ae6b813a TI |
11562 | /* additional initialization for auto-configuration model */ |
11563 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 11564 | { |
df694daa KY |
11565 | alc861_auto_init_multi_out(codec); |
11566 | alc861_auto_init_hp_out(codec); | |
11567 | alc861_auto_init_analog_input(codec); | |
df694daa KY |
11568 | } |
11569 | ||
cb53c626 TI |
11570 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
11571 | static struct hda_amp_list alc861_loopbacks[] = { | |
11572 | { 0x15, HDA_INPUT, 0 }, | |
11573 | { 0x15, HDA_INPUT, 1 }, | |
11574 | { 0x15, HDA_INPUT, 2 }, | |
11575 | { 0x15, HDA_INPUT, 3 }, | |
11576 | { } /* end */ | |
11577 | }; | |
11578 | #endif | |
11579 | ||
df694daa KY |
11580 | |
11581 | /* | |
11582 | * configuration and preset | |
11583 | */ | |
f5fcc13c TI |
11584 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
11585 | [ALC861_3ST] = "3stack", | |
11586 | [ALC660_3ST] = "3stack-660", | |
11587 | [ALC861_3ST_DIG] = "3stack-dig", | |
11588 | [ALC861_6ST_DIG] = "6stack-dig", | |
11589 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
11590 | [ALC861_TOSHIBA] = "toshiba", | |
11591 | [ALC861_ASUS] = "asus", | |
11592 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
11593 | [ALC861_AUTO] = "auto", | |
11594 | }; | |
11595 | ||
11596 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 11597 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
11598 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
11599 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
11600 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), | |
ac3e3741 | 11601 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 11602 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 11603 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
11604 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
11605 | * Any other models that need this preset? | |
11606 | */ | |
11607 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
ac3e3741 TI |
11608 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
11609 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
4147dab6 | 11610 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
ac3e3741 TI |
11611 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
11612 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), | |
11613 | /* FIXME: the below seems conflict */ | |
11614 | /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ | |
07e038b3 | 11615 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 11616 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
11617 | {} |
11618 | }; | |
11619 | ||
11620 | static struct alc_config_preset alc861_presets[] = { | |
11621 | [ALC861_3ST] = { | |
11622 | .mixers = { alc861_3ST_mixer }, | |
11623 | .init_verbs = { alc861_threestack_init_verbs }, | |
11624 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
11625 | .dac_nids = alc861_dac_nids, | |
11626 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
11627 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 11628 | .need_dac_fix = 1, |
df694daa KY |
11629 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
11630 | .adc_nids = alc861_adc_nids, | |
11631 | .input_mux = &alc861_capture_source, | |
11632 | }, | |
11633 | [ALC861_3ST_DIG] = { | |
11634 | .mixers = { alc861_base_mixer }, | |
11635 | .init_verbs = { alc861_threestack_init_verbs }, | |
11636 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
11637 | .dac_nids = alc861_dac_nids, | |
11638 | .dig_out_nid = ALC861_DIGOUT_NID, | |
11639 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
11640 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 11641 | .need_dac_fix = 1, |
df694daa KY |
11642 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
11643 | .adc_nids = alc861_adc_nids, | |
11644 | .input_mux = &alc861_capture_source, | |
11645 | }, | |
11646 | [ALC861_6ST_DIG] = { | |
11647 | .mixers = { alc861_base_mixer }, | |
11648 | .init_verbs = { alc861_base_init_verbs }, | |
11649 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
11650 | .dac_nids = alc861_dac_nids, | |
11651 | .dig_out_nid = ALC861_DIGOUT_NID, | |
11652 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
11653 | .channel_mode = alc861_8ch_modes, | |
11654 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
11655 | .adc_nids = alc861_adc_nids, | |
11656 | .input_mux = &alc861_capture_source, | |
11657 | }, | |
9c7f852e TI |
11658 | [ALC660_3ST] = { |
11659 | .mixers = { alc861_3ST_mixer }, | |
11660 | .init_verbs = { alc861_threestack_init_verbs }, | |
11661 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
11662 | .dac_nids = alc660_dac_nids, | |
11663 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
11664 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 11665 | .need_dac_fix = 1, |
9c7f852e TI |
11666 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
11667 | .adc_nids = alc861_adc_nids, | |
11668 | .input_mux = &alc861_capture_source, | |
11669 | }, | |
22309c3e TI |
11670 | [ALC861_UNIWILL_M31] = { |
11671 | .mixers = { alc861_uniwill_m31_mixer }, | |
11672 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
11673 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
11674 | .dac_nids = alc861_dac_nids, | |
11675 | .dig_out_nid = ALC861_DIGOUT_NID, | |
11676 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
11677 | .channel_mode = alc861_uniwill_m31_modes, | |
11678 | .need_dac_fix = 1, | |
11679 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
11680 | .adc_nids = alc861_adc_nids, | |
11681 | .input_mux = &alc861_capture_source, | |
11682 | }, | |
a53d1aec TD |
11683 | [ALC861_TOSHIBA] = { |
11684 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
11685 | .init_verbs = { alc861_base_init_verbs, |
11686 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
11687 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
11688 | .dac_nids = alc861_dac_nids, | |
11689 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
11690 | .channel_mode = alc883_3ST_2ch_modes, | |
11691 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
11692 | .adc_nids = alc861_adc_nids, | |
11693 | .input_mux = &alc861_capture_source, | |
11694 | .unsol_event = alc861_toshiba_unsol_event, | |
11695 | .init_hook = alc861_toshiba_automute, | |
11696 | }, | |
7cdbff94 MD |
11697 | [ALC861_ASUS] = { |
11698 | .mixers = { alc861_asus_mixer }, | |
11699 | .init_verbs = { alc861_asus_init_verbs }, | |
11700 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
11701 | .dac_nids = alc861_dac_nids, | |
11702 | .dig_out_nid = ALC861_DIGOUT_NID, | |
11703 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
11704 | .channel_mode = alc861_asus_modes, | |
11705 | .need_dac_fix = 1, | |
11706 | .hp_nid = 0x06, | |
11707 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
11708 | .adc_nids = alc861_adc_nids, | |
11709 | .input_mux = &alc861_capture_source, | |
11710 | }, | |
56bb0cab TI |
11711 | [ALC861_ASUS_LAPTOP] = { |
11712 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
11713 | .init_verbs = { alc861_asus_init_verbs, | |
11714 | alc861_asus_laptop_init_verbs }, | |
11715 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
11716 | .dac_nids = alc861_dac_nids, | |
11717 | .dig_out_nid = ALC861_DIGOUT_NID, | |
11718 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
11719 | .channel_mode = alc883_3ST_2ch_modes, | |
11720 | .need_dac_fix = 1, | |
11721 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
11722 | .adc_nids = alc861_adc_nids, | |
11723 | .input_mux = &alc861_capture_source, | |
11724 | }, | |
11725 | }; | |
df694daa KY |
11726 | |
11727 | ||
11728 | static int patch_alc861(struct hda_codec *codec) | |
11729 | { | |
11730 | struct alc_spec *spec; | |
11731 | int board_config; | |
11732 | int err; | |
11733 | ||
dc041e0b | 11734 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
11735 | if (spec == NULL) |
11736 | return -ENOMEM; | |
11737 | ||
f12ab1e0 | 11738 | codec->spec = spec; |
df694daa | 11739 | |
f5fcc13c TI |
11740 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
11741 | alc861_models, | |
11742 | alc861_cfg_tbl); | |
9c7f852e | 11743 | |
f5fcc13c | 11744 | if (board_config < 0) { |
9c7f852e TI |
11745 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
11746 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
11747 | board_config = ALC861_AUTO; |
11748 | } | |
11749 | ||
11750 | if (board_config == ALC861_AUTO) { | |
11751 | /* automatic parse from the BIOS config */ | |
11752 | err = alc861_parse_auto_config(codec); | |
11753 | if (err < 0) { | |
11754 | alc_free(codec); | |
11755 | return err; | |
f12ab1e0 | 11756 | } else if (!err) { |
9c7f852e TI |
11757 | printk(KERN_INFO |
11758 | "hda_codec: Cannot set up configuration " | |
11759 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
11760 | board_config = ALC861_3ST_DIG; |
11761 | } | |
11762 | } | |
11763 | ||
11764 | if (board_config != ALC861_AUTO) | |
11765 | setup_preset(spec, &alc861_presets[board_config]); | |
11766 | ||
11767 | spec->stream_name_analog = "ALC861 Analog"; | |
11768 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
11769 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
11770 | ||
11771 | spec->stream_name_digital = "ALC861 Digital"; | |
11772 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
11773 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
11774 | ||
2134ea4f TI |
11775 | spec->vmaster_nid = 0x03; |
11776 | ||
df694daa KY |
11777 | codec->patch_ops = alc_patch_ops; |
11778 | if (board_config == ALC861_AUTO) | |
ae6b813a | 11779 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
11780 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
11781 | if (!spec->loopback.amplist) | |
11782 | spec->loopback.amplist = alc861_loopbacks; | |
11783 | #endif | |
df694daa | 11784 | |
1da177e4 LT |
11785 | return 0; |
11786 | } | |
11787 | ||
f32610ed JS |
11788 | /* |
11789 | * ALC861-VD support | |
11790 | * | |
11791 | * Based on ALC882 | |
11792 | * | |
11793 | * In addition, an independent DAC | |
11794 | */ | |
11795 | #define ALC861VD_DIGOUT_NID 0x06 | |
11796 | ||
11797 | static hda_nid_t alc861vd_dac_nids[4] = { | |
11798 | /* front, surr, clfe, side surr */ | |
11799 | 0x02, 0x03, 0x04, 0x05 | |
11800 | }; | |
11801 | ||
11802 | /* dac_nids for ALC660vd are in a different order - according to | |
11803 | * Realtek's driver. | |
11804 | * This should probably tesult in a different mixer for 6stack models | |
11805 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
11806 | * - and it is the same as in 861vd. | |
11807 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
11808 | */ | |
11809 | static hda_nid_t alc660vd_dac_nids[3] = { | |
11810 | /* front, rear, clfe, rear_surr */ | |
11811 | 0x02, 0x04, 0x03 | |
11812 | }; | |
11813 | ||
11814 | static hda_nid_t alc861vd_adc_nids[1] = { | |
11815 | /* ADC0 */ | |
11816 | 0x09, | |
11817 | }; | |
11818 | ||
11819 | /* input MUX */ | |
11820 | /* FIXME: should be a matrix-type input source selection */ | |
11821 | static struct hda_input_mux alc861vd_capture_source = { | |
11822 | .num_items = 4, | |
11823 | .items = { | |
11824 | { "Mic", 0x0 }, | |
11825 | { "Front Mic", 0x1 }, | |
11826 | { "Line", 0x2 }, | |
11827 | { "CD", 0x4 }, | |
11828 | }, | |
11829 | }; | |
11830 | ||
272a527c KY |
11831 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
11832 | .num_items = 3, | |
11833 | .items = { | |
11834 | { "Front Mic", 0x0 }, | |
11835 | { "ATAPI Mic", 0x1 }, | |
11836 | { "Line In", 0x5 }, | |
11837 | }, | |
11838 | }; | |
11839 | ||
d1a991a6 KY |
11840 | static struct hda_input_mux alc861vd_hp_capture_source = { |
11841 | .num_items = 2, | |
11842 | .items = { | |
11843 | { "Front Mic", 0x0 }, | |
11844 | { "ATAPI Mic", 0x1 }, | |
11845 | }, | |
11846 | }; | |
11847 | ||
f32610ed JS |
11848 | #define alc861vd_mux_enum_info alc_mux_enum_info |
11849 | #define alc861vd_mux_enum_get alc_mux_enum_get | |
11850 | ||
11851 | static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol, | |
11852 | struct snd_ctl_elem_value *ucontrol) | |
11853 | { | |
11854 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
11855 | struct alc_spec *spec = codec->spec; | |
11856 | const struct hda_input_mux *imux = spec->input_mux; | |
11857 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
11858 | static hda_nid_t capture_mixers[1] = { 0x22 }; | |
11859 | hda_nid_t nid = capture_mixers[adc_idx]; | |
11860 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
11861 | unsigned int i, idx; | |
11862 | ||
11863 | idx = ucontrol->value.enumerated.item[0]; | |
11864 | if (idx >= imux->num_items) | |
11865 | idx = imux->num_items - 1; | |
82beb8fd | 11866 | if (*cur_val == idx) |
f32610ed JS |
11867 | return 0; |
11868 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
11869 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
11870 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
11871 | imux->items[i].index, | |
11872 | HDA_AMP_MUTE, v); | |
f32610ed JS |
11873 | } |
11874 | *cur_val = idx; | |
11875 | return 1; | |
11876 | } | |
11877 | ||
11878 | /* | |
11879 | * 2ch mode | |
11880 | */ | |
11881 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
11882 | { 2, NULL } | |
11883 | }; | |
11884 | ||
11885 | /* | |
11886 | * 6ch mode | |
11887 | */ | |
11888 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
11889 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11890 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11891 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11892 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11893 | { } /* end */ | |
11894 | }; | |
11895 | ||
11896 | /* | |
11897 | * 8ch mode | |
11898 | */ | |
11899 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
11900 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11901 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11902 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11903 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11904 | { } /* end */ | |
11905 | }; | |
11906 | ||
11907 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
11908 | { 6, alc861vd_6stack_ch6_init }, | |
11909 | { 8, alc861vd_6stack_ch8_init }, | |
11910 | }; | |
11911 | ||
11912 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
11913 | { | |
11914 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11915 | .name = "Channel Mode", | |
11916 | .info = alc_ch_mode_info, | |
11917 | .get = alc_ch_mode_get, | |
11918 | .put = alc_ch_mode_put, | |
11919 | }, | |
11920 | { } /* end */ | |
11921 | }; | |
11922 | ||
11923 | static struct snd_kcontrol_new alc861vd_capture_mixer[] = { | |
11924 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11925 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11926 | ||
11927 | { | |
11928 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11929 | /* The multiple "Capture Source" controls confuse alsamixer | |
11930 | * So call somewhat different.. | |
f32610ed JS |
11931 | */ |
11932 | /* .name = "Capture Source", */ | |
11933 | .name = "Input Source", | |
11934 | .count = 1, | |
11935 | .info = alc861vd_mux_enum_info, | |
11936 | .get = alc861vd_mux_enum_get, | |
11937 | .put = alc861vd_mux_enum_put, | |
11938 | }, | |
11939 | { } /* end */ | |
11940 | }; | |
11941 | ||
11942 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
11943 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
11944 | */ | |
11945 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
11946 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11947 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
11948 | ||
11949 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11950 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
11951 | ||
11952 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
11953 | HDA_OUTPUT), | |
11954 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
11955 | HDA_OUTPUT), | |
11956 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
11957 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
11958 | ||
11959 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
11960 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
11961 | ||
11962 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11963 | ||
11964 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11965 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11966 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11967 | ||
11968 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
11969 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11970 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11971 | ||
11972 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11973 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11974 | ||
11975 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
11976 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
11977 | ||
11978 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
11979 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
11980 | ||
11981 | { } /* end */ | |
11982 | }; | |
11983 | ||
11984 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
11985 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11986 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
11987 | ||
11988 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11989 | ||
11990 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11991 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11992 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11993 | ||
11994 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
11995 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11996 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11997 | ||
11998 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11999 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
12000 | ||
12001 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12002 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12003 | ||
12004 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
12005 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
12006 | ||
12007 | { } /* end */ | |
12008 | }; | |
12009 | ||
bdd148a3 KY |
12010 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
12011 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12012 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
12013 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12014 | ||
12015 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
12016 | ||
12017 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12018 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12019 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12020 | ||
12021 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
12022 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12023 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12024 | ||
12025 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12026 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12027 | ||
12028 | { } /* end */ | |
12029 | }; | |
12030 | ||
272a527c KY |
12031 | /* Pin assignment: Front=0x14, HP = 0x15, |
12032 | * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d | |
12033 | */ | |
12034 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
12035 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12036 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
12037 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
12038 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
12039 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12040 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12041 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12042 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12043 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
12044 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
272a527c KY |
12045 | { } /* end */ |
12046 | }; | |
12047 | ||
d1a991a6 KY |
12048 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
12049 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
12050 | */ | |
12051 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
12052 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12053 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
12054 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
12055 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
12056 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12057 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12058 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12059 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12060 | ||
12061 | { } /* end */ | |
12062 | }; | |
12063 | ||
f32610ed JS |
12064 | /* |
12065 | * generic initialization of ADC, input mixers and output mixers | |
12066 | */ | |
12067 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
12068 | /* | |
12069 | * Unmute ADC0 and set the default input to mic-in | |
12070 | */ | |
12071 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12072 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12073 | ||
12074 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
12075 | * the analog-loopback mixer widget | |
12076 | */ | |
12077 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
12078 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
12079 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12080 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12081 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12082 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
12083 | |
12084 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
12085 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
12086 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12087 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 12088 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
12089 | |
12090 | /* | |
12091 | * Set up output mixers (0x02 - 0x05) | |
12092 | */ | |
12093 | /* set vol=0 to output mixers */ | |
12094 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12095 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12096 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12097 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12098 | ||
12099 | /* set up input amps for analog loopback */ | |
12100 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
12101 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12102 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12103 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12104 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12105 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12106 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12107 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12108 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12109 | ||
12110 | { } | |
12111 | }; | |
12112 | ||
12113 | /* | |
12114 | * 3-stack pin configuration: | |
12115 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
12116 | */ | |
12117 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
12118 | /* | |
12119 | * Set pin mode and muting | |
12120 | */ | |
12121 | /* set front pin widgets 0x14 for output */ | |
12122 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12123 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12124 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12125 | ||
12126 | /* Mic (rear) pin: input vref at 80% */ | |
12127 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12128 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12129 | /* Front Mic pin: input vref at 80% */ | |
12130 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12131 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12132 | /* Line In pin: input */ | |
12133 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12134 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12135 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
12136 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12137 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12138 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12139 | /* CD pin widget for input */ | |
12140 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12141 | ||
12142 | { } | |
12143 | }; | |
12144 | ||
12145 | /* | |
12146 | * 6-stack pin configuration: | |
12147 | */ | |
12148 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
12149 | /* | |
12150 | * Set pin mode and muting | |
12151 | */ | |
12152 | /* set front pin widgets 0x14 for output */ | |
12153 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12154 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12155 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12156 | ||
12157 | /* Rear Pin: output 1 (0x0d) */ | |
12158 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12159 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12160 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12161 | /* CLFE Pin: output 2 (0x0e) */ | |
12162 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12163 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12164 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
12165 | /* Side Pin: output 3 (0x0f) */ | |
12166 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12167 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12168 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
12169 | ||
12170 | /* Mic (rear) pin: input vref at 80% */ | |
12171 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12172 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12173 | /* Front Mic pin: input vref at 80% */ | |
12174 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12175 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12176 | /* Line In pin: input */ | |
12177 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12178 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12179 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
12180 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12181 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12182 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12183 | /* CD pin widget for input */ | |
12184 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12185 | ||
12186 | { } | |
12187 | }; | |
12188 | ||
bdd148a3 KY |
12189 | static struct hda_verb alc861vd_eapd_verbs[] = { |
12190 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
12191 | { } | |
12192 | }; | |
12193 | ||
12194 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { | |
12195 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12196 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12197 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
12198 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12199 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12200 | {} | |
12201 | }; | |
12202 | ||
12203 | /* toggle speaker-output according to the hp-jack state */ | |
12204 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
12205 | { | |
12206 | unsigned int present; | |
12207 | unsigned char bits; | |
12208 | ||
12209 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
12210 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
12211 | bits = present ? HDA_AMP_MUTE : 0; |
12212 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
12213 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
12214 | } |
12215 | ||
12216 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
12217 | { | |
12218 | unsigned int present; | |
12219 | unsigned char bits; | |
12220 | ||
12221 | present = snd_hda_codec_read(codec, 0x18, 0, | |
12222 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
12223 | bits = present ? HDA_AMP_MUTE : 0; |
12224 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
12225 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
12226 | } |
12227 | ||
12228 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
12229 | { | |
12230 | alc861vd_lenovo_hp_automute(codec); | |
12231 | alc861vd_lenovo_mic_automute(codec); | |
12232 | } | |
12233 | ||
12234 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
12235 | unsigned int res) | |
12236 | { | |
12237 | switch (res >> 26) { | |
12238 | case ALC880_HP_EVENT: | |
12239 | alc861vd_lenovo_hp_automute(codec); | |
12240 | break; | |
12241 | case ALC880_MIC_EVENT: | |
12242 | alc861vd_lenovo_mic_automute(codec); | |
12243 | break; | |
12244 | } | |
12245 | } | |
12246 | ||
272a527c KY |
12247 | static struct hda_verb alc861vd_dallas_verbs[] = { |
12248 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12249 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12250 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12251 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12252 | ||
12253 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12254 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12255 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12256 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12257 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12258 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12259 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12260 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12261 | ||
12262 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12263 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12264 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12265 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12266 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12267 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12268 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12269 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12270 | ||
12271 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
12272 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12273 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
12274 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12275 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12276 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12277 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12278 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12279 | ||
12280 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12281 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12282 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12283 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
12284 | ||
12285 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12286 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12287 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12288 | ||
12289 | { } /* end */ | |
12290 | }; | |
12291 | ||
12292 | /* toggle speaker-output according to the hp-jack state */ | |
12293 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
12294 | { | |
12295 | unsigned int present; | |
12296 | ||
12297 | present = snd_hda_codec_read(codec, 0x15, 0, | |
12298 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
12299 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
12300 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
12301 | } |
12302 | ||
12303 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
12304 | { | |
12305 | if ((res >> 26) == ALC880_HP_EVENT) | |
12306 | alc861vd_dallas_automute(codec); | |
12307 | } | |
12308 | ||
cb53c626 TI |
12309 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
12310 | #define alc861vd_loopbacks alc880_loopbacks | |
12311 | #endif | |
12312 | ||
f32610ed JS |
12313 | /* pcm configuration: identiacal with ALC880 */ |
12314 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
12315 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
12316 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
12317 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
12318 | ||
12319 | /* | |
12320 | * configuration and preset | |
12321 | */ | |
12322 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
12323 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 12324 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
f32610ed JS |
12325 | [ALC861VD_3ST] = "3stack", |
12326 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
12327 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 12328 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 12329 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 12330 | [ALC861VD_HP] = "hp", |
f32610ed JS |
12331 | [ALC861VD_AUTO] = "auto", |
12332 | }; | |
12333 | ||
12334 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
ac3e3741 TI |
12335 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), |
12336 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), | |
07e038b3 | 12337 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 12338 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
6963f84c | 12339 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed | 12340 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
ac3e3741 | 12341 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
38baf5ad | 12342 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 12343 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
542d7c66 | 12344 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
39c5d41f | 12345 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
ac3e3741 TI |
12346 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), |
12347 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), | |
625dc0bf | 12348 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
f32610ed JS |
12349 | {} |
12350 | }; | |
12351 | ||
12352 | static struct alc_config_preset alc861vd_presets[] = { | |
12353 | [ALC660VD_3ST] = { | |
12354 | .mixers = { alc861vd_3st_mixer }, | |
12355 | .init_verbs = { alc861vd_volume_init_verbs, | |
12356 | alc861vd_3stack_init_verbs }, | |
12357 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
12358 | .dac_nids = alc660vd_dac_nids, | |
12359 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
12360 | .adc_nids = alc861vd_adc_nids, | |
12361 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
12362 | .channel_mode = alc861vd_3stack_2ch_modes, | |
12363 | .input_mux = &alc861vd_capture_source, | |
12364 | }, | |
6963f84c MC |
12365 | [ALC660VD_3ST_DIG] = { |
12366 | .mixers = { alc861vd_3st_mixer }, | |
12367 | .init_verbs = { alc861vd_volume_init_verbs, | |
12368 | alc861vd_3stack_init_verbs }, | |
12369 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
12370 | .dac_nids = alc660vd_dac_nids, | |
12371 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
12372 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
12373 | .adc_nids = alc861vd_adc_nids, | |
12374 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
12375 | .channel_mode = alc861vd_3stack_2ch_modes, | |
12376 | .input_mux = &alc861vd_capture_source, | |
12377 | }, | |
f32610ed JS |
12378 | [ALC861VD_3ST] = { |
12379 | .mixers = { alc861vd_3st_mixer }, | |
12380 | .init_verbs = { alc861vd_volume_init_verbs, | |
12381 | alc861vd_3stack_init_verbs }, | |
12382 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
12383 | .dac_nids = alc861vd_dac_nids, | |
12384 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
12385 | .channel_mode = alc861vd_3stack_2ch_modes, | |
12386 | .input_mux = &alc861vd_capture_source, | |
12387 | }, | |
12388 | [ALC861VD_3ST_DIG] = { | |
12389 | .mixers = { alc861vd_3st_mixer }, | |
12390 | .init_verbs = { alc861vd_volume_init_verbs, | |
12391 | alc861vd_3stack_init_verbs }, | |
12392 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
12393 | .dac_nids = alc861vd_dac_nids, | |
12394 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
12395 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
12396 | .channel_mode = alc861vd_3stack_2ch_modes, | |
12397 | .input_mux = &alc861vd_capture_source, | |
12398 | }, | |
12399 | [ALC861VD_6ST_DIG] = { | |
12400 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
12401 | .init_verbs = { alc861vd_volume_init_verbs, | |
12402 | alc861vd_6stack_init_verbs }, | |
12403 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
12404 | .dac_nids = alc861vd_dac_nids, | |
12405 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
12406 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
12407 | .channel_mode = alc861vd_6stack_modes, | |
12408 | .input_mux = &alc861vd_capture_source, | |
12409 | }, | |
bdd148a3 KY |
12410 | [ALC861VD_LENOVO] = { |
12411 | .mixers = { alc861vd_lenovo_mixer }, | |
12412 | .init_verbs = { alc861vd_volume_init_verbs, | |
12413 | alc861vd_3stack_init_verbs, | |
12414 | alc861vd_eapd_verbs, | |
12415 | alc861vd_lenovo_unsol_verbs }, | |
12416 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
12417 | .dac_nids = alc660vd_dac_nids, | |
12418 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
12419 | .adc_nids = alc861vd_adc_nids, | |
12420 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
12421 | .channel_mode = alc861vd_3stack_2ch_modes, | |
12422 | .input_mux = &alc861vd_capture_source, | |
12423 | .unsol_event = alc861vd_lenovo_unsol_event, | |
12424 | .init_hook = alc861vd_lenovo_automute, | |
12425 | }, | |
272a527c KY |
12426 | [ALC861VD_DALLAS] = { |
12427 | .mixers = { alc861vd_dallas_mixer }, | |
12428 | .init_verbs = { alc861vd_dallas_verbs }, | |
12429 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
12430 | .dac_nids = alc861vd_dac_nids, | |
12431 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
12432 | .adc_nids = alc861vd_adc_nids, | |
12433 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
12434 | .channel_mode = alc861vd_3stack_2ch_modes, | |
12435 | .input_mux = &alc861vd_dallas_capture_source, | |
12436 | .unsol_event = alc861vd_dallas_unsol_event, | |
12437 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
12438 | }, |
12439 | [ALC861VD_HP] = { | |
12440 | .mixers = { alc861vd_hp_mixer }, | |
12441 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
12442 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
12443 | .dac_nids = alc861vd_dac_nids, | |
12444 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
12445 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
12446 | .adc_nids = alc861vd_adc_nids, | |
12447 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
12448 | .channel_mode = alc861vd_3stack_2ch_modes, | |
12449 | .input_mux = &alc861vd_hp_capture_source, | |
12450 | .unsol_event = alc861vd_dallas_unsol_event, | |
12451 | .init_hook = alc861vd_dallas_automute, | |
12452 | }, | |
f32610ed JS |
12453 | }; |
12454 | ||
12455 | /* | |
12456 | * BIOS auto configuration | |
12457 | */ | |
12458 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
12459 | hda_nid_t nid, int pin_type, int dac_idx) | |
12460 | { | |
12461 | /* set as output */ | |
12462 | snd_hda_codec_write(codec, nid, 0, | |
12463 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
12464 | snd_hda_codec_write(codec, nid, 0, | |
12465 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
12466 | } | |
12467 | ||
12468 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
12469 | { | |
12470 | struct alc_spec *spec = codec->spec; | |
12471 | int i; | |
12472 | ||
bc9f98a9 | 12473 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
12474 | for (i = 0; i <= HDA_SIDE; i++) { |
12475 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 12476 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
12477 | if (nid) |
12478 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 12479 | pin_type, i); |
f32610ed JS |
12480 | } |
12481 | } | |
12482 | ||
12483 | ||
12484 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
12485 | { | |
12486 | struct alc_spec *spec = codec->spec; | |
12487 | hda_nid_t pin; | |
12488 | ||
12489 | pin = spec->autocfg.hp_pins[0]; | |
12490 | if (pin) /* connect to front and use dac 0 */ | |
12491 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
12492 | } | |
12493 | ||
12494 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
12495 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
12496 | ||
12497 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
12498 | { | |
12499 | struct alc_spec *spec = codec->spec; | |
12500 | int i; | |
12501 | ||
12502 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
12503 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
12504 | if (alc861vd_is_input_pin(nid)) { | |
12505 | snd_hda_codec_write(codec, nid, 0, | |
12506 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
12507 | i <= AUTO_PIN_FRONT_MIC ? | |
12508 | PIN_VREF80 : PIN_IN); | |
12509 | if (nid != ALC861VD_PIN_CD_NID) | |
12510 | snd_hda_codec_write(codec, nid, 0, | |
12511 | AC_VERB_SET_AMP_GAIN_MUTE, | |
12512 | AMP_OUT_MUTE); | |
12513 | } | |
12514 | } | |
12515 | } | |
12516 | ||
12517 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) | |
12518 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
12519 | ||
12520 | /* add playback controls from the parsed DAC table */ | |
12521 | /* Based on ALC880 version. But ALC861VD has separate, | |
12522 | * different NIDs for mute/unmute switch and volume control */ | |
12523 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
12524 | const struct auto_pin_cfg *cfg) | |
12525 | { | |
12526 | char name[32]; | |
12527 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
12528 | hda_nid_t nid_v, nid_s; | |
12529 | int i, err; | |
12530 | ||
12531 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 12532 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
12533 | continue; |
12534 | nid_v = alc861vd_idx_to_mixer_vol( | |
12535 | alc880_dac_to_idx( | |
12536 | spec->multiout.dac_nids[i])); | |
12537 | nid_s = alc861vd_idx_to_mixer_switch( | |
12538 | alc880_dac_to_idx( | |
12539 | spec->multiout.dac_nids[i])); | |
12540 | ||
12541 | if (i == 2) { | |
12542 | /* Center/LFE */ | |
f12ab1e0 TI |
12543 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
12544 | "Center Playback Volume", | |
12545 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
12546 | HDA_OUTPUT)); | |
12547 | if (err < 0) | |
f32610ed | 12548 | return err; |
f12ab1e0 TI |
12549 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
12550 | "LFE Playback Volume", | |
12551 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
12552 | HDA_OUTPUT)); | |
12553 | if (err < 0) | |
f32610ed | 12554 | return err; |
f12ab1e0 TI |
12555 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
12556 | "Center Playback Switch", | |
12557 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
12558 | HDA_INPUT)); | |
12559 | if (err < 0) | |
f32610ed | 12560 | return err; |
f12ab1e0 TI |
12561 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
12562 | "LFE Playback Switch", | |
12563 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
12564 | HDA_INPUT)); | |
12565 | if (err < 0) | |
f32610ed JS |
12566 | return err; |
12567 | } else { | |
12568 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
12569 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
12570 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
12571 | HDA_OUTPUT)); | |
12572 | if (err < 0) | |
f32610ed JS |
12573 | return err; |
12574 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 12575 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 12576 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
12577 | HDA_INPUT)); |
12578 | if (err < 0) | |
f32610ed JS |
12579 | return err; |
12580 | } | |
12581 | } | |
12582 | return 0; | |
12583 | } | |
12584 | ||
12585 | /* add playback controls for speaker and HP outputs */ | |
12586 | /* Based on ALC880 version. But ALC861VD has separate, | |
12587 | * different NIDs for mute/unmute switch and volume control */ | |
12588 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
12589 | hda_nid_t pin, const char *pfx) | |
12590 | { | |
12591 | hda_nid_t nid_v, nid_s; | |
12592 | int err; | |
12593 | char name[32]; | |
12594 | ||
f12ab1e0 | 12595 | if (!pin) |
f32610ed JS |
12596 | return 0; |
12597 | ||
12598 | if (alc880_is_fixed_pin(pin)) { | |
12599 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
12600 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 12601 | if (!spec->multiout.hp_nid) |
f32610ed JS |
12602 | spec->multiout.hp_nid = nid_v; |
12603 | else | |
12604 | spec->multiout.extra_out_nid[0] = nid_v; | |
12605 | /* control HP volume/switch on the output mixer amp */ | |
12606 | nid_v = alc861vd_idx_to_mixer_vol( | |
12607 | alc880_fixed_pin_idx(pin)); | |
12608 | nid_s = alc861vd_idx_to_mixer_switch( | |
12609 | alc880_fixed_pin_idx(pin)); | |
12610 | ||
12611 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
12612 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
12613 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
12614 | if (err < 0) | |
f32610ed JS |
12615 | return err; |
12616 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
12617 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
12618 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
12619 | if (err < 0) | |
f32610ed JS |
12620 | return err; |
12621 | } else if (alc880_is_multi_pin(pin)) { | |
12622 | /* set manual connection */ | |
12623 | /* we have only a switch on HP-out PIN */ | |
12624 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
12625 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
12626 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
12627 | if (err < 0) | |
f32610ed JS |
12628 | return err; |
12629 | } | |
12630 | return 0; | |
12631 | } | |
12632 | ||
12633 | /* parse the BIOS configuration and set up the alc_spec | |
12634 | * return 1 if successful, 0 if the proper config is not found, | |
12635 | * or a negative error code | |
12636 | * Based on ALC880 version - had to change it to override | |
12637 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
12638 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
12639 | { | |
12640 | struct alc_spec *spec = codec->spec; | |
12641 | int err; | |
12642 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
12643 | ||
f12ab1e0 TI |
12644 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
12645 | alc861vd_ignore); | |
12646 | if (err < 0) | |
f32610ed | 12647 | return err; |
f12ab1e0 | 12648 | if (!spec->autocfg.line_outs) |
f32610ed JS |
12649 | return 0; /* can't find valid BIOS pin config */ |
12650 | ||
f12ab1e0 TI |
12651 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
12652 | if (err < 0) | |
12653 | return err; | |
12654 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
12655 | if (err < 0) | |
12656 | return err; | |
12657 | err = alc861vd_auto_create_extra_out(spec, | |
12658 | spec->autocfg.speaker_pins[0], | |
12659 | "Speaker"); | |
12660 | if (err < 0) | |
12661 | return err; | |
12662 | err = alc861vd_auto_create_extra_out(spec, | |
12663 | spec->autocfg.hp_pins[0], | |
12664 | "Headphone"); | |
12665 | if (err < 0) | |
12666 | return err; | |
12667 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
12668 | if (err < 0) | |
f32610ed JS |
12669 | return err; |
12670 | ||
12671 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
12672 | ||
12673 | if (spec->autocfg.dig_out_pin) | |
12674 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
12675 | ||
12676 | if (spec->kctl_alloc) | |
12677 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
12678 | ||
12679 | spec->init_verbs[spec->num_init_verbs++] | |
12680 | = alc861vd_volume_init_verbs; | |
12681 | ||
12682 | spec->num_mux_defs = 1; | |
12683 | spec->input_mux = &spec->private_imux; | |
12684 | ||
776e184e TI |
12685 | err = alc_auto_add_mic_boost(codec); |
12686 | if (err < 0) | |
12687 | return err; | |
12688 | ||
f32610ed JS |
12689 | return 1; |
12690 | } | |
12691 | ||
12692 | /* additional initialization for auto-configuration model */ | |
12693 | static void alc861vd_auto_init(struct hda_codec *codec) | |
12694 | { | |
12695 | alc861vd_auto_init_multi_out(codec); | |
12696 | alc861vd_auto_init_hp_out(codec); | |
12697 | alc861vd_auto_init_analog_input(codec); | |
12698 | } | |
12699 | ||
12700 | static int patch_alc861vd(struct hda_codec *codec) | |
12701 | { | |
12702 | struct alc_spec *spec; | |
12703 | int err, board_config; | |
12704 | ||
12705 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
12706 | if (spec == NULL) | |
12707 | return -ENOMEM; | |
12708 | ||
12709 | codec->spec = spec; | |
12710 | ||
12711 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
12712 | alc861vd_models, | |
12713 | alc861vd_cfg_tbl); | |
12714 | ||
12715 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
12716 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
12717 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
12718 | board_config = ALC861VD_AUTO; | |
12719 | } | |
12720 | ||
12721 | if (board_config == ALC861VD_AUTO) { | |
12722 | /* automatic parse from the BIOS config */ | |
12723 | err = alc861vd_parse_auto_config(codec); | |
12724 | if (err < 0) { | |
12725 | alc_free(codec); | |
12726 | return err; | |
f12ab1e0 | 12727 | } else if (!err) { |
f32610ed JS |
12728 | printk(KERN_INFO |
12729 | "hda_codec: Cannot set up configuration " | |
12730 | "from BIOS. Using base mode...\n"); | |
12731 | board_config = ALC861VD_3ST; | |
12732 | } | |
12733 | } | |
12734 | ||
12735 | if (board_config != ALC861VD_AUTO) | |
12736 | setup_preset(spec, &alc861vd_presets[board_config]); | |
12737 | ||
12738 | spec->stream_name_analog = "ALC861VD Analog"; | |
12739 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; | |
12740 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
12741 | ||
12742 | spec->stream_name_digital = "ALC861VD Digital"; | |
12743 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; | |
12744 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
12745 | ||
12746 | spec->adc_nids = alc861vd_adc_nids; | |
12747 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
12748 | ||
12749 | spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; | |
12750 | spec->num_mixers++; | |
12751 | ||
2134ea4f TI |
12752 | spec->vmaster_nid = 0x02; |
12753 | ||
f32610ed JS |
12754 | codec->patch_ops = alc_patch_ops; |
12755 | ||
12756 | if (board_config == ALC861VD_AUTO) | |
12757 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
12758 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
12759 | if (!spec->loopback.amplist) | |
12760 | spec->loopback.amplist = alc861vd_loopbacks; | |
12761 | #endif | |
f32610ed JS |
12762 | |
12763 | return 0; | |
12764 | } | |
12765 | ||
bc9f98a9 KY |
12766 | /* |
12767 | * ALC662 support | |
12768 | * | |
12769 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
12770 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
12771 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
12772 | * 6-channel independent captures. | |
12773 | * | |
12774 | * In addition, an independent DAC for the multi-playback (not used in this | |
12775 | * driver yet). | |
12776 | */ | |
12777 | #define ALC662_DIGOUT_NID 0x06 | |
12778 | #define ALC662_DIGIN_NID 0x0a | |
12779 | ||
12780 | static hda_nid_t alc662_dac_nids[4] = { | |
12781 | /* front, rear, clfe, rear_surr */ | |
12782 | 0x02, 0x03, 0x04 | |
12783 | }; | |
12784 | ||
12785 | static hda_nid_t alc662_adc_nids[1] = { | |
12786 | /* ADC1-2 */ | |
12787 | 0x09, | |
12788 | }; | |
12789 | /* input MUX */ | |
12790 | /* FIXME: should be a matrix-type input source selection */ | |
12791 | ||
12792 | static struct hda_input_mux alc662_capture_source = { | |
12793 | .num_items = 4, | |
12794 | .items = { | |
12795 | { "Mic", 0x0 }, | |
12796 | { "Front Mic", 0x1 }, | |
12797 | { "Line", 0x2 }, | |
12798 | { "CD", 0x4 }, | |
12799 | }, | |
12800 | }; | |
12801 | ||
12802 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
12803 | .num_items = 2, | |
12804 | .items = { | |
12805 | { "Mic", 0x1 }, | |
12806 | { "Line", 0x2 }, | |
12807 | }, | |
12808 | }; | |
291702f0 KY |
12809 | |
12810 | static struct hda_input_mux alc662_eeepc_capture_source = { | |
12811 | .num_items = 2, | |
12812 | .items = { | |
12813 | { "i-Mic", 0x1 }, | |
12814 | { "e-Mic", 0x0 }, | |
12815 | }, | |
12816 | }; | |
12817 | ||
bc9f98a9 KY |
12818 | #define alc662_mux_enum_info alc_mux_enum_info |
12819 | #define alc662_mux_enum_get alc_mux_enum_get | |
12820 | ||
12821 | static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol, | |
12822 | struct snd_ctl_elem_value *ucontrol) | |
12823 | { | |
12824 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
12825 | struct alc_spec *spec = codec->spec; | |
12826 | const struct hda_input_mux *imux = spec->input_mux; | |
12827 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
d1a991a6 | 12828 | static hda_nid_t capture_mixers[2] = { 0x23, 0x22 }; |
bc9f98a9 KY |
12829 | hda_nid_t nid = capture_mixers[adc_idx]; |
12830 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
12831 | unsigned int i, idx; | |
12832 | ||
12833 | idx = ucontrol->value.enumerated.item[0]; | |
12834 | if (idx >= imux->num_items) | |
12835 | idx = imux->num_items - 1; | |
82beb8fd | 12836 | if (*cur_val == idx) |
bc9f98a9 KY |
12837 | return 0; |
12838 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
12839 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
12840 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
12841 | imux->items[i].index, | |
12842 | HDA_AMP_MUTE, v); | |
bc9f98a9 KY |
12843 | } |
12844 | *cur_val = idx; | |
12845 | return 1; | |
12846 | } | |
12847 | /* | |
12848 | * 2ch mode | |
12849 | */ | |
12850 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
12851 | { 2, NULL } | |
12852 | }; | |
12853 | ||
12854 | /* | |
12855 | * 2ch mode | |
12856 | */ | |
12857 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
12858 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
12859 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
12860 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
12861 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
12862 | { } /* end */ | |
12863 | }; | |
12864 | ||
12865 | /* | |
12866 | * 6ch mode | |
12867 | */ | |
12868 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
12869 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12870 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
12871 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
12872 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12873 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
12874 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
12875 | { } /* end */ | |
12876 | }; | |
12877 | ||
12878 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
12879 | { 2, alc662_3ST_ch2_init }, | |
12880 | { 6, alc662_3ST_ch6_init }, | |
12881 | }; | |
12882 | ||
12883 | /* | |
12884 | * 2ch mode | |
12885 | */ | |
12886 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
12887 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12888 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12889 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12890 | { } /* end */ | |
12891 | }; | |
12892 | ||
12893 | /* | |
12894 | * 6ch mode | |
12895 | */ | |
12896 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
12897 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12898 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12899 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12900 | { } /* end */ | |
12901 | }; | |
12902 | ||
12903 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
12904 | { 2, alc662_sixstack_ch6_init }, | |
12905 | { 6, alc662_sixstack_ch8_init }, | |
12906 | }; | |
12907 | ||
12908 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
12909 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
12910 | */ | |
12911 | ||
12912 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
12913 | /* output mixer control */ | |
12914 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
12915 | HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT), | |
12916 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
12917 | HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12918 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
12919 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
12920 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
12921 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
12922 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
12923 | ||
12924 | /*Input mixer control */ | |
12925 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
12926 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
12927 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
12928 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
12929 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
12930 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
12931 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
12932 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
bc9f98a9 KY |
12933 | { } /* end */ |
12934 | }; | |
12935 | ||
12936 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
12937 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12938 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
12939 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
12940 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12941 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12942 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
12943 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
12944 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12945 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12946 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12947 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12948 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
12949 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
12950 | { } /* end */ |
12951 | }; | |
12952 | ||
12953 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
12954 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12955 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
12956 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
12957 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
12958 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
12959 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
12960 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
12961 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
12962 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
12963 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12964 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12965 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
12966 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
12967 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12968 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12969 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12970 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12971 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
12972 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
12973 | { } /* end */ |
12974 | }; | |
12975 | ||
12976 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
12977 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12978 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
86cd9298 TI |
12979 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
12980 | HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), | |
bc9f98a9 KY |
12981 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
12982 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
12983 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
12984 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12985 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
12986 | { } /* end */ |
12987 | }; | |
12988 | ||
291702f0 | 12989 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
86cd9298 | 12990 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
291702f0 KY |
12991 | |
12992 | HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12993 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
12994 | ||
12995 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | |
12996 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12997 | HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12998 | ||
12999 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
13000 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13001 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13002 | { } /* end */ | |
13003 | }; | |
13004 | ||
8c427226 KY |
13005 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { |
13006 | HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13007 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
13008 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
13009 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
13010 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
13011 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
13012 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
13013 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
86cd9298 | 13014 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
8c427226 KY |
13015 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), |
13016 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13017 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13018 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13019 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13020 | { } /* end */ | |
13021 | }; | |
13022 | ||
bc9f98a9 KY |
13023 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
13024 | { | |
13025 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13026 | .name = "Channel Mode", | |
13027 | .info = alc_ch_mode_info, | |
13028 | .get = alc_ch_mode_get, | |
13029 | .put = alc_ch_mode_put, | |
13030 | }, | |
13031 | { } /* end */ | |
13032 | }; | |
13033 | ||
13034 | static struct hda_verb alc662_init_verbs[] = { | |
13035 | /* ADC: mute amp left and right */ | |
13036 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13037 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13038 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
13039 | ||
cb53c626 TI |
13040 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13041 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13042 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13043 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
13044 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 | 13045 | |
b60dd394 KY |
13046 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
13047 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13048 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13049 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13050 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13051 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
13052 | |
13053 | /* Front Pin: output 0 (0x0c) */ | |
13054 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13055 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13056 | ||
13057 | /* Rear Pin: output 1 (0x0d) */ | |
13058 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13059 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13060 | ||
13061 | /* CLFE Pin: output 2 (0x0e) */ | |
13062 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13063 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13064 | ||
13065 | /* Mic (rear) pin: input vref at 80% */ | |
13066 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13067 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13068 | /* Front Mic pin: input vref at 80% */ | |
13069 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13070 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13071 | /* Line In pin: input */ | |
13072 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13073 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13074 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
13075 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
13076 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13077 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13078 | /* CD pin widget for input */ | |
13079 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13080 | ||
13081 | /* FIXME: use matrix-type input source selection */ | |
13082 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
13083 | /* Input mixer */ | |
13084 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13085 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13086 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
13087 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
291702f0 KY |
13088 | |
13089 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13090 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13091 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
13092 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
bc9f98a9 KY |
13093 | { } |
13094 | }; | |
13095 | ||
13096 | static struct hda_verb alc662_sue_init_verbs[] = { | |
13097 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
13098 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
291702f0 KY |
13099 | {} |
13100 | }; | |
13101 | ||
13102 | static struct hda_verb alc662_eeepc_sue_init_verbs[] = { | |
13103 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
13104 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
13105 | {} | |
bc9f98a9 KY |
13106 | }; |
13107 | ||
8c427226 KY |
13108 | /* Set Unsolicited Event*/ |
13109 | static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { | |
13110 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13111 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
13112 | {} | |
13113 | }; | |
13114 | ||
bc9f98a9 KY |
13115 | /* |
13116 | * generic initialization of ADC, input mixers and output mixers | |
13117 | */ | |
13118 | static struct hda_verb alc662_auto_init_verbs[] = { | |
13119 | /* | |
13120 | * Unmute ADC and set the default input to mic-in | |
13121 | */ | |
13122 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13123 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13124 | ||
13125 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
13126 | * mixer widget | |
13127 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
13128 | * panel mic (mic 2) | |
13129 | */ | |
13130 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
13131 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13132 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13133 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13134 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
13135 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
13136 | |
13137 | /* | |
13138 | * Set up output mixers (0x0c - 0x0f) | |
13139 | */ | |
13140 | /* set vol=0 to output mixers */ | |
13141 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13142 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13143 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13144 | ||
13145 | /* set up input amps for analog loopback */ | |
13146 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
b60dd394 KY |
13147 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
13148 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13149 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13150 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13151 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13152 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
13153 | |
13154 | ||
13155 | /* FIXME: use matrix-type input source selection */ | |
13156 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
13157 | /* Input mixer */ | |
13158 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 13159 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
13160 | { } |
13161 | }; | |
13162 | ||
13163 | /* capture mixer elements */ | |
13164 | static struct snd_kcontrol_new alc662_capture_mixer[] = { | |
13165 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
13166 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
13167 | { | |
13168 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13169 | /* The multiple "Capture Source" controls confuse alsamixer | |
13170 | * So call somewhat different.. | |
bc9f98a9 KY |
13171 | */ |
13172 | /* .name = "Capture Source", */ | |
13173 | .name = "Input Source", | |
13174 | .count = 1, | |
6e7939bb HRK |
13175 | .info = alc662_mux_enum_info, |
13176 | .get = alc662_mux_enum_get, | |
13177 | .put = alc662_mux_enum_put, | |
bc9f98a9 KY |
13178 | }, |
13179 | { } /* end */ | |
13180 | }; | |
13181 | ||
13182 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |
13183 | { | |
13184 | unsigned int present; | |
f12ab1e0 | 13185 | unsigned char bits; |
bc9f98a9 KY |
13186 | |
13187 | present = snd_hda_codec_read(codec, 0x14, 0, | |
13188 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13189 | bits = present ? HDA_AMP_MUTE : 0; |
13190 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
13191 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
13192 | } |
13193 | ||
13194 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
13195 | { | |
13196 | unsigned int present; | |
f12ab1e0 | 13197 | unsigned char bits; |
bc9f98a9 KY |
13198 | |
13199 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
13200 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13201 | bits = present ? HDA_AMP_MUTE : 0; |
13202 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
13203 | HDA_AMP_MUTE, bits); | |
13204 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
13205 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
13206 | } |
13207 | ||
13208 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
13209 | unsigned int res) | |
13210 | { | |
13211 | if ((res >> 26) == ALC880_HP_EVENT) | |
13212 | alc662_lenovo_101e_all_automute(codec); | |
13213 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
13214 | alc662_lenovo_101e_ispeaker_automute(codec); | |
13215 | } | |
13216 | ||
291702f0 KY |
13217 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) |
13218 | { | |
13219 | unsigned int present; | |
13220 | ||
13221 | present = snd_hda_codec_read(codec, 0x18, 0, | |
13222 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
13223 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
13224 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
13225 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
13226 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
13227 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
13228 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
13229 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
13230 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
13231 | } | |
13232 | ||
13233 | /* unsolicited event for HP jack sensing */ | |
13234 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | |
13235 | unsigned int res) | |
13236 | { | |
13237 | if ((res >> 26) == ALC880_HP_EVENT) | |
13238 | alc262_hippo1_automute( codec ); | |
13239 | ||
13240 | if ((res >> 26) == ALC880_MIC_EVENT) | |
13241 | alc662_eeepc_mic_automute(codec); | |
13242 | } | |
13243 | ||
13244 | static void alc662_eeepc_inithook(struct hda_codec *codec) | |
13245 | { | |
13246 | alc262_hippo1_automute( codec ); | |
13247 | alc662_eeepc_mic_automute(codec); | |
13248 | } | |
13249 | ||
8c427226 KY |
13250 | static void alc662_eeepc_ep20_automute(struct hda_codec *codec) |
13251 | { | |
13252 | unsigned int mute; | |
13253 | unsigned int present; | |
13254 | ||
13255 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
13256 | present = snd_hda_codec_read(codec, 0x14, 0, | |
13257 | AC_VERB_GET_PIN_SENSE, 0); | |
13258 | present = (present & 0x80000000) != 0; | |
13259 | if (present) { | |
13260 | /* mute internal speaker */ | |
13261 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
13262 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
13263 | } else { | |
13264 | /* unmute internal speaker if necessary */ | |
13265 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
13266 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
13267 | HDA_AMP_MUTE, mute); | |
13268 | } | |
13269 | } | |
13270 | ||
13271 | /* unsolicited event for HP jack sensing */ | |
13272 | static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, | |
13273 | unsigned int res) | |
13274 | { | |
13275 | if ((res >> 26) == ALC880_HP_EVENT) | |
13276 | alc662_eeepc_ep20_automute(codec); | |
13277 | } | |
13278 | ||
13279 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | |
13280 | { | |
13281 | alc662_eeepc_ep20_automute(codec); | |
13282 | } | |
13283 | ||
cb53c626 TI |
13284 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13285 | #define alc662_loopbacks alc880_loopbacks | |
13286 | #endif | |
13287 | ||
bc9f98a9 KY |
13288 | |
13289 | /* pcm configuration: identiacal with ALC880 */ | |
13290 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
13291 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
13292 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
13293 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
13294 | ||
13295 | /* | |
13296 | * configuration and preset | |
13297 | */ | |
13298 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
13299 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
13300 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
13301 | [ALC662_3ST_6ch] = "3stack-6ch", | |
13302 | [ALC662_5ST_DIG] = "6stack-dig", | |
13303 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
b995d76d | 13304 | [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", |
8c427226 | 13305 | [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", |
bc9f98a9 KY |
13306 | [ALC662_AUTO] = "auto", |
13307 | }; | |
13308 | ||
13309 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
291702f0 | 13310 | SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), |
8c427226 | 13311 | SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), |
ac3e3741 | 13312 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), |
bc9f98a9 KY |
13313 | {} |
13314 | }; | |
13315 | ||
13316 | static struct alc_config_preset alc662_presets[] = { | |
13317 | [ALC662_3ST_2ch_DIG] = { | |
291702f0 | 13318 | .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer }, |
bc9f98a9 KY |
13319 | .init_verbs = { alc662_init_verbs }, |
13320 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
13321 | .dac_nids = alc662_dac_nids, | |
13322 | .dig_out_nid = ALC662_DIGOUT_NID, | |
13323 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
13324 | .adc_nids = alc662_adc_nids, | |
13325 | .dig_in_nid = ALC662_DIGIN_NID, | |
13326 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
13327 | .channel_mode = alc662_3ST_2ch_modes, | |
13328 | .input_mux = &alc662_capture_source, | |
13329 | }, | |
13330 | [ALC662_3ST_6ch_DIG] = { | |
291702f0 KY |
13331 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, |
13332 | alc662_capture_mixer }, | |
bc9f98a9 KY |
13333 | .init_verbs = { alc662_init_verbs }, |
13334 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
13335 | .dac_nids = alc662_dac_nids, | |
13336 | .dig_out_nid = ALC662_DIGOUT_NID, | |
13337 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
13338 | .adc_nids = alc662_adc_nids, | |
13339 | .dig_in_nid = ALC662_DIGIN_NID, | |
13340 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
13341 | .channel_mode = alc662_3ST_6ch_modes, | |
13342 | .need_dac_fix = 1, | |
13343 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 13344 | }, |
bc9f98a9 | 13345 | [ALC662_3ST_6ch] = { |
291702f0 KY |
13346 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, |
13347 | alc662_capture_mixer }, | |
bc9f98a9 KY |
13348 | .init_verbs = { alc662_init_verbs }, |
13349 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
13350 | .dac_nids = alc662_dac_nids, | |
13351 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
13352 | .adc_nids = alc662_adc_nids, | |
13353 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
13354 | .channel_mode = alc662_3ST_6ch_modes, | |
13355 | .need_dac_fix = 1, | |
13356 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 13357 | }, |
bc9f98a9 | 13358 | [ALC662_5ST_DIG] = { |
291702f0 KY |
13359 | .mixers = { alc662_base_mixer, alc662_chmode_mixer, |
13360 | alc662_capture_mixer }, | |
bc9f98a9 KY |
13361 | .init_verbs = { alc662_init_verbs }, |
13362 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
13363 | .dac_nids = alc662_dac_nids, | |
13364 | .dig_out_nid = ALC662_DIGOUT_NID, | |
13365 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
13366 | .adc_nids = alc662_adc_nids, | |
13367 | .dig_in_nid = ALC662_DIGIN_NID, | |
13368 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
13369 | .channel_mode = alc662_5stack_modes, | |
13370 | .input_mux = &alc662_capture_source, | |
13371 | }, | |
13372 | [ALC662_LENOVO_101E] = { | |
291702f0 | 13373 | .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer }, |
bc9f98a9 KY |
13374 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, |
13375 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
13376 | .dac_nids = alc662_dac_nids, | |
13377 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
13378 | .adc_nids = alc662_adc_nids, | |
13379 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
13380 | .channel_mode = alc662_3ST_2ch_modes, | |
13381 | .input_mux = &alc662_lenovo_101e_capture_source, | |
13382 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
13383 | .init_hook = alc662_lenovo_101e_all_automute, | |
13384 | }, | |
291702f0 KY |
13385 | [ALC662_ASUS_EEEPC_P701] = { |
13386 | .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer }, | |
13387 | .init_verbs = { alc662_init_verbs, | |
13388 | alc662_eeepc_sue_init_verbs }, | |
13389 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
13390 | .dac_nids = alc662_dac_nids, | |
13391 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
13392 | .adc_nids = alc662_adc_nids, | |
13393 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
13394 | .channel_mode = alc662_3ST_2ch_modes, | |
13395 | .input_mux = &alc662_eeepc_capture_source, | |
13396 | .unsol_event = alc662_eeepc_unsol_event, | |
13397 | .init_hook = alc662_eeepc_inithook, | |
13398 | }, | |
8c427226 KY |
13399 | [ALC662_ASUS_EEEPC_EP20] = { |
13400 | .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer, | |
13401 | alc662_chmode_mixer }, | |
13402 | .init_verbs = { alc662_init_verbs, | |
13403 | alc662_eeepc_ep20_sue_init_verbs }, | |
13404 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
13405 | .dac_nids = alc662_dac_nids, | |
13406 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
13407 | .adc_nids = alc662_adc_nids, | |
13408 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
13409 | .channel_mode = alc662_3ST_6ch_modes, | |
13410 | .input_mux = &alc662_lenovo_101e_capture_source, | |
13411 | .unsol_event = alc662_eeepc_ep20_unsol_event, | |
13412 | .init_hook = alc662_eeepc_ep20_inithook, | |
13413 | }, | |
bc9f98a9 KY |
13414 | |
13415 | }; | |
13416 | ||
13417 | ||
13418 | /* | |
13419 | * BIOS auto configuration | |
13420 | */ | |
13421 | ||
13422 | /* add playback controls from the parsed DAC table */ | |
13423 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
13424 | const struct auto_pin_cfg *cfg) | |
13425 | { | |
13426 | char name[32]; | |
13427 | static const char *chname[4] = { | |
13428 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
13429 | }; | |
13430 | hda_nid_t nid; | |
13431 | int i, err; | |
13432 | ||
13433 | for (i = 0; i < cfg->line_outs; i++) { | |
13434 | if (!spec->multiout.dac_nids[i]) | |
13435 | continue; | |
b60dd394 | 13436 | nid = alc880_idx_to_dac(i); |
bc9f98a9 KY |
13437 | if (i == 2) { |
13438 | /* Center/LFE */ | |
13439 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
13440 | "Center Playback Volume", | |
f12ab1e0 TI |
13441 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
13442 | HDA_OUTPUT)); | |
bc9f98a9 KY |
13443 | if (err < 0) |
13444 | return err; | |
13445 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
13446 | "LFE Playback Volume", | |
f12ab1e0 TI |
13447 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
13448 | HDA_OUTPUT)); | |
bc9f98a9 KY |
13449 | if (err < 0) |
13450 | return err; | |
13451 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
13452 | "Center Playback Switch", | |
f12ab1e0 TI |
13453 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
13454 | HDA_INPUT)); | |
bc9f98a9 KY |
13455 | if (err < 0) |
13456 | return err; | |
13457 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
13458 | "LFE Playback Switch", | |
f12ab1e0 TI |
13459 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
13460 | HDA_INPUT)); | |
bc9f98a9 KY |
13461 | if (err < 0) |
13462 | return err; | |
13463 | } else { | |
13464 | sprintf(name, "%s Playback Volume", chname[i]); | |
13465 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
13466 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
13467 | HDA_OUTPUT)); | |
bc9f98a9 KY |
13468 | if (err < 0) |
13469 | return err; | |
13470 | sprintf(name, "%s Playback Switch", chname[i]); | |
13471 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
f12ab1e0 TI |
13472 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
13473 | HDA_INPUT)); | |
bc9f98a9 KY |
13474 | if (err < 0) |
13475 | return err; | |
13476 | } | |
13477 | } | |
13478 | return 0; | |
13479 | } | |
13480 | ||
13481 | /* add playback controls for speaker and HP outputs */ | |
13482 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
13483 | const char *pfx) | |
13484 | { | |
13485 | hda_nid_t nid; | |
13486 | int err; | |
13487 | char name[32]; | |
13488 | ||
13489 | if (!pin) | |
13490 | return 0; | |
13491 | ||
13492 | if (alc880_is_fixed_pin(pin)) { | |
13493 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
13494 | /* printk("DAC nid=%x\n",nid); */ | |
13495 | /* specify the DAC as the extra output */ | |
13496 | if (!spec->multiout.hp_nid) | |
13497 | spec->multiout.hp_nid = nid; | |
13498 | else | |
13499 | spec->multiout.extra_out_nid[0] = nid; | |
13500 | /* control HP volume/switch on the output mixer amp */ | |
13501 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
13502 | sprintf(name, "%s Playback Volume", pfx); | |
13503 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
13504 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
13505 | if (err < 0) | |
13506 | return err; | |
13507 | sprintf(name, "%s Playback Switch", pfx); | |
13508 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
13509 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
13510 | if (err < 0) | |
13511 | return err; | |
13512 | } else if (alc880_is_multi_pin(pin)) { | |
13513 | /* set manual connection */ | |
13514 | /* we have only a switch on HP-out PIN */ | |
13515 | sprintf(name, "%s Playback Switch", pfx); | |
13516 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
13517 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
13518 | if (err < 0) | |
13519 | return err; | |
13520 | } | |
13521 | return 0; | |
13522 | } | |
13523 | ||
13524 | /* create playback/capture controls for input pins */ | |
13525 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
13526 | const struct auto_pin_cfg *cfg) | |
13527 | { | |
13528 | struct hda_input_mux *imux = &spec->private_imux; | |
13529 | int i, err, idx; | |
13530 | ||
13531 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13532 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
13533 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
13534 | err = new_analog_input(spec, cfg->input_pins[i], | |
13535 | auto_pin_cfg_labels[i], | |
13536 | idx, 0x0b); | |
13537 | if (err < 0) | |
13538 | return err; | |
13539 | imux->items[imux->num_items].label = | |
13540 | auto_pin_cfg_labels[i]; | |
13541 | imux->items[imux->num_items].index = | |
13542 | alc880_input_pin_idx(cfg->input_pins[i]); | |
13543 | imux->num_items++; | |
13544 | } | |
13545 | } | |
13546 | return 0; | |
13547 | } | |
13548 | ||
13549 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
13550 | hda_nid_t nid, int pin_type, | |
13551 | int dac_idx) | |
13552 | { | |
13553 | /* set as output */ | |
13554 | snd_hda_codec_write(codec, nid, 0, | |
13555 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
13556 | snd_hda_codec_write(codec, nid, 0, | |
13557 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
13558 | /* need the manual connection? */ | |
13559 | if (alc880_is_multi_pin(nid)) { | |
13560 | struct alc_spec *spec = codec->spec; | |
13561 | int idx = alc880_multi_pin_idx(nid); | |
13562 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
13563 | AC_VERB_SET_CONNECT_SEL, | |
13564 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
13565 | } | |
13566 | } | |
13567 | ||
13568 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
13569 | { | |
13570 | struct alc_spec *spec = codec->spec; | |
13571 | int i; | |
13572 | ||
8c427226 | 13573 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
bc9f98a9 KY |
13574 | for (i = 0; i <= HDA_SIDE; i++) { |
13575 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 13576 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 13577 | if (nid) |
baba8ee9 | 13578 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
13579 | i); |
13580 | } | |
13581 | } | |
13582 | ||
13583 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
13584 | { | |
13585 | struct alc_spec *spec = codec->spec; | |
13586 | hda_nid_t pin; | |
13587 | ||
13588 | pin = spec->autocfg.hp_pins[0]; | |
13589 | if (pin) /* connect to front */ | |
13590 | /* use dac 0 */ | |
13591 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
13592 | } | |
13593 | ||
13594 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
13595 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
13596 | ||
13597 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
13598 | { | |
13599 | struct alc_spec *spec = codec->spec; | |
13600 | int i; | |
13601 | ||
13602 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13603 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
13604 | if (alc662_is_input_pin(nid)) { | |
13605 | snd_hda_codec_write(codec, nid, 0, | |
13606 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
13607 | (i <= AUTO_PIN_FRONT_MIC ? | |
13608 | PIN_VREF80 : PIN_IN)); | |
13609 | if (nid != ALC662_PIN_CD_NID) | |
13610 | snd_hda_codec_write(codec, nid, 0, | |
13611 | AC_VERB_SET_AMP_GAIN_MUTE, | |
13612 | AMP_OUT_MUTE); | |
13613 | } | |
13614 | } | |
13615 | } | |
13616 | ||
13617 | static int alc662_parse_auto_config(struct hda_codec *codec) | |
13618 | { | |
13619 | struct alc_spec *spec = codec->spec; | |
13620 | int err; | |
13621 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
13622 | ||
13623 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
13624 | alc662_ignore); | |
13625 | if (err < 0) | |
13626 | return err; | |
13627 | if (!spec->autocfg.line_outs) | |
13628 | return 0; /* can't find valid BIOS pin config */ | |
13629 | ||
f12ab1e0 TI |
13630 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
13631 | if (err < 0) | |
13632 | return err; | |
13633 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
13634 | if (err < 0) | |
13635 | return err; | |
13636 | err = alc662_auto_create_extra_out(spec, | |
13637 | spec->autocfg.speaker_pins[0], | |
13638 | "Speaker"); | |
13639 | if (err < 0) | |
13640 | return err; | |
13641 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
13642 | "Headphone"); | |
13643 | if (err < 0) | |
13644 | return err; | |
13645 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
13646 | if (err < 0) | |
bc9f98a9 KY |
13647 | return err; |
13648 | ||
13649 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
13650 | ||
13651 | if (spec->autocfg.dig_out_pin) | |
13652 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
13653 | ||
13654 | if (spec->kctl_alloc) | |
13655 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
13656 | ||
13657 | spec->num_mux_defs = 1; | |
13658 | spec->input_mux = &spec->private_imux; | |
13659 | ||
8c87286f | 13660 | spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; |
bc9f98a9 KY |
13661 | spec->mixers[spec->num_mixers] = alc662_capture_mixer; |
13662 | spec->num_mixers++; | |
8c87286f | 13663 | return 1; |
bc9f98a9 KY |
13664 | } |
13665 | ||
13666 | /* additional initialization for auto-configuration model */ | |
13667 | static void alc662_auto_init(struct hda_codec *codec) | |
13668 | { | |
13669 | alc662_auto_init_multi_out(codec); | |
13670 | alc662_auto_init_hp_out(codec); | |
13671 | alc662_auto_init_analog_input(codec); | |
13672 | } | |
13673 | ||
13674 | static int patch_alc662(struct hda_codec *codec) | |
13675 | { | |
13676 | struct alc_spec *spec; | |
13677 | int err, board_config; | |
13678 | ||
13679 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
13680 | if (!spec) | |
13681 | return -ENOMEM; | |
13682 | ||
13683 | codec->spec = spec; | |
13684 | ||
13685 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, | |
13686 | alc662_models, | |
13687 | alc662_cfg_tbl); | |
13688 | if (board_config < 0) { | |
13689 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
13690 | "trying auto-probe from BIOS...\n"); | |
13691 | board_config = ALC662_AUTO; | |
13692 | } | |
13693 | ||
13694 | if (board_config == ALC662_AUTO) { | |
13695 | /* automatic parse from the BIOS config */ | |
13696 | err = alc662_parse_auto_config(codec); | |
13697 | if (err < 0) { | |
13698 | alc_free(codec); | |
13699 | return err; | |
8c87286f | 13700 | } else if (!err) { |
bc9f98a9 KY |
13701 | printk(KERN_INFO |
13702 | "hda_codec: Cannot set up configuration " | |
13703 | "from BIOS. Using base mode...\n"); | |
13704 | board_config = ALC662_3ST_2ch_DIG; | |
13705 | } | |
13706 | } | |
13707 | ||
13708 | if (board_config != ALC662_AUTO) | |
13709 | setup_preset(spec, &alc662_presets[board_config]); | |
13710 | ||
13711 | spec->stream_name_analog = "ALC662 Analog"; | |
13712 | spec->stream_analog_playback = &alc662_pcm_analog_playback; | |
13713 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
13714 | ||
13715 | spec->stream_name_digital = "ALC662 Digital"; | |
13716 | spec->stream_digital_playback = &alc662_pcm_digital_playback; | |
13717 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
13718 | ||
13719 | if (!spec->adc_nids && spec->input_mux) { | |
13720 | spec->adc_nids = alc662_adc_nids; | |
13721 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
13722 | } | |
13723 | ||
2134ea4f TI |
13724 | spec->vmaster_nid = 0x02; |
13725 | ||
bc9f98a9 KY |
13726 | codec->patch_ops = alc_patch_ops; |
13727 | if (board_config == ALC662_AUTO) | |
13728 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
13729 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13730 | if (!spec->loopback.amplist) | |
13731 | spec->loopback.amplist = alc662_loopbacks; | |
13732 | #endif | |
bc9f98a9 KY |
13733 | |
13734 | return 0; | |
13735 | } | |
13736 | ||
1da177e4 LT |
13737 | /* |
13738 | * patch entries | |
13739 | */ | |
13740 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
13741 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 13742 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f6a92248 | 13743 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
a361d84b | 13744 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f6a92248 | 13745 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
f32610ed | 13746 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 13747 | .patch = patch_alc861 }, |
f32610ed JS |
13748 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
13749 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
13750 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
13751 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
13752 | .patch = patch_alc883 }, | |
13753 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
13754 | .patch = patch_alc662 }, | |
f32610ed | 13755 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 13756 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 13757 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
df694daa | 13758 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
9c7f852e | 13759 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
f6a92248 | 13760 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, |
1da177e4 LT |
13761 | {} /* terminator */ |
13762 | }; |