]>
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" | |
680cd536 | 33 | #include "hda_beep.h" |
1da177e4 | 34 | |
ccc656ce KY |
35 | #define ALC880_FRONT_EVENT 0x01 |
36 | #define ALC880_DCVOL_EVENT 0x02 | |
37 | #define ALC880_HP_EVENT 0x04 | |
38 | #define ALC880_MIC_EVENT 0x08 | |
1da177e4 LT |
39 | |
40 | /* ALC880 board config type */ | |
41 | enum { | |
1da177e4 LT |
42 | ALC880_3ST, |
43 | ALC880_3ST_DIG, | |
44 | ALC880_5ST, | |
45 | ALC880_5ST_DIG, | |
46 | ALC880_W810, | |
dfc0ff62 | 47 | ALC880_Z71V, |
b6482d48 | 48 | ALC880_6ST, |
16ded525 TI |
49 | ALC880_6ST_DIG, |
50 | ALC880_F1734, | |
51 | ALC880_ASUS, | |
52 | ALC880_ASUS_DIG, | |
53 | ALC880_ASUS_W1V, | |
df694daa | 54 | ALC880_ASUS_DIG2, |
2cf9f0fc | 55 | ALC880_FUJITSU, |
16ded525 | 56 | ALC880_UNIWILL_DIG, |
ccc656ce KY |
57 | ALC880_UNIWILL, |
58 | ALC880_UNIWILL_P53, | |
df694daa KY |
59 | ALC880_CLEVO, |
60 | ALC880_TCL_S700, | |
ae6b813a | 61 | ALC880_LG, |
d681518a | 62 | ALC880_LG_LW, |
df99cd33 | 63 | ALC880_MEDION_RIM, |
e9edcee0 TI |
64 | #ifdef CONFIG_SND_DEBUG |
65 | ALC880_TEST, | |
66 | #endif | |
df694daa | 67 | ALC880_AUTO, |
16ded525 TI |
68 | ALC880_MODEL_LAST /* last tag */ |
69 | }; | |
70 | ||
71 | /* ALC260 models */ | |
72 | enum { | |
73 | ALC260_BASIC, | |
74 | ALC260_HP, | |
3f878308 | 75 | ALC260_HP_DC7600, |
df694daa KY |
76 | ALC260_HP_3013, |
77 | ALC260_FUJITSU_S702X, | |
0bfc90e9 | 78 | ALC260_ACER, |
bc9f98a9 KY |
79 | ALC260_WILL, |
80 | ALC260_REPLACER_672V, | |
7cf51e48 JW |
81 | #ifdef CONFIG_SND_DEBUG |
82 | ALC260_TEST, | |
83 | #endif | |
df694daa | 84 | ALC260_AUTO, |
16ded525 | 85 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
86 | }; |
87 | ||
df694daa KY |
88 | /* ALC262 models */ |
89 | enum { | |
90 | ALC262_BASIC, | |
ccc656ce KY |
91 | ALC262_HIPPO, |
92 | ALC262_HIPPO_1, | |
834be88d | 93 | ALC262_FUJITSU, |
9c7f852e | 94 | ALC262_HP_BPC, |
cd7509a4 KY |
95 | ALC262_HP_BPC_D7000_WL, |
96 | ALC262_HP_BPC_D7000_WF, | |
66d2a9d6 | 97 | ALC262_HP_TC_T5735, |
8c427226 | 98 | ALC262_HP_RP5700, |
304dcaac | 99 | ALC262_BENQ_ED8, |
272a527c | 100 | ALC262_SONY_ASSAMD, |
83c34218 | 101 | ALC262_BENQ_T31, |
f651b50b | 102 | ALC262_ULTRA, |
0e31daf7 | 103 | ALC262_LENOVO_3000, |
e8f9ae2a | 104 | ALC262_NEC, |
4e555fe5 | 105 | ALC262_TOSHIBA_S06, |
9f99a638 | 106 | ALC262_TOSHIBA_RX1, |
ba340e82 | 107 | ALC262_TYAN, |
df694daa KY |
108 | ALC262_AUTO, |
109 | ALC262_MODEL_LAST /* last tag */ | |
110 | }; | |
111 | ||
a361d84b KY |
112 | /* ALC268 models */ |
113 | enum { | |
eb5a6621 | 114 | ALC267_QUANTA_IL1, |
a361d84b | 115 | ALC268_3ST, |
d1a991a6 | 116 | ALC268_TOSHIBA, |
d273809e | 117 | ALC268_ACER, |
c238b4f4 | 118 | ALC268_ACER_DMIC, |
8ef355da | 119 | ALC268_ACER_ASPIRE_ONE, |
3866f0b0 | 120 | ALC268_DELL, |
f12462c5 | 121 | ALC268_ZEPTO, |
86c53bd2 JW |
122 | #ifdef CONFIG_SND_DEBUG |
123 | ALC268_TEST, | |
124 | #endif | |
a361d84b KY |
125 | ALC268_AUTO, |
126 | ALC268_MODEL_LAST /* last tag */ | |
127 | }; | |
128 | ||
f6a92248 KY |
129 | /* ALC269 models */ |
130 | enum { | |
131 | ALC269_BASIC, | |
60db6b53 | 132 | ALC269_QUANTA_FL1, |
f53281e6 KY |
133 | ALC269_ASUS_EEEPC_P703, |
134 | ALC269_ASUS_EEEPC_P901, | |
26f5df26 | 135 | ALC269_FUJITSU, |
64154835 | 136 | ALC269_LIFEBOOK, |
f6a92248 KY |
137 | ALC269_AUTO, |
138 | ALC269_MODEL_LAST /* last tag */ | |
139 | }; | |
140 | ||
df694daa KY |
141 | /* ALC861 models */ |
142 | enum { | |
143 | ALC861_3ST, | |
9c7f852e | 144 | ALC660_3ST, |
df694daa KY |
145 | ALC861_3ST_DIG, |
146 | ALC861_6ST_DIG, | |
22309c3e | 147 | ALC861_UNIWILL_M31, |
a53d1aec | 148 | ALC861_TOSHIBA, |
7cdbff94 | 149 | ALC861_ASUS, |
56bb0cab | 150 | ALC861_ASUS_LAPTOP, |
df694daa KY |
151 | ALC861_AUTO, |
152 | ALC861_MODEL_LAST, | |
153 | }; | |
154 | ||
f32610ed JS |
155 | /* ALC861-VD models */ |
156 | enum { | |
157 | ALC660VD_3ST, | |
6963f84c | 158 | ALC660VD_3ST_DIG, |
13c94744 | 159 | ALC660VD_ASUS_V1S, |
f32610ed JS |
160 | ALC861VD_3ST, |
161 | ALC861VD_3ST_DIG, | |
162 | ALC861VD_6ST_DIG, | |
bdd148a3 | 163 | ALC861VD_LENOVO, |
272a527c | 164 | ALC861VD_DALLAS, |
d1a991a6 | 165 | ALC861VD_HP, |
f32610ed JS |
166 | ALC861VD_AUTO, |
167 | ALC861VD_MODEL_LAST, | |
168 | }; | |
169 | ||
bc9f98a9 KY |
170 | /* ALC662 models */ |
171 | enum { | |
172 | ALC662_3ST_2ch_DIG, | |
173 | ALC662_3ST_6ch_DIG, | |
174 | ALC662_3ST_6ch, | |
175 | ALC662_5ST_DIG, | |
176 | ALC662_LENOVO_101E, | |
291702f0 | 177 | ALC662_ASUS_EEEPC_P701, |
8c427226 | 178 | ALC662_ASUS_EEEPC_EP20, |
6dda9f4a KY |
179 | ALC663_ASUS_M51VA, |
180 | ALC663_ASUS_G71V, | |
181 | ALC663_ASUS_H13, | |
182 | ALC663_ASUS_G50V, | |
f1d4e28b KY |
183 | ALC662_ECS, |
184 | ALC663_ASUS_MODE1, | |
185 | ALC662_ASUS_MODE2, | |
186 | ALC663_ASUS_MODE3, | |
187 | ALC663_ASUS_MODE4, | |
188 | ALC663_ASUS_MODE5, | |
189 | ALC663_ASUS_MODE6, | |
bc9f98a9 KY |
190 | ALC662_AUTO, |
191 | ALC662_MODEL_LAST, | |
192 | }; | |
193 | ||
df694daa KY |
194 | /* ALC882 models */ |
195 | enum { | |
196 | ALC882_3ST_DIG, | |
197 | ALC882_6ST_DIG, | |
4b146cb0 | 198 | ALC882_ARIMA, |
bdd148a3 | 199 | ALC882_W2JC, |
272a527c KY |
200 | ALC882_TARGA, |
201 | ALC882_ASUS_A7J, | |
914759b7 | 202 | ALC882_ASUS_A7M, |
9102cd1c | 203 | ALC885_MACPRO, |
87350ad0 | 204 | ALC885_MBP3, |
c54728d8 | 205 | ALC885_IMAC24, |
272a527c | 206 | ALC882_AUTO, |
df694daa KY |
207 | ALC882_MODEL_LAST, |
208 | }; | |
209 | ||
9c7f852e TI |
210 | /* ALC883 models */ |
211 | enum { | |
212 | ALC883_3ST_2ch_DIG, | |
213 | ALC883_3ST_6ch_DIG, | |
214 | ALC883_3ST_6ch, | |
215 | ALC883_6ST_DIG, | |
ccc656ce KY |
216 | ALC883_TARGA_DIG, |
217 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 218 | ALC883_ACER, |
2880a867 | 219 | ALC883_ACER_ASPIRE, |
5b2d1eca | 220 | ALC888_ACER_ASPIRE_4930G, |
c07584c8 | 221 | ALC883_MEDION, |
ea1fb29a | 222 | ALC883_MEDION_MD2, |
b373bdeb | 223 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 224 | ALC883_LENOVO_101E_2ch, |
272a527c | 225 | ALC883_LENOVO_NB0763, |
189609ae | 226 | ALC888_LENOVO_MS7195_DIG, |
e2757d5e | 227 | ALC888_LENOVO_SKY, |
ea1fb29a | 228 | ALC883_HAIER_W66, |
4723c022 | 229 | ALC888_3ST_HP, |
5795b9e6 | 230 | ALC888_6ST_DELL, |
a8848bd6 | 231 | ALC883_MITAC, |
0c4cc443 | 232 | ALC883_CLEVO_M720, |
fb97dc67 | 233 | ALC883_FUJITSU_PI2515, |
ef8ef5fb | 234 | ALC888_FUJITSU_XA3530, |
17bba1b7 | 235 | ALC883_3ST_6ch_INTEL, |
e2757d5e KY |
236 | ALC888_ASUS_M90V, |
237 | ALC888_ASUS_EEE1601, | |
3ab90935 | 238 | ALC1200_ASUS_P5Q, |
9c7f852e TI |
239 | ALC883_AUTO, |
240 | ALC883_MODEL_LAST, | |
241 | }; | |
242 | ||
61b9b9b1 HRK |
243 | /* styles of capture selection */ |
244 | enum { | |
245 | CAPT_MUX = 0, /* only mux based */ | |
246 | CAPT_MIX, /* only mixer based */ | |
247 | CAPT_1MUX_MIX, /* first mux and other mixers */ | |
248 | }; | |
249 | ||
df694daa KY |
250 | /* for GPIO Poll */ |
251 | #define GPIO_MASK 0x03 | |
252 | ||
1da177e4 LT |
253 | struct alc_spec { |
254 | /* codec parameterization */ | |
df694daa | 255 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 | 256 | unsigned int num_mixers; |
f9e336f6 | 257 | struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
45bdd1c1 | 258 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
1da177e4 | 259 | |
df694daa | 260 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
261 | * don't forget NULL |
262 | * termination! | |
e9edcee0 TI |
263 | */ |
264 | unsigned int num_init_verbs; | |
1da177e4 | 265 | |
16ded525 | 266 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
267 | struct hda_pcm_stream *stream_analog_playback; |
268 | struct hda_pcm_stream *stream_analog_capture; | |
6330079f TI |
269 | struct hda_pcm_stream *stream_analog_alt_playback; |
270 | struct hda_pcm_stream *stream_analog_alt_capture; | |
1da177e4 | 271 | |
f12ab1e0 | 272 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
273 | struct hda_pcm_stream *stream_digital_playback; |
274 | struct hda_pcm_stream *stream_digital_capture; | |
275 | ||
276 | /* playback */ | |
16ded525 TI |
277 | struct hda_multi_out multiout; /* playback set-up |
278 | * max_channels, dacs must be set | |
279 | * dig_out_nid and hp_nid are optional | |
280 | */ | |
6330079f | 281 | hda_nid_t alt_dac_nid; |
8c441982 | 282 | int dig_out_type; |
1da177e4 LT |
283 | |
284 | /* capture */ | |
285 | unsigned int num_adc_nids; | |
286 | hda_nid_t *adc_nids; | |
e1406348 | 287 | hda_nid_t *capsrc_nids; |
16ded525 | 288 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
61b9b9b1 | 289 | int capture_style; /* capture style (CAPT_*) */ |
1da177e4 LT |
290 | |
291 | /* capture source */ | |
a1e8d2da | 292 | unsigned int num_mux_defs; |
1da177e4 LT |
293 | const struct hda_input_mux *input_mux; |
294 | unsigned int cur_mux[3]; | |
295 | ||
296 | /* channel model */ | |
d2a6d7dc | 297 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 298 | int num_channel_mode; |
4e195a7b | 299 | int need_dac_fix; |
1da177e4 LT |
300 | |
301 | /* PCM information */ | |
4c5186ed | 302 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 303 | |
e9edcee0 TI |
304 | /* dynamic controls, init_verbs and input_mux */ |
305 | struct auto_pin_cfg autocfg; | |
603c4019 | 306 | struct snd_array kctls; |
61b9b9b1 | 307 | struct hda_input_mux private_imux[3]; |
41923e44 | 308 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
834be88d | 309 | |
ae6b813a TI |
310 | /* hooks */ |
311 | void (*init_hook)(struct hda_codec *codec); | |
312 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
313 | ||
834be88d TI |
314 | /* for pin sensing */ |
315 | unsigned int sense_updated: 1; | |
316 | unsigned int jack_present: 1; | |
bec15c3a | 317 | unsigned int master_sw: 1; |
cb53c626 | 318 | |
e64f14f4 TI |
319 | /* other flags */ |
320 | unsigned int no_analog :1; /* digital I/O only */ | |
321 | ||
2134ea4f TI |
322 | /* for virtual master */ |
323 | hda_nid_t vmaster_nid; | |
cb53c626 TI |
324 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
325 | struct hda_loopback_check loopback; | |
326 | #endif | |
2c3bf9ab TI |
327 | |
328 | /* for PLL fix */ | |
329 | hda_nid_t pll_nid; | |
330 | unsigned int pll_coef_idx, pll_coef_bit; | |
e044c39a TI |
331 | |
332 | #ifdef SND_HDA_NEEDS_RESUME | |
333 | #define ALC_MAX_PINS 16 | |
334 | unsigned int num_pins; | |
335 | hda_nid_t pin_nids[ALC_MAX_PINS]; | |
336 | unsigned int pin_cfgs[ALC_MAX_PINS]; | |
337 | #endif | |
df694daa KY |
338 | }; |
339 | ||
340 | /* | |
341 | * configuration template - to be copied to the spec instance | |
342 | */ | |
343 | struct alc_config_preset { | |
9c7f852e TI |
344 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
345 | * with spec | |
346 | */ | |
f9e336f6 | 347 | struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
df694daa KY |
348 | const struct hda_verb *init_verbs[5]; |
349 | unsigned int num_dacs; | |
350 | hda_nid_t *dac_nids; | |
351 | hda_nid_t dig_out_nid; /* optional */ | |
352 | hda_nid_t hp_nid; /* optional */ | |
b25c9da1 | 353 | hda_nid_t *slave_dig_outs; |
df694daa KY |
354 | unsigned int num_adc_nids; |
355 | hda_nid_t *adc_nids; | |
e1406348 | 356 | hda_nid_t *capsrc_nids; |
df694daa KY |
357 | hda_nid_t dig_in_nid; |
358 | unsigned int num_channel_mode; | |
359 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 360 | int need_dac_fix; |
a1e8d2da | 361 | unsigned int num_mux_defs; |
df694daa | 362 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
363 | void (*unsol_event)(struct hda_codec *, unsigned int); |
364 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
365 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
366 | struct hda_amp_list *loopbacks; | |
367 | #endif | |
1da177e4 LT |
368 | }; |
369 | ||
1da177e4 LT |
370 | |
371 | /* | |
372 | * input MUX handling | |
373 | */ | |
9c7f852e TI |
374 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
375 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
376 | { |
377 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
378 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
379 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
380 | if (mux_idx >= spec->num_mux_defs) | |
381 | mux_idx = 0; | |
382 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
383 | } |
384 | ||
9c7f852e TI |
385 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
386 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
387 | { |
388 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
389 | struct alc_spec *spec = codec->spec; | |
390 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
391 | ||
392 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
393 | return 0; | |
394 | } | |
395 | ||
9c7f852e TI |
396 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
397 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
398 | { |
399 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
400 | struct alc_spec *spec = codec->spec; | |
cd896c33 | 401 | const struct hda_input_mux *imux; |
1da177e4 | 402 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
cd896c33 | 403 | unsigned int mux_idx; |
e1406348 TI |
404 | hda_nid_t nid = spec->capsrc_nids ? |
405 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | |
1da177e4 | 406 | |
cd896c33 TI |
407 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
408 | imux = &spec->input_mux[mux_idx]; | |
409 | ||
61b9b9b1 HRK |
410 | if (spec->capture_style && |
411 | !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) { | |
54cbc9ab TI |
412 | /* Matrix-mixer style (e.g. ALC882) */ |
413 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
414 | unsigned int i, idx; | |
415 | ||
416 | idx = ucontrol->value.enumerated.item[0]; | |
417 | if (idx >= imux->num_items) | |
418 | idx = imux->num_items - 1; | |
419 | if (*cur_val == idx) | |
420 | return 0; | |
421 | for (i = 0; i < imux->num_items; i++) { | |
422 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; | |
423 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
424 | imux->items[i].index, | |
425 | HDA_AMP_MUTE, v); | |
426 | } | |
427 | *cur_val = idx; | |
428 | return 1; | |
429 | } else { | |
430 | /* MUX style (e.g. ALC880) */ | |
cd896c33 | 431 | return snd_hda_input_mux_put(codec, imux, ucontrol, nid, |
54cbc9ab TI |
432 | &spec->cur_mux[adc_idx]); |
433 | } | |
434 | } | |
e9edcee0 | 435 | |
1da177e4 LT |
436 | /* |
437 | * channel mode setting | |
438 | */ | |
9c7f852e TI |
439 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
440 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
441 | { |
442 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
443 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
444 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
445 | spec->num_channel_mode); | |
1da177e4 LT |
446 | } |
447 | ||
9c7f852e TI |
448 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
449 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
450 | { |
451 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
452 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 453 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
454 | spec->num_channel_mode, |
455 | spec->multiout.max_channels); | |
1da177e4 LT |
456 | } |
457 | ||
9c7f852e TI |
458 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
459 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
460 | { |
461 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
462 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
463 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
464 | spec->num_channel_mode, | |
465 | &spec->multiout.max_channels); | |
bd2033f2 | 466 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
467 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
468 | return err; | |
1da177e4 LT |
469 | } |
470 | ||
a9430dd8 | 471 | /* |
4c5186ed | 472 | * Control the mode of pin widget settings via the mixer. "pc" is used |
ea1fb29a | 473 | * instead of "%" to avoid consequences of accidently treating the % as |
4c5186ed JW |
474 | * being part of a format specifier. Maximum allowed length of a value is |
475 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
476 | * |
477 | * Note: some retasking pin complexes seem to ignore requests for input | |
478 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
479 | * are requested. Therefore order this list so that this behaviour will not | |
480 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
481 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
482 | * March 2006. | |
4c5186ed JW |
483 | */ |
484 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
485 | "Mic 50pc bias", "Mic 80pc bias", |
486 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
487 | }; |
488 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 489 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
490 | }; |
491 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
492 | * in the pin being assumed to be exclusively an input or an output pin. In |
493 | * addition, "input" pins may or may not process the mic bias option | |
494 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
495 | * accept requests for bias as of chip versions up to March 2006) and/or | |
496 | * wiring in the computer. | |
a9430dd8 | 497 | */ |
a1e8d2da JW |
498 | #define ALC_PIN_DIR_IN 0x00 |
499 | #define ALC_PIN_DIR_OUT 0x01 | |
500 | #define ALC_PIN_DIR_INOUT 0x02 | |
501 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
502 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 503 | |
ea1fb29a | 504 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
505 | * For each direction the minimum and maximum values are given. |
506 | */ | |
a1e8d2da | 507 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
508 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
509 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
510 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
511 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
512 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
513 | }; |
514 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
515 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
516 | #define alc_pin_mode_n_items(_dir) \ | |
517 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
518 | ||
9c7f852e TI |
519 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
520 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 521 | { |
4c5186ed JW |
522 | unsigned int item_num = uinfo->value.enumerated.item; |
523 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
524 | ||
525 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 526 | uinfo->count = 1; |
4c5186ed JW |
527 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
528 | ||
529 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
530 | item_num = alc_pin_mode_min(dir); | |
531 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
532 | return 0; |
533 | } | |
534 | ||
9c7f852e TI |
535 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
536 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 537 | { |
4c5186ed | 538 | unsigned int i; |
a9430dd8 JW |
539 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
540 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 541 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 542 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
543 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
544 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
545 | 0x00); | |
a9430dd8 | 546 | |
4c5186ed JW |
547 | /* Find enumerated value for current pinctl setting */ |
548 | i = alc_pin_mode_min(dir); | |
9c7f852e | 549 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 550 | i++; |
9c7f852e | 551 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
552 | return 0; |
553 | } | |
554 | ||
9c7f852e TI |
555 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
556 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 557 | { |
4c5186ed | 558 | signed int change; |
a9430dd8 JW |
559 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
560 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
561 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
562 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
563 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
564 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
565 | 0x00); | |
a9430dd8 | 566 | |
f12ab1e0 | 567 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
568 | val = alc_pin_mode_min(dir); |
569 | ||
570 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
571 | if (change) { |
572 | /* Set pin mode to that requested */ | |
82beb8fd TI |
573 | snd_hda_codec_write_cache(codec, nid, 0, |
574 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
575 | alc_pin_mode_values[val]); | |
cdcd9268 | 576 | |
ea1fb29a | 577 | /* Also enable the retasking pin's input/output as required |
cdcd9268 JW |
578 | * for the requested pin mode. Enum values of 2 or less are |
579 | * input modes. | |
580 | * | |
581 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
582 | * reduces noise slightly (particularly on input) so we'll |
583 | * do it. However, having both input and output buffers | |
584 | * enabled simultaneously doesn't seem to be problematic if | |
585 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
586 | */ |
587 | if (val <= 2) { | |
47fd830a TI |
588 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
589 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
590 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
591 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 592 | } else { |
47fd830a TI |
593 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
594 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
595 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
596 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
597 | } |
598 | } | |
a9430dd8 JW |
599 | return change; |
600 | } | |
601 | ||
4c5186ed | 602 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 603 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
604 | .info = alc_pin_mode_info, \ |
605 | .get = alc_pin_mode_get, \ | |
606 | .put = alc_pin_mode_put, \ | |
607 | .private_value = nid | (dir<<16) } | |
df694daa | 608 | |
5c8f858d JW |
609 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
610 | * together using a mask with more than one bit set. This control is | |
611 | * currently used only by the ALC260 test model. At this stage they are not | |
612 | * needed for any "production" models. | |
613 | */ | |
614 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 615 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 616 | |
9c7f852e TI |
617 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
618 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
619 | { |
620 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
621 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
622 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
623 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
624 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
625 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
626 | |
627 | *valp = (val & mask) != 0; | |
628 | return 0; | |
629 | } | |
9c7f852e TI |
630 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
631 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
632 | { |
633 | signed int change; | |
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 val = *ucontrol->value.integer.value; | |
9c7f852e TI |
638 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
639 | AC_VERB_GET_GPIO_DATA, | |
640 | 0x00); | |
5c8f858d JW |
641 | |
642 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
643 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
644 | if (val == 0) | |
5c8f858d JW |
645 | gpio_data &= ~mask; |
646 | else | |
647 | gpio_data |= mask; | |
82beb8fd TI |
648 | snd_hda_codec_write_cache(codec, nid, 0, |
649 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
650 | |
651 | return change; | |
652 | } | |
653 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
654 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
655 | .info = alc_gpio_data_info, \ | |
656 | .get = alc_gpio_data_get, \ | |
657 | .put = alc_gpio_data_put, \ | |
658 | .private_value = nid | (mask<<16) } | |
659 | #endif /* CONFIG_SND_DEBUG */ | |
660 | ||
92621f13 JW |
661 | /* A switch control to allow the enabling of the digital IO pins on the |
662 | * ALC260. This is incredibly simplistic; the intention of this control is | |
663 | * to provide something in the test model allowing digital outputs to be | |
664 | * identified if present. If models are found which can utilise these | |
665 | * outputs a more complete mixer control can be devised for those models if | |
666 | * necessary. | |
667 | */ | |
668 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 669 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 670 | |
9c7f852e TI |
671 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
672 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
673 | { |
674 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
675 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
676 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
677 | long *valp = ucontrol->value.integer.value; | |
9c7f852e | 678 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 679 | AC_VERB_GET_DIGI_CONVERT_1, 0x00); |
92621f13 JW |
680 | |
681 | *valp = (val & mask) != 0; | |
682 | return 0; | |
683 | } | |
9c7f852e TI |
684 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
685 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
686 | { |
687 | signed int change; | |
688 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
689 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
690 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
691 | long val = *ucontrol->value.integer.value; | |
9c7f852e | 692 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 693 | AC_VERB_GET_DIGI_CONVERT_1, |
9c7f852e | 694 | 0x00); |
92621f13 JW |
695 | |
696 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 697 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
698 | if (val==0) |
699 | ctrl_data &= ~mask; | |
700 | else | |
701 | ctrl_data |= mask; | |
82beb8fd TI |
702 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
703 | ctrl_data); | |
92621f13 JW |
704 | |
705 | return change; | |
706 | } | |
707 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
708 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
709 | .info = alc_spdif_ctrl_info, \ | |
710 | .get = alc_spdif_ctrl_get, \ | |
711 | .put = alc_spdif_ctrl_put, \ | |
712 | .private_value = nid | (mask<<16) } | |
713 | #endif /* CONFIG_SND_DEBUG */ | |
714 | ||
f8225f6d JW |
715 | /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. |
716 | * Again, this is only used in the ALC26x test models to help identify when | |
717 | * the EAPD line must be asserted for features to work. | |
718 | */ | |
719 | #ifdef CONFIG_SND_DEBUG | |
720 | #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info | |
721 | ||
722 | static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, | |
723 | struct snd_ctl_elem_value *ucontrol) | |
724 | { | |
725 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
726 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
727 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
728 | long *valp = ucontrol->value.integer.value; | |
729 | unsigned int val = snd_hda_codec_read(codec, nid, 0, | |
730 | AC_VERB_GET_EAPD_BTLENABLE, 0x00); | |
731 | ||
732 | *valp = (val & mask) != 0; | |
733 | return 0; | |
734 | } | |
735 | ||
736 | static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, | |
737 | struct snd_ctl_elem_value *ucontrol) | |
738 | { | |
739 | int change; | |
740 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
741 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
742 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
743 | long val = *ucontrol->value.integer.value; | |
744 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, | |
745 | AC_VERB_GET_EAPD_BTLENABLE, | |
746 | 0x00); | |
747 | ||
748 | /* Set/unset the masked control bit(s) as needed */ | |
749 | change = (!val ? 0 : mask) != (ctrl_data & mask); | |
750 | if (!val) | |
751 | ctrl_data &= ~mask; | |
752 | else | |
753 | ctrl_data |= mask; | |
754 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
755 | ctrl_data); | |
756 | ||
757 | return change; | |
758 | } | |
759 | ||
760 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ | |
761 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
762 | .info = alc_eapd_ctrl_info, \ | |
763 | .get = alc_eapd_ctrl_get, \ | |
764 | .put = alc_eapd_ctrl_put, \ | |
765 | .private_value = nid | (mask<<16) } | |
766 | #endif /* CONFIG_SND_DEBUG */ | |
767 | ||
d88897ea TI |
768 | /* |
769 | */ | |
770 | static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix) | |
771 | { | |
772 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) | |
773 | return; | |
774 | spec->mixers[spec->num_mixers++] = mix; | |
775 | } | |
776 | ||
777 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) | |
778 | { | |
779 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) | |
780 | return; | |
781 | spec->init_verbs[spec->num_init_verbs++] = verb; | |
782 | } | |
783 | ||
daead538 TI |
784 | #ifdef CONFIG_PROC_FS |
785 | /* | |
786 | * hook for proc | |
787 | */ | |
788 | static void print_realtek_coef(struct snd_info_buffer *buffer, | |
789 | struct hda_codec *codec, hda_nid_t nid) | |
790 | { | |
791 | int coeff; | |
792 | ||
793 | if (nid != 0x20) | |
794 | return; | |
795 | coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0); | |
796 | snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff); | |
797 | coeff = snd_hda_codec_read(codec, nid, 0, | |
798 | AC_VERB_GET_COEF_INDEX, 0); | |
799 | snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff); | |
800 | } | |
801 | #else | |
802 | #define print_realtek_coef NULL | |
803 | #endif | |
804 | ||
df694daa KY |
805 | /* |
806 | * set up from the preset table | |
807 | */ | |
9c7f852e TI |
808 | static void setup_preset(struct alc_spec *spec, |
809 | const struct alc_config_preset *preset) | |
df694daa KY |
810 | { |
811 | int i; | |
812 | ||
813 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
d88897ea | 814 | add_mixer(spec, preset->mixers[i]); |
f9e336f6 | 815 | spec->cap_mixer = preset->cap_mixer; |
9c7f852e TI |
816 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
817 | i++) | |
d88897ea | 818 | add_verb(spec, preset->init_verbs[i]); |
ea1fb29a | 819 | |
df694daa KY |
820 | spec->channel_mode = preset->channel_mode; |
821 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 822 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
823 | |
824 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
825 | ||
826 | spec->multiout.num_dacs = preset->num_dacs; | |
827 | spec->multiout.dac_nids = preset->dac_nids; | |
828 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
b25c9da1 | 829 | spec->multiout.slave_dig_outs = preset->slave_dig_outs; |
df694daa | 830 | spec->multiout.hp_nid = preset->hp_nid; |
ea1fb29a | 831 | |
a1e8d2da | 832 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 833 | if (!spec->num_mux_defs) |
a1e8d2da | 834 | spec->num_mux_defs = 1; |
df694daa KY |
835 | spec->input_mux = preset->input_mux; |
836 | ||
837 | spec->num_adc_nids = preset->num_adc_nids; | |
838 | spec->adc_nids = preset->adc_nids; | |
e1406348 | 839 | spec->capsrc_nids = preset->capsrc_nids; |
df694daa | 840 | spec->dig_in_nid = preset->dig_in_nid; |
ae6b813a TI |
841 | |
842 | spec->unsol_event = preset->unsol_event; | |
843 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
844 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
845 | spec->loopback.amplist = preset->loopbacks; | |
846 | #endif | |
df694daa KY |
847 | } |
848 | ||
bc9f98a9 KY |
849 | /* Enable GPIO mask and set output */ |
850 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
851 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
852 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
853 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
854 | { } | |
855 | }; | |
856 | ||
857 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
858 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
859 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
860 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
861 | { } | |
862 | }; | |
863 | ||
bdd148a3 KY |
864 | static struct hda_verb alc_gpio3_init_verbs[] = { |
865 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
866 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
867 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
868 | { } | |
869 | }; | |
870 | ||
2c3bf9ab TI |
871 | /* |
872 | * Fix hardware PLL issue | |
873 | * On some codecs, the analog PLL gating control must be off while | |
874 | * the default value is 1. | |
875 | */ | |
876 | static void alc_fix_pll(struct hda_codec *codec) | |
877 | { | |
878 | struct alc_spec *spec = codec->spec; | |
879 | unsigned int val; | |
880 | ||
881 | if (!spec->pll_nid) | |
882 | return; | |
883 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
884 | spec->pll_coef_idx); | |
885 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, | |
886 | AC_VERB_GET_PROC_COEF, 0); | |
887 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
888 | spec->pll_coef_idx); | |
889 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, | |
890 | val & ~(1 << spec->pll_coef_bit)); | |
891 | } | |
892 | ||
893 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |
894 | unsigned int coef_idx, unsigned int coef_bit) | |
895 | { | |
896 | struct alc_spec *spec = codec->spec; | |
897 | spec->pll_nid = nid; | |
898 | spec->pll_coef_idx = coef_idx; | |
899 | spec->pll_coef_bit = coef_bit; | |
900 | alc_fix_pll(codec); | |
901 | } | |
902 | ||
c9b58006 KY |
903 | static void alc_sku_automute(struct hda_codec *codec) |
904 | { | |
905 | struct alc_spec *spec = codec->spec; | |
c9b58006 KY |
906 | unsigned int present; |
907 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | |
908 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | |
909 | ||
910 | /* need to execute and sync at first */ | |
911 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | |
912 | present = snd_hda_codec_read(codec, hp_nid, 0, | |
913 | AC_VERB_GET_PIN_SENSE, 0); | |
914 | spec->jack_present = (present & 0x80000000) != 0; | |
f6c7e546 TI |
915 | snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
916 | spec->jack_present ? 0 : PIN_OUT); | |
c9b58006 KY |
917 | } |
918 | ||
4605b718 | 919 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
7fb0d78f KY |
920 | static void alc_mic_automute(struct hda_codec *codec) |
921 | { | |
922 | struct alc_spec *spec = codec->spec; | |
923 | unsigned int present; | |
924 | unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
925 | unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
926 | unsigned int mix_nid = spec->capsrc_nids[0]; | |
927 | unsigned int capsrc_idx_mic, capsrc_idx_fmic; | |
928 | ||
929 | capsrc_idx_mic = mic_nid - 0x18; | |
930 | capsrc_idx_fmic = fmic_nid - 0x18; | |
931 | present = snd_hda_codec_read(codec, mic_nid, 0, | |
932 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
933 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
934 | 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); | |
935 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
936 | 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); | |
937 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, | |
938 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
939 | } | |
4605b718 | 940 | #else |
45bdd1c1 | 941 | #define alc_mic_automute(codec) do {} while(0) /* NOP */ |
4605b718 | 942 | #endif /* disabled */ |
7fb0d78f | 943 | |
c9b58006 KY |
944 | /* unsolicited event for HP jack sensing */ |
945 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |
946 | { | |
947 | if (codec->vendor_id == 0x10ec0880) | |
948 | res >>= 28; | |
949 | else | |
950 | res >>= 26; | |
7fb0d78f KY |
951 | if (res == ALC880_HP_EVENT) |
952 | alc_sku_automute(codec); | |
c9b58006 | 953 | |
7fb0d78f KY |
954 | if (res == ALC880_MIC_EVENT) |
955 | alc_mic_automute(codec); | |
956 | } | |
957 | ||
958 | static void alc_inithook(struct hda_codec *codec) | |
959 | { | |
c9b58006 | 960 | alc_sku_automute(codec); |
7fb0d78f | 961 | alc_mic_automute(codec); |
c9b58006 KY |
962 | } |
963 | ||
f9423e7a KY |
964 | /* additional initialization for ALC888 variants */ |
965 | static void alc888_coef_init(struct hda_codec *codec) | |
966 | { | |
967 | unsigned int tmp; | |
968 | ||
969 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); | |
970 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
971 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
972 | if ((tmp & 0xf0) == 2) | |
973 | /* alc888S-VC */ | |
974 | snd_hda_codec_read(codec, 0x20, 0, | |
975 | AC_VERB_SET_PROC_COEF, 0x830); | |
976 | else | |
977 | /* alc888-VB */ | |
978 | snd_hda_codec_read(codec, 0x20, 0, | |
979 | AC_VERB_SET_PROC_COEF, 0x3030); | |
980 | } | |
981 | ||
bc9f98a9 KY |
982 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
983 | * 31 ~ 16 : Manufacture ID | |
984 | * 15 ~ 8 : SKU ID | |
985 | * 7 ~ 0 : Assembly ID | |
986 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
987 | */ | |
988 | static void alc_subsystem_id(struct hda_codec *codec, | |
989 | unsigned int porta, unsigned int porte, | |
990 | unsigned int portd) | |
991 | { | |
c9b58006 KY |
992 | unsigned int ass, tmp, i; |
993 | unsigned nid; | |
994 | struct alc_spec *spec = codec->spec; | |
bc9f98a9 | 995 | |
c9b58006 KY |
996 | ass = codec->subsystem_id & 0xffff; |
997 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
998 | goto do_sku; | |
999 | ||
ea1fb29a | 1000 | /* |
c9b58006 KY |
1001 | * 31~30 : port conetcivity |
1002 | * 29~21 : reserve | |
1003 | * 20 : PCBEEP input | |
1004 | * 19~16 : Check sum (15:1) | |
1005 | * 15~1 : Custom | |
1006 | * 0 : override | |
1007 | */ | |
1008 | nid = 0x1d; | |
1009 | if (codec->vendor_id == 0x10ec0260) | |
1010 | nid = 0x17; | |
1011 | ass = snd_hda_codec_read(codec, nid, 0, | |
1012 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
1013 | if (!(ass & 1) && !(ass & 0x100000)) | |
1014 | return; | |
1015 | if ((ass >> 30) != 1) /* no physical connection */ | |
bc9f98a9 KY |
1016 | return; |
1017 | ||
c9b58006 KY |
1018 | /* check sum */ |
1019 | tmp = 0; | |
1020 | for (i = 1; i < 16; i++) { | |
8c427226 | 1021 | if ((ass >> i) & 1) |
c9b58006 KY |
1022 | tmp++; |
1023 | } | |
1024 | if (((ass >> 16) & 0xf) != tmp) | |
1025 | return; | |
1026 | do_sku: | |
1027 | /* | |
1028 | * 0 : override | |
1029 | * 1 : Swap Jack | |
1030 | * 2 : 0 --> Desktop, 1 --> Laptop | |
1031 | * 3~5 : External Amplifier control | |
1032 | * 7~6 : Reserved | |
1033 | */ | |
bc9f98a9 KY |
1034 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
1035 | switch (tmp) { | |
1036 | case 1: | |
1037 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
1038 | break; | |
1039 | case 3: | |
1040 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
1041 | break; | |
bdd148a3 KY |
1042 | case 7: |
1043 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
1044 | break; | |
c9b58006 | 1045 | case 5: /* set EAPD output high */ |
bdd148a3 | 1046 | switch (codec->vendor_id) { |
c9b58006 KY |
1047 | case 0x10ec0260: |
1048 | snd_hda_codec_write(codec, 0x0f, 0, | |
1049 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1050 | snd_hda_codec_write(codec, 0x10, 0, | |
1051 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1052 | break; | |
1053 | case 0x10ec0262: | |
bdd148a3 KY |
1054 | case 0x10ec0267: |
1055 | case 0x10ec0268: | |
c9b58006 | 1056 | case 0x10ec0269: |
c6e8f2da | 1057 | case 0x10ec0272: |
f9423e7a KY |
1058 | case 0x10ec0660: |
1059 | case 0x10ec0662: | |
1060 | case 0x10ec0663: | |
c9b58006 | 1061 | case 0x10ec0862: |
20a3a05d | 1062 | case 0x10ec0889: |
bdd148a3 KY |
1063 | snd_hda_codec_write(codec, 0x14, 0, |
1064 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1065 | snd_hda_codec_write(codec, 0x15, 0, | |
1066 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
c9b58006 | 1067 | break; |
bdd148a3 | 1068 | } |
c9b58006 KY |
1069 | switch (codec->vendor_id) { |
1070 | case 0x10ec0260: | |
1071 | snd_hda_codec_write(codec, 0x1a, 0, | |
1072 | AC_VERB_SET_COEF_INDEX, 7); | |
1073 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
1074 | AC_VERB_GET_PROC_COEF, 0); | |
1075 | snd_hda_codec_write(codec, 0x1a, 0, | |
1076 | AC_VERB_SET_COEF_INDEX, 7); | |
1077 | snd_hda_codec_write(codec, 0x1a, 0, | |
1078 | AC_VERB_SET_PROC_COEF, | |
1079 | tmp | 0x2010); | |
1080 | break; | |
1081 | case 0x10ec0262: | |
1082 | case 0x10ec0880: | |
1083 | case 0x10ec0882: | |
1084 | case 0x10ec0883: | |
1085 | case 0x10ec0885: | |
4a5a4c56 | 1086 | case 0x10ec0887: |
20a3a05d | 1087 | case 0x10ec0889: |
c9b58006 KY |
1088 | snd_hda_codec_write(codec, 0x20, 0, |
1089 | AC_VERB_SET_COEF_INDEX, 7); | |
1090 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
1091 | AC_VERB_GET_PROC_COEF, 0); | |
1092 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 1093 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
1094 | snd_hda_codec_write(codec, 0x20, 0, |
1095 | AC_VERB_SET_PROC_COEF, | |
1096 | tmp | 0x2010); | |
1097 | break; | |
f9423e7a | 1098 | case 0x10ec0888: |
1082c748 | 1099 | /*alc888_coef_init(codec);*/ /* called in alc_init() */ |
f9423e7a | 1100 | break; |
c9b58006 KY |
1101 | case 0x10ec0267: |
1102 | case 0x10ec0268: | |
1103 | snd_hda_codec_write(codec, 0x20, 0, | |
1104 | AC_VERB_SET_COEF_INDEX, 7); | |
1105 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
1106 | AC_VERB_GET_PROC_COEF, 0); | |
1107 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 1108 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
1109 | snd_hda_codec_write(codec, 0x20, 0, |
1110 | AC_VERB_SET_PROC_COEF, | |
1111 | tmp | 0x3000); | |
1112 | break; | |
bc9f98a9 | 1113 | } |
c9b58006 | 1114 | default: |
bc9f98a9 KY |
1115 | break; |
1116 | } | |
ea1fb29a | 1117 | |
8c427226 | 1118 | /* is laptop or Desktop and enable the function "Mute internal speaker |
c9b58006 KY |
1119 | * when the external headphone out jack is plugged" |
1120 | */ | |
8c427226 | 1121 | if (!(ass & 0x8000)) |
c9b58006 KY |
1122 | return; |
1123 | /* | |
1124 | * 10~8 : Jack location | |
1125 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
1126 | * 14~13: Resvered | |
1127 | * 15 : 1 --> enable the function "Mute internal speaker | |
1128 | * when the external headphone out jack is plugged" | |
1129 | */ | |
1130 | if (!spec->autocfg.speaker_pins[0]) { | |
8c427226 | 1131 | if (spec->autocfg.line_out_pins[0]) |
c9b58006 | 1132 | spec->autocfg.speaker_pins[0] = |
8c427226 | 1133 | spec->autocfg.line_out_pins[0]; |
c9b58006 KY |
1134 | else |
1135 | return; | |
1136 | } | |
1137 | ||
1138 | if (!spec->autocfg.hp_pins[0]) { | |
1139 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | |
1140 | if (tmp == 0) | |
1141 | spec->autocfg.hp_pins[0] = porta; | |
1142 | else if (tmp == 1) | |
1143 | spec->autocfg.hp_pins[0] = porte; | |
1144 | else if (tmp == 2) | |
1145 | spec->autocfg.hp_pins[0] = portd; | |
1146 | else | |
1147 | return; | |
1148 | } | |
7fb0d78f KY |
1149 | if (spec->autocfg.hp_pins[0]) |
1150 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | |
1151 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1152 | AC_USRSP_EN | ALC880_HP_EVENT); | |
c9b58006 | 1153 | |
4605b718 | 1154 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
7fb0d78f KY |
1155 | if (spec->autocfg.input_pins[AUTO_PIN_MIC] && |
1156 | spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]) | |
1157 | snd_hda_codec_write(codec, | |
1158 | spec->autocfg.input_pins[AUTO_PIN_MIC], 0, | |
1159 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1160 | AC_USRSP_EN | ALC880_MIC_EVENT); | |
4605b718 | 1161 | #endif /* disabled */ |
ea1fb29a | 1162 | |
c9b58006 | 1163 | spec->unsol_event = alc_sku_unsol_event; |
bc9f98a9 KY |
1164 | } |
1165 | ||
f95474ec TI |
1166 | /* |
1167 | * Fix-up pin default configurations | |
1168 | */ | |
1169 | ||
1170 | struct alc_pincfg { | |
1171 | hda_nid_t nid; | |
1172 | u32 val; | |
1173 | }; | |
1174 | ||
1175 | static void alc_fix_pincfg(struct hda_codec *codec, | |
1176 | const struct snd_pci_quirk *quirk, | |
1177 | const struct alc_pincfg **pinfix) | |
1178 | { | |
1179 | const struct alc_pincfg *cfg; | |
1180 | ||
1181 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
1182 | if (!quirk) | |
1183 | return; | |
1184 | ||
1185 | cfg = pinfix[quirk->value]; | |
1186 | for (; cfg->nid; cfg++) { | |
1187 | int i; | |
1188 | u32 val = cfg->val; | |
1189 | for (i = 0; i < 4; i++) { | |
1190 | snd_hda_codec_write(codec, cfg->nid, 0, | |
1191 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
1192 | val & 0xff); | |
1193 | val >>= 8; | |
1194 | } | |
1195 | } | |
1196 | } | |
1197 | ||
ef8ef5fb VP |
1198 | /* |
1199 | * ALC888 | |
1200 | */ | |
1201 | ||
1202 | /* | |
1203 | * 2ch mode | |
1204 | */ | |
1205 | static struct hda_verb alc888_4ST_ch2_intel_init[] = { | |
1206 | /* Mic-in jack as mic in */ | |
1207 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1208 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1209 | /* Line-in jack as Line in */ | |
1210 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1211 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1212 | /* Line-Out as Front */ | |
1213 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1214 | { } /* end */ | |
1215 | }; | |
1216 | ||
1217 | /* | |
1218 | * 4ch mode | |
1219 | */ | |
1220 | static struct hda_verb alc888_4ST_ch4_intel_init[] = { | |
1221 | /* Mic-in jack as mic in */ | |
1222 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1223 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1224 | /* Line-in jack as Surround */ | |
1225 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1226 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1227 | /* Line-Out as Front */ | |
1228 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1229 | { } /* end */ | |
1230 | }; | |
1231 | ||
1232 | /* | |
1233 | * 6ch mode | |
1234 | */ | |
1235 | static struct hda_verb alc888_4ST_ch6_intel_init[] = { | |
1236 | /* Mic-in jack as CLFE */ | |
1237 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1238 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1239 | /* Line-in jack as Surround */ | |
1240 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1241 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1242 | /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */ | |
1243 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1244 | { } /* end */ | |
1245 | }; | |
1246 | ||
1247 | /* | |
1248 | * 8ch mode | |
1249 | */ | |
1250 | static struct hda_verb alc888_4ST_ch8_intel_init[] = { | |
1251 | /* Mic-in jack as CLFE */ | |
1252 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1253 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1254 | /* Line-in jack as Surround */ | |
1255 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1256 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1257 | /* Line-Out as Side */ | |
1258 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1259 | { } /* end */ | |
1260 | }; | |
1261 | ||
1262 | static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = { | |
1263 | { 2, alc888_4ST_ch2_intel_init }, | |
1264 | { 4, alc888_4ST_ch4_intel_init }, | |
1265 | { 6, alc888_4ST_ch6_intel_init }, | |
1266 | { 8, alc888_4ST_ch8_intel_init }, | |
1267 | }; | |
1268 | ||
1269 | /* | |
1270 | * ALC888 Fujitsu Siemens Amillo xa3530 | |
1271 | */ | |
1272 | ||
1273 | static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { | |
1274 | /* Front Mic: set to PIN_IN (empty by default) */ | |
1275 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1276 | /* Connect Internal HP to Front */ | |
1277 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1278 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1279 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1280 | /* Connect Bass HP to Front */ | |
1281 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1282 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1283 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1284 | /* Connect Line-Out side jack (SPDIF) to Side */ | |
1285 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1286 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1287 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1288 | /* Connect Mic jack to CLFE */ | |
1289 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1290 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1291 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
1292 | /* Connect Line-in jack to Surround */ | |
1293 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1294 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1295 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1296 | /* Connect HP out jack to Front */ | |
1297 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1298 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1299 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1300 | /* Enable unsolicited event for HP jack and Line-out jack */ | |
1301 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
1302 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
1303 | {} | |
1304 | }; | |
1305 | ||
1306 | static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec) | |
1307 | { | |
1308 | unsigned int present; | |
1309 | unsigned int bits; | |
1310 | /* Line out presence */ | |
1311 | present = snd_hda_codec_read(codec, 0x17, 0, | |
1312 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1313 | /* HP out presence */ | |
1314 | present = present || snd_hda_codec_read(codec, 0x1b, 0, | |
1315 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1316 | bits = present ? HDA_AMP_MUTE : 0; | |
1317 | /* Toggle internal speakers muting */ | |
1318 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
1319 | HDA_AMP_MUTE, bits); | |
1320 | /* Toggle internal bass muting */ | |
1321 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
1322 | HDA_AMP_MUTE, bits); | |
1323 | } | |
1324 | ||
1325 | static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec, | |
1326 | unsigned int res) | |
1327 | { | |
1328 | if (res >> 26 == ALC880_HP_EVENT) | |
1329 | alc888_fujitsu_xa3530_automute(codec); | |
1330 | } | |
1331 | ||
1332 | ||
5b2d1eca VP |
1333 | /* |
1334 | * ALC888 Acer Aspire 4930G model | |
1335 | */ | |
1336 | ||
1337 | static struct hda_verb alc888_acer_aspire_4930g_verbs[] = { | |
1338 | /* Front Mic: set to PIN_IN (empty by default) */ | |
1339 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1340 | /* Unselect Front Mic by default in input mixer 3 */ | |
1341 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)}, | |
ef8ef5fb | 1342 | /* Enable unsolicited event for HP jack */ |
5b2d1eca VP |
1343 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
1344 | /* Connect Internal HP to front */ | |
1345 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1346 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1347 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1348 | /* Connect HP out to front */ | |
1349 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1350 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1351 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1352 | { } | |
1353 | }; | |
1354 | ||
ef8ef5fb | 1355 | static struct hda_input_mux alc888_2_capture_sources[2] = { |
5b2d1eca VP |
1356 | /* Front mic only available on one ADC */ |
1357 | { | |
1358 | .num_items = 4, | |
1359 | .items = { | |
1360 | { "Mic", 0x0 }, | |
1361 | { "Line", 0x2 }, | |
1362 | { "CD", 0x4 }, | |
1363 | { "Front Mic", 0xb }, | |
1364 | }, | |
1365 | }, | |
1366 | { | |
1367 | .num_items = 3, | |
1368 | .items = { | |
1369 | { "Mic", 0x0 }, | |
1370 | { "Line", 0x2 }, | |
1371 | { "CD", 0x4 }, | |
1372 | }, | |
1373 | } | |
1374 | }; | |
1375 | ||
ef8ef5fb | 1376 | static struct snd_kcontrol_new alc888_base_mixer[] = { |
5b2d1eca VP |
1377 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1378 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
1379 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1380 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
1381 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
1382 | HDA_OUTPUT), | |
1383 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1384 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1385 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1386 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1387 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
1388 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1389 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1390 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1391 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1392 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1393 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
1394 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5b2d1eca VP |
1395 | { } /* end */ |
1396 | }; | |
1397 | ||
1398 | static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec) | |
1399 | { | |
1400 | unsigned int present; | |
ef8ef5fb | 1401 | unsigned int bits; |
5b2d1eca VP |
1402 | present = snd_hda_codec_read(codec, 0x15, 0, |
1403 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
ef8ef5fb VP |
1404 | bits = present ? HDA_AMP_MUTE : 0; |
1405 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
1406 | HDA_AMP_MUTE, bits); | |
5b2d1eca VP |
1407 | } |
1408 | ||
1409 | static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec, | |
1410 | unsigned int res) | |
1411 | { | |
1412 | if (res >> 26 == ALC880_HP_EVENT) | |
1413 | alc888_acer_aspire_4930g_automute(codec); | |
1414 | } | |
1415 | ||
1da177e4 | 1416 | /* |
e9edcee0 TI |
1417 | * ALC880 3-stack model |
1418 | * | |
1419 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
1420 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
1421 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
1422 | */ |
1423 | ||
e9edcee0 TI |
1424 | static hda_nid_t alc880_dac_nids[4] = { |
1425 | /* front, rear, clfe, rear_surr */ | |
1426 | 0x02, 0x05, 0x04, 0x03 | |
1427 | }; | |
1428 | ||
1429 | static hda_nid_t alc880_adc_nids[3] = { | |
1430 | /* ADC0-2 */ | |
1431 | 0x07, 0x08, 0x09, | |
1432 | }; | |
1433 | ||
1434 | /* The datasheet says the node 0x07 is connected from inputs, | |
1435 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 1436 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 1437 | */ |
e9edcee0 TI |
1438 | static hda_nid_t alc880_adc_nids_alt[2] = { |
1439 | /* ADC1-2 */ | |
1440 | 0x08, 0x09, | |
1441 | }; | |
1442 | ||
1443 | #define ALC880_DIGOUT_NID 0x06 | |
1444 | #define ALC880_DIGIN_NID 0x0a | |
1445 | ||
1446 | static struct hda_input_mux alc880_capture_source = { | |
1447 | .num_items = 4, | |
1448 | .items = { | |
1449 | { "Mic", 0x0 }, | |
1450 | { "Front Mic", 0x3 }, | |
1451 | { "Line", 0x2 }, | |
1452 | { "CD", 0x4 }, | |
1453 | }, | |
1454 | }; | |
1455 | ||
1456 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
1457 | /* 2ch mode */ | |
1458 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
1459 | /* set line-in to input, mute it */ | |
1460 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1461 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1462 | /* set mic-in to input vref 80%, mute it */ | |
1463 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1464 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1465 | { } /* end */ | |
1466 | }; | |
1467 | ||
1468 | /* 6ch mode */ | |
1469 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
1470 | /* set line-in to output, unmute it */ | |
1471 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1472 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1473 | /* set mic-in to output, unmute it */ | |
1474 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1475 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1476 | { } /* end */ | |
1477 | }; | |
1478 | ||
d2a6d7dc | 1479 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
1480 | { 2, alc880_threestack_ch2_init }, |
1481 | { 6, alc880_threestack_ch6_init }, | |
1482 | }; | |
1483 | ||
c8b6bf9b | 1484 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 1485 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1486 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 1487 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1488 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
1489 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1490 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1491 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1492 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
1493 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1494 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1495 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1496 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1497 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1498 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1499 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
1500 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
e9edcee0 TI |
1501 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
1502 | { | |
1503 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1504 | .name = "Channel Mode", | |
df694daa KY |
1505 | .info = alc_ch_mode_info, |
1506 | .get = alc_ch_mode_get, | |
1507 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
1508 | }, |
1509 | { } /* end */ | |
1510 | }; | |
1511 | ||
1512 | /* capture mixer elements */ | |
f9e336f6 TI |
1513 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
1514 | struct snd_ctl_elem_info *uinfo) | |
1515 | { | |
1516 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1517 | struct alc_spec *spec = codec->spec; | |
1518 | int err; | |
1da177e4 | 1519 | |
5a9e02e9 | 1520 | mutex_lock(&codec->control_mutex); |
f9e336f6 TI |
1521 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, |
1522 | HDA_INPUT); | |
1523 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); | |
5a9e02e9 | 1524 | mutex_unlock(&codec->control_mutex); |
f9e336f6 TI |
1525 | return err; |
1526 | } | |
1527 | ||
1528 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |
1529 | unsigned int size, unsigned int __user *tlv) | |
1530 | { | |
1531 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1532 | struct alc_spec *spec = codec->spec; | |
1533 | int err; | |
1da177e4 | 1534 | |
5a9e02e9 | 1535 | mutex_lock(&codec->control_mutex); |
f9e336f6 TI |
1536 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, |
1537 | HDA_INPUT); | |
1538 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); | |
5a9e02e9 | 1539 | mutex_unlock(&codec->control_mutex); |
f9e336f6 TI |
1540 | return err; |
1541 | } | |
1542 | ||
1543 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, | |
1544 | struct snd_ctl_elem_value *ucontrol); | |
1545 | ||
1546 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, | |
1547 | struct snd_ctl_elem_value *ucontrol, | |
1548 | getput_call_t func) | |
1549 | { | |
1550 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1551 | struct alc_spec *spec = codec->spec; | |
1552 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
1553 | int err; | |
1554 | ||
5a9e02e9 | 1555 | mutex_lock(&codec->control_mutex); |
f9e336f6 TI |
1556 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx], |
1557 | 3, 0, HDA_INPUT); | |
1558 | err = func(kcontrol, ucontrol); | |
5a9e02e9 | 1559 | mutex_unlock(&codec->control_mutex); |
f9e336f6 TI |
1560 | return err; |
1561 | } | |
1562 | ||
1563 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, | |
1564 | struct snd_ctl_elem_value *ucontrol) | |
1565 | { | |
1566 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1567 | snd_hda_mixer_amp_volume_get); | |
1568 | } | |
1569 | ||
1570 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, | |
1571 | struct snd_ctl_elem_value *ucontrol) | |
1572 | { | |
1573 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1574 | snd_hda_mixer_amp_volume_put); | |
1575 | } | |
1576 | ||
1577 | /* capture mixer elements */ | |
1578 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info | |
1579 | ||
1580 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, | |
1581 | struct snd_ctl_elem_value *ucontrol) | |
1582 | { | |
1583 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1584 | snd_hda_mixer_amp_switch_get); | |
1585 | } | |
1586 | ||
1587 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, | |
1588 | struct snd_ctl_elem_value *ucontrol) | |
1589 | { | |
1590 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1591 | snd_hda_mixer_amp_switch_put); | |
1592 | } | |
1593 | ||
1594 | #define DEFINE_CAPMIX(num) \ | |
1595 | static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ | |
1596 | { \ | |
1597 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1598 | .name = "Capture Switch", \ | |
1599 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
1600 | .count = num, \ | |
1601 | .info = alc_cap_sw_info, \ | |
1602 | .get = alc_cap_sw_get, \ | |
1603 | .put = alc_cap_sw_put, \ | |
1604 | }, \ | |
1605 | { \ | |
1606 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1607 | .name = "Capture Volume", \ | |
1608 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | |
1609 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
1610 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ | |
1611 | .count = num, \ | |
1612 | .info = alc_cap_vol_info, \ | |
1613 | .get = alc_cap_vol_get, \ | |
1614 | .put = alc_cap_vol_put, \ | |
1615 | .tlv = { .c = alc_cap_vol_tlv }, \ | |
1616 | }, \ | |
3c3e9892 TI |
1617 | { \ |
1618 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1619 | /* .name = "Capture Source", */ \ | |
1620 | .name = "Input Source", \ | |
1621 | .count = num, \ | |
1622 | .info = alc_mux_enum_info, \ | |
1623 | .get = alc_mux_enum_get, \ | |
1624 | .put = alc_mux_enum_put, \ | |
1625 | }, \ | |
f9e336f6 TI |
1626 | { } /* end */ \ |
1627 | } | |
1628 | ||
1629 | /* up to three ADCs */ | |
1630 | DEFINE_CAPMIX(1); | |
1631 | DEFINE_CAPMIX(2); | |
1632 | DEFINE_CAPMIX(3); | |
e9edcee0 TI |
1633 | |
1634 | ||
1635 | /* | |
1636 | * ALC880 5-stack model | |
1637 | * | |
9c7f852e TI |
1638 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
1639 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
1640 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
1641 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
1642 | */ | |
1643 | ||
1644 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 1645 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 1646 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1647 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
1648 | { } /* end */ |
1649 | }; | |
1650 | ||
e9edcee0 TI |
1651 | /* channel source setting (6/8 channel selection for 5-stack) */ |
1652 | /* 6ch mode */ | |
1653 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
1654 | /* set line-in to input, mute it */ | |
1655 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1656 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
1657 | { } /* end */ |
1658 | }; | |
1659 | ||
e9edcee0 TI |
1660 | /* 8ch mode */ |
1661 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
1662 | /* set line-in to output, unmute it */ | |
1663 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1664 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1665 | { } /* end */ | |
1666 | }; | |
1667 | ||
d2a6d7dc | 1668 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
1669 | { 6, alc880_fivestack_ch6_init }, |
1670 | { 8, alc880_fivestack_ch8_init }, | |
1671 | }; | |
1672 | ||
1673 | ||
1674 | /* | |
1675 | * ALC880 6-stack model | |
1676 | * | |
9c7f852e TI |
1677 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
1678 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
1679 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
1680 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
1681 | */ | |
1682 | ||
1683 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
1684 | /* front, rear, clfe, rear_surr */ | |
1685 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 1686 | }; |
e9edcee0 TI |
1687 | |
1688 | static struct hda_input_mux alc880_6stack_capture_source = { | |
1689 | .num_items = 4, | |
1690 | .items = { | |
1691 | { "Mic", 0x0 }, | |
1692 | { "Front Mic", 0x1 }, | |
1693 | { "Line", 0x2 }, | |
1694 | { "CD", 0x4 }, | |
1695 | }, | |
1696 | }; | |
1697 | ||
1698 | /* fixed 8-channels */ | |
d2a6d7dc | 1699 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
1700 | { 8, NULL }, |
1701 | }; | |
1702 | ||
c8b6bf9b | 1703 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 1704 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1705 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1706 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1707 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1708 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1709 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1710 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1711 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 1712 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1713 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
1714 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1715 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1716 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1717 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1718 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1719 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1720 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1721 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
16ded525 TI |
1722 | { |
1723 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1724 | .name = "Channel Mode", | |
df694daa KY |
1725 | .info = alc_ch_mode_info, |
1726 | .get = alc_ch_mode_get, | |
1727 | .put = alc_ch_mode_put, | |
16ded525 TI |
1728 | }, |
1729 | { } /* end */ | |
1730 | }; | |
1731 | ||
e9edcee0 TI |
1732 | |
1733 | /* | |
1734 | * ALC880 W810 model | |
1735 | * | |
1736 | * W810 has rear IO for: | |
1737 | * Front (DAC 02) | |
1738 | * Surround (DAC 03) | |
1739 | * Center/LFE (DAC 04) | |
1740 | * Digital out (06) | |
1741 | * | |
1742 | * The system also has a pair of internal speakers, and a headphone jack. | |
1743 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
ea1fb29a | 1744 | * |
e9edcee0 TI |
1745 | * There is a variable resistor to control the speaker or headphone |
1746 | * volume. This is a hardware-only device without a software API. | |
1747 | * | |
1748 | * Plugging headphones in will disable the internal speakers. This is | |
1749 | * implemented in hardware, not via the driver using jack sense. In | |
1750 | * a similar fashion, plugging into the rear socket marked "front" will | |
1751 | * disable both the speakers and headphones. | |
1752 | * | |
1753 | * For input, there's a microphone jack, and an "audio in" jack. | |
1754 | * These may not do anything useful with this driver yet, because I | |
1755 | * haven't setup any initialization verbs for these yet... | |
1756 | */ | |
1757 | ||
1758 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1759 | /* front, rear/surround, clfe */ | |
1760 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1761 | }; |
1762 | ||
e9edcee0 | 1763 | /* fixed 6 channels */ |
d2a6d7dc | 1764 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1765 | { 6, NULL } |
1766 | }; | |
1767 | ||
1768 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1769 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1770 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1771 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1772 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1773 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1774 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1775 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1776 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1777 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1778 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1779 | { } /* end */ | |
1780 | }; | |
1781 | ||
1782 | ||
1783 | /* | |
1784 | * Z710V model | |
1785 | * | |
1786 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1787 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1788 | * Line = 0x1a | |
e9edcee0 TI |
1789 | */ |
1790 | ||
1791 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1792 | 0x02 | |
1793 | }; | |
1794 | #define ALC880_Z71V_HP_DAC 0x03 | |
1795 | ||
1796 | /* fixed 2 channels */ | |
d2a6d7dc | 1797 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1798 | { 2, NULL } |
1799 | }; | |
1800 | ||
c8b6bf9b | 1801 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1802 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1803 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1804 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1805 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1806 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1807 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1808 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1809 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1810 | { } /* end */ |
1811 | }; | |
1812 | ||
e9edcee0 | 1813 | |
e9edcee0 TI |
1814 | /* |
1815 | * ALC880 F1734 model | |
1816 | * | |
1817 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1818 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1819 | */ | |
1820 | ||
1821 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1822 | 0x03 | |
1823 | }; | |
1824 | #define ALC880_F1734_HP_DAC 0x02 | |
1825 | ||
c8b6bf9b | 1826 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1827 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1828 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
2134ea4f TI |
1829 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
1830 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
e9edcee0 TI |
1831 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1832 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
937b4160 TI |
1833 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
1834 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e9edcee0 TI |
1835 | { } /* end */ |
1836 | }; | |
1837 | ||
937b4160 TI |
1838 | static struct hda_input_mux alc880_f1734_capture_source = { |
1839 | .num_items = 2, | |
1840 | .items = { | |
1841 | { "Mic", 0x1 }, | |
1842 | { "CD", 0x4 }, | |
1843 | }, | |
1844 | }; | |
1845 | ||
e9edcee0 | 1846 | |
e9edcee0 TI |
1847 | /* |
1848 | * ALC880 ASUS model | |
1849 | * | |
1850 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1851 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1852 | * Mic = 0x18, Line = 0x1a | |
1853 | */ | |
1854 | ||
1855 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1856 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1857 | ||
c8b6bf9b | 1858 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1859 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1860 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1861 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1862 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1863 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1864 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1865 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1866 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1867 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1868 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1869 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1870 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1871 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1872 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1873 | { |
1874 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1875 | .name = "Channel Mode", | |
df694daa KY |
1876 | .info = alc_ch_mode_info, |
1877 | .get = alc_ch_mode_get, | |
1878 | .put = alc_ch_mode_put, | |
16ded525 TI |
1879 | }, |
1880 | { } /* end */ | |
1881 | }; | |
e9edcee0 | 1882 | |
e9edcee0 TI |
1883 | /* |
1884 | * ALC880 ASUS W1V model | |
1885 | * | |
1886 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1887 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1888 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1889 | */ | |
1890 | ||
1891 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1892 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1893 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1894 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1895 | { } /* end */ | |
1896 | }; | |
1897 | ||
df694daa KY |
1898 | /* TCL S700 */ |
1899 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1900 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1901 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1902 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1903 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1904 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1905 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1906 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1907 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1908 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
df694daa KY |
1909 | { } /* end */ |
1910 | }; | |
1911 | ||
ccc656ce KY |
1912 | /* Uniwill */ |
1913 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
2134ea4f TI |
1914 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1915 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1916 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1917 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1918 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1919 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1920 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1921 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1922 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1923 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1924 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1925 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1926 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1927 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1928 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1929 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ccc656ce KY |
1930 | { |
1931 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1932 | .name = "Channel Mode", | |
1933 | .info = alc_ch_mode_info, | |
1934 | .get = alc_ch_mode_get, | |
1935 | .put = alc_ch_mode_put, | |
1936 | }, | |
1937 | { } /* end */ | |
1938 | }; | |
1939 | ||
2cf9f0fc TD |
1940 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1941 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1942 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1943 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1944 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1945 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1946 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1947 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1948 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1949 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1950 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1951 | { } /* end */ | |
1952 | }; | |
1953 | ||
ccc656ce | 1954 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
2134ea4f TI |
1955 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1956 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1957 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1958 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1959 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1960 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1961 | { } /* end */ | |
1962 | }; | |
1963 | ||
2134ea4f TI |
1964 | /* |
1965 | * virtual master controls | |
1966 | */ | |
1967 | ||
1968 | /* | |
1969 | * slave controls for virtual master | |
1970 | */ | |
1971 | static const char *alc_slave_vols[] = { | |
1972 | "Front Playback Volume", | |
1973 | "Surround Playback Volume", | |
1974 | "Center Playback Volume", | |
1975 | "LFE Playback Volume", | |
1976 | "Side Playback Volume", | |
1977 | "Headphone Playback Volume", | |
1978 | "Speaker Playback Volume", | |
1979 | "Mono Playback Volume", | |
2134ea4f | 1980 | "Line-Out Playback Volume", |
26f5df26 | 1981 | "PCM Playback Volume", |
2134ea4f TI |
1982 | NULL, |
1983 | }; | |
1984 | ||
1985 | static const char *alc_slave_sws[] = { | |
1986 | "Front Playback Switch", | |
1987 | "Surround Playback Switch", | |
1988 | "Center Playback Switch", | |
1989 | "LFE Playback Switch", | |
1990 | "Side Playback Switch", | |
1991 | "Headphone Playback Switch", | |
1992 | "Speaker Playback Switch", | |
1993 | "Mono Playback Switch", | |
edb54a55 | 1994 | "IEC958 Playback Switch", |
2134ea4f TI |
1995 | NULL, |
1996 | }; | |
1997 | ||
1da177e4 | 1998 | /* |
e9edcee0 | 1999 | * build control elements |
1da177e4 | 2000 | */ |
603c4019 TI |
2001 | |
2002 | static void alc_free_kctls(struct hda_codec *codec); | |
2003 | ||
45bdd1c1 TI |
2004 | /* additional beep mixers; the actual parameters are overwritten at build */ |
2005 | static struct snd_kcontrol_new alc_beep_mixer[] = { | |
2006 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), | |
2007 | HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT), | |
2008 | { } /* end */ | |
2009 | }; | |
2010 | ||
1da177e4 LT |
2011 | static int alc_build_controls(struct hda_codec *codec) |
2012 | { | |
2013 | struct alc_spec *spec = codec->spec; | |
2014 | int err; | |
2015 | int i; | |
2016 | ||
2017 | for (i = 0; i < spec->num_mixers; i++) { | |
2018 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
2019 | if (err < 0) | |
2020 | return err; | |
2021 | } | |
f9e336f6 TI |
2022 | if (spec->cap_mixer) { |
2023 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); | |
2024 | if (err < 0) | |
2025 | return err; | |
2026 | } | |
1da177e4 | 2027 | if (spec->multiout.dig_out_nid) { |
9c7f852e TI |
2028 | err = snd_hda_create_spdif_out_ctls(codec, |
2029 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
2030 | if (err < 0) |
2031 | return err; | |
e64f14f4 TI |
2032 | if (!spec->no_analog) { |
2033 | err = snd_hda_create_spdif_share_sw(codec, | |
2034 | &spec->multiout); | |
2035 | if (err < 0) | |
2036 | return err; | |
2037 | spec->multiout.share_spdif = 1; | |
2038 | } | |
1da177e4 LT |
2039 | } |
2040 | if (spec->dig_in_nid) { | |
2041 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
2042 | if (err < 0) | |
2043 | return err; | |
2044 | } | |
2134ea4f | 2045 | |
45bdd1c1 TI |
2046 | /* create beep controls if needed */ |
2047 | if (spec->beep_amp) { | |
2048 | struct snd_kcontrol_new *knew; | |
2049 | for (knew = alc_beep_mixer; knew->name; knew++) { | |
2050 | struct snd_kcontrol *kctl; | |
2051 | kctl = snd_ctl_new1(knew, codec); | |
2052 | if (!kctl) | |
2053 | return -ENOMEM; | |
2054 | kctl->private_value = spec->beep_amp; | |
2055 | err = snd_hda_ctl_add(codec, kctl); | |
2056 | if (err < 0) | |
2057 | return err; | |
2058 | } | |
2059 | } | |
2060 | ||
2134ea4f | 2061 | /* if we have no master control, let's create it */ |
e64f14f4 TI |
2062 | if (!spec->no_analog && |
2063 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
1c82ed1b | 2064 | unsigned int vmaster_tlv[4]; |
2134ea4f | 2065 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
1c82ed1b | 2066 | HDA_OUTPUT, vmaster_tlv); |
2134ea4f | 2067 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
1c82ed1b | 2068 | vmaster_tlv, alc_slave_vols); |
2134ea4f TI |
2069 | if (err < 0) |
2070 | return err; | |
2071 | } | |
e64f14f4 TI |
2072 | if (!spec->no_analog && |
2073 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
2134ea4f TI |
2074 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
2075 | NULL, alc_slave_sws); | |
2076 | if (err < 0) | |
2077 | return err; | |
2078 | } | |
2079 | ||
603c4019 | 2080 | alc_free_kctls(codec); /* no longer needed */ |
1da177e4 LT |
2081 | return 0; |
2082 | } | |
2083 | ||
e9edcee0 | 2084 | |
1da177e4 LT |
2085 | /* |
2086 | * initialize the codec volumes, etc | |
2087 | */ | |
2088 | ||
e9edcee0 TI |
2089 | /* |
2090 | * generic initialization of ADC, input mixers and output mixers | |
2091 | */ | |
2092 | static struct hda_verb alc880_volume_init_verbs[] = { | |
2093 | /* | |
2094 | * Unmute ADC0-2 and set the default input to mic-in | |
2095 | */ | |
71fe7b82 | 2096 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2097 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 2098 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2099 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 2100 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2101 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 2102 | |
e9edcee0 TI |
2103 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
2104 | * mixer widget | |
9c7f852e TI |
2105 | * Note: PASD motherboards uses the Line In 2 as the input for front |
2106 | * panel mic (mic 2) | |
1da177e4 | 2107 | */ |
e9edcee0 | 2108 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
2109 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2110 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2111 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2112 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2113 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2114 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
2115 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 2116 | |
e9edcee0 TI |
2117 | /* |
2118 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 2119 | */ |
e9edcee0 TI |
2120 | /* set vol=0 to output mixers */ |
2121 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2122 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2123 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2124 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2125 | /* set up input amps for analog loopback */ | |
2126 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
2127 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2128 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2129 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2130 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2131 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2132 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2133 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2134 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
2135 | |
2136 | { } | |
2137 | }; | |
2138 | ||
e9edcee0 TI |
2139 | /* |
2140 | * 3-stack pin configuration: | |
2141 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
2142 | */ | |
2143 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
2144 | /* | |
2145 | * preset connection lists of input pins | |
2146 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
2147 | */ | |
2148 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2149 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2150 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2151 | ||
2152 | /* | |
2153 | * Set pin mode and muting | |
2154 | */ | |
2155 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 2156 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2157 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2158 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2159 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2160 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2161 | /* Mic2 (as headphone out) for HP output */ | |
2162 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2163 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 2164 | /* Line In pin widget for input */ |
05acb863 | 2165 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
2166 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2167 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
2168 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2169 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 2170 | /* CD pin widget for input */ |
05acb863 | 2171 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 2172 | |
e9edcee0 TI |
2173 | { } |
2174 | }; | |
1da177e4 | 2175 | |
e9edcee0 TI |
2176 | /* |
2177 | * 5-stack pin configuration: | |
2178 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
2179 | * line-in/side = 0x1a, f-mic = 0x1b | |
2180 | */ | |
2181 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
2182 | /* | |
2183 | * preset connection lists of input pins | |
2184 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 2185 | */ |
e9edcee0 TI |
2186 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2187 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 2188 | |
e9edcee0 TI |
2189 | /* |
2190 | * Set pin mode and muting | |
1da177e4 | 2191 | */ |
e9edcee0 TI |
2192 | /* set pin widgets 0x14-0x17 for output */ |
2193 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2194 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2195 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2196 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2197 | /* unmute pins for output (no gain on this amp) */ | |
2198 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2199 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2200 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2201 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2202 | ||
2203 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2204 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2205 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2206 | /* Mic2 (as headphone out) for HP output */ | |
2207 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2208 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2209 | /* Line In pin widget for input */ | |
2210 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2211 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2212 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
2213 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2214 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2215 | /* CD pin widget for input */ | |
2216 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
2217 | |
2218 | { } | |
2219 | }; | |
2220 | ||
e9edcee0 TI |
2221 | /* |
2222 | * W810 pin configuration: | |
2223 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
2224 | */ | |
2225 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
2226 | /* hphone/speaker input selector: front DAC */ | |
2227 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 2228 | |
05acb863 | 2229 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2230 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2231 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2232 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2233 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2234 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 2235 | |
e9edcee0 | 2236 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 2237 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 2238 | |
1da177e4 LT |
2239 | { } |
2240 | }; | |
2241 | ||
e9edcee0 TI |
2242 | /* |
2243 | * Z71V pin configuration: | |
2244 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
2245 | */ | |
2246 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 2247 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2248 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2249 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 2250 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 2251 | |
16ded525 | 2252 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2253 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 2254 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2255 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
2256 | |
2257 | { } | |
2258 | }; | |
2259 | ||
e9edcee0 TI |
2260 | /* |
2261 | * 6-stack pin configuration: | |
9c7f852e TI |
2262 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
2263 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
2264 | */ |
2265 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
2266 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2267 | ||
16ded525 | 2268 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2269 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2270 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2271 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2272 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2273 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2274 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2275 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2276 | ||
16ded525 | 2277 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2278 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2279 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2280 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2281 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 2282 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2283 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 2284 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2285 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2286 | |
e9edcee0 TI |
2287 | { } |
2288 | }; | |
2289 | ||
ccc656ce KY |
2290 | /* |
2291 | * Uniwill pin configuration: | |
2292 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
2293 | * line = 0x1a | |
2294 | */ | |
2295 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
2296 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2297 | ||
2298 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2299 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2300 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2301 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2302 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2303 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2304 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2305 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2306 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2307 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2308 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2309 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2310 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2311 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2312 | ||
2313 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2314 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2315 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2316 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2317 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2318 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2319 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
2320 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
2321 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2322 | ||
2323 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2324 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
2325 | ||
2326 | { } | |
2327 | }; | |
2328 | ||
2329 | /* | |
2330 | * Uniwill P53 | |
ea1fb29a | 2331 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, |
ccc656ce KY |
2332 | */ |
2333 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
2334 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2335 | ||
2336 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2337 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2338 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2339 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2340 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2341 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2342 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2343 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2344 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2345 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2346 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2347 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2348 | ||
2349 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2350 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2351 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2352 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2353 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2354 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2355 | ||
2356 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2357 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
2358 | ||
2359 | { } | |
2360 | }; | |
2361 | ||
2cf9f0fc TD |
2362 | static struct hda_verb alc880_beep_init_verbs[] = { |
2363 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
2364 | { } | |
2365 | }; | |
2366 | ||
ccc656ce | 2367 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 2368 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
2369 | { |
2370 | unsigned int present; | |
f12ab1e0 | 2371 | unsigned char bits; |
ccc656ce KY |
2372 | |
2373 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2374 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2375 | bits = present ? HDA_AMP_MUTE : 0; |
2376 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
2377 | HDA_AMP_MUTE, bits); | |
2378 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
2379 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
2380 | } |
2381 | ||
2382 | /* auto-toggle front mic */ | |
2383 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
2384 | { | |
2385 | unsigned int present; | |
2386 | unsigned char bits; | |
ccc656ce KY |
2387 | |
2388 | present = snd_hda_codec_read(codec, 0x18, 0, | |
2389 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2390 | bits = present ? HDA_AMP_MUTE : 0; |
2391 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
2392 | } |
2393 | ||
2394 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
2395 | { | |
2396 | alc880_uniwill_hp_automute(codec); | |
2397 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
2398 | } |
2399 | ||
2400 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
2401 | unsigned int res) | |
2402 | { | |
2403 | /* Looks like the unsol event is incompatible with the standard | |
2404 | * definition. 4bit tag is placed at 28 bit! | |
2405 | */ | |
458a4fab TI |
2406 | switch (res >> 28) { |
2407 | case ALC880_HP_EVENT: | |
2408 | alc880_uniwill_hp_automute(codec); | |
2409 | break; | |
2410 | case ALC880_MIC_EVENT: | |
2411 | alc880_uniwill_mic_automute(codec); | |
2412 | break; | |
2413 | } | |
ccc656ce KY |
2414 | } |
2415 | ||
2416 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
2417 | { | |
2418 | unsigned int present; | |
f12ab1e0 | 2419 | unsigned char bits; |
ccc656ce KY |
2420 | |
2421 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2422 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a | 2423 | bits = present ? HDA_AMP_MUTE : 0; |
64654c2f | 2424 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); |
ccc656ce KY |
2425 | } |
2426 | ||
2427 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
2428 | { | |
2429 | unsigned int present; | |
ea1fb29a | 2430 | |
ccc656ce | 2431 | present = snd_hda_codec_read(codec, 0x21, 0, |
47fd830a TI |
2432 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
2433 | present &= HDA_AMP_VOLMASK; | |
2434 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
2435 | HDA_AMP_VOLMASK, present); | |
2436 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
2437 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 2438 | } |
47fd830a | 2439 | |
ccc656ce KY |
2440 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
2441 | unsigned int res) | |
2442 | { | |
2443 | /* Looks like the unsol event is incompatible with the standard | |
2444 | * definition. 4bit tag is placed at 28 bit! | |
2445 | */ | |
2446 | if ((res >> 28) == ALC880_HP_EVENT) | |
2447 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 2448 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
2449 | alc880_uniwill_p53_dcvol_automute(codec); |
2450 | } | |
2451 | ||
e9edcee0 TI |
2452 | /* |
2453 | * F1734 pin configuration: | |
2454 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
2455 | */ | |
2456 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
ee7a9c7c | 2457 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x01}, |
16ded525 TI |
2458 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2459 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2460 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2461 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2462 | ||
e9edcee0 | 2463 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 2464 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 2465 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 2466 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2467 | |
e9edcee0 TI |
2468 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2469 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
ee7a9c7c | 2470 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, |
e9edcee0 | 2471 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2472 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2473 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2474 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2475 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2476 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 | 2477 | |
937b4160 TI |
2478 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, |
2479 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT}, | |
2480 | ||
dfc0ff62 TI |
2481 | { } |
2482 | }; | |
2483 | ||
e9edcee0 TI |
2484 | /* |
2485 | * ASUS pin configuration: | |
2486 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
2487 | */ | |
2488 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
2489 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2490 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2491 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2492 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2493 | ||
2494 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 2495 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2496 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2497 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2498 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2499 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2500 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2501 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2502 | ||
2503 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2504 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2505 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2506 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2507 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2508 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 2509 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2510 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2511 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2512 | |
e9edcee0 TI |
2513 | { } |
2514 | }; | |
16ded525 | 2515 | |
e9edcee0 | 2516 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
2517 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
2518 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
2519 | |
2520 | /* Clevo m520g init */ | |
2521 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
2522 | /* headphone output */ | |
2523 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2524 | /* line-out */ | |
2525 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2526 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2527 | /* Line-in */ | |
2528 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2529 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2530 | /* CD */ | |
2531 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2532 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2533 | /* Mic1 (rear panel) */ | |
2534 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2535 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2536 | /* Mic2 (front panel) */ | |
2537 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2538 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2539 | /* headphone */ | |
2540 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2541 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2542 | /* change to EAPD mode */ | |
2543 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2544 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2545 | ||
2546 | { } | |
16ded525 TI |
2547 | }; |
2548 | ||
df694daa | 2549 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
2550 | /* change to EAPD mode */ |
2551 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2552 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2553 | ||
df694daa KY |
2554 | /* Headphone output */ |
2555 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2556 | /* Front output*/ | |
2557 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2558 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2559 | ||
2560 | /* Line In pin widget for input */ | |
2561 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2562 | /* CD pin widget for input */ | |
2563 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2564 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2565 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2566 | ||
2567 | /* change to EAPD mode */ | |
2568 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2569 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
2570 | ||
2571 | { } | |
2572 | }; | |
16ded525 | 2573 | |
e9edcee0 | 2574 | /* |
ae6b813a TI |
2575 | * LG m1 express dual |
2576 | * | |
2577 | * Pin assignment: | |
2578 | * Rear Line-In/Out (blue): 0x14 | |
2579 | * Build-in Mic-In: 0x15 | |
2580 | * Speaker-out: 0x17 | |
2581 | * HP-Out (green): 0x1b | |
2582 | * Mic-In/Out (red): 0x19 | |
2583 | * SPDIF-Out: 0x1e | |
2584 | */ | |
2585 | ||
2586 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
2587 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
2588 | 0x05, 0x02, 0x03 | |
2589 | }; | |
2590 | ||
2591 | /* seems analog CD is not working */ | |
2592 | static struct hda_input_mux alc880_lg_capture_source = { | |
2593 | .num_items = 3, | |
2594 | .items = { | |
2595 | { "Mic", 0x1 }, | |
2596 | { "Line", 0x5 }, | |
2597 | { "Internal Mic", 0x6 }, | |
2598 | }, | |
2599 | }; | |
2600 | ||
2601 | /* 2,4,6 channel modes */ | |
2602 | static struct hda_verb alc880_lg_ch2_init[] = { | |
2603 | /* set line-in and mic-in to input */ | |
2604 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
2605 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2606 | { } | |
2607 | }; | |
2608 | ||
2609 | static struct hda_verb alc880_lg_ch4_init[] = { | |
2610 | /* set line-in to out and mic-in to input */ | |
2611 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2612 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2613 | { } | |
2614 | }; | |
2615 | ||
2616 | static struct hda_verb alc880_lg_ch6_init[] = { | |
2617 | /* set line-in and mic-in to output */ | |
2618 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2619 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2620 | { } | |
2621 | }; | |
2622 | ||
2623 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
2624 | { 2, alc880_lg_ch2_init }, | |
2625 | { 4, alc880_lg_ch4_init }, | |
2626 | { 6, alc880_lg_ch6_init }, | |
2627 | }; | |
2628 | ||
2629 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
2134ea4f TI |
2630 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
2631 | HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), | |
ae6b813a TI |
2632 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2633 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
2634 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
2635 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
2636 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
2637 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
2638 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2639 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2640 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
2641 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
2642 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
2643 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
2644 | { | |
2645 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2646 | .name = "Channel Mode", | |
2647 | .info = alc_ch_mode_info, | |
2648 | .get = alc_ch_mode_get, | |
2649 | .put = alc_ch_mode_put, | |
2650 | }, | |
2651 | { } /* end */ | |
2652 | }; | |
2653 | ||
2654 | static struct hda_verb alc880_lg_init_verbs[] = { | |
2655 | /* set capture source to mic-in */ | |
2656 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2657 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2658 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2659 | /* mute all amp mixer inputs */ | |
2660 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
2661 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
2662 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
2663 | /* line-in to input */ |
2664 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2665 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2666 | /* built-in mic */ | |
2667 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2668 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2669 | /* speaker-out */ | |
2670 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2671 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2672 | /* mic-in to input */ | |
2673 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2674 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2675 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2676 | /* HP-out */ | |
2677 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
2678 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2679 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2680 | /* jack sense */ | |
2681 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2682 | { } | |
2683 | }; | |
2684 | ||
2685 | /* toggle speaker-output according to the hp-jack state */ | |
2686 | static void alc880_lg_automute(struct hda_codec *codec) | |
2687 | { | |
2688 | unsigned int present; | |
f12ab1e0 | 2689 | unsigned char bits; |
ae6b813a TI |
2690 | |
2691 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2692 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2693 | bits = present ? HDA_AMP_MUTE : 0; |
2694 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
2695 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
2696 | } |
2697 | ||
2698 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
2699 | { | |
2700 | /* Looks like the unsol event is incompatible with the standard | |
2701 | * definition. 4bit tag is placed at 28 bit! | |
2702 | */ | |
2703 | if ((res >> 28) == 0x01) | |
2704 | alc880_lg_automute(codec); | |
2705 | } | |
2706 | ||
d681518a TI |
2707 | /* |
2708 | * LG LW20 | |
2709 | * | |
2710 | * Pin assignment: | |
2711 | * Speaker-out: 0x14 | |
2712 | * Mic-In: 0x18 | |
e4f41da9 CM |
2713 | * Built-in Mic-In: 0x19 |
2714 | * Line-In: 0x1b | |
2715 | * HP-Out: 0x1a | |
d681518a TI |
2716 | * SPDIF-Out: 0x1e |
2717 | */ | |
2718 | ||
d681518a | 2719 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 2720 | .num_items = 3, |
d681518a TI |
2721 | .items = { |
2722 | { "Mic", 0x0 }, | |
2723 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 2724 | { "Line In", 0x2 }, |
d681518a TI |
2725 | }, |
2726 | }; | |
2727 | ||
0a8c5da3 CM |
2728 | #define alc880_lg_lw_modes alc880_threestack_modes |
2729 | ||
d681518a | 2730 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
2731 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2732 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2733 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
2734 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
2735 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
2736 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
2737 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
2738 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
2739 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
2740 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
2741 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
2742 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2743 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
2744 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
2745 | { |
2746 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2747 | .name = "Channel Mode", | |
2748 | .info = alc_ch_mode_info, | |
2749 | .get = alc_ch_mode_get, | |
2750 | .put = alc_ch_mode_put, | |
2751 | }, | |
d681518a TI |
2752 | { } /* end */ |
2753 | }; | |
2754 | ||
2755 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
2756 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2757 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2758 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2759 | ||
d681518a TI |
2760 | /* set capture source to mic-in */ |
2761 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2762 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2763 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 2764 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
2765 | /* speaker-out */ |
2766 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2767 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2768 | /* HP-out */ | |
d681518a TI |
2769 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2770 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2771 | /* mic-in to input */ | |
2772 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2773 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2774 | /* built-in mic */ | |
2775 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2776 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2777 | /* jack sense */ | |
2778 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2779 | { } | |
2780 | }; | |
2781 | ||
2782 | /* toggle speaker-output according to the hp-jack state */ | |
2783 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
2784 | { | |
2785 | unsigned int present; | |
f12ab1e0 | 2786 | unsigned char bits; |
d681518a TI |
2787 | |
2788 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2789 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2790 | bits = present ? HDA_AMP_MUTE : 0; |
2791 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
2792 | HDA_AMP_MUTE, bits); | |
d681518a TI |
2793 | } |
2794 | ||
2795 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
2796 | { | |
2797 | /* Looks like the unsol event is incompatible with the standard | |
2798 | * definition. 4bit tag is placed at 28 bit! | |
2799 | */ | |
2800 | if ((res >> 28) == 0x01) | |
2801 | alc880_lg_lw_automute(codec); | |
2802 | } | |
2803 | ||
df99cd33 TI |
2804 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
2805 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
2806 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
2807 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2808 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2809 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2810 | HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2811 | { } /* end */ | |
2812 | }; | |
2813 | ||
2814 | static struct hda_input_mux alc880_medion_rim_capture_source = { | |
2815 | .num_items = 2, | |
2816 | .items = { | |
2817 | { "Mic", 0x0 }, | |
2818 | { "Internal Mic", 0x1 }, | |
2819 | }, | |
2820 | }; | |
2821 | ||
2822 | static struct hda_verb alc880_medion_rim_init_verbs[] = { | |
2823 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2824 | ||
2825 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2826 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2827 | ||
2828 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2829 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2830 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2831 | /* Mic2 (as headphone out) for HP output */ | |
2832 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2833 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2834 | /* Internal Speaker */ | |
2835 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2836 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2837 | ||
2838 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2839 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2840 | ||
2841 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2842 | { } | |
2843 | }; | |
2844 | ||
2845 | /* toggle speaker-output according to the hp-jack state */ | |
2846 | static void alc880_medion_rim_automute(struct hda_codec *codec) | |
2847 | { | |
2848 | unsigned int present; | |
2849 | unsigned char bits; | |
2850 | ||
2851 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2852 | AC_VERB_GET_PIN_SENSE, 0) | |
2853 | & AC_PINSENSE_PRESENCE; | |
2854 | bits = present ? HDA_AMP_MUTE : 0; | |
2855 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
2856 | HDA_AMP_MUTE, bits); | |
2857 | if (present) | |
2858 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | |
2859 | else | |
2860 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); | |
2861 | } | |
2862 | ||
2863 | static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |
2864 | unsigned int res) | |
2865 | { | |
2866 | /* Looks like the unsol event is incompatible with the standard | |
2867 | * definition. 4bit tag is placed at 28 bit! | |
2868 | */ | |
2869 | if ((res >> 28) == ALC880_HP_EVENT) | |
2870 | alc880_medion_rim_automute(codec); | |
2871 | } | |
2872 | ||
cb53c626 TI |
2873 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2874 | static struct hda_amp_list alc880_loopbacks[] = { | |
2875 | { 0x0b, HDA_INPUT, 0 }, | |
2876 | { 0x0b, HDA_INPUT, 1 }, | |
2877 | { 0x0b, HDA_INPUT, 2 }, | |
2878 | { 0x0b, HDA_INPUT, 3 }, | |
2879 | { 0x0b, HDA_INPUT, 4 }, | |
2880 | { } /* end */ | |
2881 | }; | |
2882 | ||
2883 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2884 | { 0x0b, HDA_INPUT, 1 }, | |
2885 | { 0x0b, HDA_INPUT, 6 }, | |
2886 | { 0x0b, HDA_INPUT, 7 }, | |
2887 | { } /* end */ | |
2888 | }; | |
2889 | #endif | |
2890 | ||
ae6b813a TI |
2891 | /* |
2892 | * Common callbacks | |
e9edcee0 TI |
2893 | */ |
2894 | ||
1da177e4 LT |
2895 | static int alc_init(struct hda_codec *codec) |
2896 | { | |
2897 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2898 | unsigned int i; |
2899 | ||
2c3bf9ab | 2900 | alc_fix_pll(codec); |
1082c748 TI |
2901 | if (codec->vendor_id == 0x10ec0888) |
2902 | alc888_coef_init(codec); | |
2c3bf9ab | 2903 | |
e9edcee0 TI |
2904 | for (i = 0; i < spec->num_init_verbs; i++) |
2905 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2906 | |
2907 | if (spec->init_hook) | |
2908 | spec->init_hook(codec); | |
2909 | ||
1da177e4 LT |
2910 | return 0; |
2911 | } | |
2912 | ||
ae6b813a TI |
2913 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2914 | { | |
2915 | struct alc_spec *spec = codec->spec; | |
2916 | ||
2917 | if (spec->unsol_event) | |
2918 | spec->unsol_event(codec, res); | |
2919 | } | |
2920 | ||
cb53c626 TI |
2921 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2922 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2923 | { | |
2924 | struct alc_spec *spec = codec->spec; | |
2925 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2926 | } | |
2927 | #endif | |
2928 | ||
1da177e4 LT |
2929 | /* |
2930 | * Analog playback callbacks | |
2931 | */ | |
2932 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2933 | struct hda_codec *codec, | |
c8b6bf9b | 2934 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2935 | { |
2936 | struct alc_spec *spec = codec->spec; | |
9a08160b TI |
2937 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
2938 | hinfo); | |
1da177e4 LT |
2939 | } |
2940 | ||
2941 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2942 | struct hda_codec *codec, | |
2943 | unsigned int stream_tag, | |
2944 | unsigned int format, | |
c8b6bf9b | 2945 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2946 | { |
2947 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2948 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2949 | stream_tag, format, substream); | |
1da177e4 LT |
2950 | } |
2951 | ||
2952 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2953 | struct hda_codec *codec, | |
c8b6bf9b | 2954 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2955 | { |
2956 | struct alc_spec *spec = codec->spec; | |
2957 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2958 | } | |
2959 | ||
2960 | /* | |
2961 | * Digital out | |
2962 | */ | |
2963 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2964 | struct hda_codec *codec, | |
c8b6bf9b | 2965 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2966 | { |
2967 | struct alc_spec *spec = codec->spec; | |
2968 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2969 | } | |
2970 | ||
6b97eb45 TI |
2971 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2972 | struct hda_codec *codec, | |
2973 | unsigned int stream_tag, | |
2974 | unsigned int format, | |
2975 | struct snd_pcm_substream *substream) | |
2976 | { | |
2977 | struct alc_spec *spec = codec->spec; | |
2978 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2979 | stream_tag, format, substream); | |
2980 | } | |
2981 | ||
9b5f12e5 TI |
2982 | static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
2983 | struct hda_codec *codec, | |
2984 | struct snd_pcm_substream *substream) | |
2985 | { | |
2986 | struct alc_spec *spec = codec->spec; | |
2987 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); | |
2988 | } | |
2989 | ||
1da177e4 LT |
2990 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2991 | struct hda_codec *codec, | |
c8b6bf9b | 2992 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2993 | { |
2994 | struct alc_spec *spec = codec->spec; | |
2995 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2996 | } | |
2997 | ||
2998 | /* | |
2999 | * Analog capture | |
3000 | */ | |
6330079f | 3001 | static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
1da177e4 LT |
3002 | struct hda_codec *codec, |
3003 | unsigned int stream_tag, | |
3004 | unsigned int format, | |
c8b6bf9b | 3005 | struct snd_pcm_substream *substream) |
1da177e4 LT |
3006 | { |
3007 | struct alc_spec *spec = codec->spec; | |
3008 | ||
6330079f | 3009 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
1da177e4 LT |
3010 | stream_tag, 0, format); |
3011 | return 0; | |
3012 | } | |
3013 | ||
6330079f | 3014 | static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
1da177e4 | 3015 | struct hda_codec *codec, |
c8b6bf9b | 3016 | struct snd_pcm_substream *substream) |
1da177e4 LT |
3017 | { |
3018 | struct alc_spec *spec = codec->spec; | |
3019 | ||
888afa15 TI |
3020 | snd_hda_codec_cleanup_stream(codec, |
3021 | spec->adc_nids[substream->number + 1]); | |
1da177e4 LT |
3022 | return 0; |
3023 | } | |
3024 | ||
3025 | ||
3026 | /* | |
3027 | */ | |
3028 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
3029 | .substreams = 1, | |
3030 | .channels_min = 2, | |
3031 | .channels_max = 8, | |
e9edcee0 | 3032 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
3033 | .ops = { |
3034 | .open = alc880_playback_pcm_open, | |
3035 | .prepare = alc880_playback_pcm_prepare, | |
3036 | .cleanup = alc880_playback_pcm_cleanup | |
3037 | }, | |
3038 | }; | |
3039 | ||
3040 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
6330079f TI |
3041 | .substreams = 1, |
3042 | .channels_min = 2, | |
3043 | .channels_max = 2, | |
3044 | /* NID is set in alc_build_pcms */ | |
3045 | }; | |
3046 | ||
3047 | static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { | |
3048 | .substreams = 1, | |
3049 | .channels_min = 2, | |
3050 | .channels_max = 2, | |
3051 | /* NID is set in alc_build_pcms */ | |
3052 | }; | |
3053 | ||
3054 | static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { | |
3055 | .substreams = 2, /* can be overridden */ | |
1da177e4 LT |
3056 | .channels_min = 2, |
3057 | .channels_max = 2, | |
e9edcee0 | 3058 | /* NID is set in alc_build_pcms */ |
1da177e4 | 3059 | .ops = { |
6330079f TI |
3060 | .prepare = alc880_alt_capture_pcm_prepare, |
3061 | .cleanup = alc880_alt_capture_pcm_cleanup | |
1da177e4 LT |
3062 | }, |
3063 | }; | |
3064 | ||
3065 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
3066 | .substreams = 1, | |
3067 | .channels_min = 2, | |
3068 | .channels_max = 2, | |
3069 | /* NID is set in alc_build_pcms */ | |
3070 | .ops = { | |
3071 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 | 3072 | .close = alc880_dig_playback_pcm_close, |
9b5f12e5 TI |
3073 | .prepare = alc880_dig_playback_pcm_prepare, |
3074 | .cleanup = alc880_dig_playback_pcm_cleanup | |
1da177e4 LT |
3075 | }, |
3076 | }; | |
3077 | ||
3078 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
3079 | .substreams = 1, | |
3080 | .channels_min = 2, | |
3081 | .channels_max = 2, | |
3082 | /* NID is set in alc_build_pcms */ | |
3083 | }; | |
3084 | ||
4c5186ed | 3085 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
6330079f | 3086 | static struct hda_pcm_stream alc_pcm_null_stream = { |
4c5186ed JW |
3087 | .substreams = 0, |
3088 | .channels_min = 0, | |
3089 | .channels_max = 0, | |
3090 | }; | |
3091 | ||
1da177e4 LT |
3092 | static int alc_build_pcms(struct hda_codec *codec) |
3093 | { | |
3094 | struct alc_spec *spec = codec->spec; | |
3095 | struct hda_pcm *info = spec->pcm_rec; | |
3096 | int i; | |
3097 | ||
3098 | codec->num_pcms = 1; | |
3099 | codec->pcm_info = info; | |
3100 | ||
e64f14f4 TI |
3101 | if (spec->no_analog) |
3102 | goto skip_analog; | |
3103 | ||
1da177e4 | 3104 | info->name = spec->stream_name_analog; |
4a471b7d | 3105 | if (spec->stream_analog_playback) { |
da3cec35 TI |
3106 | if (snd_BUG_ON(!spec->multiout.dac_nids)) |
3107 | return -EINVAL; | |
4a471b7d TI |
3108 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
3109 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
3110 | } | |
3111 | if (spec->stream_analog_capture) { | |
da3cec35 TI |
3112 | if (snd_BUG_ON(!spec->adc_nids)) |
3113 | return -EINVAL; | |
4a471b7d TI |
3114 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
3115 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
3116 | } | |
3117 | ||
3118 | if (spec->channel_mode) { | |
3119 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
3120 | for (i = 0; i < spec->num_channel_mode; i++) { | |
3121 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
3122 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
3123 | } | |
1da177e4 LT |
3124 | } |
3125 | } | |
3126 | ||
e64f14f4 | 3127 | skip_analog: |
e08a007d | 3128 | /* SPDIF for stream index #1 */ |
1da177e4 | 3129 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 3130 | codec->num_pcms = 2; |
b25c9da1 | 3131 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
c06134d7 | 3132 | info = spec->pcm_rec + 1; |
1da177e4 | 3133 | info->name = spec->stream_name_digital; |
8c441982 TI |
3134 | if (spec->dig_out_type) |
3135 | info->pcm_type = spec->dig_out_type; | |
3136 | else | |
3137 | info->pcm_type = HDA_PCM_TYPE_SPDIF; | |
4a471b7d TI |
3138 | if (spec->multiout.dig_out_nid && |
3139 | spec->stream_digital_playback) { | |
1da177e4 LT |
3140 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
3141 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
3142 | } | |
4a471b7d TI |
3143 | if (spec->dig_in_nid && |
3144 | spec->stream_digital_capture) { | |
1da177e4 LT |
3145 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
3146 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
3147 | } | |
963f803f TI |
3148 | /* FIXME: do we need this for all Realtek codec models? */ |
3149 | codec->spdif_status_reset = 1; | |
1da177e4 LT |
3150 | } |
3151 | ||
e64f14f4 TI |
3152 | if (spec->no_analog) |
3153 | return 0; | |
3154 | ||
e08a007d TI |
3155 | /* If the use of more than one ADC is requested for the current |
3156 | * model, configure a second analog capture-only PCM. | |
3157 | */ | |
3158 | /* Additional Analaog capture for index #2 */ | |
6330079f TI |
3159 | if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || |
3160 | (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { | |
e08a007d | 3161 | codec->num_pcms = 3; |
c06134d7 | 3162 | info = spec->pcm_rec + 2; |
e08a007d | 3163 | info->name = spec->stream_name_analog; |
6330079f TI |
3164 | if (spec->alt_dac_nid) { |
3165 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
3166 | *spec->stream_analog_alt_playback; | |
3167 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
3168 | spec->alt_dac_nid; | |
3169 | } else { | |
3170 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
3171 | alc_pcm_null_stream; | |
3172 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
3173 | } | |
3174 | if (spec->num_adc_nids > 1) { | |
3175 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
3176 | *spec->stream_analog_alt_capture; | |
3177 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
3178 | spec->adc_nids[1]; | |
3179 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
3180 | spec->num_adc_nids - 1; | |
3181 | } else { | |
3182 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
3183 | alc_pcm_null_stream; | |
3184 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; | |
e08a007d TI |
3185 | } |
3186 | } | |
3187 | ||
1da177e4 LT |
3188 | return 0; |
3189 | } | |
3190 | ||
603c4019 TI |
3191 | static void alc_free_kctls(struct hda_codec *codec) |
3192 | { | |
3193 | struct alc_spec *spec = codec->spec; | |
3194 | ||
3195 | if (spec->kctls.list) { | |
3196 | struct snd_kcontrol_new *kctl = spec->kctls.list; | |
3197 | int i; | |
3198 | for (i = 0; i < spec->kctls.used; i++) | |
3199 | kfree(kctl[i].name); | |
3200 | } | |
3201 | snd_array_free(&spec->kctls); | |
3202 | } | |
3203 | ||
1da177e4 LT |
3204 | static void alc_free(struct hda_codec *codec) |
3205 | { | |
e9edcee0 | 3206 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 3207 | |
f12ab1e0 | 3208 | if (!spec) |
e9edcee0 TI |
3209 | return; |
3210 | ||
603c4019 | 3211 | alc_free_kctls(codec); |
e9edcee0 | 3212 | kfree(spec); |
680cd536 | 3213 | snd_hda_detach_beep_device(codec); |
1da177e4 LT |
3214 | } |
3215 | ||
e044c39a TI |
3216 | #ifdef SND_HDA_NEEDS_RESUME |
3217 | static void store_pin_configs(struct hda_codec *codec) | |
3218 | { | |
3219 | struct alc_spec *spec = codec->spec; | |
3220 | hda_nid_t nid, end_nid; | |
3221 | ||
3222 | end_nid = codec->start_nid + codec->num_nodes; | |
3223 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
3224 | unsigned int wid_caps = get_wcaps(codec, nid); | |
3225 | unsigned int wid_type = | |
3226 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
3227 | if (wid_type != AC_WID_PIN) | |
3228 | continue; | |
3229 | if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids)) | |
3230 | break; | |
3231 | spec->pin_nids[spec->num_pins] = nid; | |
3232 | spec->pin_cfgs[spec->num_pins] = | |
3233 | snd_hda_codec_read(codec, nid, 0, | |
3234 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
3235 | spec->num_pins++; | |
3236 | } | |
3237 | } | |
3238 | ||
3239 | static void resume_pin_configs(struct hda_codec *codec) | |
3240 | { | |
3241 | struct alc_spec *spec = codec->spec; | |
3242 | int i; | |
3243 | ||
3244 | for (i = 0; i < spec->num_pins; i++) { | |
3245 | hda_nid_t pin_nid = spec->pin_nids[i]; | |
3246 | unsigned int pin_config = spec->pin_cfgs[i]; | |
3247 | snd_hda_codec_write(codec, pin_nid, 0, | |
3248 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, | |
3249 | pin_config & 0x000000ff); | |
3250 | snd_hda_codec_write(codec, pin_nid, 0, | |
3251 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, | |
3252 | (pin_config & 0x0000ff00) >> 8); | |
3253 | snd_hda_codec_write(codec, pin_nid, 0, | |
3254 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, | |
3255 | (pin_config & 0x00ff0000) >> 16); | |
3256 | snd_hda_codec_write(codec, pin_nid, 0, | |
3257 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | |
3258 | pin_config >> 24); | |
3259 | } | |
3260 | } | |
3261 | ||
3262 | static int alc_resume(struct hda_codec *codec) | |
3263 | { | |
3264 | resume_pin_configs(codec); | |
3265 | codec->patch_ops.init(codec); | |
3266 | snd_hda_codec_resume_amp(codec); | |
3267 | snd_hda_codec_resume_cache(codec); | |
3268 | return 0; | |
3269 | } | |
3270 | #else | |
3271 | #define store_pin_configs(codec) | |
3272 | #endif | |
3273 | ||
1da177e4 LT |
3274 | /* |
3275 | */ | |
3276 | static struct hda_codec_ops alc_patch_ops = { | |
3277 | .build_controls = alc_build_controls, | |
3278 | .build_pcms = alc_build_pcms, | |
3279 | .init = alc_init, | |
3280 | .free = alc_free, | |
ae6b813a | 3281 | .unsol_event = alc_unsol_event, |
e044c39a TI |
3282 | #ifdef SND_HDA_NEEDS_RESUME |
3283 | .resume = alc_resume, | |
3284 | #endif | |
cb53c626 TI |
3285 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3286 | .check_power_status = alc_check_power_status, | |
3287 | #endif | |
1da177e4 LT |
3288 | }; |
3289 | ||
2fa522be TI |
3290 | |
3291 | /* | |
3292 | * Test configuration for debugging | |
3293 | * | |
3294 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
3295 | * enum controls. | |
3296 | */ | |
3297 | #ifdef CONFIG_SND_DEBUG | |
3298 | static hda_nid_t alc880_test_dac_nids[4] = { | |
3299 | 0x02, 0x03, 0x04, 0x05 | |
3300 | }; | |
3301 | ||
3302 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 3303 | .num_items = 7, |
2fa522be TI |
3304 | .items = { |
3305 | { "In-1", 0x0 }, | |
3306 | { "In-2", 0x1 }, | |
3307 | { "In-3", 0x2 }, | |
3308 | { "In-4", 0x3 }, | |
3309 | { "CD", 0x4 }, | |
ae6b813a TI |
3310 | { "Front", 0x5 }, |
3311 | { "Surround", 0x6 }, | |
2fa522be TI |
3312 | }, |
3313 | }; | |
3314 | ||
d2a6d7dc | 3315 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 3316 | { 2, NULL }, |
fd2c326d | 3317 | { 4, NULL }, |
2fa522be | 3318 | { 6, NULL }, |
fd2c326d | 3319 | { 8, NULL }, |
2fa522be TI |
3320 | }; |
3321 | ||
9c7f852e TI |
3322 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
3323 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
3324 | { |
3325 | static char *texts[] = { | |
3326 | "N/A", "Line Out", "HP Out", | |
3327 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
3328 | }; | |
3329 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3330 | uinfo->count = 1; | |
3331 | uinfo->value.enumerated.items = 8; | |
3332 | if (uinfo->value.enumerated.item >= 8) | |
3333 | uinfo->value.enumerated.item = 7; | |
3334 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
3335 | return 0; | |
3336 | } | |
3337 | ||
9c7f852e TI |
3338 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
3339 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3340 | { |
3341 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3342 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3343 | unsigned int pin_ctl, item = 0; | |
3344 | ||
3345 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
3346 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
3347 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
3348 | if (pin_ctl & AC_PINCTL_HP_EN) | |
3349 | item = 2; | |
3350 | else | |
3351 | item = 1; | |
3352 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
3353 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
3354 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
3355 | case AC_PINCTL_VREF_50: item = 4; break; | |
3356 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
3357 | case AC_PINCTL_VREF_80: item = 6; break; | |
3358 | case AC_PINCTL_VREF_100: item = 7; break; | |
3359 | } | |
3360 | } | |
3361 | ucontrol->value.enumerated.item[0] = item; | |
3362 | return 0; | |
3363 | } | |
3364 | ||
9c7f852e TI |
3365 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
3366 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3367 | { |
3368 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3369 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3370 | static unsigned int ctls[] = { | |
3371 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
3372 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
3373 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
3374 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
3375 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
3376 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
3377 | }; | |
3378 | unsigned int old_ctl, new_ctl; | |
3379 | ||
3380 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
3381 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
3382 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
3383 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
3384 | int val; |
3385 | snd_hda_codec_write_cache(codec, nid, 0, | |
3386 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3387 | new_ctl); | |
47fd830a TI |
3388 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
3389 | HDA_AMP_MUTE : 0; | |
3390 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
3391 | HDA_AMP_MUTE, val); | |
2fa522be TI |
3392 | return 1; |
3393 | } | |
3394 | return 0; | |
3395 | } | |
3396 | ||
9c7f852e TI |
3397 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
3398 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
3399 | { |
3400 | static char *texts[] = { | |
3401 | "Front", "Surround", "CLFE", "Side" | |
3402 | }; | |
3403 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3404 | uinfo->count = 1; | |
3405 | uinfo->value.enumerated.items = 4; | |
3406 | if (uinfo->value.enumerated.item >= 4) | |
3407 | uinfo->value.enumerated.item = 3; | |
3408 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
3409 | return 0; | |
3410 | } | |
3411 | ||
9c7f852e TI |
3412 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
3413 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3414 | { |
3415 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3416 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3417 | unsigned int sel; | |
3418 | ||
3419 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
3420 | ucontrol->value.enumerated.item[0] = sel & 3; | |
3421 | return 0; | |
3422 | } | |
3423 | ||
9c7f852e TI |
3424 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
3425 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3426 | { |
3427 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3428 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3429 | unsigned int sel; | |
3430 | ||
3431 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
3432 | if (ucontrol->value.enumerated.item[0] != sel) { | |
3433 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
3434 | snd_hda_codec_write_cache(codec, nid, 0, |
3435 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
3436 | return 1; |
3437 | } | |
3438 | return 0; | |
3439 | } | |
3440 | ||
3441 | #define PIN_CTL_TEST(xname,nid) { \ | |
3442 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
3443 | .name = xname, \ | |
3444 | .info = alc_test_pin_ctl_info, \ | |
3445 | .get = alc_test_pin_ctl_get, \ | |
3446 | .put = alc_test_pin_ctl_put, \ | |
3447 | .private_value = nid \ | |
3448 | } | |
3449 | ||
3450 | #define PIN_SRC_TEST(xname,nid) { \ | |
3451 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
3452 | .name = xname, \ | |
3453 | .info = alc_test_pin_src_info, \ | |
3454 | .get = alc_test_pin_src_get, \ | |
3455 | .put = alc_test_pin_src_put, \ | |
3456 | .private_value = nid \ | |
3457 | } | |
3458 | ||
c8b6bf9b | 3459 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
3460 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
3461 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
3462 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
3463 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
3464 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
3465 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
3466 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
3467 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
3468 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
3469 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
3470 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
3471 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
3472 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
3473 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
3474 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
3475 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
3476 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
3477 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
3478 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
3479 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
3480 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
3481 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
3482 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
3483 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
3484 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
3485 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
3486 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
3487 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
3488 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
3489 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
3490 | { |
3491 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3492 | .name = "Channel Mode", | |
df694daa KY |
3493 | .info = alc_ch_mode_info, |
3494 | .get = alc_ch_mode_get, | |
3495 | .put = alc_ch_mode_put, | |
2fa522be TI |
3496 | }, |
3497 | { } /* end */ | |
3498 | }; | |
3499 | ||
3500 | static struct hda_verb alc880_test_init_verbs[] = { | |
3501 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
3502 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
3503 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3504 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3505 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3506 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3507 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3508 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3509 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 3510 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
3511 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
3512 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3513 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3514 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 3515 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
3516 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3517 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3518 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3519 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 3520 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
3521 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
3522 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3523 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3524 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 3525 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
3526 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
3527 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
3528 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
3529 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3530 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 3531 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
3532 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
3533 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3534 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3535 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 3536 | /* ADC set up */ |
05acb863 | 3537 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3538 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3539 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3540 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3541 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3542 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
3543 | /* Analog input/passthru */ |
3544 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3545 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3546 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3547 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3548 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
3549 | { } |
3550 | }; | |
3551 | #endif | |
3552 | ||
1da177e4 LT |
3553 | /* |
3554 | */ | |
3555 | ||
f5fcc13c TI |
3556 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
3557 | [ALC880_3ST] = "3stack", | |
3558 | [ALC880_TCL_S700] = "tcl", | |
3559 | [ALC880_3ST_DIG] = "3stack-digout", | |
3560 | [ALC880_CLEVO] = "clevo", | |
3561 | [ALC880_5ST] = "5stack", | |
3562 | [ALC880_5ST_DIG] = "5stack-digout", | |
3563 | [ALC880_W810] = "w810", | |
3564 | [ALC880_Z71V] = "z71v", | |
3565 | [ALC880_6ST] = "6stack", | |
3566 | [ALC880_6ST_DIG] = "6stack-digout", | |
3567 | [ALC880_ASUS] = "asus", | |
3568 | [ALC880_ASUS_W1V] = "asus-w1v", | |
3569 | [ALC880_ASUS_DIG] = "asus-dig", | |
3570 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
3571 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
3572 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
3573 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
3574 | [ALC880_F1734] = "F1734", |
3575 | [ALC880_LG] = "lg", | |
3576 | [ALC880_LG_LW] = "lg-lw", | |
df99cd33 | 3577 | [ALC880_MEDION_RIM] = "medion", |
2fa522be | 3578 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 3579 | [ALC880_TEST] = "test", |
2fa522be | 3580 | #endif |
f5fcc13c TI |
3581 | [ALC880_AUTO] = "auto", |
3582 | }; | |
3583 | ||
3584 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
ac3e3741 | 3585 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
3586 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), |
3587 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
3588 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), | |
3589 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
3590 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
3591 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
3592 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
3593 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
f5fcc13c TI |
3594 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), |
3595 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
f5fcc13c TI |
3596 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), |
3597 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
3598 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
3599 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
3600 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
3601 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
3602 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
3603 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
3604 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
3605 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
186c3117 | 3606 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), |
f5fcc13c TI |
3607 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
3608 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
3609 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
dea0a509 | 3610 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */ |
f5fcc13c | 3611 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), |
ac3e3741 TI |
3612 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), |
3613 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3614 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), |
3615 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3616 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), |
3617 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
3618 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
3619 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
ac3e3741 TI |
3620 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), |
3621 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
f5fcc13c | 3622 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), |
ac3e3741 | 3623 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), |
f5fcc13c | 3624 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), |
ac3e3741 | 3625 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), |
f5fcc13c TI |
3626 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), |
3627 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
ac3e3741 | 3628 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), |
df99cd33 | 3629 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), |
ac3e3741 | 3630 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), |
f5fcc13c | 3631 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), |
f5fcc13c | 3632 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), |
1d11604e | 3633 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), |
ac3e3741 | 3634 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), |
2cf9f0fc | 3635 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
ac3e3741 | 3636 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), |
f5fcc13c TI |
3637 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), |
3638 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
f5fcc13c | 3639 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), |
ac3e3741 TI |
3640 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), |
3641 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ | |
3642 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
3643 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
f5fcc13c TI |
3644 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), |
3645 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 | 3646 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), |
f5fcc13c | 3647 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), |
ac3e3741 TI |
3648 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), |
3649 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
f5fcc13c TI |
3650 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), |
3651 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
3652 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
dea0a509 TI |
3653 | /* default Intel */ |
3654 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST), | |
ac3e3741 TI |
3655 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), |
3656 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
1da177e4 LT |
3657 | {} |
3658 | }; | |
3659 | ||
16ded525 | 3660 | /* |
df694daa | 3661 | * ALC880 codec presets |
16ded525 | 3662 | */ |
16ded525 TI |
3663 | static struct alc_config_preset alc880_presets[] = { |
3664 | [ALC880_3ST] = { | |
e9edcee0 | 3665 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3666 | .init_verbs = { alc880_volume_init_verbs, |
3667 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3668 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 3669 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
3670 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3671 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3672 | .need_dac_fix = 1, |
16ded525 TI |
3673 | .input_mux = &alc880_capture_source, |
3674 | }, | |
3675 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 3676 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3677 | .init_verbs = { alc880_volume_init_verbs, |
3678 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3679 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
3680 | .dac_nids = alc880_dac_nids, |
3681 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3682 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3683 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3684 | .need_dac_fix = 1, |
16ded525 TI |
3685 | .input_mux = &alc880_capture_source, |
3686 | }, | |
df694daa KY |
3687 | [ALC880_TCL_S700] = { |
3688 | .mixers = { alc880_tcl_s700_mixer }, | |
3689 | .init_verbs = { alc880_volume_init_verbs, | |
3690 | alc880_pin_tcl_S700_init_verbs, | |
3691 | alc880_gpio2_init_verbs }, | |
3692 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3693 | .dac_nids = alc880_dac_nids, | |
f9e336f6 TI |
3694 | .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */ |
3695 | .num_adc_nids = 1, /* single ADC */ | |
df694daa KY |
3696 | .hp_nid = 0x03, |
3697 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3698 | .channel_mode = alc880_2_jack_modes, | |
3699 | .input_mux = &alc880_capture_source, | |
3700 | }, | |
16ded525 | 3701 | [ALC880_5ST] = { |
f12ab1e0 TI |
3702 | .mixers = { alc880_three_stack_mixer, |
3703 | alc880_five_stack_mixer}, | |
3704 | .init_verbs = { alc880_volume_init_verbs, | |
3705 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3706 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3707 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
3708 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3709 | .channel_mode = alc880_fivestack_modes, | |
3710 | .input_mux = &alc880_capture_source, | |
3711 | }, | |
3712 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
3713 | .mixers = { alc880_three_stack_mixer, |
3714 | alc880_five_stack_mixer }, | |
3715 | .init_verbs = { alc880_volume_init_verbs, | |
3716 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3717 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3718 | .dac_nids = alc880_dac_nids, | |
3719 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3720 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3721 | .channel_mode = alc880_fivestack_modes, | |
3722 | .input_mux = &alc880_capture_source, | |
3723 | }, | |
b6482d48 TI |
3724 | [ALC880_6ST] = { |
3725 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
3726 | .init_verbs = { alc880_volume_init_verbs, |
3727 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
3728 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3729 | .dac_nids = alc880_6st_dac_nids, | |
3730 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
3731 | .channel_mode = alc880_sixstack_modes, | |
3732 | .input_mux = &alc880_6stack_capture_source, | |
3733 | }, | |
16ded525 | 3734 | [ALC880_6ST_DIG] = { |
e9edcee0 | 3735 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
3736 | .init_verbs = { alc880_volume_init_verbs, |
3737 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
3738 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3739 | .dac_nids = alc880_6st_dac_nids, | |
3740 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3741 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
3742 | .channel_mode = alc880_sixstack_modes, | |
3743 | .input_mux = &alc880_6stack_capture_source, | |
3744 | }, | |
3745 | [ALC880_W810] = { | |
e9edcee0 | 3746 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
3747 | .init_verbs = { alc880_volume_init_verbs, |
3748 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 3749 | alc880_gpio2_init_verbs }, |
16ded525 TI |
3750 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
3751 | .dac_nids = alc880_w810_dac_nids, | |
3752 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3753 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
3754 | .channel_mode = alc880_w810_modes, | |
3755 | .input_mux = &alc880_capture_source, | |
3756 | }, | |
3757 | [ALC880_Z71V] = { | |
e9edcee0 | 3758 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
3759 | .init_verbs = { alc880_volume_init_verbs, |
3760 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
3761 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
3762 | .dac_nids = alc880_z71v_dac_nids, | |
3763 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3764 | .hp_nid = 0x03, | |
e9edcee0 TI |
3765 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3766 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
3767 | .input_mux = &alc880_capture_source, |
3768 | }, | |
3769 | [ALC880_F1734] = { | |
e9edcee0 | 3770 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
3771 | .init_verbs = { alc880_volume_init_verbs, |
3772 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
3773 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
3774 | .dac_nids = alc880_f1734_dac_nids, | |
3775 | .hp_nid = 0x02, | |
3776 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3777 | .channel_mode = alc880_2_jack_modes, | |
937b4160 TI |
3778 | .input_mux = &alc880_f1734_capture_source, |
3779 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3780 | .init_hook = alc880_uniwill_p53_hp_automute, | |
16ded525 TI |
3781 | }, |
3782 | [ALC880_ASUS] = { | |
e9edcee0 | 3783 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3784 | .init_verbs = { alc880_volume_init_verbs, |
3785 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3786 | alc880_gpio1_init_verbs }, |
3787 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3788 | .dac_nids = alc880_asus_dac_nids, | |
3789 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3790 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3791 | .need_dac_fix = 1, |
16ded525 TI |
3792 | .input_mux = &alc880_capture_source, |
3793 | }, | |
3794 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 3795 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3796 | .init_verbs = { alc880_volume_init_verbs, |
3797 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3798 | alc880_gpio1_init_verbs }, |
3799 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3800 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3801 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3802 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3803 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3804 | .need_dac_fix = 1, |
16ded525 TI |
3805 | .input_mux = &alc880_capture_source, |
3806 | }, | |
df694daa KY |
3807 | [ALC880_ASUS_DIG2] = { |
3808 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
3809 | .init_verbs = { alc880_volume_init_verbs, |
3810 | alc880_pin_asus_init_verbs, | |
df694daa KY |
3811 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
3812 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3813 | .dac_nids = alc880_asus_dac_nids, | |
3814 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3815 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3816 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3817 | .need_dac_fix = 1, |
df694daa KY |
3818 | .input_mux = &alc880_capture_source, |
3819 | }, | |
16ded525 | 3820 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 3821 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
3822 | .init_verbs = { alc880_volume_init_verbs, |
3823 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3824 | alc880_gpio1_init_verbs }, |
3825 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3826 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3827 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3828 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3829 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3830 | .need_dac_fix = 1, |
16ded525 TI |
3831 | .input_mux = &alc880_capture_source, |
3832 | }, | |
3833 | [ALC880_UNIWILL_DIG] = { | |
45bdd1c1 | 3834 | .mixers = { alc880_asus_mixer }, |
ccc656ce KY |
3835 | .init_verbs = { alc880_volume_init_verbs, |
3836 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
3837 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
3838 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3839 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3840 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3841 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3842 | .need_dac_fix = 1, |
16ded525 TI |
3843 | .input_mux = &alc880_capture_source, |
3844 | }, | |
ccc656ce KY |
3845 | [ALC880_UNIWILL] = { |
3846 | .mixers = { alc880_uniwill_mixer }, | |
3847 | .init_verbs = { alc880_volume_init_verbs, | |
3848 | alc880_uniwill_init_verbs }, | |
3849 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3850 | .dac_nids = alc880_asus_dac_nids, | |
3851 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3852 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3853 | .channel_mode = alc880_threestack_modes, | |
3854 | .need_dac_fix = 1, | |
3855 | .input_mux = &alc880_capture_source, | |
3856 | .unsol_event = alc880_uniwill_unsol_event, | |
3857 | .init_hook = alc880_uniwill_automute, | |
3858 | }, | |
3859 | [ALC880_UNIWILL_P53] = { | |
3860 | .mixers = { alc880_uniwill_p53_mixer }, | |
3861 | .init_verbs = { alc880_volume_init_verbs, | |
3862 | alc880_uniwill_p53_init_verbs }, | |
3863 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3864 | .dac_nids = alc880_asus_dac_nids, | |
3865 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
3866 | .channel_mode = alc880_threestack_modes, |
3867 | .input_mux = &alc880_capture_source, | |
3868 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3869 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3870 | }, | |
3871 | [ALC880_FUJITSU] = { | |
45bdd1c1 | 3872 | .mixers = { alc880_fujitsu_mixer }, |
2cf9f0fc TD |
3873 | .init_verbs = { alc880_volume_init_verbs, |
3874 | alc880_uniwill_p53_init_verbs, | |
3875 | alc880_beep_init_verbs }, | |
3876 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3877 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 3878 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
3879 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3880 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
3881 | .input_mux = &alc880_capture_source, |
3882 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3883 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3884 | }, | |
df694daa KY |
3885 | [ALC880_CLEVO] = { |
3886 | .mixers = { alc880_three_stack_mixer }, | |
3887 | .init_verbs = { alc880_volume_init_verbs, | |
3888 | alc880_pin_clevo_init_verbs }, | |
3889 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3890 | .dac_nids = alc880_dac_nids, | |
3891 | .hp_nid = 0x03, | |
3892 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3893 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3894 | .need_dac_fix = 1, |
df694daa KY |
3895 | .input_mux = &alc880_capture_source, |
3896 | }, | |
ae6b813a TI |
3897 | [ALC880_LG] = { |
3898 | .mixers = { alc880_lg_mixer }, | |
3899 | .init_verbs = { alc880_volume_init_verbs, | |
3900 | alc880_lg_init_verbs }, | |
3901 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
3902 | .dac_nids = alc880_lg_dac_nids, | |
3903 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3904 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
3905 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 3906 | .need_dac_fix = 1, |
ae6b813a TI |
3907 | .input_mux = &alc880_lg_capture_source, |
3908 | .unsol_event = alc880_lg_unsol_event, | |
3909 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
3910 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3911 | .loopbacks = alc880_lg_loopbacks, | |
3912 | #endif | |
ae6b813a | 3913 | }, |
d681518a TI |
3914 | [ALC880_LG_LW] = { |
3915 | .mixers = { alc880_lg_lw_mixer }, | |
3916 | .init_verbs = { alc880_volume_init_verbs, | |
3917 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 3918 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
3919 | .dac_nids = alc880_dac_nids, |
3920 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
3921 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3922 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
3923 | .input_mux = &alc880_lg_lw_capture_source, |
3924 | .unsol_event = alc880_lg_lw_unsol_event, | |
3925 | .init_hook = alc880_lg_lw_automute, | |
3926 | }, | |
df99cd33 TI |
3927 | [ALC880_MEDION_RIM] = { |
3928 | .mixers = { alc880_medion_rim_mixer }, | |
3929 | .init_verbs = { alc880_volume_init_verbs, | |
3930 | alc880_medion_rim_init_verbs, | |
3931 | alc_gpio2_init_verbs }, | |
3932 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3933 | .dac_nids = alc880_dac_nids, | |
3934 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3935 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3936 | .channel_mode = alc880_2_jack_modes, | |
3937 | .input_mux = &alc880_medion_rim_capture_source, | |
3938 | .unsol_event = alc880_medion_rim_unsol_event, | |
3939 | .init_hook = alc880_medion_rim_automute, | |
3940 | }, | |
16ded525 TI |
3941 | #ifdef CONFIG_SND_DEBUG |
3942 | [ALC880_TEST] = { | |
e9edcee0 TI |
3943 | .mixers = { alc880_test_mixer }, |
3944 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
3945 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
3946 | .dac_nids = alc880_test_dac_nids, | |
3947 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3948 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
3949 | .channel_mode = alc880_test_modes, | |
3950 | .input_mux = &alc880_test_capture_source, | |
3951 | }, | |
3952 | #endif | |
3953 | }; | |
3954 | ||
e9edcee0 TI |
3955 | /* |
3956 | * Automatic parse of I/O pins from the BIOS configuration | |
3957 | */ | |
3958 | ||
e9edcee0 TI |
3959 | enum { |
3960 | ALC_CTL_WIDGET_VOL, | |
3961 | ALC_CTL_WIDGET_MUTE, | |
3962 | ALC_CTL_BIND_MUTE, | |
3963 | }; | |
c8b6bf9b | 3964 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
3965 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
3966 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 3967 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
3968 | }; |
3969 | ||
3970 | /* add dynamic controls */ | |
f12ab1e0 TI |
3971 | static int add_control(struct alc_spec *spec, int type, const char *name, |
3972 | unsigned long val) | |
e9edcee0 | 3973 | { |
c8b6bf9b | 3974 | struct snd_kcontrol_new *knew; |
e9edcee0 | 3975 | |
603c4019 TI |
3976 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
3977 | knew = snd_array_new(&spec->kctls); | |
3978 | if (!knew) | |
3979 | return -ENOMEM; | |
e9edcee0 | 3980 | *knew = alc880_control_templates[type]; |
543537bd | 3981 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 3982 | if (!knew->name) |
e9edcee0 TI |
3983 | return -ENOMEM; |
3984 | knew->private_value = val; | |
e9edcee0 TI |
3985 | return 0; |
3986 | } | |
3987 | ||
3988 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
3989 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
3990 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
3991 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
3992 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
3993 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
3994 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
3995 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
3996 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3997 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3998 | #define ALC880_PIN_CD_NID 0x1c | |
3999 | ||
4000 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
4001 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
4002 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
4003 | { |
4004 | hda_nid_t nid; | |
4005 | int assigned[4]; | |
4006 | int i, j; | |
4007 | ||
4008 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 4009 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
4010 | |
4011 | /* check the pins hardwired to audio widget */ | |
4012 | for (i = 0; i < cfg->line_outs; i++) { | |
4013 | nid = cfg->line_out_pins[i]; | |
4014 | if (alc880_is_fixed_pin(nid)) { | |
4015 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 4016 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
4017 | assigned[idx] = 1; |
4018 | } | |
4019 | } | |
4020 | /* left pins can be connect to any audio widget */ | |
4021 | for (i = 0; i < cfg->line_outs; i++) { | |
4022 | nid = cfg->line_out_pins[i]; | |
4023 | if (alc880_is_fixed_pin(nid)) | |
4024 | continue; | |
4025 | /* search for an empty channel */ | |
4026 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
4027 | if (!assigned[j]) { |
4028 | spec->multiout.dac_nids[i] = | |
4029 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
4030 | assigned[j] = 1; |
4031 | break; | |
4032 | } | |
4033 | } | |
4034 | } | |
4035 | spec->multiout.num_dacs = cfg->line_outs; | |
4036 | return 0; | |
4037 | } | |
4038 | ||
4039 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
4040 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
4041 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
4042 | { |
4043 | char name[32]; | |
f12ab1e0 TI |
4044 | static const char *chname[4] = { |
4045 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
4046 | }; | |
e9edcee0 TI |
4047 | hda_nid_t nid; |
4048 | int i, err; | |
4049 | ||
4050 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 4051 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
4052 | continue; |
4053 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
4054 | if (i == 2) { | |
4055 | /* Center/LFE */ | |
f12ab1e0 TI |
4056 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
4057 | "Center Playback Volume", | |
4058 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
4059 | HDA_OUTPUT)); | |
4060 | if (err < 0) | |
e9edcee0 | 4061 | return err; |
f12ab1e0 TI |
4062 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
4063 | "LFE Playback Volume", | |
4064 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
4065 | HDA_OUTPUT)); | |
4066 | if (err < 0) | |
e9edcee0 | 4067 | return err; |
f12ab1e0 TI |
4068 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
4069 | "Center Playback Switch", | |
4070 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
4071 | HDA_INPUT)); | |
4072 | if (err < 0) | |
e9edcee0 | 4073 | return err; |
f12ab1e0 TI |
4074 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
4075 | "LFE Playback Switch", | |
4076 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
4077 | HDA_INPUT)); | |
4078 | if (err < 0) | |
e9edcee0 TI |
4079 | return err; |
4080 | } else { | |
4081 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
4082 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4083 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
4084 | HDA_OUTPUT)); | |
4085 | if (err < 0) | |
e9edcee0 TI |
4086 | return err; |
4087 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
4088 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
4089 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
4090 | HDA_INPUT)); | |
4091 | if (err < 0) | |
e9edcee0 TI |
4092 | return err; |
4093 | } | |
4094 | } | |
e9edcee0 TI |
4095 | return 0; |
4096 | } | |
4097 | ||
8d88bc3d TI |
4098 | /* add playback controls for speaker and HP outputs */ |
4099 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
4100 | const char *pfx) | |
e9edcee0 TI |
4101 | { |
4102 | hda_nid_t nid; | |
4103 | int err; | |
8d88bc3d | 4104 | char name[32]; |
e9edcee0 | 4105 | |
f12ab1e0 | 4106 | if (!pin) |
e9edcee0 TI |
4107 | return 0; |
4108 | ||
4109 | if (alc880_is_fixed_pin(pin)) { | |
4110 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 4111 | /* specify the DAC as the extra output */ |
f12ab1e0 | 4112 | if (!spec->multiout.hp_nid) |
e9edcee0 | 4113 | spec->multiout.hp_nid = nid; |
82bc955f TI |
4114 | else |
4115 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
4116 | /* control HP volume/switch on the output mixer amp */ |
4117 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 4118 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
4119 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4120 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
4121 | if (err < 0) | |
e9edcee0 | 4122 | return err; |
8d88bc3d | 4123 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
4124 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
4125 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
4126 | if (err < 0) | |
e9edcee0 TI |
4127 | return err; |
4128 | } else if (alc880_is_multi_pin(pin)) { | |
4129 | /* set manual connection */ | |
e9edcee0 | 4130 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 4131 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
4132 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
4133 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
4134 | if (err < 0) | |
e9edcee0 TI |
4135 | return err; |
4136 | } | |
4137 | return 0; | |
4138 | } | |
4139 | ||
4140 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
4141 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
4142 | const char *ctlname, | |
df694daa | 4143 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
4144 | { |
4145 | char name[32]; | |
df694daa | 4146 | int err; |
e9edcee0 TI |
4147 | |
4148 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
4149 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4150 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
4151 | if (err < 0) | |
e9edcee0 TI |
4152 | return err; |
4153 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
4154 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
4155 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
4156 | if (err < 0) | |
e9edcee0 TI |
4157 | return err; |
4158 | return 0; | |
4159 | } | |
4160 | ||
4161 | /* create playback/capture controls for input pins */ | |
df694daa KY |
4162 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
4163 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 4164 | { |
61b9b9b1 | 4165 | struct hda_input_mux *imux = &spec->private_imux[0]; |
df694daa | 4166 | int i, err, idx; |
e9edcee0 TI |
4167 | |
4168 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4169 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 4170 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
4171 | err = new_analog_input(spec, cfg->input_pins[i], |
4172 | auto_pin_cfg_labels[i], | |
df694daa | 4173 | idx, 0x0b); |
e9edcee0 TI |
4174 | if (err < 0) |
4175 | return err; | |
f12ab1e0 TI |
4176 | imux->items[imux->num_items].label = |
4177 | auto_pin_cfg_labels[i]; | |
4178 | imux->items[imux->num_items].index = | |
4179 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
4180 | imux->num_items++; |
4181 | } | |
4182 | } | |
4183 | return 0; | |
4184 | } | |
4185 | ||
f6c7e546 TI |
4186 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
4187 | unsigned int pin_type) | |
4188 | { | |
4189 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4190 | pin_type); | |
4191 | /* unmute pin */ | |
d260cdf6 TI |
4192 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
4193 | AMP_OUT_UNMUTE); | |
f6c7e546 TI |
4194 | } |
4195 | ||
df694daa KY |
4196 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
4197 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
4198 | int dac_idx) |
4199 | { | |
f6c7e546 | 4200 | alc_set_pin_output(codec, nid, pin_type); |
e9edcee0 TI |
4201 | /* need the manual connection? */ |
4202 | if (alc880_is_multi_pin(nid)) { | |
4203 | struct alc_spec *spec = codec->spec; | |
4204 | int idx = alc880_multi_pin_idx(nid); | |
4205 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
4206 | AC_VERB_SET_CONNECT_SEL, | |
4207 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
4208 | } | |
4209 | } | |
4210 | ||
baba8ee9 TI |
4211 | static int get_pin_type(int line_out_type) |
4212 | { | |
4213 | if (line_out_type == AUTO_PIN_HP_OUT) | |
4214 | return PIN_HP; | |
4215 | else | |
4216 | return PIN_OUT; | |
4217 | } | |
4218 | ||
e9edcee0 TI |
4219 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
4220 | { | |
4221 | struct alc_spec *spec = codec->spec; | |
4222 | int i; | |
ea1fb29a | 4223 | |
bc9f98a9 | 4224 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
e9edcee0 TI |
4225 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
4226 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
4227 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
4228 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
4229 | } |
4230 | } | |
4231 | ||
8d88bc3d | 4232 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
4233 | { |
4234 | struct alc_spec *spec = codec->spec; | |
4235 | hda_nid_t pin; | |
4236 | ||
82bc955f | 4237 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
4238 | if (pin) /* connect to front */ |
4239 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 4240 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
4241 | if (pin) /* connect to front */ |
4242 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
4243 | } | |
4244 | ||
4245 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
4246 | { | |
4247 | struct alc_spec *spec = codec->spec; | |
4248 | int i; | |
4249 | ||
4250 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4251 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4252 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
4253 | snd_hda_codec_write(codec, nid, 0, |
4254 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4255 | i <= AUTO_PIN_FRONT_MIC ? | |
4256 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 4257 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
4258 | snd_hda_codec_write(codec, nid, 0, |
4259 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
4260 | AMP_OUT_MUTE); |
4261 | } | |
4262 | } | |
4263 | } | |
4264 | ||
4265 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
4266 | /* return 1 if successful, 0 if the proper config is not found, |
4267 | * or a negative error code | |
4268 | */ | |
e9edcee0 TI |
4269 | static int alc880_parse_auto_config(struct hda_codec *codec) |
4270 | { | |
4271 | struct alc_spec *spec = codec->spec; | |
4272 | int err; | |
df694daa | 4273 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 4274 | |
f12ab1e0 TI |
4275 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
4276 | alc880_ignore); | |
4277 | if (err < 0) | |
e9edcee0 | 4278 | return err; |
f12ab1e0 | 4279 | if (!spec->autocfg.line_outs) |
e9edcee0 | 4280 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 4281 | |
f12ab1e0 TI |
4282 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
4283 | if (err < 0) | |
4284 | return err; | |
4285 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
4286 | if (err < 0) | |
4287 | return err; | |
4288 | err = alc880_auto_create_extra_out(spec, | |
4289 | spec->autocfg.speaker_pins[0], | |
4290 | "Speaker"); | |
4291 | if (err < 0) | |
4292 | return err; | |
4293 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
4294 | "Headphone"); | |
4295 | if (err < 0) | |
4296 | return err; | |
4297 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
4298 | if (err < 0) | |
e9edcee0 TI |
4299 | return err; |
4300 | ||
4301 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
4302 | ||
0852d7a6 | 4303 | if (spec->autocfg.dig_outs) |
e9edcee0 TI |
4304 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; |
4305 | if (spec->autocfg.dig_in_pin) | |
4306 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
4307 | ||
603c4019 | 4308 | if (spec->kctls.list) |
d88897ea | 4309 | add_mixer(spec, spec->kctls.list); |
e9edcee0 | 4310 | |
d88897ea | 4311 | add_verb(spec, alc880_volume_init_verbs); |
e9edcee0 | 4312 | |
a1e8d2da | 4313 | spec->num_mux_defs = 1; |
61b9b9b1 | 4314 | spec->input_mux = &spec->private_imux[0]; |
e9edcee0 | 4315 | |
e044c39a | 4316 | store_pin_configs(codec); |
e9edcee0 TI |
4317 | return 1; |
4318 | } | |
4319 | ||
ae6b813a TI |
4320 | /* additional initialization for auto-configuration model */ |
4321 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 4322 | { |
f6c7e546 | 4323 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 4324 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 4325 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 4326 | alc880_auto_init_analog_input(codec); |
f6c7e546 | 4327 | if (spec->unsol_event) |
7fb0d78f | 4328 | alc_inithook(codec); |
e9edcee0 TI |
4329 | } |
4330 | ||
f9e336f6 TI |
4331 | static void set_capture_mixer(struct alc_spec *spec) |
4332 | { | |
4333 | static struct snd_kcontrol_new *caps[3] = { | |
4334 | alc_capture_mixer1, | |
4335 | alc_capture_mixer2, | |
4336 | alc_capture_mixer3, | |
4337 | }; | |
30d72e9f | 4338 | if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) |
f9e336f6 TI |
4339 | spec->cap_mixer = caps[spec->num_adc_nids - 1]; |
4340 | } | |
4341 | ||
45bdd1c1 TI |
4342 | #define set_beep_amp(spec, nid, idx, dir) \ |
4343 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) | |
4344 | ||
4345 | /* | |
4346 | * OK, here we have finally the patch for ALC880 | |
4347 | */ | |
4348 | ||
1da177e4 LT |
4349 | static int patch_alc880(struct hda_codec *codec) |
4350 | { | |
4351 | struct alc_spec *spec; | |
4352 | int board_config; | |
df694daa | 4353 | int err; |
1da177e4 | 4354 | |
e560d8d8 | 4355 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
4356 | if (spec == NULL) |
4357 | return -ENOMEM; | |
4358 | ||
4359 | codec->spec = spec; | |
4360 | ||
f5fcc13c TI |
4361 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
4362 | alc880_models, | |
4363 | alc880_cfg_tbl); | |
4364 | if (board_config < 0) { | |
9c7f852e TI |
4365 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
4366 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 4367 | board_config = ALC880_AUTO; |
1da177e4 | 4368 | } |
1da177e4 | 4369 | |
e9edcee0 TI |
4370 | if (board_config == ALC880_AUTO) { |
4371 | /* automatic parse from the BIOS config */ | |
4372 | err = alc880_parse_auto_config(codec); | |
4373 | if (err < 0) { | |
4374 | alc_free(codec); | |
4375 | return err; | |
f12ab1e0 | 4376 | } else if (!err) { |
9c7f852e TI |
4377 | printk(KERN_INFO |
4378 | "hda_codec: Cannot set up configuration " | |
4379 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
4380 | board_config = ALC880_3ST; |
4381 | } | |
1da177e4 LT |
4382 | } |
4383 | ||
680cd536 KK |
4384 | err = snd_hda_attach_beep_device(codec, 0x1); |
4385 | if (err < 0) { | |
4386 | alc_free(codec); | |
4387 | return err; | |
4388 | } | |
4389 | ||
df694daa KY |
4390 | if (board_config != ALC880_AUTO) |
4391 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
4392 | |
4393 | spec->stream_name_analog = "ALC880 Analog"; | |
4394 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
4395 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
6330079f | 4396 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
1da177e4 LT |
4397 | |
4398 | spec->stream_name_digital = "ALC880 Digital"; | |
4399 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
4400 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
4401 | ||
f12ab1e0 | 4402 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 4403 | /* check whether NID 0x07 is valid */ |
54d17403 | 4404 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
4405 | /* get type */ |
4406 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
4407 | if (wcap != AC_WID_AUD_IN) { |
4408 | spec->adc_nids = alc880_adc_nids_alt; | |
4409 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
e9edcee0 TI |
4410 | } else { |
4411 | spec->adc_nids = alc880_adc_nids; | |
4412 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
e9edcee0 TI |
4413 | } |
4414 | } | |
f9e336f6 | 4415 | set_capture_mixer(spec); |
45bdd1c1 | 4416 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
1da177e4 | 4417 | |
2134ea4f TI |
4418 | spec->vmaster_nid = 0x0c; |
4419 | ||
1da177e4 | 4420 | codec->patch_ops = alc_patch_ops; |
e9edcee0 | 4421 | if (board_config == ALC880_AUTO) |
ae6b813a | 4422 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
4423 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4424 | if (!spec->loopback.amplist) | |
4425 | spec->loopback.amplist = alc880_loopbacks; | |
4426 | #endif | |
daead538 | 4427 | codec->proc_widget_hook = print_realtek_coef; |
1da177e4 LT |
4428 | |
4429 | return 0; | |
4430 | } | |
4431 | ||
e9edcee0 | 4432 | |
1da177e4 LT |
4433 | /* |
4434 | * ALC260 support | |
4435 | */ | |
4436 | ||
e9edcee0 TI |
4437 | static hda_nid_t alc260_dac_nids[1] = { |
4438 | /* front */ | |
4439 | 0x02, | |
4440 | }; | |
4441 | ||
4442 | static hda_nid_t alc260_adc_nids[1] = { | |
4443 | /* ADC0 */ | |
4444 | 0x04, | |
4445 | }; | |
4446 | ||
df694daa | 4447 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
4448 | /* ADC1 */ |
4449 | 0x05, | |
4450 | }; | |
4451 | ||
d57fdac0 JW |
4452 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
4453 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
4454 | */ | |
4455 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
4456 | /* ADC0, ADC1 */ |
4457 | 0x04, 0x05 | |
4458 | }; | |
4459 | ||
e9edcee0 TI |
4460 | #define ALC260_DIGOUT_NID 0x03 |
4461 | #define ALC260_DIGIN_NID 0x06 | |
4462 | ||
4463 | static struct hda_input_mux alc260_capture_source = { | |
4464 | .num_items = 4, | |
4465 | .items = { | |
4466 | { "Mic", 0x0 }, | |
4467 | { "Front Mic", 0x1 }, | |
4468 | { "Line", 0x2 }, | |
4469 | { "CD", 0x4 }, | |
4470 | }, | |
4471 | }; | |
4472 | ||
17e7aec6 | 4473 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
4474 | * headphone jack and the internal CD lines since these are the only pins at |
4475 | * which audio can appear. For flexibility, also allow the option of | |
4476 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
4477 | * connection to the mixer output). | |
a9430dd8 | 4478 | */ |
a1e8d2da JW |
4479 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
4480 | { | |
4481 | .num_items = 3, | |
4482 | .items = { | |
4483 | { "Mic/Line", 0x0 }, | |
4484 | { "CD", 0x4 }, | |
4485 | { "Headphone", 0x2 }, | |
4486 | }, | |
a9430dd8 | 4487 | }, |
a1e8d2da JW |
4488 | { |
4489 | .num_items = 4, | |
4490 | .items = { | |
4491 | { "Mic/Line", 0x0 }, | |
4492 | { "CD", 0x4 }, | |
4493 | { "Headphone", 0x2 }, | |
4494 | { "Mixer", 0x5 }, | |
4495 | }, | |
4496 | }, | |
4497 | ||
a9430dd8 JW |
4498 | }; |
4499 | ||
a1e8d2da JW |
4500 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
4501 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 4502 | */ |
a1e8d2da JW |
4503 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
4504 | { | |
4505 | .num_items = 4, | |
4506 | .items = { | |
4507 | { "Mic", 0x0 }, | |
4508 | { "Line", 0x2 }, | |
4509 | { "CD", 0x4 }, | |
4510 | { "Headphone", 0x5 }, | |
4511 | }, | |
4512 | }, | |
4513 | { | |
4514 | .num_items = 5, | |
4515 | .items = { | |
4516 | { "Mic", 0x0 }, | |
4517 | { "Line", 0x2 }, | |
4518 | { "CD", 0x4 }, | |
4519 | { "Headphone", 0x6 }, | |
4520 | { "Mixer", 0x5 }, | |
4521 | }, | |
0bfc90e9 JW |
4522 | }, |
4523 | }; | |
1da177e4 LT |
4524 | /* |
4525 | * This is just place-holder, so there's something for alc_build_pcms to look | |
4526 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
4527 | * element which allows changing the channel mode, so the verb list is | |
4528 | * never used. | |
4529 | */ | |
d2a6d7dc | 4530 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
4531 | { 2, NULL }, |
4532 | }; | |
4533 | ||
df694daa KY |
4534 | |
4535 | /* Mixer combinations | |
4536 | * | |
4537 | * basic: base_output + input + pc_beep + capture | |
4538 | * HP: base_output + input + capture_alt | |
4539 | * HP_3013: hp_3013 + input + capture | |
4540 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 4541 | * acer: acer + capture |
df694daa KY |
4542 | */ |
4543 | ||
4544 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 4545 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4546 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 4547 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 4548 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 4549 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 4550 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 4551 | { } /* end */ |
f12ab1e0 | 4552 | }; |
1da177e4 | 4553 | |
df694daa | 4554 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
4555 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4556 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4557 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4558 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4559 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4560 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4561 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4562 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
4563 | { } /* end */ |
4564 | }; | |
4565 | ||
bec15c3a TI |
4566 | /* update HP, line and mono out pins according to the master switch */ |
4567 | static void alc260_hp_master_update(struct hda_codec *codec, | |
4568 | hda_nid_t hp, hda_nid_t line, | |
4569 | hda_nid_t mono) | |
4570 | { | |
4571 | struct alc_spec *spec = codec->spec; | |
4572 | unsigned int val = spec->master_sw ? PIN_HP : 0; | |
4573 | /* change HP and line-out pins */ | |
30cde0aa | 4574 | snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a | 4575 | val); |
30cde0aa | 4576 | snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a TI |
4577 | val); |
4578 | /* mono (speaker) depending on the HP jack sense */ | |
4579 | val = (val && !spec->jack_present) ? PIN_OUT : 0; | |
30cde0aa | 4580 | snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a TI |
4581 | val); |
4582 | } | |
4583 | ||
4584 | static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
4585 | struct snd_ctl_elem_value *ucontrol) | |
4586 | { | |
4587 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4588 | struct alc_spec *spec = codec->spec; | |
4589 | *ucontrol->value.integer.value = spec->master_sw; | |
4590 | return 0; | |
4591 | } | |
4592 | ||
4593 | static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
4594 | struct snd_ctl_elem_value *ucontrol) | |
4595 | { | |
4596 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4597 | struct alc_spec *spec = codec->spec; | |
4598 | int val = !!*ucontrol->value.integer.value; | |
4599 | hda_nid_t hp, line, mono; | |
4600 | ||
4601 | if (val == spec->master_sw) | |
4602 | return 0; | |
4603 | spec->master_sw = val; | |
4604 | hp = (kcontrol->private_value >> 16) & 0xff; | |
4605 | line = (kcontrol->private_value >> 8) & 0xff; | |
4606 | mono = kcontrol->private_value & 0xff; | |
4607 | alc260_hp_master_update(codec, hp, line, mono); | |
4608 | return 1; | |
4609 | } | |
4610 | ||
4611 | static struct snd_kcontrol_new alc260_hp_output_mixer[] = { | |
4612 | { | |
4613 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4614 | .name = "Master Playback Switch", | |
4615 | .info = snd_ctl_boolean_mono_info, | |
4616 | .get = alc260_hp_master_sw_get, | |
4617 | .put = alc260_hp_master_sw_put, | |
4618 | .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 | |
4619 | }, | |
4620 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4621 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), | |
4622 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4623 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), | |
4624 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, | |
4625 | HDA_OUTPUT), | |
4626 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4627 | { } /* end */ | |
4628 | }; | |
4629 | ||
4630 | static struct hda_verb alc260_hp_unsol_verbs[] = { | |
4631 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4632 | {}, | |
4633 | }; | |
4634 | ||
4635 | static void alc260_hp_automute(struct hda_codec *codec) | |
4636 | { | |
4637 | struct alc_spec *spec = codec->spec; | |
4638 | unsigned int present; | |
4639 | ||
4640 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4641 | AC_VERB_GET_PIN_SENSE, 0); | |
4642 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4643 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | |
4644 | } | |
4645 | ||
4646 | static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) | |
4647 | { | |
4648 | if ((res >> 26) == ALC880_HP_EVENT) | |
4649 | alc260_hp_automute(codec); | |
4650 | } | |
4651 | ||
df694daa | 4652 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
bec15c3a TI |
4653 | { |
4654 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4655 | .name = "Master Playback Switch", | |
4656 | .info = snd_ctl_boolean_mono_info, | |
4657 | .get = alc260_hp_master_sw_get, | |
4658 | .put = alc260_hp_master_sw_put, | |
30cde0aa | 4659 | .private_value = (0x15 << 16) | (0x10 << 8) | 0x11 |
bec15c3a | 4660 | }, |
df694daa KY |
4661 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4662 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4663 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4664 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4665 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4666 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
4667 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
4668 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
4669 | { } /* end */ |
4670 | }; | |
4671 | ||
3f878308 KY |
4672 | static struct hda_bind_ctls alc260_dc7600_bind_master_vol = { |
4673 | .ops = &snd_hda_bind_vol, | |
4674 | .values = { | |
4675 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT), | |
4676 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), | |
4677 | HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT), | |
4678 | 0 | |
4679 | }, | |
4680 | }; | |
4681 | ||
4682 | static struct hda_bind_ctls alc260_dc7600_bind_switch = { | |
4683 | .ops = &snd_hda_bind_sw, | |
4684 | .values = { | |
4685 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), | |
4686 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
4687 | 0 | |
4688 | }, | |
4689 | }; | |
4690 | ||
4691 | static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = { | |
4692 | HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol), | |
4693 | HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch), | |
4694 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT), | |
4695 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4696 | { } /* end */ | |
4697 | }; | |
4698 | ||
bec15c3a TI |
4699 | static struct hda_verb alc260_hp_3013_unsol_verbs[] = { |
4700 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4701 | {}, | |
4702 | }; | |
4703 | ||
4704 | static void alc260_hp_3013_automute(struct hda_codec *codec) | |
4705 | { | |
4706 | struct alc_spec *spec = codec->spec; | |
4707 | unsigned int present; | |
4708 | ||
4709 | present = snd_hda_codec_read(codec, 0x15, 0, | |
4710 | AC_VERB_GET_PIN_SENSE, 0); | |
4711 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
30cde0aa | 4712 | alc260_hp_master_update(codec, 0x15, 0x10, 0x11); |
bec15c3a TI |
4713 | } |
4714 | ||
4715 | static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |
4716 | unsigned int res) | |
4717 | { | |
4718 | if ((res >> 26) == ALC880_HP_EVENT) | |
4719 | alc260_hp_3013_automute(codec); | |
4720 | } | |
4721 | ||
3f878308 KY |
4722 | static void alc260_hp_3012_automute(struct hda_codec *codec) |
4723 | { | |
4724 | unsigned int present, bits; | |
4725 | ||
4726 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4727 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | |
4728 | ||
4729 | bits = present ? 0 : PIN_OUT; | |
4730 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4731 | bits); | |
4732 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4733 | bits); | |
4734 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4735 | bits); | |
4736 | } | |
4737 | ||
4738 | static void alc260_hp_3012_unsol_event(struct hda_codec *codec, | |
4739 | unsigned int res) | |
4740 | { | |
4741 | if ((res >> 26) == ALC880_HP_EVENT) | |
4742 | alc260_hp_3012_automute(codec); | |
4743 | } | |
4744 | ||
4745 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, | |
a1e8d2da JW |
4746 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. |
4747 | */ | |
c8b6bf9b | 4748 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 4749 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4750 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 4751 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
4752 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4753 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4754 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4755 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 4756 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
31bffaa9 TI |
4757 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4758 | HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), | |
df694daa KY |
4759 | { } /* end */ |
4760 | }; | |
4761 | ||
a1e8d2da JW |
4762 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
4763 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
4764 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
4765 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
4766 | * whether this behaviour is intentional or is a hardware bug in chip | |
4767 | * revisions available in early 2006. Therefore for now allow the | |
4768 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
4769 | * that the lack of mic bias for this NID is intentional we could change the | |
4770 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4771 | * | |
4772 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
4773 | * don't appear to make the mic bias available from the "line" jack, even | |
4774 | * though the NID used for this jack (0x14) can supply it. The theory is | |
4775 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
4776 | * and the output jack. If this turns out to be the case for all such | |
4777 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
4778 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
4779 | * |
4780 | * The C20x Tablet series have a mono internal speaker which is controlled | |
4781 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
4782 | * controls for such models. On models without a "mono speaker" the control | |
4783 | * won't do anything. | |
a1e8d2da | 4784 | */ |
0bfc90e9 JW |
4785 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
4786 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4787 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 4788 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
31bffaa9 | 4789 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, |
bd869485 | 4790 | HDA_OUTPUT), |
31bffaa9 | 4791 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, |
bd869485 | 4792 | HDA_INPUT), |
0bfc90e9 JW |
4793 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4794 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4795 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4796 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4797 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4798 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4799 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4800 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
0bfc90e9 JW |
4801 | { } /* end */ |
4802 | }; | |
4803 | ||
bc9f98a9 KY |
4804 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
4805 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
4806 | */ | |
4807 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
4808 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4809 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4810 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4811 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4812 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4813 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4814 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4815 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4816 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4817 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
bc9f98a9 KY |
4818 | { } /* end */ |
4819 | }; | |
4820 | ||
4821 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
4822 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
4823 | */ | |
4824 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
4825 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4826 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4827 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4828 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4829 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4830 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
4831 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
4832 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4833 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4834 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4835 | { } /* end */ | |
4836 | }; | |
4837 | ||
df694daa KY |
4838 | /* |
4839 | * initialization verbs | |
4840 | */ | |
1da177e4 LT |
4841 | static struct hda_verb alc260_init_verbs[] = { |
4842 | /* Line In pin widget for input */ | |
05acb863 | 4843 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4844 | /* CD pin widget for input */ |
05acb863 | 4845 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4846 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 4847 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4848 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 4849 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4850 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 4851 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4852 | /* select line-out */ |
fd56f2db | 4853 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 4854 | /* LINE-OUT pin */ |
05acb863 | 4855 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4856 | /* enable HP */ |
05acb863 | 4857 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 4858 | /* enable Mono */ |
05acb863 TI |
4859 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
4860 | /* mute capture amp left and right */ | |
16ded525 | 4861 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
4862 | /* set connection select to line in (default select for this ADC) */ |
4863 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
4864 | /* mute capture amp left and right */ |
4865 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4866 | /* set connection select to line in (default select for this ADC) */ | |
4867 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
4868 | /* set vol=0 Line-Out mixer amp left and right */ |
4869 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4870 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4871 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4872 | /* set vol=0 HP mixer amp left and right */ | |
4873 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4874 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4875 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4876 | /* set vol=0 Mono mixer amp left and right */ | |
4877 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4878 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4879 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4880 | /* unmute LINE-2 out pin */ | |
4881 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
4882 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4883 | * Line In 2 = 0x03 | |
4884 | */ | |
cb53c626 TI |
4885 | /* mute analog inputs */ |
4886 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4887 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4888 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4889 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4890 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4891 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
4892 | /* mute Front out path */ |
4893 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4894 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4895 | /* mute Headphone out path */ | |
4896 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4897 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4898 | /* mute Mono out path */ | |
4899 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4900 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
4901 | { } |
4902 | }; | |
4903 | ||
474167d6 | 4904 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
4905 | static struct hda_verb alc260_hp_init_verbs[] = { |
4906 | /* Headphone and output */ | |
4907 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4908 | /* mono output */ | |
4909 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4910 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4911 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4912 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4913 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4914 | /* Line In pin widget for input */ | |
4915 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4916 | /* Line-2 pin widget for output */ | |
4917 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4918 | /* CD pin widget for input */ | |
4919 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4920 | /* unmute amp left and right */ | |
4921 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4922 | /* set connection select to line in (default select for this ADC) */ | |
4923 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4924 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4925 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4926 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4927 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4928 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4929 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4930 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4931 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4932 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4933 | * Line In 2 = 0x03 | |
4934 | */ | |
cb53c626 TI |
4935 | /* mute analog inputs */ |
4936 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4937 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4938 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4939 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4940 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4941 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4942 | /* Unmute Front out path */ | |
4943 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4944 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4945 | /* Unmute Headphone out path */ | |
4946 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4947 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4948 | /* Unmute Mono out path */ | |
4949 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4950 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4951 | { } | |
4952 | }; | |
474167d6 | 4953 | #endif |
df694daa KY |
4954 | |
4955 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
4956 | /* Line out and output */ | |
4957 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4958 | /* mono output */ | |
4959 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4960 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4961 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4962 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4963 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4964 | /* Line In pin widget for input */ | |
4965 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4966 | /* Headphone pin widget for output */ | |
4967 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4968 | /* CD pin widget for input */ | |
4969 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4970 | /* unmute amp left and right */ | |
4971 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4972 | /* set connection select to line in (default select for this ADC) */ | |
4973 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4974 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4975 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4976 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4977 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4978 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4979 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4980 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4981 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4982 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4983 | * Line In 2 = 0x03 | |
4984 | */ | |
cb53c626 TI |
4985 | /* mute analog inputs */ |
4986 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4987 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4988 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4989 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4990 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4991 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4992 | /* Unmute Front out path */ | |
4993 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4994 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4995 | /* Unmute Headphone out path */ | |
4996 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4997 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4998 | /* Unmute Mono out path */ | |
4999 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5000 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
5001 | { } | |
5002 | }; | |
5003 | ||
a9430dd8 | 5004 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
5005 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
5006 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
5007 | */ |
5008 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
5009 | /* Disable all GPIOs */ | |
5010 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
5011 | /* Internal speaker is connected to headphone pin */ | |
5012 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5013 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
5014 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
5015 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
5016 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
5017 | /* Ensure all other unused pins are disabled and muted. */ | |
5018 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
5019 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 5020 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 5021 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 5022 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
5023 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
5024 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
5025 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5026 | ||
5027 | /* Disable digital (SPDIF) pins */ | |
5028 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5029 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 5030 | |
ea1fb29a | 5031 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
f7ace40d JW |
5032 | * when acting as an output. |
5033 | */ | |
5034 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 5035 | |
f7ace40d | 5036 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
5037 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
5038 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5039 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5040 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5041 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5042 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5043 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5044 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5045 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 5046 | |
f7ace40d JW |
5047 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
5048 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5049 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
5050 | * If the pin mode is changed by the user the pin mode control will | |
5051 | * take care of enabling the pin's input/output buffers as needed. | |
5052 | * Therefore there's no need to enable the input buffer at this | |
5053 | * stage. | |
cdcd9268 | 5054 | */ |
f7ace40d | 5055 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
ea1fb29a | 5056 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
cdcd9268 JW |
5057 | * mixer ctrl) |
5058 | */ | |
f7ace40d JW |
5059 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5060 | ||
5061 | /* Mute capture amp left and right */ | |
5062 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 5063 | /* Set ADC connection select to match default mixer setting - line |
f7ace40d JW |
5064 | * in (on mic1 pin) |
5065 | */ | |
5066 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5067 | ||
5068 | /* Do the same for the second ADC: mute capture input amp and | |
5069 | * set ADC connection to line in (on mic1 pin) | |
5070 | */ | |
5071 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5072 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5073 | ||
5074 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5075 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5076 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5077 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5078 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5079 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5080 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5081 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5082 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
5083 | |
5084 | { } | |
a9430dd8 JW |
5085 | }; |
5086 | ||
0bfc90e9 JW |
5087 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
5088 | * similar laptops (adapted from Fujitsu init verbs). | |
5089 | */ | |
5090 | static struct hda_verb alc260_acer_init_verbs[] = { | |
5091 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
5092 | * the headphone jack. Turn this on and rely on the standard mute | |
5093 | * methods whenever the user wants to turn these outputs off. | |
5094 | */ | |
5095 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
5096 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
5097 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
5098 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
5099 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5100 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
5101 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
5102 | /* Line In jack is connected to Line1 pin */ | |
5103 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
5104 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
5105 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
5106 | /* Ensure all other unused pins are disabled and muted. */ |
5107 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
5108 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
5109 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
5110 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5111 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
5112 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5113 | /* Disable digital (SPDIF) pins */ | |
5114 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5115 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5116 | ||
ea1fb29a | 5117 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum |
0bfc90e9 JW |
5118 | * bus when acting as outputs. |
5119 | */ | |
5120 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
5121 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
5122 | ||
5123 | /* Start with output sum widgets muted and their output gains at min */ | |
5124 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5125 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5126 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5127 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5128 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5129 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5130 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5131 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5132 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5133 | ||
f12ab1e0 TI |
5134 | /* Unmute Line-out pin widget amp left and right |
5135 | * (no equiv mixer ctrl) | |
5136 | */ | |
0bfc90e9 | 5137 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
5138 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
5139 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
5140 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
5141 | * inputs. If the pin mode is changed by the user the pin mode control | |
5142 | * will take care of enabling the pin's input/output buffers as needed. | |
5143 | * Therefore there's no need to enable the input buffer at this | |
5144 | * stage. | |
5145 | */ | |
5146 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5147 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5148 | ||
5149 | /* Mute capture amp left and right */ | |
5150 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5151 | /* Set ADC connection select to match default mixer setting - mic | |
5152 | * (on mic1 pin) | |
5153 | */ | |
5154 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5155 | ||
5156 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 5157 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
5158 | */ |
5159 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 5160 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
5161 | |
5162 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5163 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5164 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5165 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5166 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5167 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5168 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5169 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5170 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
5171 | ||
5172 | { } | |
5173 | }; | |
5174 | ||
bc9f98a9 KY |
5175 | static struct hda_verb alc260_will_verbs[] = { |
5176 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5177 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5178 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5179 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
5180 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
5181 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
5182 | {} | |
5183 | }; | |
5184 | ||
5185 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
5186 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
5187 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
5188 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
5189 | ||
5190 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
5191 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
5192 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
5193 | ||
5194 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5195 | {} | |
5196 | }; | |
5197 | ||
5198 | /* toggle speaker-output according to the hp-jack state */ | |
5199 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
5200 | { | |
5201 | unsigned int present; | |
5202 | ||
5203 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
5204 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
5205 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
5206 | if (present) { | |
82beb8fd TI |
5207 | snd_hda_codec_write_cache(codec, 0x01, 0, |
5208 | AC_VERB_SET_GPIO_DATA, 1); | |
5209 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
5210 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5211 | PIN_HP); | |
bc9f98a9 | 5212 | } else { |
82beb8fd TI |
5213 | snd_hda_codec_write_cache(codec, 0x01, 0, |
5214 | AC_VERB_SET_GPIO_DATA, 0); | |
5215 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
5216 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5217 | PIN_OUT); | |
bc9f98a9 KY |
5218 | } |
5219 | } | |
5220 | ||
5221 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
5222 | unsigned int res) | |
5223 | { | |
5224 | if ((res >> 26) == ALC880_HP_EVENT) | |
5225 | alc260_replacer_672v_automute(codec); | |
5226 | } | |
5227 | ||
3f878308 KY |
5228 | static struct hda_verb alc260_hp_dc7600_verbs[] = { |
5229 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5230 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5231 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5232 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5233 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5234 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5235 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5236 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5237 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5238 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5239 | {} | |
5240 | }; | |
5241 | ||
7cf51e48 JW |
5242 | /* Test configuration for debugging, modelled after the ALC880 test |
5243 | * configuration. | |
5244 | */ | |
5245 | #ifdef CONFIG_SND_DEBUG | |
5246 | static hda_nid_t alc260_test_dac_nids[1] = { | |
5247 | 0x02, | |
5248 | }; | |
5249 | static hda_nid_t alc260_test_adc_nids[2] = { | |
5250 | 0x04, 0x05, | |
5251 | }; | |
a1e8d2da | 5252 | /* For testing the ALC260, each input MUX needs its own definition since |
ea1fb29a | 5253 | * the signal assignments are different. This assumes that the first ADC |
a1e8d2da | 5254 | * is NID 0x04. |
17e7aec6 | 5255 | */ |
a1e8d2da JW |
5256 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
5257 | { | |
5258 | .num_items = 7, | |
5259 | .items = { | |
5260 | { "MIC1 pin", 0x0 }, | |
5261 | { "MIC2 pin", 0x1 }, | |
5262 | { "LINE1 pin", 0x2 }, | |
5263 | { "LINE2 pin", 0x3 }, | |
5264 | { "CD pin", 0x4 }, | |
5265 | { "LINE-OUT pin", 0x5 }, | |
5266 | { "HP-OUT pin", 0x6 }, | |
5267 | }, | |
5268 | }, | |
5269 | { | |
5270 | .num_items = 8, | |
5271 | .items = { | |
5272 | { "MIC1 pin", 0x0 }, | |
5273 | { "MIC2 pin", 0x1 }, | |
5274 | { "LINE1 pin", 0x2 }, | |
5275 | { "LINE2 pin", 0x3 }, | |
5276 | { "CD pin", 0x4 }, | |
5277 | { "Mixer", 0x5 }, | |
5278 | { "LINE-OUT pin", 0x6 }, | |
5279 | { "HP-OUT pin", 0x7 }, | |
5280 | }, | |
7cf51e48 JW |
5281 | }, |
5282 | }; | |
5283 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
5284 | /* Output driver widgets */ | |
5285 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
5286 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
5287 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
5288 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
5289 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
5290 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
5291 | ||
a1e8d2da JW |
5292 | /* Modes for retasking pin widgets |
5293 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
5294 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
5295 | * mention this restriction. At this stage it's not clear whether | |
5296 | * this behaviour is intentional or is a hardware bug in chip | |
5297 | * revisions available at least up until early 2006. Therefore for | |
5298 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
5299 | * choices, but if it turns out that the lack of mic bias for these | |
5300 | * NIDs is intentional we could change their modes from | |
5301 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
5302 | */ | |
7cf51e48 JW |
5303 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
5304 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
5305 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
5306 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
5307 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
5308 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
5309 | ||
5310 | /* Loopback mixer controls */ | |
5311 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
5312 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
5313 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
5314 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
5315 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
5316 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
5317 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
5318 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
5319 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
5320 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
7cf51e48 JW |
5321 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), |
5322 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
5323 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
5324 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
5325 | |
5326 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
5327 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
5328 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
5329 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
5330 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
5331 | ||
92621f13 JW |
5332 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
5333 | * is ambigious as to which NID is which; testing on laptops which | |
ea1fb29a | 5334 | * make this output available should provide clarification. |
92621f13 JW |
5335 | */ |
5336 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
5337 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
5338 | ||
f8225f6d JW |
5339 | /* A switch allowing EAPD to be enabled. Some laptops seem to use |
5340 | * this output to turn on an external amplifier. | |
5341 | */ | |
5342 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
5343 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
5344 | ||
7cf51e48 JW |
5345 | { } /* end */ |
5346 | }; | |
5347 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
5348 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
5349 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
5350 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
5351 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
5352 | ||
7cf51e48 JW |
5353 | /* Enable retasking pins as output, initially without power amp */ |
5354 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5355 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5356 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5357 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5358 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5359 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5360 | ||
92621f13 JW |
5361 | /* Disable digital (SPDIF) pins initially, but users can enable |
5362 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
5363 | * payload also sets the generation to 0, output to be in "consumer" | |
5364 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
5365 | * control. | |
5366 | */ | |
7cf51e48 JW |
5367 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
5368 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5369 | ||
ea1fb29a | 5370 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
5371 | * OUT1 sum bus when acting as an output. |
5372 | */ | |
5373 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
5374 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
5375 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
5376 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
5377 | ||
5378 | /* Start with output sum widgets muted and their output gains at min */ | |
5379 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5380 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5381 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5382 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5383 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5384 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5385 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5386 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5387 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5388 | ||
cdcd9268 JW |
5389 | /* Unmute retasking pin widget output buffers since the default |
5390 | * state appears to be output. As the pin mode is changed by the | |
5391 | * user the pin mode control will take care of enabling the pin's | |
5392 | * input/output buffers as needed. | |
5393 | */ | |
7cf51e48 JW |
5394 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
5395 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5396 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5397 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5398 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5399 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5400 | /* Also unmute the mono-out pin widget */ | |
5401 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5402 | ||
7cf51e48 JW |
5403 | /* Mute capture amp left and right */ |
5404 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
5405 | /* Set ADC connection select to match default mixer setting (mic1 |
5406 | * pin) | |
7cf51e48 JW |
5407 | */ |
5408 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5409 | ||
5410 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 5411 | * set ADC connection to mic1 pin |
7cf51e48 JW |
5412 | */ |
5413 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5414 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5415 | ||
5416 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5417 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5418 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5419 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5420 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5421 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5422 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5423 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5424 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
5425 | ||
5426 | { } | |
5427 | }; | |
5428 | #endif | |
5429 | ||
6330079f TI |
5430 | #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback |
5431 | #define alc260_pcm_analog_capture alc880_pcm_analog_capture | |
1da177e4 | 5432 | |
a3bcba38 TI |
5433 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
5434 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
5435 | ||
df694daa KY |
5436 | /* |
5437 | * for BIOS auto-configuration | |
5438 | */ | |
16ded525 | 5439 | |
df694daa | 5440 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
863b4518 | 5441 | const char *pfx, int *vol_bits) |
df694daa KY |
5442 | { |
5443 | hda_nid_t nid_vol; | |
5444 | unsigned long vol_val, sw_val; | |
5445 | char name[32]; | |
5446 | int err; | |
5447 | ||
5448 | if (nid >= 0x0f && nid < 0x11) { | |
5449 | nid_vol = nid - 0x7; | |
5450 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
5451 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
5452 | } else if (nid == 0x11) { | |
5453 | nid_vol = nid - 0x7; | |
5454 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
5455 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
5456 | } else if (nid >= 0x12 && nid <= 0x15) { | |
5457 | nid_vol = 0x08; | |
5458 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
5459 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
5460 | } else | |
5461 | return 0; /* N/A */ | |
ea1fb29a | 5462 | |
863b4518 TI |
5463 | if (!(*vol_bits & (1 << nid_vol))) { |
5464 | /* first control for the volume widget */ | |
5465 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
5466 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); | |
5467 | if (err < 0) | |
5468 | return err; | |
5469 | *vol_bits |= (1 << nid_vol); | |
5470 | } | |
df694daa | 5471 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
f12ab1e0 TI |
5472 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
5473 | if (err < 0) | |
df694daa KY |
5474 | return err; |
5475 | return 1; | |
5476 | } | |
5477 | ||
5478 | /* add playback controls from the parsed DAC table */ | |
5479 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
5480 | const struct auto_pin_cfg *cfg) | |
5481 | { | |
5482 | hda_nid_t nid; | |
5483 | int err; | |
863b4518 | 5484 | int vols = 0; |
df694daa KY |
5485 | |
5486 | spec->multiout.num_dacs = 1; | |
5487 | spec->multiout.dac_nids = spec->private_dac_nids; | |
5488 | spec->multiout.dac_nids[0] = 0x02; | |
5489 | ||
5490 | nid = cfg->line_out_pins[0]; | |
5491 | if (nid) { | |
863b4518 | 5492 | err = alc260_add_playback_controls(spec, nid, "Front", &vols); |
df694daa KY |
5493 | if (err < 0) |
5494 | return err; | |
5495 | } | |
5496 | ||
82bc955f | 5497 | nid = cfg->speaker_pins[0]; |
df694daa | 5498 | if (nid) { |
863b4518 | 5499 | err = alc260_add_playback_controls(spec, nid, "Speaker", &vols); |
df694daa KY |
5500 | if (err < 0) |
5501 | return err; | |
5502 | } | |
5503 | ||
eb06ed8f | 5504 | nid = cfg->hp_pins[0]; |
df694daa | 5505 | if (nid) { |
863b4518 TI |
5506 | err = alc260_add_playback_controls(spec, nid, "Headphone", |
5507 | &vols); | |
df694daa KY |
5508 | if (err < 0) |
5509 | return err; | |
5510 | } | |
f12ab1e0 | 5511 | return 0; |
df694daa KY |
5512 | } |
5513 | ||
5514 | /* create playback/capture controls for input pins */ | |
5515 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
5516 | const struct auto_pin_cfg *cfg) | |
5517 | { | |
61b9b9b1 | 5518 | struct hda_input_mux *imux = &spec->private_imux[0]; |
df694daa KY |
5519 | int i, err, idx; |
5520 | ||
5521 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5522 | if (cfg->input_pins[i] >= 0x12) { | |
5523 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 5524 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5525 | auto_pin_cfg_labels[i], idx, |
5526 | 0x07); | |
df694daa KY |
5527 | if (err < 0) |
5528 | return err; | |
f12ab1e0 TI |
5529 | imux->items[imux->num_items].label = |
5530 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5531 | imux->items[imux->num_items].index = idx; |
5532 | imux->num_items++; | |
5533 | } | |
f12ab1e0 | 5534 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 5535 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 5536 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5537 | auto_pin_cfg_labels[i], idx, |
5538 | 0x07); | |
df694daa KY |
5539 | if (err < 0) |
5540 | return err; | |
f12ab1e0 TI |
5541 | imux->items[imux->num_items].label = |
5542 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5543 | imux->items[imux->num_items].index = idx; |
5544 | imux->num_items++; | |
5545 | } | |
5546 | } | |
5547 | return 0; | |
5548 | } | |
5549 | ||
5550 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
5551 | hda_nid_t nid, int pin_type, | |
5552 | int sel_idx) | |
5553 | { | |
f6c7e546 | 5554 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
5555 | /* need the manual connection? */ |
5556 | if (nid >= 0x12) { | |
5557 | int idx = nid - 0x12; | |
5558 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
5559 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
5560 | } |
5561 | } | |
5562 | ||
5563 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
5564 | { | |
5565 | struct alc_spec *spec = codec->spec; | |
5566 | hda_nid_t nid; | |
5567 | ||
bc9f98a9 | 5568 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 5569 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
5570 | if (nid) { |
5571 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
5572 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
5573 | } | |
ea1fb29a | 5574 | |
82bc955f | 5575 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
5576 | if (nid) |
5577 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
5578 | ||
eb06ed8f | 5579 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 5580 | if (nid) |
baba8ee9 | 5581 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 5582 | } |
df694daa KY |
5583 | |
5584 | #define ALC260_PIN_CD_NID 0x16 | |
5585 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
5586 | { | |
5587 | struct alc_spec *spec = codec->spec; | |
5588 | int i; | |
5589 | ||
5590 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5591 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5592 | if (nid >= 0x12) { | |
f12ab1e0 TI |
5593 | snd_hda_codec_write(codec, nid, 0, |
5594 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5595 | i <= AUTO_PIN_FRONT_MIC ? | |
5596 | PIN_VREF80 : PIN_IN); | |
df694daa | 5597 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
5598 | snd_hda_codec_write(codec, nid, 0, |
5599 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5600 | AMP_OUT_MUTE); |
5601 | } | |
5602 | } | |
5603 | } | |
5604 | ||
5605 | /* | |
5606 | * generic initialization of ADC, input mixers and output mixers | |
5607 | */ | |
5608 | static struct hda_verb alc260_volume_init_verbs[] = { | |
5609 | /* | |
5610 | * Unmute ADC0-1 and set the default input to mic-in | |
5611 | */ | |
5612 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5613 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5614 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5615 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 5616 | |
df694daa KY |
5617 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
5618 | * mixer widget | |
f12ab1e0 TI |
5619 | * Note: PASD motherboards uses the Line In 2 as the input for |
5620 | * front panel mic (mic 2) | |
df694daa KY |
5621 | */ |
5622 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5623 | /* mute analog inputs */ |
5624 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5625 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5626 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5627 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5628 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
5629 | |
5630 | /* | |
5631 | * Set up output mixers (0x08 - 0x0a) | |
5632 | */ | |
5633 | /* set vol=0 to output mixers */ | |
5634 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5635 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5636 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5637 | /* set up input amps for analog loopback */ | |
5638 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5639 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5640 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5641 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5642 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5643 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5644 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 5645 | |
df694daa KY |
5646 | { } |
5647 | }; | |
5648 | ||
5649 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
5650 | { | |
5651 | struct alc_spec *spec = codec->spec; | |
df694daa KY |
5652 | int err; |
5653 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
5654 | ||
f12ab1e0 TI |
5655 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
5656 | alc260_ignore); | |
5657 | if (err < 0) | |
df694daa | 5658 | return err; |
f12ab1e0 TI |
5659 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
5660 | if (err < 0) | |
4a471b7d | 5661 | return err; |
603c4019 | 5662 | if (!spec->kctls.list) |
df694daa | 5663 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
5664 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
5665 | if (err < 0) | |
df694daa KY |
5666 | return err; |
5667 | ||
5668 | spec->multiout.max_channels = 2; | |
5669 | ||
0852d7a6 | 5670 | if (spec->autocfg.dig_outs) |
df694daa | 5671 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; |
603c4019 | 5672 | if (spec->kctls.list) |
d88897ea | 5673 | add_mixer(spec, spec->kctls.list); |
df694daa | 5674 | |
d88897ea | 5675 | add_verb(spec, alc260_volume_init_verbs); |
df694daa | 5676 | |
a1e8d2da | 5677 | spec->num_mux_defs = 1; |
61b9b9b1 | 5678 | spec->input_mux = &spec->private_imux[0]; |
df694daa | 5679 | |
e044c39a | 5680 | store_pin_configs(codec); |
df694daa KY |
5681 | return 1; |
5682 | } | |
5683 | ||
ae6b813a TI |
5684 | /* additional initialization for auto-configuration model */ |
5685 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 5686 | { |
f6c7e546 | 5687 | struct alc_spec *spec = codec->spec; |
df694daa KY |
5688 | alc260_auto_init_multi_out(codec); |
5689 | alc260_auto_init_analog_input(codec); | |
f6c7e546 | 5690 | if (spec->unsol_event) |
7fb0d78f | 5691 | alc_inithook(codec); |
df694daa KY |
5692 | } |
5693 | ||
cb53c626 TI |
5694 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5695 | static struct hda_amp_list alc260_loopbacks[] = { | |
5696 | { 0x07, HDA_INPUT, 0 }, | |
5697 | { 0x07, HDA_INPUT, 1 }, | |
5698 | { 0x07, HDA_INPUT, 2 }, | |
5699 | { 0x07, HDA_INPUT, 3 }, | |
5700 | { 0x07, HDA_INPUT, 4 }, | |
5701 | { } /* end */ | |
5702 | }; | |
5703 | #endif | |
5704 | ||
df694daa KY |
5705 | /* |
5706 | * ALC260 configurations | |
5707 | */ | |
f5fcc13c TI |
5708 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
5709 | [ALC260_BASIC] = "basic", | |
5710 | [ALC260_HP] = "hp", | |
5711 | [ALC260_HP_3013] = "hp-3013", | |
2922c9af | 5712 | [ALC260_HP_DC7600] = "hp-dc7600", |
f5fcc13c TI |
5713 | [ALC260_FUJITSU_S702X] = "fujitsu", |
5714 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
5715 | [ALC260_WILL] = "will", |
5716 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 5717 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 5718 | [ALC260_TEST] = "test", |
7cf51e48 | 5719 | #endif |
f5fcc13c TI |
5720 | [ALC260_AUTO] = "auto", |
5721 | }; | |
5722 | ||
5723 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 5724 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 5725 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 5726 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 5727 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c | 5728 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
34ec8a0a | 5729 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), |
3f878308 | 5730 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600), |
f5fcc13c TI |
5731 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), |
5732 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
5733 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
5734 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
5735 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
5736 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
5737 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
5738 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
5739 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 | 5740 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), |
ac3e3741 | 5741 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
df694daa KY |
5742 | {} |
5743 | }; | |
5744 | ||
5745 | static struct alc_config_preset alc260_presets[] = { | |
5746 | [ALC260_BASIC] = { | |
5747 | .mixers = { alc260_base_output_mixer, | |
45bdd1c1 | 5748 | alc260_input_mixer }, |
df694daa KY |
5749 | .init_verbs = { alc260_init_verbs }, |
5750 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5751 | .dac_nids = alc260_dac_nids, | |
f9e336f6 | 5752 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
df694daa KY |
5753 | .adc_nids = alc260_adc_nids, |
5754 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5755 | .channel_mode = alc260_modes, | |
5756 | .input_mux = &alc260_capture_source, | |
5757 | }, | |
5758 | [ALC260_HP] = { | |
bec15c3a | 5759 | .mixers = { alc260_hp_output_mixer, |
f9e336f6 | 5760 | alc260_input_mixer }, |
bec15c3a TI |
5761 | .init_verbs = { alc260_init_verbs, |
5762 | alc260_hp_unsol_verbs }, | |
df694daa KY |
5763 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5764 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5765 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5766 | .adc_nids = alc260_adc_nids_alt, | |
df694daa KY |
5767 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5768 | .channel_mode = alc260_modes, | |
5769 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5770 | .unsol_event = alc260_hp_unsol_event, |
5771 | .init_hook = alc260_hp_automute, | |
df694daa | 5772 | }, |
3f878308 KY |
5773 | [ALC260_HP_DC7600] = { |
5774 | .mixers = { alc260_hp_dc7600_mixer, | |
f9e336f6 | 5775 | alc260_input_mixer }, |
3f878308 KY |
5776 | .init_verbs = { alc260_init_verbs, |
5777 | alc260_hp_dc7600_verbs }, | |
5778 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5779 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5780 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5781 | .adc_nids = alc260_adc_nids_alt, | |
3f878308 KY |
5782 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5783 | .channel_mode = alc260_modes, | |
5784 | .input_mux = &alc260_capture_source, | |
5785 | .unsol_event = alc260_hp_3012_unsol_event, | |
5786 | .init_hook = alc260_hp_3012_automute, | |
5787 | }, | |
df694daa KY |
5788 | [ALC260_HP_3013] = { |
5789 | .mixers = { alc260_hp_3013_mixer, | |
f9e336f6 | 5790 | alc260_input_mixer }, |
bec15c3a TI |
5791 | .init_verbs = { alc260_hp_3013_init_verbs, |
5792 | alc260_hp_3013_unsol_verbs }, | |
df694daa KY |
5793 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5794 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5795 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5796 | .adc_nids = alc260_adc_nids_alt, | |
df694daa KY |
5797 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5798 | .channel_mode = alc260_modes, | |
5799 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5800 | .unsol_event = alc260_hp_3013_unsol_event, |
5801 | .init_hook = alc260_hp_3013_automute, | |
df694daa KY |
5802 | }, |
5803 | [ALC260_FUJITSU_S702X] = { | |
f9e336f6 | 5804 | .mixers = { alc260_fujitsu_mixer }, |
df694daa KY |
5805 | .init_verbs = { alc260_fujitsu_init_verbs }, |
5806 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5807 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
5808 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
5809 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
5810 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5811 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5812 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
5813 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 5814 | }, |
0bfc90e9 | 5815 | [ALC260_ACER] = { |
f9e336f6 | 5816 | .mixers = { alc260_acer_mixer }, |
0bfc90e9 JW |
5817 | .init_verbs = { alc260_acer_init_verbs }, |
5818 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5819 | .dac_nids = alc260_dac_nids, | |
5820 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
5821 | .adc_nids = alc260_dual_adc_nids, | |
5822 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5823 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5824 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
5825 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 5826 | }, |
bc9f98a9 | 5827 | [ALC260_WILL] = { |
f9e336f6 | 5828 | .mixers = { alc260_will_mixer }, |
bc9f98a9 KY |
5829 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, |
5830 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5831 | .dac_nids = alc260_dac_nids, | |
5832 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5833 | .adc_nids = alc260_adc_nids, | |
5834 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5835 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5836 | .channel_mode = alc260_modes, | |
5837 | .input_mux = &alc260_capture_source, | |
5838 | }, | |
5839 | [ALC260_REPLACER_672V] = { | |
f9e336f6 | 5840 | .mixers = { alc260_replacer_672v_mixer }, |
bc9f98a9 KY |
5841 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, |
5842 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5843 | .dac_nids = alc260_dac_nids, | |
5844 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5845 | .adc_nids = alc260_adc_nids, | |
5846 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5847 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5848 | .channel_mode = alc260_modes, | |
5849 | .input_mux = &alc260_capture_source, | |
5850 | .unsol_event = alc260_replacer_672v_unsol_event, | |
5851 | .init_hook = alc260_replacer_672v_automute, | |
5852 | }, | |
7cf51e48 JW |
5853 | #ifdef CONFIG_SND_DEBUG |
5854 | [ALC260_TEST] = { | |
f9e336f6 | 5855 | .mixers = { alc260_test_mixer }, |
7cf51e48 JW |
5856 | .init_verbs = { alc260_test_init_verbs }, |
5857 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
5858 | .dac_nids = alc260_test_dac_nids, | |
5859 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
5860 | .adc_nids = alc260_test_adc_nids, | |
5861 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5862 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5863 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
5864 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
5865 | }, |
5866 | #endif | |
df694daa KY |
5867 | }; |
5868 | ||
5869 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
5870 | { |
5871 | struct alc_spec *spec; | |
df694daa | 5872 | int err, board_config; |
1da177e4 | 5873 | |
e560d8d8 | 5874 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
5875 | if (spec == NULL) |
5876 | return -ENOMEM; | |
5877 | ||
5878 | codec->spec = spec; | |
5879 | ||
f5fcc13c TI |
5880 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
5881 | alc260_models, | |
5882 | alc260_cfg_tbl); | |
5883 | if (board_config < 0) { | |
9c7f852e TI |
5884 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
5885 | "trying auto-probe from BIOS...\n"); | |
df694daa | 5886 | board_config = ALC260_AUTO; |
16ded525 | 5887 | } |
1da177e4 | 5888 | |
df694daa KY |
5889 | if (board_config == ALC260_AUTO) { |
5890 | /* automatic parse from the BIOS config */ | |
5891 | err = alc260_parse_auto_config(codec); | |
5892 | if (err < 0) { | |
5893 | alc_free(codec); | |
5894 | return err; | |
f12ab1e0 | 5895 | } else if (!err) { |
9c7f852e TI |
5896 | printk(KERN_INFO |
5897 | "hda_codec: Cannot set up configuration " | |
5898 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5899 | board_config = ALC260_BASIC; |
5900 | } | |
a9430dd8 | 5901 | } |
e9edcee0 | 5902 | |
680cd536 KK |
5903 | err = snd_hda_attach_beep_device(codec, 0x1); |
5904 | if (err < 0) { | |
5905 | alc_free(codec); | |
5906 | return err; | |
5907 | } | |
5908 | ||
df694daa KY |
5909 | if (board_config != ALC260_AUTO) |
5910 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
5911 | |
5912 | spec->stream_name_analog = "ALC260 Analog"; | |
5913 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
5914 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
5915 | ||
a3bcba38 TI |
5916 | spec->stream_name_digital = "ALC260 Digital"; |
5917 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
5918 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
5919 | ||
4ef0ef19 TI |
5920 | if (!spec->adc_nids && spec->input_mux) { |
5921 | /* check whether NID 0x04 is valid */ | |
5922 | unsigned int wcap = get_wcaps(codec, 0x04); | |
5923 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
5924 | /* get type */ | |
5925 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | |
5926 | spec->adc_nids = alc260_adc_nids_alt; | |
5927 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
5928 | } else { | |
5929 | spec->adc_nids = alc260_adc_nids; | |
5930 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
5931 | } | |
5932 | } | |
f9e336f6 | 5933 | set_capture_mixer(spec); |
45bdd1c1 | 5934 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
f9e336f6 | 5935 | |
2134ea4f TI |
5936 | spec->vmaster_nid = 0x08; |
5937 | ||
1da177e4 | 5938 | codec->patch_ops = alc_patch_ops; |
df694daa | 5939 | if (board_config == ALC260_AUTO) |
ae6b813a | 5940 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
5941 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5942 | if (!spec->loopback.amplist) | |
5943 | spec->loopback.amplist = alc260_loopbacks; | |
5944 | #endif | |
daead538 | 5945 | codec->proc_widget_hook = print_realtek_coef; |
1da177e4 LT |
5946 | |
5947 | return 0; | |
5948 | } | |
5949 | ||
e9edcee0 | 5950 | |
1da177e4 LT |
5951 | /* |
5952 | * ALC882 support | |
5953 | * | |
5954 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
5955 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5956 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5957 | * 6-channel independent captures. | |
5958 | * | |
5959 | * In addition, an independent DAC for the multi-playback (not used in this | |
5960 | * driver yet). | |
5961 | */ | |
df694daa KY |
5962 | #define ALC882_DIGOUT_NID 0x06 |
5963 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 5964 | |
d2a6d7dc | 5965 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
5966 | { 8, NULL } |
5967 | }; | |
5968 | ||
5969 | static hda_nid_t alc882_dac_nids[4] = { | |
5970 | /* front, rear, clfe, rear_surr */ | |
5971 | 0x02, 0x03, 0x04, 0x05 | |
5972 | }; | |
5973 | ||
df694daa KY |
5974 | /* identical with ALC880 */ |
5975 | #define alc882_adc_nids alc880_adc_nids | |
5976 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 | 5977 | |
e1406348 TI |
5978 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; |
5979 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; | |
5980 | ||
1da177e4 LT |
5981 | /* input MUX */ |
5982 | /* FIXME: should be a matrix-type input source selection */ | |
5983 | ||
5984 | static struct hda_input_mux alc882_capture_source = { | |
5985 | .num_items = 4, | |
5986 | .items = { | |
5987 | { "Mic", 0x0 }, | |
5988 | { "Front Mic", 0x1 }, | |
5989 | { "Line", 0x2 }, | |
5990 | { "CD", 0x4 }, | |
5991 | }, | |
5992 | }; | |
272a527c KY |
5993 | /* |
5994 | * 2ch mode | |
5995 | */ | |
5996 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
5997 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5998 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5999 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6000 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6001 | { } /* end */ | |
6002 | }; | |
6003 | ||
6004 | /* | |
6005 | * 6ch mode | |
6006 | */ | |
6007 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
6008 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6009 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6010 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6011 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6012 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6013 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6014 | { } /* end */ | |
6015 | }; | |
6016 | ||
6017 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
6018 | { 2, alc882_3ST_ch2_init }, | |
6019 | { 6, alc882_3ST_ch6_init }, | |
6020 | }; | |
6021 | ||
df694daa KY |
6022 | /* |
6023 | * 6ch mode | |
6024 | */ | |
6025 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
6026 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
6027 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6028 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6029 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6030 | { } /* end */ | |
6031 | }; | |
6032 | ||
6033 | /* | |
6034 | * 8ch mode | |
6035 | */ | |
6036 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
6037 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6038 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6039 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6040 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6041 | { } /* end */ | |
6042 | }; | |
6043 | ||
6044 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
6045 | { 6, alc882_sixstack_ch6_init }, | |
6046 | { 8, alc882_sixstack_ch8_init }, | |
6047 | }; | |
6048 | ||
87350ad0 TI |
6049 | /* |
6050 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
6051 | */ | |
6052 | ||
6053 | /* | |
6054 | * 2ch mode | |
6055 | */ | |
6056 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
6057 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6058 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6059 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6060 | { } /* end */ | |
6061 | }; | |
6062 | ||
6063 | /* | |
6064 | * 6ch mode | |
6065 | */ | |
6066 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
6067 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6068 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6069 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6070 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6071 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6072 | { } /* end */ | |
6073 | }; | |
6074 | ||
6075 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
6076 | { 2, alc885_mbp_ch2_init }, | |
6077 | { 6, alc885_mbp_ch6_init }, | |
6078 | }; | |
6079 | ||
6080 | ||
1da177e4 LT |
6081 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6082 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
6083 | */ | |
c8b6bf9b | 6084 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 6085 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 6086 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 6087 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 6088 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
6089 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
6090 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
6091 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
6092 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 6093 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 6094 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
6095 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
6096 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6097 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6098 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6099 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6100 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6101 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
6102 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6103 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6104 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 | 6105 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
1da177e4 LT |
6106 | { } /* end */ |
6107 | }; | |
6108 | ||
87350ad0 | 6109 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
2134ea4f TI |
6110 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
6111 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | |
6112 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | |
6113 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | |
6114 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6115 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
87350ad0 TI |
6116 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
6117 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
2134ea4f | 6118 | HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), |
87350ad0 TI |
6119 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), |
6120 | { } /* end */ | |
6121 | }; | |
bdd148a3 KY |
6122 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
6123 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6124 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6125 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6126 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6127 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6128 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6129 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6130 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6131 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
bdd148a3 KY |
6132 | { } /* end */ |
6133 | }; | |
6134 | ||
272a527c KY |
6135 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
6136 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6137 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6138 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6139 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6140 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6141 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6142 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6143 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6144 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 6145 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
6146 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
6147 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
96fe7cc8 | 6148 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
272a527c KY |
6149 | { } /* end */ |
6150 | }; | |
6151 | ||
6152 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
6153 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
6154 | */ | |
6155 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
6156 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6157 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6158 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6159 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
6160 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6161 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6162 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6163 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6164 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
6165 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
6166 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6167 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 6168 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
6169 | { } /* end */ |
6170 | }; | |
6171 | ||
914759b7 TI |
6172 | static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { |
6173 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6174 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6175 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6176 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6177 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6178 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6179 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6180 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6181 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6182 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
914759b7 TI |
6183 | { } /* end */ |
6184 | }; | |
6185 | ||
df694daa KY |
6186 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
6187 | { | |
6188 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6189 | .name = "Channel Mode", | |
6190 | .info = alc_ch_mode_info, | |
6191 | .get = alc_ch_mode_get, | |
6192 | .put = alc_ch_mode_put, | |
6193 | }, | |
6194 | { } /* end */ | |
6195 | }; | |
6196 | ||
1da177e4 LT |
6197 | static struct hda_verb alc882_init_verbs[] = { |
6198 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
6199 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6200 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6201 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6202 | /* Rear mixer */ |
05acb863 TI |
6203 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6204 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6205 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6206 | /* CLFE mixer */ |
05acb863 TI |
6207 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6208 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6209 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6210 | /* Side mixer */ |
05acb863 TI |
6211 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6212 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6213 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6214 | |
e9edcee0 | 6215 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 6216 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6217 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6218 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 6219 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 6220 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6221 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6222 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 6223 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 6224 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6225 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6226 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 6227 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 6228 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6229 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6230 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 6231 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 6232 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
6233 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6234 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 6235 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
6236 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6237 | /* Line In pin: input */ | |
05acb863 | 6238 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
6239 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6240 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
6241 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6242 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6243 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 6244 | /* CD pin widget for input */ |
05acb863 | 6245 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
6246 | |
6247 | /* FIXME: use matrix-type input source selection */ | |
6248 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6249 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
6250 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6251 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6252 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6253 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 6254 | /* Input mixer2 */ |
05acb863 TI |
6255 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6256 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6257 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6258 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 6259 | /* Input mixer3 */ |
05acb863 TI |
6260 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6261 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6262 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6263 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6264 | /* ADC1: mute amp left and right */ | |
6265 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6266 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
6267 | /* ADC2: mute amp left and right */ |
6268 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6269 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
6270 | /* ADC3: mute amp left and right */ |
6271 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6272 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
6273 | |
6274 | { } | |
6275 | }; | |
6276 | ||
4b146cb0 TI |
6277 | static struct hda_verb alc882_eapd_verbs[] = { |
6278 | /* change to EAPD mode */ | |
6279 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 6280 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 6281 | { } |
4b146cb0 TI |
6282 | }; |
6283 | ||
9102cd1c TD |
6284 | /* Mac Pro test */ |
6285 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
6286 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6287 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6288 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
6289 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
6290 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
45bdd1c1 | 6291 | /* FIXME: this looks suspicious... |
9102cd1c TD |
6292 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), |
6293 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
45bdd1c1 | 6294 | */ |
9102cd1c TD |
6295 | { } /* end */ |
6296 | }; | |
6297 | ||
6298 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
6299 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
6300 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6301 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6302 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6303 | /* Front Pin: output 0 (0x0c) */ | |
6304 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6305 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6306 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6307 | /* Front Mic pin: input vref at 80% */ | |
6308 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6309 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6310 | /* Speaker: output */ | |
6311 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6312 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6313 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
6314 | /* Headphone output (output 0 - 0x0c) */ | |
6315 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6316 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6317 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6318 | ||
6319 | /* FIXME: use matrix-type input source selection */ | |
6320 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6321 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6322 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6323 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6324 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6325 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6326 | /* Input mixer2 */ | |
6327 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6328 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6329 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6330 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6331 | /* Input mixer3 */ | |
6332 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6333 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6334 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6335 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6336 | /* ADC1: mute amp left and right */ | |
6337 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6338 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6339 | /* ADC2: mute amp left and right */ | |
6340 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6341 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6342 | /* ADC3: mute amp left and right */ | |
6343 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6344 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6345 | ||
6346 | { } | |
6347 | }; | |
f12ab1e0 | 6348 | |
87350ad0 TI |
6349 | /* Macbook Pro rev3 */ |
6350 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
6351 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
6352 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6353 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6354 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6355 | /* Rear mixer */ | |
6356 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6357 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6358 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6359 | /* Front Pin: output 0 (0x0c) */ | |
6360 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6361 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6362 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6363 | /* HP Pin: output 0 (0x0d) */ | |
6364 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
6365 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6366 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6367 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6368 | /* Mic (rear) pin: input vref at 80% */ | |
6369 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6370 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6371 | /* Front Mic pin: input vref at 80% */ | |
6372 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6373 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6374 | /* Line In pin: use output 1 when in LineOut mode */ | |
6375 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6376 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6377 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
6378 | ||
6379 | /* FIXME: use matrix-type input source selection */ | |
6380 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6381 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6382 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6383 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6384 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6385 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6386 | /* Input mixer2 */ | |
6387 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6388 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6389 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6390 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6391 | /* Input mixer3 */ | |
6392 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6393 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6394 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6395 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6396 | /* ADC1: mute amp left and right */ | |
6397 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6398 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6399 | /* ADC2: mute amp left and right */ | |
6400 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6401 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6402 | /* ADC3: mute amp left and right */ | |
6403 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6404 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6405 | ||
6406 | { } | |
6407 | }; | |
6408 | ||
c54728d8 NF |
6409 | /* iMac 24 mixer. */ |
6410 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
6411 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
6412 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
6413 | { } /* end */ | |
6414 | }; | |
6415 | ||
6416 | /* iMac 24 init verbs. */ | |
6417 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
6418 | /* Internal speakers: output 0 (0x0c) */ | |
6419 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6420 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6421 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6422 | /* Internal speakers: output 0 (0x0c) */ | |
6423 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6424 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6425 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6426 | /* Headphone: output 0 (0x0c) */ | |
6427 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6428 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6429 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6430 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6431 | /* Front Mic: input vref at 80% */ | |
6432 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6433 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6434 | { } | |
6435 | }; | |
6436 | ||
6437 | /* Toggle speaker-output according to the hp-jack state */ | |
6438 | static void alc885_imac24_automute(struct hda_codec *codec) | |
6439 | { | |
6440 | unsigned int present; | |
6441 | ||
6442 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6443 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6444 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
6445 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6446 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
6447 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
6448 | } |
6449 | ||
6450 | /* Processes unsolicited events. */ | |
6451 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
6452 | unsigned int res) | |
6453 | { | |
6454 | /* Headphone insertion or removal. */ | |
6455 | if ((res >> 26) == ALC880_HP_EVENT) | |
6456 | alc885_imac24_automute(codec); | |
6457 | } | |
6458 | ||
87350ad0 TI |
6459 | static void alc885_mbp3_automute(struct hda_codec *codec) |
6460 | { | |
6461 | unsigned int present; | |
6462 | ||
6463 | present = snd_hda_codec_read(codec, 0x15, 0, | |
6464 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6465 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6466 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6467 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6468 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
6469 | ||
6470 | } | |
6471 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
6472 | unsigned int res) | |
6473 | { | |
6474 | /* Headphone insertion or removal. */ | |
6475 | if ((res >> 26) == ALC880_HP_EVENT) | |
6476 | alc885_mbp3_automute(codec); | |
6477 | } | |
6478 | ||
6479 | ||
272a527c KY |
6480 | static struct hda_verb alc882_targa_verbs[] = { |
6481 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6482 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6483 | ||
6484 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6485 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6486 | |
272a527c KY |
6487 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
6488 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6489 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6490 | ||
6491 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6492 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
6493 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
6494 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
6495 | { } /* end */ | |
6496 | }; | |
6497 | ||
6498 | /* toggle speaker-output according to the hp-jack state */ | |
6499 | static void alc882_targa_automute(struct hda_codec *codec) | |
6500 | { | |
6501 | unsigned int present; | |
ea1fb29a | 6502 | |
272a527c KY |
6503 | present = snd_hda_codec_read(codec, 0x14, 0, |
6504 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6505 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
6506 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
6507 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6508 | present ? 1 : 3); | |
272a527c KY |
6509 | } |
6510 | ||
6511 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
6512 | { | |
6513 | /* Looks like the unsol event is incompatible with the standard | |
6514 | * definition. 4bit tag is placed at 26 bit! | |
6515 | */ | |
6516 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
6517 | alc882_targa_automute(codec); | |
6518 | } | |
6519 | } | |
6520 | ||
6521 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
6522 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6523 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6524 | ||
6525 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6526 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6527 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6528 | |
272a527c KY |
6529 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6530 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6531 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6532 | ||
6533 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6534 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6535 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6536 | { } /* end */ | |
6537 | }; | |
6538 | ||
914759b7 TI |
6539 | static struct hda_verb alc882_asus_a7m_verbs[] = { |
6540 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6541 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6542 | ||
6543 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6544 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6545 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6546 | |
914759b7 TI |
6547 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6548 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6549 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6550 | ||
6551 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6552 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6553 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6554 | { } /* end */ | |
6555 | }; | |
6556 | ||
9102cd1c TD |
6557 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
6558 | { | |
6559 | unsigned int gpiostate, gpiomask, gpiodir; | |
6560 | ||
6561 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
6562 | AC_VERB_GET_GPIO_DATA, 0); | |
6563 | ||
6564 | if (!muted) | |
6565 | gpiostate |= (1 << pin); | |
6566 | else | |
6567 | gpiostate &= ~(1 << pin); | |
6568 | ||
6569 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
6570 | AC_VERB_GET_GPIO_MASK, 0); | |
6571 | gpiomask |= (1 << pin); | |
6572 | ||
6573 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
6574 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
6575 | gpiodir |= (1 << pin); | |
6576 | ||
6577 | ||
6578 | snd_hda_codec_write(codec, codec->afg, 0, | |
6579 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
6580 | snd_hda_codec_write(codec, codec->afg, 0, | |
6581 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
6582 | ||
6583 | msleep(1); | |
6584 | ||
6585 | snd_hda_codec_write(codec, codec->afg, 0, | |
6586 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
6587 | } | |
6588 | ||
7debbe51 TI |
6589 | /* set up GPIO at initialization */ |
6590 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
6591 | { | |
6592 | alc882_gpio_mute(codec, 0, 0); | |
6593 | alc882_gpio_mute(codec, 1, 0); | |
6594 | } | |
6595 | ||
6596 | /* set up GPIO and update auto-muting at initialization */ | |
6597 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
6598 | { | |
6599 | alc885_macpro_init_hook(codec); | |
6600 | alc885_imac24_automute(codec); | |
6601 | } | |
6602 | ||
df694daa KY |
6603 | /* |
6604 | * generic initialization of ADC, input mixers and output mixers | |
6605 | */ | |
6606 | static struct hda_verb alc882_auto_init_verbs[] = { | |
6607 | /* | |
6608 | * Unmute ADC0-2 and set the default input to mic-in | |
6609 | */ | |
6610 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6611 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6612 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6613 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6614 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6615 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 6616 | |
cb53c626 | 6617 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 6618 | * mixer widget |
f12ab1e0 TI |
6619 | * Note: PASD motherboards uses the Line In 2 as the input for |
6620 | * front panel mic (mic 2) | |
df694daa KY |
6621 | */ |
6622 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
6623 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6624 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6625 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6626 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6627 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 6628 | |
df694daa KY |
6629 | /* |
6630 | * Set up output mixers (0x0c - 0x0f) | |
6631 | */ | |
6632 | /* set vol=0 to output mixers */ | |
6633 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6634 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6635 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6636 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6637 | /* set up input amps for analog loopback */ | |
6638 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6639 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6640 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6641 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6642 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6643 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6644 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6645 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6646 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6647 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6648 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6649 | ||
6650 | /* FIXME: use matrix-type input source selection */ | |
6651 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6652 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6653 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6654 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6655 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6656 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6657 | /* Input mixer2 */ | |
6658 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6659 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6660 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6661 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6662 | /* Input mixer3 */ | |
6663 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6664 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6665 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6666 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6667 | ||
6668 | { } | |
6669 | }; | |
6670 | ||
cb53c626 TI |
6671 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6672 | #define alc882_loopbacks alc880_loopbacks | |
6673 | #endif | |
6674 | ||
df694daa KY |
6675 | /* pcm configuration: identiacal with ALC880 */ |
6676 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
6677 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
6678 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
6679 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
6680 | ||
6681 | /* | |
6682 | * configuration and preset | |
6683 | */ | |
f5fcc13c TI |
6684 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
6685 | [ALC882_3ST_DIG] = "3stack-dig", | |
6686 | [ALC882_6ST_DIG] = "6stack-dig", | |
6687 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 6688 | [ALC882_W2JC] = "w2jc", |
0438a00e TI |
6689 | [ALC882_TARGA] = "targa", |
6690 | [ALC882_ASUS_A7J] = "asus-a7j", | |
6691 | [ALC882_ASUS_A7M] = "asus-a7m", | |
9102cd1c | 6692 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 6693 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 6694 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
6695 | [ALC882_AUTO] = "auto", |
6696 | }; | |
6697 | ||
6698 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
6699 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
272a527c | 6700 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
ac8842a0 | 6701 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), |
914759b7 | 6702 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), |
ac3e3741 | 6703 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
c5d9f1cd | 6704 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 6705 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
ac3e3741 | 6706 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
4444704c | 6707 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
ac3e3741 TI |
6708 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
6709 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
6710 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | |
df694daa KY |
6711 | {} |
6712 | }; | |
6713 | ||
6714 | static struct alc_config_preset alc882_presets[] = { | |
6715 | [ALC882_3ST_DIG] = { | |
6716 | .mixers = { alc882_base_mixer }, | |
6717 | .init_verbs = { alc882_init_verbs }, | |
6718 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6719 | .dac_nids = alc882_dac_nids, | |
6720 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6721 | .dig_in_nid = ALC882_DIGIN_NID, |
6722 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6723 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 6724 | .need_dac_fix = 1, |
df694daa KY |
6725 | .input_mux = &alc882_capture_source, |
6726 | }, | |
6727 | [ALC882_6ST_DIG] = { | |
6728 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6729 | .init_verbs = { alc882_init_verbs }, | |
6730 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6731 | .dac_nids = alc882_dac_nids, | |
6732 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6733 | .dig_in_nid = ALC882_DIGIN_NID, |
6734 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6735 | .channel_mode = alc882_sixstack_modes, | |
6736 | .input_mux = &alc882_capture_source, | |
6737 | }, | |
4b146cb0 TI |
6738 | [ALC882_ARIMA] = { |
6739 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6740 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
6741 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6742 | .dac_nids = alc882_dac_nids, | |
6743 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6744 | .channel_mode = alc882_sixstack_modes, | |
6745 | .input_mux = &alc882_capture_source, | |
6746 | }, | |
bdd148a3 KY |
6747 | [ALC882_W2JC] = { |
6748 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
6749 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6750 | alc880_gpio1_init_verbs }, | |
6751 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6752 | .dac_nids = alc882_dac_nids, | |
6753 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6754 | .channel_mode = alc880_threestack_modes, | |
6755 | .need_dac_fix = 1, | |
6756 | .input_mux = &alc882_capture_source, | |
6757 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6758 | }, | |
87350ad0 TI |
6759 | [ALC885_MBP3] = { |
6760 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
6761 | .init_verbs = { alc885_mbp3_init_verbs, | |
6762 | alc880_gpio1_init_verbs }, | |
6763 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6764 | .dac_nids = alc882_dac_nids, | |
6765 | .channel_mode = alc885_mbp_6ch_modes, | |
6766 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
6767 | .input_mux = &alc882_capture_source, | |
6768 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6769 | .dig_in_nid = ALC882_DIGIN_NID, | |
6770 | .unsol_event = alc885_mbp3_unsol_event, | |
6771 | .init_hook = alc885_mbp3_automute, | |
6772 | }, | |
9102cd1c TD |
6773 | [ALC885_MACPRO] = { |
6774 | .mixers = { alc882_macpro_mixer }, | |
6775 | .init_verbs = { alc882_macpro_init_verbs }, | |
6776 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6777 | .dac_nids = alc882_dac_nids, | |
6778 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6779 | .dig_in_nid = ALC882_DIGIN_NID, | |
6780 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6781 | .channel_mode = alc882_ch_modes, | |
6782 | .input_mux = &alc882_capture_source, | |
7debbe51 | 6783 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 6784 | }, |
c54728d8 NF |
6785 | [ALC885_IMAC24] = { |
6786 | .mixers = { alc885_imac24_mixer }, | |
6787 | .init_verbs = { alc885_imac24_init_verbs }, | |
6788 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6789 | .dac_nids = alc882_dac_nids, | |
6790 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6791 | .dig_in_nid = ALC882_DIGIN_NID, | |
6792 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6793 | .channel_mode = alc882_ch_modes, | |
6794 | .input_mux = &alc882_capture_source, | |
6795 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 6796 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 6797 | }, |
272a527c | 6798 | [ALC882_TARGA] = { |
f9e336f6 | 6799 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, |
272a527c KY |
6800 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, |
6801 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6802 | .dac_nids = alc882_dac_nids, | |
6803 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6804 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6805 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6806 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6807 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6808 | .channel_mode = alc882_3ST_6ch_modes, | |
6809 | .need_dac_fix = 1, | |
6810 | .input_mux = &alc882_capture_source, | |
6811 | .unsol_event = alc882_targa_unsol_event, | |
6812 | .init_hook = alc882_targa_automute, | |
6813 | }, | |
6814 | [ALC882_ASUS_A7J] = { | |
f9e336f6 | 6815 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, |
272a527c KY |
6816 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, |
6817 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6818 | .dac_nids = alc882_dac_nids, | |
6819 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6820 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6821 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6822 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6823 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6824 | .channel_mode = alc882_3ST_6ch_modes, | |
6825 | .need_dac_fix = 1, | |
6826 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6827 | }, |
914759b7 TI |
6828 | [ALC882_ASUS_A7M] = { |
6829 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | |
6830 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6831 | alc880_gpio1_init_verbs, | |
6832 | alc882_asus_a7m_verbs }, | |
6833 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6834 | .dac_nids = alc882_dac_nids, | |
6835 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6836 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6837 | .channel_mode = alc880_threestack_modes, | |
6838 | .need_dac_fix = 1, | |
6839 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6840 | }, |
df694daa KY |
6841 | }; |
6842 | ||
6843 | ||
f95474ec TI |
6844 | /* |
6845 | * Pin config fixes | |
6846 | */ | |
ea1fb29a | 6847 | enum { |
f95474ec TI |
6848 | PINFIX_ABIT_AW9D_MAX |
6849 | }; | |
6850 | ||
6851 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
6852 | { 0x15, 0x01080104 }, /* side */ | |
6853 | { 0x16, 0x01011012 }, /* rear */ | |
6854 | { 0x17, 0x01016011 }, /* clfe */ | |
6855 | { } | |
6856 | }; | |
6857 | ||
6858 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
6859 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
6860 | }; | |
6861 | ||
6862 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
6863 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
6864 | {} | |
6865 | }; | |
6866 | ||
df694daa KY |
6867 | /* |
6868 | * BIOS auto configuration | |
6869 | */ | |
6870 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
6871 | hda_nid_t nid, int pin_type, | |
6872 | int dac_idx) | |
6873 | { | |
6874 | /* set as output */ | |
6875 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6876 | int idx; |
6877 | ||
f6c7e546 | 6878 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
6879 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6880 | idx = 4; | |
6881 | else | |
6882 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
df694daa KY |
6883 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
6884 | ||
6885 | } | |
6886 | ||
6887 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
6888 | { | |
6889 | struct alc_spec *spec = codec->spec; | |
6890 | int i; | |
6891 | ||
bc9f98a9 | 6892 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 6893 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6894 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6895 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 6896 | if (nid) |
baba8ee9 | 6897 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6898 | i); |
df694daa KY |
6899 | } |
6900 | } | |
6901 | ||
6902 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
6903 | { | |
6904 | struct alc_spec *spec = codec->spec; | |
6905 | hda_nid_t pin; | |
6906 | ||
eb06ed8f | 6907 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 6908 | if (pin) /* connect to front */ |
f12ab1e0 TI |
6909 | /* use dac 0 */ |
6910 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
6911 | pin = spec->autocfg.speaker_pins[0]; |
6912 | if (pin) | |
6913 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
6914 | } |
6915 | ||
6916 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
6917 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
6918 | ||
6919 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
6920 | { | |
6921 | struct alc_spec *spec = codec->spec; | |
6922 | int i; | |
6923 | ||
6924 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6925 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7194cae6 TI |
6926 | unsigned int vref; |
6927 | if (!nid) | |
6928 | continue; | |
6929 | vref = PIN_IN; | |
6930 | if (1 /*i <= AUTO_PIN_FRONT_MIC*/) { | |
531240ff KY |
6931 | unsigned int pincap; |
6932 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | |
6933 | if ((pincap >> AC_PINCAP_VREF_SHIFT) & | |
7194cae6 TI |
6934 | AC_PINCAP_VREF_80) |
6935 | vref = PIN_VREF80; | |
df694daa | 6936 | } |
7194cae6 TI |
6937 | snd_hda_codec_write(codec, nid, 0, |
6938 | AC_VERB_SET_PIN_WIDGET_CONTROL, vref); | |
6939 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | |
6940 | snd_hda_codec_write(codec, nid, 0, | |
6941 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6942 | AMP_OUT_MUTE); | |
df694daa KY |
6943 | } |
6944 | } | |
6945 | ||
f511b01c TI |
6946 | static void alc882_auto_init_input_src(struct hda_codec *codec) |
6947 | { | |
6948 | struct alc_spec *spec = codec->spec; | |
f511b01c TI |
6949 | int c; |
6950 | ||
6951 | for (c = 0; c < spec->num_adc_nids; c++) { | |
6952 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | |
6953 | hda_nid_t nid = spec->capsrc_nids[c]; | |
b98b7b34 HRK |
6954 | unsigned int mux_idx; |
6955 | const struct hda_input_mux *imux; | |
f511b01c TI |
6956 | int conns, mute, idx, item; |
6957 | ||
6958 | conns = snd_hda_get_connections(codec, nid, conn_list, | |
6959 | ARRAY_SIZE(conn_list)); | |
6960 | if (conns < 0) | |
6961 | continue; | |
b98b7b34 HRK |
6962 | mux_idx = c >= spec->num_mux_defs ? 0 : c; |
6963 | imux = &spec->input_mux[mux_idx]; | |
f511b01c TI |
6964 | for (idx = 0; idx < conns; idx++) { |
6965 | /* if the current connection is the selected one, | |
6966 | * unmute it as default - otherwise mute it | |
6967 | */ | |
6968 | mute = AMP_IN_MUTE(idx); | |
6969 | for (item = 0; item < imux->num_items; item++) { | |
6970 | if (imux->items[item].index == idx) { | |
6971 | if (spec->cur_mux[c] == item) | |
6972 | mute = AMP_IN_UNMUTE(idx); | |
6973 | break; | |
6974 | } | |
6975 | } | |
b98b7b34 HRK |
6976 | /* check if we have a selector or mixer |
6977 | * we could check for the widget type instead, but | |
6978 | * just check for Amp-In presence (in case of mixer | |
6979 | * without amp-in there is something wrong, this | |
6980 | * function shouldn't be used or capsrc nid is wrong) | |
6981 | */ | |
6982 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) | |
6983 | snd_hda_codec_write(codec, nid, 0, | |
6984 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6985 | mute); | |
6986 | else if (mute != AMP_IN_MUTE(idx)) | |
6987 | snd_hda_codec_write(codec, nid, 0, | |
6988 | AC_VERB_SET_CONNECT_SEL, | |
6989 | idx); | |
f511b01c TI |
6990 | } |
6991 | } | |
6992 | } | |
6993 | ||
776e184e TI |
6994 | /* add mic boosts if needed */ |
6995 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | |
6996 | { | |
6997 | struct alc_spec *spec = codec->spec; | |
6998 | int err; | |
6999 | hda_nid_t nid; | |
7000 | ||
7001 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
ce22e03e | 7002 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
7003 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
7004 | "Mic Boost", | |
7005 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
7006 | if (err < 0) | |
7007 | return err; | |
7008 | } | |
7009 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
ce22e03e | 7010 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
7011 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
7012 | "Front Mic Boost", | |
7013 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
7014 | if (err < 0) | |
7015 | return err; | |
7016 | } | |
7017 | return 0; | |
7018 | } | |
7019 | ||
df694daa KY |
7020 | /* almost identical with ALC880 parser... */ |
7021 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
7022 | { | |
7023 | struct alc_spec *spec = codec->spec; | |
7024 | int err = alc880_parse_auto_config(codec); | |
7025 | ||
7026 | if (err < 0) | |
7027 | return err; | |
776e184e TI |
7028 | else if (!err) |
7029 | return 0; /* no config found */ | |
7030 | ||
7031 | err = alc_auto_add_mic_boost(codec); | |
7032 | if (err < 0) | |
7033 | return err; | |
7034 | ||
7035 | /* hack - override the init verbs */ | |
7036 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
7037 | ||
7038 | return 1; /* config found */ | |
df694daa KY |
7039 | } |
7040 | ||
ae6b813a TI |
7041 | /* additional initialization for auto-configuration model */ |
7042 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 7043 | { |
f6c7e546 | 7044 | struct alc_spec *spec = codec->spec; |
df694daa KY |
7045 | alc882_auto_init_multi_out(codec); |
7046 | alc882_auto_init_hp_out(codec); | |
7047 | alc882_auto_init_analog_input(codec); | |
f511b01c | 7048 | alc882_auto_init_input_src(codec); |
f6c7e546 | 7049 | if (spec->unsol_event) |
7fb0d78f | 7050 | alc_inithook(codec); |
df694daa KY |
7051 | } |
7052 | ||
7943a8ab TI |
7053 | static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ |
7054 | ||
df694daa KY |
7055 | static int patch_alc882(struct hda_codec *codec) |
7056 | { | |
7057 | struct alc_spec *spec; | |
7058 | int err, board_config; | |
7059 | ||
7060 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
7061 | if (spec == NULL) | |
7062 | return -ENOMEM; | |
7063 | ||
7064 | codec->spec = spec; | |
7065 | ||
f5fcc13c TI |
7066 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
7067 | alc882_models, | |
7068 | alc882_cfg_tbl); | |
df694daa KY |
7069 | |
7070 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
7071 | /* Pick up systems that don't supply PCI SSID */ |
7072 | switch (codec->subsystem_id) { | |
7073 | case 0x106b0c00: /* Mac Pro */ | |
7074 | board_config = ALC885_MACPRO; | |
7075 | break; | |
c54728d8 | 7076 | case 0x106b1000: /* iMac 24 */ |
f3911c5a | 7077 | case 0x106b2800: /* AppleTV */ |
3077e44c | 7078 | case 0x106b3e00: /* iMac 24 Aluminium */ |
c54728d8 NF |
7079 | board_config = ALC885_IMAC24; |
7080 | break; | |
c7e0757a | 7081 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ |
9c95c43d | 7082 | case 0x106b00a4: /* MacbookPro4,1 */ |
87350ad0 | 7083 | case 0x106b2c00: /* Macbook Pro rev3 */ |
c7e0757a | 7084 | case 0x106b3600: /* Macbook 3.1 */ |
2a88464c | 7085 | case 0x106b3800: /* MacbookPro4,1 - latter revision */ |
87350ad0 TI |
7086 | board_config = ALC885_MBP3; |
7087 | break; | |
081d17c4 | 7088 | default: |
7943a8ab | 7089 | /* ALC889A is handled better as ALC888-compatible */ |
669faba2 CM |
7090 | if (codec->revision_id == 0x100101 || |
7091 | codec->revision_id == 0x100103) { | |
7943a8ab TI |
7092 | alc_free(codec); |
7093 | return patch_alc883(codec); | |
7094 | } | |
081d17c4 TD |
7095 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " |
7096 | "trying auto-probe from BIOS...\n"); | |
7097 | board_config = ALC882_AUTO; | |
7098 | } | |
df694daa KY |
7099 | } |
7100 | ||
f95474ec TI |
7101 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
7102 | ||
df694daa KY |
7103 | if (board_config == ALC882_AUTO) { |
7104 | /* automatic parse from the BIOS config */ | |
7105 | err = alc882_parse_auto_config(codec); | |
7106 | if (err < 0) { | |
7107 | alc_free(codec); | |
7108 | return err; | |
f12ab1e0 | 7109 | } else if (!err) { |
9c7f852e TI |
7110 | printk(KERN_INFO |
7111 | "hda_codec: Cannot set up configuration " | |
7112 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
7113 | board_config = ALC882_3ST_DIG; |
7114 | } | |
7115 | } | |
7116 | ||
680cd536 KK |
7117 | err = snd_hda_attach_beep_device(codec, 0x1); |
7118 | if (err < 0) { | |
7119 | alc_free(codec); | |
7120 | return err; | |
7121 | } | |
7122 | ||
df694daa KY |
7123 | if (board_config != ALC882_AUTO) |
7124 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 | 7125 | |
2f893286 KY |
7126 | if (codec->vendor_id == 0x10ec0885) { |
7127 | spec->stream_name_analog = "ALC885 Analog"; | |
7128 | spec->stream_name_digital = "ALC885 Digital"; | |
7129 | } else { | |
7130 | spec->stream_name_analog = "ALC882 Analog"; | |
7131 | spec->stream_name_digital = "ALC882 Digital"; | |
7132 | } | |
7133 | ||
df694daa KY |
7134 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
7135 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
6330079f TI |
7136 | /* FIXME: setup DAC5 */ |
7137 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | |
7138 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | |
1da177e4 | 7139 | |
df694daa KY |
7140 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
7141 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 7142 | |
61b9b9b1 | 7143 | spec->capture_style = CAPT_MIX; /* matrix-style capture */ |
f12ab1e0 | 7144 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 7145 | /* check whether NID 0x07 is valid */ |
4a471b7d | 7146 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
7147 | /* get type */ |
7148 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
7149 | if (wcap != AC_WID_AUD_IN) { |
7150 | spec->adc_nids = alc882_adc_nids_alt; | |
7151 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
e1406348 | 7152 | spec->capsrc_nids = alc882_capsrc_nids_alt; |
df694daa KY |
7153 | } else { |
7154 | spec->adc_nids = alc882_adc_nids; | |
7155 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
e1406348 | 7156 | spec->capsrc_nids = alc882_capsrc_nids; |
df694daa KY |
7157 | } |
7158 | } | |
f9e336f6 | 7159 | set_capture_mixer(spec); |
45bdd1c1 | 7160 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
1da177e4 | 7161 | |
2134ea4f TI |
7162 | spec->vmaster_nid = 0x0c; |
7163 | ||
1da177e4 | 7164 | codec->patch_ops = alc_patch_ops; |
df694daa | 7165 | if (board_config == ALC882_AUTO) |
ae6b813a | 7166 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
7167 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
7168 | if (!spec->loopback.amplist) | |
7169 | spec->loopback.amplist = alc882_loopbacks; | |
7170 | #endif | |
daead538 | 7171 | codec->proc_widget_hook = print_realtek_coef; |
df694daa KY |
7172 | |
7173 | return 0; | |
7174 | } | |
7175 | ||
7176 | /* | |
9c7f852e TI |
7177 | * ALC883 support |
7178 | * | |
7179 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
7180 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
7181 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
7182 | * 6-channel independent captures. | |
7183 | * | |
7184 | * In addition, an independent DAC for the multi-playback (not used in this | |
7185 | * driver yet). | |
df694daa | 7186 | */ |
9c7f852e TI |
7187 | #define ALC883_DIGOUT_NID 0x06 |
7188 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 7189 | |
3ab90935 WF |
7190 | #define ALC1200_DIGOUT_NID 0x10 |
7191 | ||
9c7f852e TI |
7192 | static hda_nid_t alc883_dac_nids[4] = { |
7193 | /* front, rear, clfe, rear_surr */ | |
f32a19e3 | 7194 | 0x02, 0x03, 0x04, 0x05 |
9c7f852e | 7195 | }; |
df694daa | 7196 | |
9c7f852e TI |
7197 | static hda_nid_t alc883_adc_nids[2] = { |
7198 | /* ADC1-2 */ | |
7199 | 0x08, 0x09, | |
7200 | }; | |
f12ab1e0 | 7201 | |
f9e336f6 TI |
7202 | static hda_nid_t alc883_adc_nids_alt[1] = { |
7203 | /* ADC1 */ | |
7204 | 0x08, | |
7205 | }; | |
7206 | ||
5b2d1eca VP |
7207 | static hda_nid_t alc883_adc_nids_rev[2] = { |
7208 | /* ADC2-1 */ | |
7209 | 0x09, 0x08 | |
7210 | }; | |
7211 | ||
61b9b9b1 HRK |
7212 | #define alc889_adc_nids alc880_adc_nids |
7213 | ||
e1406348 TI |
7214 | static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; |
7215 | ||
5b2d1eca VP |
7216 | static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; |
7217 | ||
61b9b9b1 HRK |
7218 | #define alc889_capsrc_nids alc882_capsrc_nids |
7219 | ||
9c7f852e TI |
7220 | /* input MUX */ |
7221 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 7222 | |
9c7f852e TI |
7223 | static struct hda_input_mux alc883_capture_source = { |
7224 | .num_items = 4, | |
7225 | .items = { | |
7226 | { "Mic", 0x0 }, | |
7227 | { "Front Mic", 0x1 }, | |
7228 | { "Line", 0x2 }, | |
7229 | { "CD", 0x4 }, | |
7230 | }, | |
7231 | }; | |
bc9f98a9 | 7232 | |
17bba1b7 J |
7233 | static struct hda_input_mux alc883_3stack_6ch_intel = { |
7234 | .num_items = 4, | |
7235 | .items = { | |
7236 | { "Mic", 0x1 }, | |
7237 | { "Front Mic", 0x0 }, | |
7238 | { "Line", 0x2 }, | |
7239 | { "CD", 0x4 }, | |
7240 | }, | |
7241 | }; | |
7242 | ||
bc9f98a9 KY |
7243 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { |
7244 | .num_items = 2, | |
7245 | .items = { | |
7246 | { "Mic", 0x1 }, | |
7247 | { "Line", 0x2 }, | |
7248 | }, | |
7249 | }; | |
7250 | ||
272a527c KY |
7251 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
7252 | .num_items = 4, | |
7253 | .items = { | |
7254 | { "Mic", 0x0 }, | |
7255 | { "iMic", 0x1 }, | |
7256 | { "Line", 0x2 }, | |
7257 | { "CD", 0x4 }, | |
7258 | }, | |
7259 | }; | |
7260 | ||
fb97dc67 J |
7261 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { |
7262 | .num_items = 2, | |
7263 | .items = { | |
7264 | { "Mic", 0x0 }, | |
7265 | { "Int Mic", 0x1 }, | |
7266 | }, | |
7267 | }; | |
7268 | ||
e2757d5e KY |
7269 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { |
7270 | .num_items = 3, | |
7271 | .items = { | |
7272 | { "Mic", 0x0 }, | |
7273 | { "Front Mic", 0x1 }, | |
7274 | { "Line", 0x4 }, | |
7275 | }, | |
7276 | }; | |
7277 | ||
7278 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | |
7279 | .num_items = 2, | |
7280 | .items = { | |
7281 | { "Mic", 0x0 }, | |
7282 | { "Line", 0x2 }, | |
7283 | }, | |
7284 | }; | |
7285 | ||
9c7f852e TI |
7286 | /* |
7287 | * 2ch mode | |
7288 | */ | |
7289 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
7290 | { 2, NULL } | |
7291 | }; | |
7292 | ||
7293 | /* | |
7294 | * 2ch mode | |
7295 | */ | |
7296 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
7297 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7298 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7299 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7300 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7301 | { } /* end */ | |
7302 | }; | |
7303 | ||
b201131c TD |
7304 | /* |
7305 | * 4ch mode | |
7306 | */ | |
7307 | static struct hda_verb alc883_3ST_ch4_init[] = { | |
7308 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7309 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7310 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7311 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7312 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7313 | { } /* end */ | |
7314 | }; | |
7315 | ||
9c7f852e TI |
7316 | /* |
7317 | * 6ch mode | |
7318 | */ | |
7319 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
7320 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7321 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7322 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
7323 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7324 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7325 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7326 | { } /* end */ | |
7327 | }; | |
7328 | ||
b201131c | 7329 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { |
9c7f852e | 7330 | { 2, alc883_3ST_ch2_init }, |
b201131c | 7331 | { 4, alc883_3ST_ch4_init }, |
9c7f852e TI |
7332 | { 6, alc883_3ST_ch6_init }, |
7333 | }; | |
7334 | ||
17bba1b7 J |
7335 | /* |
7336 | * 2ch mode | |
7337 | */ | |
7338 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | |
7339 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7340 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7341 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7342 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7343 | { } /* end */ | |
7344 | }; | |
7345 | ||
7346 | /* | |
7347 | * 4ch mode | |
7348 | */ | |
7349 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | |
7350 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7351 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7352 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7353 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7354 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7355 | { } /* end */ | |
7356 | }; | |
7357 | ||
7358 | /* | |
7359 | * 6ch mode | |
7360 | */ | |
7361 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | |
7362 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7363 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7364 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
7365 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7366 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7367 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7368 | { } /* end */ | |
7369 | }; | |
7370 | ||
7371 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | |
7372 | { 2, alc883_3ST_ch2_intel_init }, | |
7373 | { 4, alc883_3ST_ch4_intel_init }, | |
7374 | { 6, alc883_3ST_ch6_intel_init }, | |
7375 | }; | |
7376 | ||
9c7f852e TI |
7377 | /* |
7378 | * 6ch mode | |
7379 | */ | |
7380 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
7381 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7382 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7383 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7384 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7385 | { } /* end */ | |
7386 | }; | |
7387 | ||
7388 | /* | |
7389 | * 8ch mode | |
7390 | */ | |
7391 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
7392 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7393 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7394 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7395 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7396 | { } /* end */ | |
7397 | }; | |
7398 | ||
7399 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
7400 | { 6, alc883_sixstack_ch6_init }, | |
7401 | { 8, alc883_sixstack_ch8_init }, | |
7402 | }; | |
7403 | ||
b373bdeb AN |
7404 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
7405 | /* eanable EAPD on medion laptop */ | |
7406 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7407 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
7408 | { } | |
7409 | }; | |
7410 | ||
9c7f852e TI |
7411 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
7412 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
7413 | */ | |
7414 | ||
7415 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 7416 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
7417 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
7418 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7419 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7420 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7421 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7422 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7423 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7424 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7425 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7426 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
7427 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
7428 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7429 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7430 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7431 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7432 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 7433 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 7434 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 7435 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e | 7436 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
df694daa | 7437 | { } /* end */ |
834be88d TI |
7438 | }; |
7439 | ||
a8848bd6 AS |
7440 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
7441 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7442 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7443 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7444 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7445 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7446 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7447 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7448 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7449 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7450 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7451 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7452 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7453 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
a8848bd6 AS |
7454 | { } /* end */ |
7455 | }; | |
7456 | ||
0c4cc443 | 7457 | static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = { |
368c7a95 J |
7458 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7459 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7460 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7461 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7462 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7463 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7464 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7465 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7466 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7467 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
368c7a95 J |
7468 | { } /* end */ |
7469 | }; | |
7470 | ||
fb97dc67 J |
7471 | static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = { |
7472 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7473 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7474 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7475 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7476 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7477 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7478 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7479 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7480 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7481 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
fb97dc67 J |
7482 | { } /* end */ |
7483 | }; | |
7484 | ||
9c7f852e TI |
7485 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
7486 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7487 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7488 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7489 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7490 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7491 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7492 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7493 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7494 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7495 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7496 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7497 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e | 7498 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
9c7f852e TI |
7499 | { } /* end */ |
7500 | }; | |
df694daa | 7501 | |
9c7f852e TI |
7502 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
7503 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7504 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7505 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7506 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7507 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7508 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7509 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7510 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7511 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7512 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7513 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7514 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7515 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7516 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7517 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7518 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7519 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7520 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e | 7521 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
9c7f852e TI |
7522 | { } /* end */ |
7523 | }; | |
7524 | ||
17bba1b7 J |
7525 | static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { |
7526 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7527 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7528 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7529 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7530 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
7531 | HDA_OUTPUT), | |
7532 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7533 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7534 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7535 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7536 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7537 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7538 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7539 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7540 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7541 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
7542 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7543 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7544 | HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), | |
7545 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
17bba1b7 J |
7546 | { } /* end */ |
7547 | }; | |
7548 | ||
d1d985f0 | 7549 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 | 7550 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
0701e064 | 7551 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
c07584c8 | 7552 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
0701e064 | 7553 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
c07584c8 TD |
7554 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
7555 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
0701e064 TI |
7556 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
7557 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
c07584c8 TD |
7558 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7559 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7560 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7561 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7562 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7563 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7564 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
7565 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7566 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7567 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 | 7568 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
c07584c8 TD |
7569 | { } /* end */ |
7570 | }; | |
7571 | ||
ccc656ce KY |
7572 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
7573 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7574 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7575 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7576 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7577 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7578 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7579 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7580 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7581 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7582 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7583 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7584 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7585 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7586 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7587 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7588 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
ccc656ce | 7589 | { } /* end */ |
f12ab1e0 | 7590 | }; |
ccc656ce KY |
7591 | |
7592 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
7593 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7594 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7595 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7596 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7597 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7598 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7599 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7600 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4383fae0 J |
7601 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
7602 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7603 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ccc656ce | 7604 | { } /* end */ |
f12ab1e0 | 7605 | }; |
ccc656ce | 7606 | |
bc9f98a9 KY |
7607 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
7608 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7609 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
86cd9298 TI |
7610 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
7611 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
bc9f98a9 KY |
7612 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7613 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7614 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7615 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 | 7616 | { } /* end */ |
f12ab1e0 | 7617 | }; |
bc9f98a9 | 7618 | |
272a527c KY |
7619 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
7620 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7621 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
7622 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7623 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7624 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7625 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7626 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7627 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7628 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
272a527c KY |
7629 | { } /* end */ |
7630 | }; | |
7631 | ||
7632 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
7633 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7634 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7635 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7636 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7637 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7638 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7639 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7640 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7641 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
272a527c | 7642 | { } /* end */ |
ea1fb29a | 7643 | }; |
272a527c | 7644 | |
2880a867 | 7645 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
7646 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7647 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 7648 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
7649 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7650 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
7651 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7652 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7653 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 | 7654 | { } /* end */ |
d1a991a6 | 7655 | }; |
2880a867 | 7656 | |
e2757d5e KY |
7657 | static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { |
7658 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7659 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7660 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
7661 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
7662 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", | |
7663 | 0x0d, 1, 0x0, HDA_OUTPUT), | |
7664 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
7665 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
7666 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
7667 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7668 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7669 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7670 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | |
7671 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7672 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7673 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7674 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7675 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7676 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7677 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7678 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7679 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7680 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e2757d5e KY |
7681 | { } /* end */ |
7682 | }; | |
7683 | ||
7684 | static struct hda_bind_ctls alc883_bind_cap_vol = { | |
7685 | .ops = &snd_hda_bind_vol, | |
7686 | .values = { | |
7687 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7688 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7689 | 0 | |
7690 | }, | |
7691 | }; | |
7692 | ||
7693 | static struct hda_bind_ctls alc883_bind_cap_switch = { | |
7694 | .ops = &snd_hda_bind_sw, | |
7695 | .values = { | |
7696 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7697 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7698 | 0 | |
7699 | }, | |
7700 | }; | |
7701 | ||
7702 | static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = { | |
7703 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7704 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7705 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7706 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7707 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7708 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7709 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7710 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f9e336f6 TI |
7711 | { } /* end */ |
7712 | }; | |
7713 | ||
7714 | static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = { | |
e2757d5e KY |
7715 | HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol), |
7716 | HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch), | |
7717 | { | |
7718 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7719 | /* .name = "Capture Source", */ | |
7720 | .name = "Input Source", | |
7721 | .count = 1, | |
54cbc9ab TI |
7722 | .info = alc_mux_enum_info, |
7723 | .get = alc_mux_enum_get, | |
7724 | .put = alc_mux_enum_put, | |
e2757d5e KY |
7725 | }, |
7726 | { } /* end */ | |
7727 | }; | |
7728 | ||
9c7f852e TI |
7729 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
7730 | { | |
7731 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7732 | .name = "Channel Mode", | |
7733 | .info = alc_ch_mode_info, | |
7734 | .get = alc_ch_mode_get, | |
7735 | .put = alc_ch_mode_put, | |
7736 | }, | |
7737 | { } /* end */ | |
7738 | }; | |
7739 | ||
7740 | static struct hda_verb alc883_init_verbs[] = { | |
7741 | /* ADC1: mute amp left and right */ | |
e2757d5e | 7742 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
df694daa | 7743 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7744 | /* ADC2: mute amp left and right */ |
7745 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7746 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7747 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7748 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7749 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7750 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7751 | /* Rear mixer */ | |
7752 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7753 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7754 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7755 | /* CLFE mixer */ | |
7756 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7757 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7758 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7759 | /* Side mixer */ | |
7760 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7761 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7762 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 7763 | |
cb53c626 TI |
7764 | /* mute analog input loopbacks */ |
7765 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7766 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7767 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7768 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7769 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 7770 | |
9c7f852e TI |
7771 | /* Front Pin: output 0 (0x0c) */ |
7772 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7773 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7774 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7775 | /* Rear Pin: output 1 (0x0d) */ | |
7776 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7777 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7778 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7779 | /* CLFE Pin: output 2 (0x0e) */ | |
7780 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7781 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7782 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7783 | /* Side Pin: output 3 (0x0f) */ | |
7784 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7785 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7786 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
7787 | /* Mic (rear) pin: input vref at 80% */ | |
7788 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7789 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7790 | /* Front Mic pin: input vref at 80% */ | |
7791 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7792 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7793 | /* Line In pin: input */ | |
7794 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7795 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7796 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
7797 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7798 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7799 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7800 | /* CD pin widget for input */ | |
7801 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7802 | ||
7803 | /* FIXME: use matrix-type input source selection */ | |
7804 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7805 | /* Input mixer2 */ | |
7806 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7807 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7808 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7809 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7810 | /* Input mixer3 */ |
7811 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7812 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7813 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7814 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7815 | { } |
7816 | }; | |
7817 | ||
a8848bd6 AS |
7818 | /* toggle speaker-output according to the hp-jack state */ |
7819 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | |
7820 | { | |
7821 | unsigned int present; | |
7822 | ||
7823 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7824 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7825 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7826 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7827 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7828 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7829 | } | |
7830 | ||
7831 | /* auto-toggle front mic */ | |
7832 | /* | |
7833 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | |
7834 | { | |
7835 | unsigned int present; | |
7836 | unsigned char bits; | |
7837 | ||
7838 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7839 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7840 | bits = present ? HDA_AMP_MUTE : 0; | |
7841 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
7842 | } | |
7843 | */ | |
7844 | ||
7845 | static void alc883_mitac_automute(struct hda_codec *codec) | |
7846 | { | |
7847 | alc883_mitac_hp_automute(codec); | |
7848 | /* alc883_mitac_mic_automute(codec); */ | |
7849 | } | |
7850 | ||
7851 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | |
7852 | unsigned int res) | |
7853 | { | |
7854 | switch (res >> 26) { | |
7855 | case ALC880_HP_EVENT: | |
7856 | alc883_mitac_hp_automute(codec); | |
7857 | break; | |
7858 | case ALC880_MIC_EVENT: | |
7859 | /* alc883_mitac_mic_automute(codec); */ | |
7860 | break; | |
7861 | } | |
7862 | } | |
7863 | ||
7864 | static struct hda_verb alc883_mitac_verbs[] = { | |
7865 | /* HP */ | |
7866 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7867 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7868 | /* Subwoofer */ | |
7869 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7870 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7871 | ||
7872 | /* enable unsolicited event */ | |
7873 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7874 | /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ | |
7875 | ||
7876 | { } /* end */ | |
7877 | }; | |
7878 | ||
0c4cc443 | 7879 | static struct hda_verb alc883_clevo_m720_verbs[] = { |
368c7a95 J |
7880 | /* HP */ |
7881 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7882 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7883 | /* Int speaker */ | |
7884 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7885 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7886 | ||
7887 | /* enable unsolicited event */ | |
7888 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
0c4cc443 | 7889 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, |
368c7a95 J |
7890 | |
7891 | { } /* end */ | |
7892 | }; | |
7893 | ||
fb97dc67 J |
7894 | static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = { |
7895 | /* HP */ | |
7896 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7897 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7898 | /* Subwoofer */ | |
7899 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7900 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7901 | ||
7902 | /* enable unsolicited event */ | |
7903 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7904 | ||
7905 | { } /* end */ | |
7906 | }; | |
7907 | ||
ccc656ce KY |
7908 | static struct hda_verb alc883_tagra_verbs[] = { |
7909 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7910 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7911 | ||
7912 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7913 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 7914 | |
ccc656ce KY |
7915 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
7916 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
7917 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
7918 | ||
7919 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
7920 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
7921 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
7922 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
7923 | |
7924 | { } /* end */ | |
7925 | }; | |
7926 | ||
bc9f98a9 KY |
7927 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
7928 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7929 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
7930 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
7931 | { } /* end */ | |
7932 | }; | |
7933 | ||
272a527c KY |
7934 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
7935 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7936 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7937 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7938 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7939 | { } /* end */ | |
7940 | }; | |
7941 | ||
7942 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
7943 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7944 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7945 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7946 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
7947 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7948 | { } /* end */ | |
7949 | }; | |
7950 | ||
189609ae KY |
7951 | static struct hda_verb alc883_haier_w66_verbs[] = { |
7952 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7953 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7954 | ||
7955 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7956 | ||
7957 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7958 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7959 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7960 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7961 | { } /* end */ | |
7962 | }; | |
7963 | ||
e2757d5e KY |
7964 | static struct hda_verb alc888_lenovo_sky_verbs[] = { |
7965 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7966 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7967 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7968 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7969 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7970 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7971 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7972 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7973 | { } /* end */ | |
7974 | }; | |
7975 | ||
4723c022 | 7976 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 | 7977 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
f32a19e3 HRK |
7978 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ |
7979 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
8341de60 CM |
7980 | { } |
7981 | }; | |
7982 | ||
5795b9e6 | 7983 | static struct hda_verb alc888_6st_dell_verbs[] = { |
5795b9e6 CM |
7984 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
7985 | { } | |
7986 | }; | |
7987 | ||
4723c022 | 7988 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
7989 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
7990 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7991 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7992 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7993 | { } | |
7994 | }; | |
7995 | ||
4723c022 | 7996 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
7997 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
7998 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7999 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8000 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8001 | { } | |
8002 | }; | |
8003 | ||
4723c022 CM |
8004 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
8005 | { 2, alc888_3st_hp_2ch_init }, | |
8006 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
8007 | }; |
8008 | ||
272a527c KY |
8009 | /* toggle front-jack and RCA according to the hp-jack state */ |
8010 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
8011 | { | |
8012 | unsigned int present; | |
ea1fb29a | 8013 | |
272a527c KY |
8014 | present = snd_hda_codec_read(codec, 0x1b, 0, |
8015 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8016 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8017 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8018 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8019 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
8020 | } |
8021 | ||
8022 | /* toggle RCA according to the front-jack state */ | |
8023 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
8024 | { | |
8025 | unsigned int present; | |
ea1fb29a | 8026 | |
272a527c KY |
8027 | present = snd_hda_codec_read(codec, 0x14, 0, |
8028 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8029 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8030 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 8031 | } |
47fd830a | 8032 | |
272a527c KY |
8033 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
8034 | unsigned int res) | |
8035 | { | |
8036 | if ((res >> 26) == ALC880_HP_EVENT) | |
8037 | alc888_lenovo_ms7195_front_automute(codec); | |
8038 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
8039 | alc888_lenovo_ms7195_rca_automute(codec); | |
8040 | } | |
8041 | ||
8042 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
8043 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8044 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8045 | ||
8046 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8047 | ||
8048 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8049 | { } /* end */ | |
8050 | }; | |
8051 | ||
8052 | /* toggle speaker-output according to the hp-jack state */ | |
8053 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
8054 | { | |
8055 | unsigned int present; | |
ea1fb29a | 8056 | |
272a527c KY |
8057 | present = snd_hda_codec_read(codec, 0x14, 0, |
8058 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8059 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8060 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
8061 | } |
8062 | ||
8063 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
8064 | unsigned int res) | |
8065 | { | |
8066 | if ((res >> 26) == ALC880_HP_EVENT) | |
8067 | alc883_medion_md2_automute(codec); | |
8068 | } | |
8069 | ||
ccc656ce KY |
8070 | /* toggle speaker-output according to the hp-jack state */ |
8071 | static void alc883_tagra_automute(struct hda_codec *codec) | |
8072 | { | |
8073 | unsigned int present; | |
f12ab1e0 | 8074 | unsigned char bits; |
ccc656ce KY |
8075 | |
8076 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8077 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8078 | bits = present ? HDA_AMP_MUTE : 0; |
8079 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
8080 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
8081 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
8082 | present ? 1 : 3); | |
ccc656ce KY |
8083 | } |
8084 | ||
8085 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
8086 | { | |
8087 | if ((res >> 26) == ALC880_HP_EVENT) | |
8088 | alc883_tagra_automute(codec); | |
8089 | } | |
8090 | ||
368c7a95 | 8091 | /* toggle speaker-output according to the hp-jack state */ |
0c4cc443 | 8092 | static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) |
368c7a95 J |
8093 | { |
8094 | unsigned int present; | |
8095 | unsigned char bits; | |
8096 | ||
8097 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
8098 | & AC_PINSENSE_PRESENCE; | |
8099 | bits = present ? HDA_AMP_MUTE : 0; | |
8100 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8101 | HDA_AMP_MUTE, bits); | |
8102 | } | |
8103 | ||
0c4cc443 HRK |
8104 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) |
8105 | { | |
8106 | unsigned int present; | |
8107 | ||
8108 | present = snd_hda_codec_read(codec, 0x18, 0, | |
8109 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8110 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
8111 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8112 | } | |
8113 | ||
8114 | static void alc883_clevo_m720_automute(struct hda_codec *codec) | |
8115 | { | |
8116 | alc883_clevo_m720_hp_automute(codec); | |
8117 | alc883_clevo_m720_mic_automute(codec); | |
8118 | } | |
8119 | ||
8120 | static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |
368c7a95 J |
8121 | unsigned int res) |
8122 | { | |
0c4cc443 HRK |
8123 | switch (res >> 26) { |
8124 | case ALC880_HP_EVENT: | |
8125 | alc883_clevo_m720_hp_automute(codec); | |
8126 | break; | |
8127 | case ALC880_MIC_EVENT: | |
8128 | alc883_clevo_m720_mic_automute(codec); | |
8129 | break; | |
8130 | } | |
368c7a95 J |
8131 | } |
8132 | ||
fb97dc67 J |
8133 | /* toggle speaker-output according to the hp-jack state */ |
8134 | static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) | |
8135 | { | |
8136 | unsigned int present; | |
8137 | unsigned char bits; | |
8138 | ||
8139 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | |
8140 | & AC_PINSENSE_PRESENCE; | |
8141 | bits = present ? HDA_AMP_MUTE : 0; | |
8142 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8143 | HDA_AMP_MUTE, bits); | |
8144 | } | |
8145 | ||
8146 | static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, | |
8147 | unsigned int res) | |
8148 | { | |
8149 | if ((res >> 26) == ALC880_HP_EVENT) | |
8150 | alc883_2ch_fujitsu_pi2515_automute(codec); | |
8151 | } | |
8152 | ||
189609ae KY |
8153 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
8154 | { | |
8155 | unsigned int present; | |
8156 | unsigned char bits; | |
8157 | ||
8158 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8159 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8160 | bits = present ? 0x80 : 0; | |
8161 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8162 | 0x80, bits); | |
8163 | } | |
8164 | ||
8165 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
8166 | unsigned int res) | |
8167 | { | |
8168 | if ((res >> 26) == ALC880_HP_EVENT) | |
8169 | alc883_haier_w66_automute(codec); | |
8170 | } | |
8171 | ||
bc9f98a9 KY |
8172 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
8173 | { | |
8174 | unsigned int present; | |
f12ab1e0 | 8175 | unsigned char bits; |
bc9f98a9 KY |
8176 | |
8177 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8178 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8179 | bits = present ? HDA_AMP_MUTE : 0; |
8180 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8181 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
8182 | } |
8183 | ||
8184 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
8185 | { | |
8186 | unsigned int present; | |
f12ab1e0 | 8187 | unsigned char bits; |
bc9f98a9 KY |
8188 | |
8189 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8190 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8191 | bits = present ? HDA_AMP_MUTE : 0; |
8192 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8193 | HDA_AMP_MUTE, bits); | |
8194 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8195 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
8196 | } |
8197 | ||
8198 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
8199 | unsigned int res) | |
8200 | { | |
8201 | if ((res >> 26) == ALC880_HP_EVENT) | |
8202 | alc883_lenovo_101e_all_automute(codec); | |
8203 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
8204 | alc883_lenovo_101e_ispeaker_automute(codec); | |
8205 | } | |
8206 | ||
676a9b53 TI |
8207 | /* toggle speaker-output according to the hp-jack state */ |
8208 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
8209 | { | |
8210 | unsigned int present; | |
ea1fb29a | 8211 | |
676a9b53 TI |
8212 | present = snd_hda_codec_read(codec, 0x14, 0, |
8213 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8214 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8215 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8216 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8217 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8218 | } | |
8219 | ||
8220 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
8221 | unsigned int res) | |
8222 | { | |
8223 | if ((res >> 26) == ALC880_HP_EVENT) | |
8224 | alc883_acer_aspire_automute(codec); | |
8225 | } | |
8226 | ||
d1a991a6 KY |
8227 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
8228 | /* HP Pin: output 0 (0x0c) */ | |
8229 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8230 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8231 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8232 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
8233 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
8234 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 8235 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
8236 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
8237 | /* eanable EAPD on medion laptop */ | |
8238 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
8239 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
8240 | /* enable unsolicited event */ |
8241 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
8242 | { } |
8243 | }; | |
8244 | ||
5795b9e6 CM |
8245 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) |
8246 | { | |
8247 | unsigned int present; | |
ea1fb29a | 8248 | |
5795b9e6 CM |
8249 | present = snd_hda_codec_read(codec, 0x1b, 0, |
8250 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8251 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8252 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8253 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8254 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8255 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8256 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8257 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8258 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8259 | } | |
8260 | ||
8261 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | |
8262 | unsigned int res) | |
8263 | { | |
8264 | switch (res >> 26) { | |
8265 | case ALC880_HP_EVENT: | |
939778ae | 8266 | /* printk(KERN_DEBUG "hp_event\n"); */ |
5795b9e6 CM |
8267 | alc888_6st_dell_front_automute(codec); |
8268 | break; | |
8269 | } | |
8270 | } | |
8271 | ||
e2757d5e KY |
8272 | static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) |
8273 | { | |
8274 | unsigned int mute; | |
8275 | unsigned int present; | |
8276 | ||
8277 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8278 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8279 | AC_VERB_GET_PIN_SENSE, 0); | |
8280 | present = (present & 0x80000000) != 0; | |
8281 | if (present) { | |
8282 | /* mute internal speaker */ | |
8283 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8284 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8285 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8286 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8287 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8288 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8289 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8290 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8291 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
8292 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8293 | } else { | |
8294 | /* unmute internal speaker if necessary */ | |
8295 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
8296 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8297 | HDA_AMP_MUTE, mute); | |
8298 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8299 | HDA_AMP_MUTE, mute); | |
8300 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8301 | HDA_AMP_MUTE, mute); | |
8302 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8303 | HDA_AMP_MUTE, mute); | |
8304 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
8305 | HDA_AMP_MUTE, mute); | |
8306 | } | |
8307 | } | |
8308 | ||
8309 | static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, | |
8310 | unsigned int res) | |
8311 | { | |
8312 | if ((res >> 26) == ALC880_HP_EVENT) | |
8313 | alc888_lenovo_sky_front_automute(codec); | |
8314 | } | |
8315 | ||
9c7f852e TI |
8316 | /* |
8317 | * generic initialization of ADC, input mixers and output mixers | |
8318 | */ | |
8319 | static struct hda_verb alc883_auto_init_verbs[] = { | |
8320 | /* | |
8321 | * Unmute ADC0-2 and set the default input to mic-in | |
8322 | */ | |
8323 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8324 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8325 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8326 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8327 | ||
cb53c626 | 8328 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 8329 | * mixer widget |
f12ab1e0 TI |
8330 | * Note: PASD motherboards uses the Line In 2 as the input for |
8331 | * front panel mic (mic 2) | |
9c7f852e TI |
8332 | */ |
8333 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8334 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8335 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8336 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8337 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8338 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
8339 | |
8340 | /* | |
8341 | * Set up output mixers (0x0c - 0x0f) | |
8342 | */ | |
8343 | /* set vol=0 to output mixers */ | |
8344 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8345 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8346 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8347 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8348 | /* set up input amps for analog loopback */ | |
8349 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8350 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8351 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8352 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8353 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8354 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8355 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8356 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8357 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8358 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8359 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8360 | ||
8361 | /* FIXME: use matrix-type input source selection */ | |
8362 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8363 | /* Input mixer1 */ | |
8364 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8365 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8366 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8367 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
8368 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
8369 | /* Input mixer2 */ | |
8370 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8371 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8372 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8373 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
e3cde64a | 8374 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
9c7f852e TI |
8375 | |
8376 | { } | |
8377 | }; | |
8378 | ||
e2757d5e KY |
8379 | static struct hda_verb alc888_asus_m90v_verbs[] = { |
8380 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8381 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8382 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8383 | /* enable unsolicited event */ | |
8384 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8385 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
8386 | { } /* end */ | |
8387 | }; | |
8388 | ||
8389 | static void alc883_nb_mic_automute(struct hda_codec *codec) | |
8390 | { | |
8391 | unsigned int present; | |
8392 | ||
8393 | present = snd_hda_codec_read(codec, 0x18, 0, | |
8394 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8395 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8396 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
8397 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8398 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
8399 | } | |
8400 | ||
8401 | static void alc883_M90V_speaker_automute(struct hda_codec *codec) | |
8402 | { | |
8403 | unsigned int present; | |
8404 | unsigned char bits; | |
8405 | ||
8406 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8407 | AC_VERB_GET_PIN_SENSE, 0) | |
8408 | & AC_PINSENSE_PRESENCE; | |
8409 | bits = present ? 0 : PIN_OUT; | |
8410 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8411 | bits); | |
8412 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8413 | bits); | |
8414 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8415 | bits); | |
8416 | } | |
8417 | ||
8418 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | |
8419 | unsigned int res) | |
8420 | { | |
8421 | switch (res >> 26) { | |
8422 | case ALC880_HP_EVENT: | |
8423 | alc883_M90V_speaker_automute(codec); | |
8424 | break; | |
8425 | case ALC880_MIC_EVENT: | |
8426 | alc883_nb_mic_automute(codec); | |
8427 | break; | |
8428 | } | |
8429 | } | |
8430 | ||
8431 | static void alc883_mode2_inithook(struct hda_codec *codec) | |
8432 | { | |
8433 | alc883_M90V_speaker_automute(codec); | |
8434 | alc883_nb_mic_automute(codec); | |
8435 | } | |
8436 | ||
8437 | static struct hda_verb alc888_asus_eee1601_verbs[] = { | |
8438 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8439 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8440 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8441 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8442 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8443 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0b}, | |
8444 | {0x20, AC_VERB_SET_PROC_COEF, 0x0838}, | |
8445 | /* enable unsolicited event */ | |
8446 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8447 | { } /* end */ | |
8448 | }; | |
8449 | ||
8450 | static void alc883_eee1601_speaker_automute(struct hda_codec *codec) | |
8451 | { | |
8452 | unsigned int present; | |
8453 | unsigned char bits; | |
8454 | ||
8455 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8456 | AC_VERB_GET_PIN_SENSE, 0) | |
8457 | & AC_PINSENSE_PRESENCE; | |
8458 | bits = present ? 0 : PIN_OUT; | |
8459 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8460 | bits); | |
8461 | } | |
8462 | ||
8463 | static void alc883_eee1601_unsol_event(struct hda_codec *codec, | |
8464 | unsigned int res) | |
8465 | { | |
8466 | switch (res >> 26) { | |
8467 | case ALC880_HP_EVENT: | |
8468 | alc883_eee1601_speaker_automute(codec); | |
8469 | break; | |
8470 | } | |
8471 | } | |
8472 | ||
8473 | static void alc883_eee1601_inithook(struct hda_codec *codec) | |
8474 | { | |
8475 | alc883_eee1601_speaker_automute(codec); | |
8476 | } | |
8477 | ||
cb53c626 TI |
8478 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8479 | #define alc883_loopbacks alc880_loopbacks | |
8480 | #endif | |
8481 | ||
9c7f852e TI |
8482 | /* pcm configuration: identiacal with ALC880 */ |
8483 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
8484 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 8485 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
9c7f852e TI |
8486 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback |
8487 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
8488 | ||
8489 | /* | |
8490 | * configuration and preset | |
8491 | */ | |
f5fcc13c TI |
8492 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
8493 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
8494 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
8495 | [ALC883_3ST_6ch] = "3stack-6ch", | |
8496 | [ALC883_6ST_DIG] = "6stack-dig", | |
8497 | [ALC883_TARGA_DIG] = "targa-dig", | |
8498 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 8499 | [ALC883_ACER] = "acer", |
2880a867 | 8500 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
5b2d1eca | 8501 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", |
f5fcc13c | 8502 | [ALC883_MEDION] = "medion", |
272a527c | 8503 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 8504 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 8505 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
8506 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
8507 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
e2757d5e | 8508 | [ALC888_LENOVO_SKY] = "lenovo-sky", |
189609ae | 8509 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 | 8510 | [ALC888_3ST_HP] = "3stack-hp", |
5795b9e6 | 8511 | [ALC888_6ST_DELL] = "6stack-dell", |
a8848bd6 | 8512 | [ALC883_MITAC] = "mitac", |
0c4cc443 | 8513 | [ALC883_CLEVO_M720] = "clevo-m720", |
fb97dc67 | 8514 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", |
ef8ef5fb | 8515 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", |
17bba1b7 | 8516 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
3ab90935 | 8517 | [ALC1200_ASUS_P5Q] = "asus-p5q", |
f5fcc13c TI |
8518 | [ALC883_AUTO] = "auto", |
8519 | }; | |
8520 | ||
8521 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
8522 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
ac3e3741 | 8523 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
69e50282 | 8524 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), |
ac3e3741 TI |
8525 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), |
8526 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), | |
0b18cb18 | 8527 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), |
5b2d1eca VP |
8528 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
8529 | ALC888_ACER_ASPIRE_4930G), | |
a8e4f9dd LW |
8530 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
8531 | ALC888_ACER_ASPIRE_4930G), | |
94683507 | 8532 | SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), |
a8e4f9dd LW |
8533 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
8534 | ALC888_ACER_ASPIRE_4930G), | |
dea0a509 TI |
8535 | /* default Acer */ |
8536 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), | |
5795b9e6 | 8537 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
febe3375 | 8538 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
ac3e3741 TI |
8539 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
8540 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
5d85f8d0 | 8541 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
06bf3e15 | 8542 | SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), |
a01c30cb | 8543 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), |
ac3e3741 | 8544 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
44a678d0 | 8545 | SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), |
3ab90935 | 8546 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), |
e2757d5e | 8547 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), |
97ec710c | 8548 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), |
f5fcc13c | 8549 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), |
2de686d2 | 8550 | SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), |
ac3e3741 TI |
8551 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
8552 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
e2757d5e | 8553 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), |
ac3e3741 | 8554 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
57b14f24 | 8555 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 8556 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
bba8dee7 | 8557 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8558 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
4383fae0 | 8559 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 8560 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
82808236 | 8561 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
f5fcc13c | 8562 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8563 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8564 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), |
8565 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 | 8566 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
64ca1c29 | 8567 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8568 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
8569 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
8570 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 TI |
8571 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
8572 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
8573 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), | |
ee09543c | 8574 | SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG), |
86d34b7e | 8575 | SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), |
ac3e3741 TI |
8576 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
8577 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | |
f5fcc13c | 8578 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8579 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
0c4cc443 HRK |
8580 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), |
8581 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), | |
dea0a509 | 8582 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), |
e60623b4 | 8583 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c | 8584 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
f67d8176 TI |
8585 | SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550", |
8586 | ALC883_FUJITSU_PI2515), | |
fb97dc67 | 8587 | SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), |
ef8ef5fb VP |
8588 | SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530", |
8589 | ALC888_FUJITSU_XA3530), | |
272a527c | 8590 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
272a527c | 8591 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
ac3e3741 TI |
8592 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
8593 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
e2757d5e | 8594 | SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY), |
272a527c | 8595 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
959973b9 | 8596 | SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), |
0b167bf4 | 8597 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), |
189609ae | 8598 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
17bba1b7 J |
8599 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
8600 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | |
2de686d2 | 8601 | SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), |
4b558991 | 8602 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), |
ac3e3741 | 8603 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9c7f852e TI |
8604 | {} |
8605 | }; | |
8606 | ||
b25c9da1 WF |
8607 | static hda_nid_t alc1200_slave_dig_outs[] = { |
8608 | ALC883_DIGOUT_NID, 0, | |
8609 | }; | |
8610 | ||
9c7f852e TI |
8611 | static struct alc_config_preset alc883_presets[] = { |
8612 | [ALC883_3ST_2ch_DIG] = { | |
8613 | .mixers = { alc883_3ST_2ch_mixer }, | |
8614 | .init_verbs = { alc883_init_verbs }, | |
8615 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8616 | .dac_nids = alc883_dac_nids, | |
8617 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8618 | .dig_in_nid = ALC883_DIGIN_NID, |
8619 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8620 | .channel_mode = alc883_3ST_2ch_modes, | |
8621 | .input_mux = &alc883_capture_source, | |
8622 | }, | |
8623 | [ALC883_3ST_6ch_DIG] = { | |
8624 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8625 | .init_verbs = { alc883_init_verbs }, | |
8626 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8627 | .dac_nids = alc883_dac_nids, | |
8628 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8629 | .dig_in_nid = ALC883_DIGIN_NID, |
8630 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8631 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8632 | .need_dac_fix = 1, |
9c7f852e | 8633 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8634 | }, |
9c7f852e TI |
8635 | [ALC883_3ST_6ch] = { |
8636 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8637 | .init_verbs = { alc883_init_verbs }, | |
8638 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8639 | .dac_nids = alc883_dac_nids, | |
9c7f852e TI |
8640 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8641 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8642 | .need_dac_fix = 1, |
9c7f852e | 8643 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8644 | }, |
17bba1b7 J |
8645 | [ALC883_3ST_6ch_INTEL] = { |
8646 | .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer }, | |
8647 | .init_verbs = { alc883_init_verbs }, | |
8648 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8649 | .dac_nids = alc883_dac_nids, | |
8650 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8651 | .dig_in_nid = ALC883_DIGIN_NID, | |
8652 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), | |
8653 | .channel_mode = alc883_3ST_6ch_intel_modes, | |
8654 | .need_dac_fix = 1, | |
8655 | .input_mux = &alc883_3stack_6ch_intel, | |
8656 | }, | |
9c7f852e TI |
8657 | [ALC883_6ST_DIG] = { |
8658 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8659 | .init_verbs = { alc883_init_verbs }, | |
8660 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8661 | .dac_nids = alc883_dac_nids, | |
8662 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8663 | .dig_in_nid = ALC883_DIGIN_NID, |
8664 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8665 | .channel_mode = alc883_sixstack_modes, | |
8666 | .input_mux = &alc883_capture_source, | |
8667 | }, | |
ccc656ce KY |
8668 | [ALC883_TARGA_DIG] = { |
8669 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
8670 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8671 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8672 | .dac_nids = alc883_dac_nids, | |
8673 | .dig_out_nid = ALC883_DIGOUT_NID, | |
ccc656ce KY |
8674 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8675 | .channel_mode = alc883_3ST_6ch_modes, | |
8676 | .need_dac_fix = 1, | |
8677 | .input_mux = &alc883_capture_source, | |
8678 | .unsol_event = alc883_tagra_unsol_event, | |
8679 | .init_hook = alc883_tagra_automute, | |
8680 | }, | |
8681 | [ALC883_TARGA_2ch_DIG] = { | |
8682 | .mixers = { alc883_tagra_2ch_mixer}, | |
8683 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8684 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8685 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8686 | .adc_nids = alc883_adc_nids_alt, |
8687 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
ccc656ce | 8688 | .dig_out_nid = ALC883_DIGOUT_NID, |
ccc656ce KY |
8689 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8690 | .channel_mode = alc883_3ST_2ch_modes, | |
8691 | .input_mux = &alc883_capture_source, | |
8692 | .unsol_event = alc883_tagra_unsol_event, | |
8693 | .init_hook = alc883_tagra_automute, | |
8694 | }, | |
bab282b9 | 8695 | [ALC883_ACER] = { |
676a9b53 | 8696 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
8697 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
8698 | * and the headphone jack. Turn this on and rely on the | |
8699 | * standard mute methods whenever the user wants to turn | |
8700 | * these outputs off. | |
8701 | */ | |
8702 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
8703 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8704 | .dac_nids = alc883_dac_nids, | |
bab282b9 VA |
8705 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8706 | .channel_mode = alc883_3ST_2ch_modes, | |
8707 | .input_mux = &alc883_capture_source, | |
8708 | }, | |
2880a867 | 8709 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 8710 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 8711 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
8712 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8713 | .dac_nids = alc883_dac_nids, | |
8714 | .dig_out_nid = ALC883_DIGOUT_NID, | |
2880a867 TD |
8715 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8716 | .channel_mode = alc883_3ST_2ch_modes, | |
8717 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
8718 | .unsol_event = alc883_acer_aspire_unsol_event, |
8719 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 8720 | }, |
5b2d1eca | 8721 | [ALC888_ACER_ASPIRE_4930G] = { |
ef8ef5fb | 8722 | .mixers = { alc888_base_mixer, |
5b2d1eca VP |
8723 | alc883_chmode_mixer }, |
8724 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, | |
8725 | alc888_acer_aspire_4930g_verbs }, | |
8726 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8727 | .dac_nids = alc883_dac_nids, | |
8728 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | |
8729 | .adc_nids = alc883_adc_nids_rev, | |
8730 | .capsrc_nids = alc883_capsrc_nids_rev, | |
8731 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8732 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8733 | .channel_mode = alc883_3ST_6ch_modes, | |
8734 | .need_dac_fix = 1, | |
8735 | .num_mux_defs = | |
ef8ef5fb VP |
8736 | ARRAY_SIZE(alc888_2_capture_sources), |
8737 | .input_mux = alc888_2_capture_sources, | |
5b2d1eca VP |
8738 | .unsol_event = alc888_acer_aspire_4930g_unsol_event, |
8739 | .init_hook = alc888_acer_aspire_4930g_automute, | |
8740 | }, | |
c07584c8 TD |
8741 | [ALC883_MEDION] = { |
8742 | .mixers = { alc883_fivestack_mixer, | |
8743 | alc883_chmode_mixer }, | |
8744 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 8745 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
8746 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8747 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8748 | .adc_nids = alc883_adc_nids_alt, |
8749 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
c07584c8 TD |
8750 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8751 | .channel_mode = alc883_sixstack_modes, | |
8752 | .input_mux = &alc883_capture_source, | |
b373bdeb | 8753 | }, |
272a527c KY |
8754 | [ALC883_MEDION_MD2] = { |
8755 | .mixers = { alc883_medion_md2_mixer}, | |
8756 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
8757 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8758 | .dac_nids = alc883_dac_nids, | |
8759 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8760 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8761 | .channel_mode = alc883_3ST_2ch_modes, | |
8762 | .input_mux = &alc883_capture_source, | |
8763 | .unsol_event = alc883_medion_md2_unsol_event, | |
8764 | .init_hook = alc883_medion_md2_automute, | |
ea1fb29a | 8765 | }, |
b373bdeb | 8766 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 8767 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
8768 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
8769 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8770 | .dac_nids = alc883_dac_nids, | |
b373bdeb AN |
8771 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8772 | .channel_mode = alc883_3ST_2ch_modes, | |
8773 | .input_mux = &alc883_capture_source, | |
8774 | }, | |
0c4cc443 HRK |
8775 | [ALC883_CLEVO_M720] = { |
8776 | .mixers = { alc883_clevo_m720_mixer }, | |
8777 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, | |
368c7a95 J |
8778 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8779 | .dac_nids = alc883_dac_nids, | |
8780 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8781 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8782 | .channel_mode = alc883_3ST_2ch_modes, | |
8783 | .input_mux = &alc883_capture_source, | |
0c4cc443 HRK |
8784 | .unsol_event = alc883_clevo_m720_unsol_event, |
8785 | .init_hook = alc883_clevo_m720_automute, | |
368c7a95 | 8786 | }, |
bc9f98a9 KY |
8787 | [ALC883_LENOVO_101E_2ch] = { |
8788 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
8789 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
8790 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8791 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8792 | .adc_nids = alc883_adc_nids_alt, |
8793 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
bc9f98a9 KY |
8794 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8795 | .channel_mode = alc883_3ST_2ch_modes, | |
8796 | .input_mux = &alc883_lenovo_101e_capture_source, | |
8797 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
8798 | .init_hook = alc883_lenovo_101e_all_automute, | |
8799 | }, | |
272a527c KY |
8800 | [ALC883_LENOVO_NB0763] = { |
8801 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
8802 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
8803 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8804 | .dac_nids = alc883_dac_nids, | |
272a527c KY |
8805 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8806 | .channel_mode = alc883_3ST_2ch_modes, | |
8807 | .need_dac_fix = 1, | |
8808 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
8809 | .unsol_event = alc883_medion_md2_unsol_event, | |
8810 | .init_hook = alc883_medion_md2_automute, | |
8811 | }, | |
8812 | [ALC888_LENOVO_MS7195_DIG] = { | |
8813 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8814 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
8815 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8816 | .dac_nids = alc883_dac_nids, | |
8817 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8818 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8819 | .channel_mode = alc883_3ST_6ch_modes, | |
8820 | .need_dac_fix = 1, | |
8821 | .input_mux = &alc883_capture_source, | |
8822 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
8823 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
8824 | }, |
8825 | [ALC883_HAIER_W66] = { | |
8826 | .mixers = { alc883_tagra_2ch_mixer}, | |
8827 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
8828 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8829 | .dac_nids = alc883_dac_nids, | |
8830 | .dig_out_nid = ALC883_DIGOUT_NID, | |
189609ae KY |
8831 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8832 | .channel_mode = alc883_3ST_2ch_modes, | |
8833 | .input_mux = &alc883_capture_source, | |
8834 | .unsol_event = alc883_haier_w66_unsol_event, | |
8835 | .init_hook = alc883_haier_w66_automute, | |
eea6419e | 8836 | }, |
4723c022 | 8837 | [ALC888_3ST_HP] = { |
eea6419e | 8838 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
4723c022 | 8839 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, |
8341de60 CM |
8840 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8841 | .dac_nids = alc883_dac_nids, | |
4723c022 CM |
8842 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
8843 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
8844 | .need_dac_fix = 1, |
8845 | .input_mux = &alc883_capture_source, | |
8846 | }, | |
5795b9e6 | 8847 | [ALC888_6ST_DELL] = { |
f24dbdc6 | 8848 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
5795b9e6 CM |
8849 | .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, |
8850 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8851 | .dac_nids = alc883_dac_nids, | |
8852 | .dig_out_nid = ALC883_DIGOUT_NID, | |
5795b9e6 CM |
8853 | .dig_in_nid = ALC883_DIGIN_NID, |
8854 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8855 | .channel_mode = alc883_sixstack_modes, | |
8856 | .input_mux = &alc883_capture_source, | |
8857 | .unsol_event = alc888_6st_dell_unsol_event, | |
8858 | .init_hook = alc888_6st_dell_front_automute, | |
8859 | }, | |
a8848bd6 AS |
8860 | [ALC883_MITAC] = { |
8861 | .mixers = { alc883_mitac_mixer }, | |
8862 | .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, | |
8863 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8864 | .dac_nids = alc883_dac_nids, | |
a8848bd6 AS |
8865 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8866 | .channel_mode = alc883_3ST_2ch_modes, | |
8867 | .input_mux = &alc883_capture_source, | |
8868 | .unsol_event = alc883_mitac_unsol_event, | |
8869 | .init_hook = alc883_mitac_automute, | |
8870 | }, | |
fb97dc67 J |
8871 | [ALC883_FUJITSU_PI2515] = { |
8872 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | |
8873 | .init_verbs = { alc883_init_verbs, | |
8874 | alc883_2ch_fujitsu_pi2515_verbs}, | |
8875 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8876 | .dac_nids = alc883_dac_nids, | |
8877 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8878 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8879 | .channel_mode = alc883_3ST_2ch_modes, | |
8880 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8881 | .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, | |
8882 | .init_hook = alc883_2ch_fujitsu_pi2515_automute, | |
8883 | }, | |
ef8ef5fb VP |
8884 | [ALC888_FUJITSU_XA3530] = { |
8885 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, | |
8886 | .init_verbs = { alc883_init_verbs, | |
8887 | alc888_fujitsu_xa3530_verbs }, | |
8888 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8889 | .dac_nids = alc883_dac_nids, | |
8890 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | |
8891 | .adc_nids = alc883_adc_nids_rev, | |
8892 | .capsrc_nids = alc883_capsrc_nids_rev, | |
8893 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8894 | .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes), | |
8895 | .channel_mode = alc888_4ST_8ch_intel_modes, | |
8896 | .num_mux_defs = | |
8897 | ARRAY_SIZE(alc888_2_capture_sources), | |
8898 | .input_mux = alc888_2_capture_sources, | |
8899 | .unsol_event = alc888_fujitsu_xa3530_unsol_event, | |
8900 | .init_hook = alc888_fujitsu_xa3530_automute, | |
8901 | }, | |
e2757d5e KY |
8902 | [ALC888_LENOVO_SKY] = { |
8903 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | |
8904 | .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs}, | |
8905 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8906 | .dac_nids = alc883_dac_nids, | |
8907 | .dig_out_nid = ALC883_DIGOUT_NID, | |
e2757d5e KY |
8908 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8909 | .channel_mode = alc883_sixstack_modes, | |
8910 | .need_dac_fix = 1, | |
8911 | .input_mux = &alc883_lenovo_sky_capture_source, | |
8912 | .unsol_event = alc883_lenovo_sky_unsol_event, | |
8913 | .init_hook = alc888_lenovo_sky_front_automute, | |
8914 | }, | |
8915 | [ALC888_ASUS_M90V] = { | |
8916 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8917 | .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs }, | |
8918 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8919 | .dac_nids = alc883_dac_nids, | |
8920 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8921 | .dig_in_nid = ALC883_DIGIN_NID, | |
8922 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8923 | .channel_mode = alc883_3ST_6ch_modes, | |
8924 | .need_dac_fix = 1, | |
8925 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8926 | .unsol_event = alc883_mode2_unsol_event, | |
8927 | .init_hook = alc883_mode2_inithook, | |
8928 | }, | |
8929 | [ALC888_ASUS_EEE1601] = { | |
8930 | .mixers = { alc883_asus_eee1601_mixer }, | |
f9e336f6 | 8931 | .cap_mixer = alc883_asus_eee1601_cap_mixer, |
e2757d5e KY |
8932 | .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs }, |
8933 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8934 | .dac_nids = alc883_dac_nids, | |
8935 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8936 | .dig_in_nid = ALC883_DIGIN_NID, | |
8937 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8938 | .channel_mode = alc883_3ST_2ch_modes, | |
8939 | .need_dac_fix = 1, | |
8940 | .input_mux = &alc883_asus_eee1601_capture_source, | |
8941 | .unsol_event = alc883_eee1601_unsol_event, | |
8942 | .init_hook = alc883_eee1601_inithook, | |
8943 | }, | |
3ab90935 WF |
8944 | [ALC1200_ASUS_P5Q] = { |
8945 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8946 | .init_verbs = { alc883_init_verbs }, | |
8947 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8948 | .dac_nids = alc883_dac_nids, | |
8949 | .dig_out_nid = ALC1200_DIGOUT_NID, | |
8950 | .dig_in_nid = ALC883_DIGIN_NID, | |
b25c9da1 | 8951 | .slave_dig_outs = alc1200_slave_dig_outs, |
3ab90935 WF |
8952 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8953 | .channel_mode = alc883_sixstack_modes, | |
8954 | .input_mux = &alc883_capture_source, | |
8955 | }, | |
9c7f852e TI |
8956 | }; |
8957 | ||
8958 | ||
8959 | /* | |
8960 | * BIOS auto configuration | |
8961 | */ | |
8962 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
8963 | hda_nid_t nid, int pin_type, | |
8964 | int dac_idx) | |
8965 | { | |
8966 | /* set as output */ | |
8967 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
8968 | int idx; |
8969 | ||
f6c7e546 | 8970 | alc_set_pin_output(codec, nid, pin_type); |
9c7f852e TI |
8971 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
8972 | idx = 4; | |
8973 | else | |
8974 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
9c7f852e TI |
8975 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
8976 | ||
8977 | } | |
8978 | ||
8979 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
8980 | { | |
8981 | struct alc_spec *spec = codec->spec; | |
8982 | int i; | |
8983 | ||
bc9f98a9 | 8984 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 8985 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 8986 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 8987 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 8988 | if (nid) |
baba8ee9 | 8989 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 8990 | i); |
9c7f852e TI |
8991 | } |
8992 | } | |
8993 | ||
8994 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
8995 | { | |
8996 | struct alc_spec *spec = codec->spec; | |
8997 | hda_nid_t pin; | |
8998 | ||
eb06ed8f | 8999 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
9000 | if (pin) /* connect to front */ |
9001 | /* use dac 0 */ | |
9002 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
9003 | pin = spec->autocfg.speaker_pins[0]; |
9004 | if (pin) | |
9005 | alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
9c7f852e TI |
9006 | } |
9007 | ||
9008 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
9009 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
9010 | ||
9011 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
9012 | { | |
9013 | struct alc_spec *spec = codec->spec; | |
9014 | int i; | |
9015 | ||
9016 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
9017 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
9018 | if (alc883_is_input_pin(nid)) { | |
9019 | snd_hda_codec_write(codec, nid, 0, | |
9020 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9021 | (i <= AUTO_PIN_FRONT_MIC ? | |
9022 | PIN_VREF80 : PIN_IN)); | |
9023 | if (nid != ALC883_PIN_CD_NID) | |
9024 | snd_hda_codec_write(codec, nid, 0, | |
9025 | AC_VERB_SET_AMP_GAIN_MUTE, | |
9026 | AMP_OUT_MUTE); | |
9027 | } | |
9028 | } | |
9029 | } | |
9030 | ||
f511b01c TI |
9031 | #define alc883_auto_init_input_src alc882_auto_init_input_src |
9032 | ||
9c7f852e TI |
9033 | /* almost identical with ALC880 parser... */ |
9034 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
9035 | { | |
9036 | struct alc_spec *spec = codec->spec; | |
9037 | int err = alc880_parse_auto_config(codec); | |
61b9b9b1 HRK |
9038 | struct auto_pin_cfg *cfg = &spec->autocfg; |
9039 | int i; | |
9c7f852e TI |
9040 | |
9041 | if (err < 0) | |
9042 | return err; | |
776e184e TI |
9043 | else if (!err) |
9044 | return 0; /* no config found */ | |
9045 | ||
9046 | err = alc_auto_add_mic_boost(codec); | |
9047 | if (err < 0) | |
9048 | return err; | |
9049 | ||
9050 | /* hack - override the init verbs */ | |
9051 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
776e184e | 9052 | |
61b9b9b1 HRK |
9053 | /* setup input_mux for ALC889 */ |
9054 | if (codec->vendor_id == 0x10ec0889) { | |
9055 | /* digital-mic input pin is excluded in alc880_auto_create..() | |
9056 | * because it's under 0x18 | |
9057 | */ | |
9058 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | |
9059 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | |
9060 | struct hda_input_mux *imux = &spec->private_imux[0]; | |
9061 | for (i = 1; i < 3; i++) | |
9062 | memcpy(&spec->private_imux[i], | |
9063 | &spec->private_imux[0], | |
9064 | sizeof(spec->private_imux[0])); | |
9065 | imux->items[imux->num_items].label = "Int DMic"; | |
9066 | imux->items[imux->num_items].index = 0x0b; | |
9067 | imux->num_items++; | |
9068 | spec->num_mux_defs = 3; | |
9069 | spec->input_mux = spec->private_imux; | |
9070 | } | |
9071 | } | |
9072 | ||
776e184e | 9073 | return 1; /* config found */ |
9c7f852e TI |
9074 | } |
9075 | ||
9076 | /* additional initialization for auto-configuration model */ | |
9077 | static void alc883_auto_init(struct hda_codec *codec) | |
9078 | { | |
f6c7e546 | 9079 | struct alc_spec *spec = codec->spec; |
9c7f852e TI |
9080 | alc883_auto_init_multi_out(codec); |
9081 | alc883_auto_init_hp_out(codec); | |
9082 | alc883_auto_init_analog_input(codec); | |
f511b01c | 9083 | alc883_auto_init_input_src(codec); |
f6c7e546 | 9084 | if (spec->unsol_event) |
7fb0d78f | 9085 | alc_inithook(codec); |
9c7f852e TI |
9086 | } |
9087 | ||
9088 | static int patch_alc883(struct hda_codec *codec) | |
9089 | { | |
9090 | struct alc_spec *spec; | |
9091 | int err, board_config; | |
9092 | ||
9093 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
9094 | if (spec == NULL) | |
9095 | return -ENOMEM; | |
9096 | ||
9097 | codec->spec = spec; | |
9098 | ||
2c3bf9ab TI |
9099 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
9100 | ||
f5fcc13c TI |
9101 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
9102 | alc883_models, | |
9103 | alc883_cfg_tbl); | |
9104 | if (board_config < 0) { | |
9c7f852e TI |
9105 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
9106 | "trying auto-probe from BIOS...\n"); | |
9107 | board_config = ALC883_AUTO; | |
9108 | } | |
9109 | ||
9110 | if (board_config == ALC883_AUTO) { | |
9111 | /* automatic parse from the BIOS config */ | |
9112 | err = alc883_parse_auto_config(codec); | |
9113 | if (err < 0) { | |
9114 | alc_free(codec); | |
9115 | return err; | |
f12ab1e0 | 9116 | } else if (!err) { |
9c7f852e TI |
9117 | printk(KERN_INFO |
9118 | "hda_codec: Cannot set up configuration " | |
9119 | "from BIOS. Using base mode...\n"); | |
9120 | board_config = ALC883_3ST_2ch_DIG; | |
9121 | } | |
9122 | } | |
9123 | ||
680cd536 KK |
9124 | err = snd_hda_attach_beep_device(codec, 0x1); |
9125 | if (err < 0) { | |
9126 | alc_free(codec); | |
9127 | return err; | |
9128 | } | |
9129 | ||
9c7f852e TI |
9130 | if (board_config != ALC883_AUTO) |
9131 | setup_preset(spec, &alc883_presets[board_config]); | |
9132 | ||
2f893286 KY |
9133 | switch (codec->vendor_id) { |
9134 | case 0x10ec0888: | |
4442608d KY |
9135 | if (codec->revision_id == 0x100101) { |
9136 | spec->stream_name_analog = "ALC1200 Analog"; | |
9137 | spec->stream_name_digital = "ALC1200 Digital"; | |
9138 | } else { | |
9139 | spec->stream_name_analog = "ALC888 Analog"; | |
9140 | spec->stream_name_digital = "ALC888 Digital"; | |
9141 | } | |
61b9b9b1 HRK |
9142 | if (!spec->num_adc_nids) { |
9143 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
9144 | spec->adc_nids = alc883_adc_nids; | |
9145 | } | |
9146 | if (!spec->capsrc_nids) | |
9147 | spec->capsrc_nids = alc883_capsrc_nids; | |
9148 | spec->capture_style = CAPT_MIX; /* matrix-style capture */ | |
2f893286 KY |
9149 | break; |
9150 | case 0x10ec0889: | |
9151 | spec->stream_name_analog = "ALC889 Analog"; | |
9152 | spec->stream_name_digital = "ALC889 Digital"; | |
61b9b9b1 HRK |
9153 | if (!spec->num_adc_nids) { |
9154 | spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); | |
9155 | spec->adc_nids = alc889_adc_nids; | |
9156 | } | |
9157 | if (!spec->capsrc_nids) | |
9158 | spec->capsrc_nids = alc889_capsrc_nids; | |
9159 | spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style | |
9160 | capture */ | |
2f893286 KY |
9161 | break; |
9162 | default: | |
9163 | spec->stream_name_analog = "ALC883 Analog"; | |
9164 | spec->stream_name_digital = "ALC883 Digital"; | |
61b9b9b1 HRK |
9165 | if (!spec->num_adc_nids) { |
9166 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
9167 | spec->adc_nids = alc883_adc_nids; | |
9168 | } | |
9169 | if (!spec->capsrc_nids) | |
9170 | spec->capsrc_nids = alc883_capsrc_nids; | |
9171 | spec->capture_style = CAPT_MIX; /* matrix-style capture */ | |
2f893286 KY |
9172 | break; |
9173 | } | |
9174 | ||
9c7f852e TI |
9175 | spec->stream_analog_playback = &alc883_pcm_analog_playback; |
9176 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6330079f | 9177 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; |
9c7f852e | 9178 | |
9c7f852e TI |
9179 | spec->stream_digital_playback = &alc883_pcm_digital_playback; |
9180 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
9181 | ||
f9e336f6 TI |
9182 | if (!spec->cap_mixer) |
9183 | set_capture_mixer(spec); | |
45bdd1c1 | 9184 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
9c7f852e | 9185 | |
2134ea4f TI |
9186 | spec->vmaster_nid = 0x0c; |
9187 | ||
9c7f852e TI |
9188 | codec->patch_ops = alc_patch_ops; |
9189 | if (board_config == ALC883_AUTO) | |
9190 | spec->init_hook = alc883_auto_init; | |
f9423e7a | 9191 | |
cb53c626 TI |
9192 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9193 | if (!spec->loopback.amplist) | |
9194 | spec->loopback.amplist = alc883_loopbacks; | |
9195 | #endif | |
daead538 | 9196 | codec->proc_widget_hook = print_realtek_coef; |
9c7f852e TI |
9197 | |
9198 | return 0; | |
9199 | } | |
9200 | ||
9201 | /* | |
9202 | * ALC262 support | |
9203 | */ | |
9204 | ||
9205 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
9206 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
9207 | ||
9208 | #define alc262_dac_nids alc260_dac_nids | |
9209 | #define alc262_adc_nids alc882_adc_nids | |
9210 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
88c71a99 TI |
9211 | #define alc262_capsrc_nids alc882_capsrc_nids |
9212 | #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt | |
9c7f852e TI |
9213 | |
9214 | #define alc262_modes alc260_modes | |
9215 | #define alc262_capture_source alc882_capture_source | |
9216 | ||
4e555fe5 KY |
9217 | static hda_nid_t alc262_dmic_adc_nids[1] = { |
9218 | /* ADC0 */ | |
9219 | 0x09 | |
9220 | }; | |
9221 | ||
9222 | static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 }; | |
9223 | ||
9c7f852e TI |
9224 | static struct snd_kcontrol_new alc262_base_mixer[] = { |
9225 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9226 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9227 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9228 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9229 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9230 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9231 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9232 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9233 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
9234 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9235 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9236 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
9237 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
9238 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9239 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
9240 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
9241 | { } /* end */ | |
9242 | }; | |
9243 | ||
ccc656ce KY |
9244 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
9245 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9246 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9247 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9248 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9249 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9250 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9251 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9252 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9253 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
9254 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9255 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9256 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce KY |
9257 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ |
9258 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9259 | { } /* end */ | |
9260 | }; | |
9261 | ||
ce875f07 TI |
9262 | /* update HP, line and mono-out pins according to the master switch */ |
9263 | static void alc262_hp_master_update(struct hda_codec *codec) | |
9264 | { | |
9265 | struct alc_spec *spec = codec->spec; | |
9266 | int val = spec->master_sw; | |
9267 | ||
9268 | /* HP & line-out */ | |
9269 | snd_hda_codec_write_cache(codec, 0x1b, 0, | |
9270 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9271 | val ? PIN_HP : 0); | |
9272 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
9273 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9274 | val ? PIN_HP : 0); | |
9275 | /* mono (speaker) depending on the HP jack sense */ | |
9276 | val = val && !spec->jack_present; | |
9277 | snd_hda_codec_write_cache(codec, 0x16, 0, | |
9278 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9279 | val ? PIN_OUT : 0); | |
9280 | } | |
9281 | ||
9282 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | |
9283 | { | |
9284 | struct alc_spec *spec = codec->spec; | |
9285 | unsigned int presence; | |
9286 | presence = snd_hda_codec_read(codec, 0x1b, 0, | |
9287 | AC_VERB_GET_PIN_SENSE, 0); | |
9288 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
9289 | alc262_hp_master_update(codec); | |
9290 | } | |
9291 | ||
9292 | static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |
9293 | { | |
9294 | if ((res >> 26) != ALC880_HP_EVENT) | |
9295 | return; | |
9296 | alc262_hp_bpc_automute(codec); | |
9297 | } | |
9298 | ||
9299 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | |
9300 | { | |
9301 | struct alc_spec *spec = codec->spec; | |
9302 | unsigned int presence; | |
9303 | presence = snd_hda_codec_read(codec, 0x15, 0, | |
9304 | AC_VERB_GET_PIN_SENSE, 0); | |
9305 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
9306 | alc262_hp_master_update(codec); | |
9307 | } | |
9308 | ||
9309 | static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, | |
9310 | unsigned int res) | |
9311 | { | |
9312 | if ((res >> 26) != ALC880_HP_EVENT) | |
9313 | return; | |
9314 | alc262_hp_wildwest_automute(codec); | |
9315 | } | |
9316 | ||
9317 | static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
9318 | struct snd_ctl_elem_value *ucontrol) | |
9319 | { | |
9320 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9321 | struct alc_spec *spec = codec->spec; | |
9322 | *ucontrol->value.integer.value = spec->master_sw; | |
9323 | return 0; | |
9324 | } | |
9325 | ||
9326 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
9327 | struct snd_ctl_elem_value *ucontrol) | |
9328 | { | |
9329 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9330 | struct alc_spec *spec = codec->spec; | |
9331 | int val = !!*ucontrol->value.integer.value; | |
9332 | ||
9333 | if (val == spec->master_sw) | |
9334 | return 0; | |
9335 | spec->master_sw = val; | |
9336 | alc262_hp_master_update(codec); | |
9337 | return 1; | |
9338 | } | |
9339 | ||
9c7f852e | 9340 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
ce875f07 TI |
9341 | { |
9342 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9343 | .name = "Master Playback Switch", | |
9344 | .info = snd_ctl_boolean_mono_info, | |
9345 | .get = alc262_hp_master_sw_get, | |
9346 | .put = alc262_hp_master_sw_put, | |
9347 | }, | |
9c7f852e TI |
9348 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9349 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9350 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
9351 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
9352 | HDA_OUTPUT), | |
9353 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
9354 | HDA_OUTPUT), | |
9c7f852e TI |
9355 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9356 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9357 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
9358 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9359 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9360 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
9361 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
9362 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9363 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9364 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9c7f852e TI |
9365 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), |
9366 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
9367 | { } /* end */ | |
9368 | }; | |
9369 | ||
cd7509a4 | 9370 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
ce875f07 TI |
9371 | { |
9372 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9373 | .name = "Master Playback Switch", | |
9374 | .info = snd_ctl_boolean_mono_info, | |
9375 | .get = alc262_hp_master_sw_get, | |
9376 | .put = alc262_hp_master_sw_put, | |
9377 | }, | |
cd7509a4 KY |
9378 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9379 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9380 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9381 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
9382 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
9383 | HDA_OUTPUT), | |
9384 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
9385 | HDA_OUTPUT), | |
cd7509a4 KY |
9386 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), |
9387 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 9388 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
9389 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9390 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9391 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9392 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
cd7509a4 KY |
9393 | { } /* end */ |
9394 | }; | |
9395 | ||
9396 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
9397 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9398 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9399 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
9400 | { } /* end */ |
9401 | }; | |
9402 | ||
66d2a9d6 KY |
9403 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9404 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | |
9405 | { | |
9406 | struct alc_spec *spec = codec->spec; | |
66d2a9d6 KY |
9407 | |
9408 | if (force || !spec->sense_updated) { | |
9409 | unsigned int present; | |
9410 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9411 | AC_VERB_GET_PIN_SENSE, 0); | |
4bb26130 | 9412 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
66d2a9d6 KY |
9413 | spec->sense_updated = 1; |
9414 | } | |
4bb26130 TI |
9415 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
9416 | spec->jack_present ? HDA_AMP_MUTE : 0); | |
66d2a9d6 KY |
9417 | } |
9418 | ||
9419 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | |
9420 | unsigned int res) | |
9421 | { | |
9422 | if ((res >> 26) != ALC880_HP_EVENT) | |
9423 | return; | |
9424 | alc262_hp_t5735_automute(codec, 1); | |
9425 | } | |
9426 | ||
9427 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | |
9428 | { | |
9429 | alc262_hp_t5735_automute(codec, 1); | |
9430 | } | |
9431 | ||
9432 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | |
86cd9298 TI |
9433 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9434 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
66d2a9d6 KY |
9435 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
9436 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9437 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9438 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9439 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9440 | { } /* end */ | |
9441 | }; | |
9442 | ||
9443 | static struct hda_verb alc262_hp_t5735_verbs[] = { | |
9444 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9445 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9446 | ||
9447 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
9448 | { } | |
9449 | }; | |
9450 | ||
8c427226 | 9451 | static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { |
f2f48e18 TI |
9452 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9453 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
9454 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
9455 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
8c427226 KY |
9456 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9457 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9458 | { } /* end */ | |
9459 | }; | |
9460 | ||
9461 | static struct hda_verb alc262_hp_rp5700_verbs[] = { | |
9462 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9463 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9464 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9465 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9466 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9467 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9468 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9469 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9470 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9471 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9472 | {} | |
9473 | }; | |
9474 | ||
9475 | static struct hda_input_mux alc262_hp_rp5700_capture_source = { | |
9476 | .num_items = 1, | |
9477 | .items = { | |
9478 | { "Line", 0x1 }, | |
9479 | }, | |
9480 | }; | |
9481 | ||
0724ea2a TI |
9482 | /* bind hp and internal speaker mute (with plug check) */ |
9483 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | |
9484 | struct snd_ctl_elem_value *ucontrol) | |
9485 | { | |
9486 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9487 | long *valp = ucontrol->value.integer.value; | |
9488 | int change; | |
9489 | ||
9490 | /* change hp mute */ | |
9491 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
9492 | HDA_AMP_MUTE, | |
9493 | valp[0] ? 0 : HDA_AMP_MUTE); | |
9494 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
9495 | HDA_AMP_MUTE, | |
9496 | valp[1] ? 0 : HDA_AMP_MUTE); | |
9497 | if (change) { | |
9498 | /* change speaker according to HP jack state */ | |
9499 | struct alc_spec *spec = codec->spec; | |
9500 | unsigned int mute; | |
9501 | if (spec->jack_present) | |
9502 | mute = HDA_AMP_MUTE; | |
9503 | else | |
9504 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | |
9505 | HDA_OUTPUT, 0); | |
9506 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9507 | HDA_AMP_MUTE, mute); | |
9508 | } | |
9509 | return change; | |
9510 | } | |
5b31954e | 9511 | |
272a527c | 9512 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
0724ea2a TI |
9513 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9514 | { | |
9515 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9516 | .name = "Master Playback Switch", | |
9517 | .info = snd_hda_mixer_amp_switch_info, | |
9518 | .get = snd_hda_mixer_amp_switch_get, | |
9519 | .put = alc262_sony_master_sw_put, | |
9520 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
9521 | }, | |
272a527c KY |
9522 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9523 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9524 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9525 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9526 | { } /* end */ | |
9527 | }; | |
9528 | ||
83c34218 KY |
9529 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
9530 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9531 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9532 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9533 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9534 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9535 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9536 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9537 | { } /* end */ | |
9538 | }; | |
272a527c | 9539 | |
ba340e82 TV |
9540 | static struct snd_kcontrol_new alc262_tyan_mixer[] = { |
9541 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9542 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
9543 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
9544 | HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
9545 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9546 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9547 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9548 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9549 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9550 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9551 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9552 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
9553 | { } /* end */ | |
9554 | }; | |
9555 | ||
9556 | static struct hda_verb alc262_tyan_verbs[] = { | |
9557 | /* Headphone automute */ | |
9558 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9559 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9560 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9561 | ||
9562 | /* P11 AUX_IN, white 4-pin connector */ | |
9563 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9564 | {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1}, | |
9565 | {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93}, | |
9566 | {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19}, | |
9567 | ||
9568 | {} | |
9569 | }; | |
9570 | ||
9571 | /* unsolicited event for HP jack sensing */ | |
9572 | static void alc262_tyan_automute(struct hda_codec *codec) | |
9573 | { | |
9574 | unsigned int mute; | |
9575 | unsigned int present; | |
9576 | ||
9577 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9578 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
9579 | AC_VERB_GET_PIN_SENSE, 0); | |
9580 | present = (present & 0x80000000) != 0; | |
9581 | if (present) { | |
9582 | /* mute line output on ATX panel */ | |
9583 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
9584 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9585 | } else { | |
9586 | /* unmute line output if necessary */ | |
9587 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
9588 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
9589 | HDA_AMP_MUTE, mute); | |
9590 | } | |
9591 | } | |
9592 | ||
9593 | static void alc262_tyan_unsol_event(struct hda_codec *codec, | |
9594 | unsigned int res) | |
9595 | { | |
9596 | if ((res >> 26) != ALC880_HP_EVENT) | |
9597 | return; | |
9598 | alc262_tyan_automute(codec); | |
9599 | } | |
9600 | ||
9c7f852e TI |
9601 | #define alc262_capture_mixer alc882_capture_mixer |
9602 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
9603 | ||
9604 | /* | |
9605 | * generic initialization of ADC, input mixers and output mixers | |
9606 | */ | |
9607 | static struct hda_verb alc262_init_verbs[] = { | |
9608 | /* | |
9609 | * Unmute ADC0-2 and set the default input to mic-in | |
9610 | */ | |
9611 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9612 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9613 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9614 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9615 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9616 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9617 | ||
cb53c626 | 9618 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 9619 | * mixer widget |
f12ab1e0 TI |
9620 | * Note: PASD motherboards uses the Line In 2 as the input for |
9621 | * front panel mic (mic 2) | |
9c7f852e TI |
9622 | */ |
9623 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9624 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9625 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9626 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9627 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9628 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
9629 | |
9630 | /* | |
df694daa KY |
9631 | * Set up output mixers (0x0c - 0x0e) |
9632 | */ | |
9633 | /* set vol=0 to output mixers */ | |
9634 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9635 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9636 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9637 | /* set up input amps for analog loopback */ | |
9638 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9639 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9640 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9641 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9642 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9643 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9644 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9645 | ||
9646 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9647 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9648 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9649 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9650 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9651 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9652 | ||
9653 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9654 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9655 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9656 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9657 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
ea1fb29a | 9658 | |
df694daa KY |
9659 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9660 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
ea1fb29a | 9661 | |
df694daa KY |
9662 | /* FIXME: use matrix-type input source selection */ |
9663 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9664 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9665 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9666 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9667 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9668 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9669 | /* Input mixer2 */ | |
9670 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9671 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9672 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9673 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9674 | /* Input mixer3 */ | |
9675 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9676 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9677 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 9678 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
9679 | |
9680 | { } | |
9681 | }; | |
1da177e4 | 9682 | |
4e555fe5 KY |
9683 | static struct hda_verb alc262_eapd_verbs[] = { |
9684 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9685 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9686 | { } | |
9687 | }; | |
9688 | ||
ccc656ce KY |
9689 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
9690 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9691 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9692 | {} | |
9693 | }; | |
9694 | ||
9695 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
9696 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9697 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9698 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9699 | ||
9700 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9701 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9702 | {} | |
9703 | }; | |
9704 | ||
272a527c KY |
9705 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
9706 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9707 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9708 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
9709 | ||
9710 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9711 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7b1e8795 | 9712 | {} |
272a527c KY |
9713 | }; |
9714 | ||
4e555fe5 KY |
9715 | static struct hda_input_mux alc262_dmic_capture_source = { |
9716 | .num_items = 2, | |
9717 | .items = { | |
9718 | { "Int DMic", 0x9 }, | |
9719 | { "Mic", 0x0 }, | |
9720 | }, | |
9721 | }; | |
9722 | ||
9723 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { | |
9724 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9725 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9726 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9727 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9728 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4e555fe5 KY |
9729 | { } /* end */ |
9730 | }; | |
9731 | ||
9732 | static struct hda_verb alc262_toshiba_s06_verbs[] = { | |
9733 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9734 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9735 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9736 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9737 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x09}, | |
9738 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9739 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
9740 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9741 | {} | |
9742 | }; | |
9743 | ||
9744 | static void alc262_dmic_automute(struct hda_codec *codec) | |
9745 | { | |
9746 | unsigned int present; | |
9747 | ||
9748 | present = snd_hda_codec_read(codec, 0x18, 0, | |
9749 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9750 | snd_hda_codec_write(codec, 0x22, 0, | |
9751 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | |
9752 | } | |
9753 | ||
9754 | /* toggle speaker-output according to the hp-jack state */ | |
9755 | static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec) | |
9756 | { | |
9757 | unsigned int present; | |
9758 | unsigned char bits; | |
9759 | ||
9760 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9761 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9762 | bits = present ? 0 : PIN_OUT; | |
9763 | snd_hda_codec_write(codec, 0x14, 0, | |
9764 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
9765 | } | |
9766 | ||
9767 | ||
9768 | ||
9769 | /* unsolicited event for HP jack sensing */ | |
9770 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | |
9771 | unsigned int res) | |
9772 | { | |
9773 | if ((res >> 26) == ALC880_HP_EVENT) | |
9774 | alc262_toshiba_s06_speaker_automute(codec); | |
9775 | if ((res >> 26) == ALC880_MIC_EVENT) | |
9776 | alc262_dmic_automute(codec); | |
9777 | ||
9778 | } | |
9779 | ||
9780 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | |
9781 | { | |
9782 | alc262_toshiba_s06_speaker_automute(codec); | |
9783 | alc262_dmic_automute(codec); | |
9784 | } | |
9785 | ||
ccc656ce | 9786 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 9787 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
9788 | { |
9789 | struct alc_spec *spec = codec->spec; | |
9790 | unsigned int mute; | |
5b31954e | 9791 | unsigned int present; |
ccc656ce | 9792 | |
5b31954e TI |
9793 | /* need to execute and sync at first */ |
9794 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9795 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9796 | AC_VERB_GET_PIN_SENSE, 0); | |
9797 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
9798 | if (spec->jack_present) { |
9799 | /* mute internal speaker */ | |
47fd830a TI |
9800 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9801 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9802 | } else { |
9803 | /* unmute internal speaker if necessary */ | |
9804 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9805 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9806 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9807 | } |
9808 | } | |
9809 | ||
9810 | /* unsolicited event for HP jack sensing */ | |
9811 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
9812 | unsigned int res) | |
9813 | { | |
9814 | if ((res >> 26) != ALC880_HP_EVENT) | |
9815 | return; | |
5b31954e | 9816 | alc262_hippo_automute(codec); |
ccc656ce KY |
9817 | } |
9818 | ||
5b31954e | 9819 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 9820 | { |
ccc656ce | 9821 | unsigned int mute; |
5b31954e | 9822 | unsigned int present; |
ccc656ce | 9823 | |
5b31954e TI |
9824 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
9825 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
9826 | AC_VERB_GET_PIN_SENSE, 0); | |
9827 | present = (present & 0x80000000) != 0; | |
9828 | if (present) { | |
ccc656ce | 9829 | /* mute internal speaker */ |
47fd830a TI |
9830 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9831 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9832 | } else { |
9833 | /* unmute internal speaker if necessary */ | |
9834 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9835 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9836 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9837 | } |
9838 | } | |
9839 | ||
9840 | /* unsolicited event for HP jack sensing */ | |
9841 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
9842 | unsigned int res) | |
9843 | { | |
9844 | if ((res >> 26) != ALC880_HP_EVENT) | |
9845 | return; | |
5b31954e | 9846 | alc262_hippo1_automute(codec); |
ccc656ce KY |
9847 | } |
9848 | ||
e8f9ae2a PT |
9849 | /* |
9850 | * nec model | |
9851 | * 0x15 = headphone | |
9852 | * 0x16 = internal speaker | |
9853 | * 0x18 = external mic | |
9854 | */ | |
9855 | ||
9856 | static struct snd_kcontrol_new alc262_nec_mixer[] = { | |
9857 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
9858 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT), | |
9859 | ||
9860 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9861 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9862 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9863 | ||
9864 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9865 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9866 | { } /* end */ | |
9867 | }; | |
9868 | ||
9869 | static struct hda_verb alc262_nec_verbs[] = { | |
9870 | /* Unmute Speaker */ | |
9871 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9872 | ||
9873 | /* Headphone */ | |
9874 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9875 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9876 | ||
9877 | /* External mic to headphone */ | |
9878 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9879 | /* External mic to speaker */ | |
9880 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9881 | {} | |
9882 | }; | |
9883 | ||
834be88d TI |
9884 | /* |
9885 | * fujitsu model | |
5d9fab2d TV |
9886 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker, |
9887 | * 0x1b = port replicator headphone out | |
834be88d TI |
9888 | */ |
9889 | ||
9890 | #define ALC_HP_EVENT 0x37 | |
9891 | ||
9892 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
9893 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9894 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5d9fab2d TV |
9895 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, |
9896 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
834be88d TI |
9897 | {} |
9898 | }; | |
9899 | ||
0e31daf7 J |
9900 | static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { |
9901 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9902 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9903 | {} | |
9904 | }; | |
9905 | ||
834be88d | 9906 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
39d3ed38 | 9907 | .num_items = 3, |
834be88d TI |
9908 | .items = { |
9909 | { "Mic", 0x0 }, | |
39d3ed38 | 9910 | { "Int Mic", 0x1 }, |
834be88d TI |
9911 | { "CD", 0x4 }, |
9912 | }, | |
9913 | }; | |
9914 | ||
9c7f852e TI |
9915 | static struct hda_input_mux alc262_HP_capture_source = { |
9916 | .num_items = 5, | |
9917 | .items = { | |
9918 | { "Mic", 0x0 }, | |
accbe498 | 9919 | { "Front Mic", 0x1 }, |
9c7f852e TI |
9920 | { "Line", 0x2 }, |
9921 | { "CD", 0x4 }, | |
9922 | { "AUX IN", 0x6 }, | |
9923 | }, | |
9924 | }; | |
9925 | ||
accbe498 | 9926 | static struct hda_input_mux alc262_HP_D7000_capture_source = { |
9927 | .num_items = 4, | |
9928 | .items = { | |
9929 | { "Mic", 0x0 }, | |
9930 | { "Front Mic", 0x2 }, | |
9931 | { "Line", 0x1 }, | |
9932 | { "CD", 0x4 }, | |
9933 | }, | |
9934 | }; | |
9935 | ||
ebc7a406 | 9936 | /* mute/unmute internal speaker according to the hp jacks and mute state */ |
834be88d TI |
9937 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
9938 | { | |
9939 | struct alc_spec *spec = codec->spec; | |
9940 | unsigned int mute; | |
9941 | ||
f12ab1e0 | 9942 | if (force || !spec->sense_updated) { |
ebc7a406 | 9943 | unsigned int present; |
834be88d TI |
9944 | /* need to execute and sync at first */ |
9945 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
ebc7a406 TI |
9946 | /* check laptop HP jack */ |
9947 | present = snd_hda_codec_read(codec, 0x14, 0, | |
9948 | AC_VERB_GET_PIN_SENSE, 0); | |
9949 | /* need to execute and sync at first */ | |
9950 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9951 | /* check docking HP jack */ | |
9952 | present |= snd_hda_codec_read(codec, 0x1b, 0, | |
9953 | AC_VERB_GET_PIN_SENSE, 0); | |
9954 | if (present & AC_PINSENSE_PRESENCE) | |
9955 | spec->jack_present = 1; | |
9956 | else | |
9957 | spec->jack_present = 0; | |
834be88d TI |
9958 | spec->sense_updated = 1; |
9959 | } | |
ebc7a406 TI |
9960 | /* unmute internal speaker only if both HPs are unplugged and |
9961 | * master switch is on | |
9962 | */ | |
9963 | if (spec->jack_present) | |
9964 | mute = HDA_AMP_MUTE; | |
9965 | else | |
834be88d | 9966 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
ebc7a406 TI |
9967 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
9968 | HDA_AMP_MUTE, mute); | |
834be88d TI |
9969 | } |
9970 | ||
9971 | /* unsolicited event for HP jack sensing */ | |
9972 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
9973 | unsigned int res) | |
9974 | { | |
9975 | if ((res >> 26) != ALC_HP_EVENT) | |
9976 | return; | |
9977 | alc262_fujitsu_automute(codec, 1); | |
9978 | } | |
9979 | ||
ebc7a406 TI |
9980 | static void alc262_fujitsu_init_hook(struct hda_codec *codec) |
9981 | { | |
9982 | alc262_fujitsu_automute(codec, 1); | |
9983 | } | |
9984 | ||
834be88d | 9985 | /* bind volumes of both NID 0x0c and 0x0d */ |
cca3b371 TI |
9986 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
9987 | .ops = &snd_hda_bind_vol, | |
9988 | .values = { | |
9989 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
9990 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
9991 | 0 | |
9992 | }, | |
9993 | }; | |
834be88d | 9994 | |
0e31daf7 J |
9995 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9996 | static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) | |
9997 | { | |
9998 | struct alc_spec *spec = codec->spec; | |
9999 | unsigned int mute; | |
10000 | ||
10001 | if (force || !spec->sense_updated) { | |
10002 | unsigned int present_int_hp; | |
10003 | /* need to execute and sync at first */ | |
10004 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
10005 | present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, | |
10006 | AC_VERB_GET_PIN_SENSE, 0); | |
10007 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | |
10008 | spec->sense_updated = 1; | |
10009 | } | |
10010 | if (spec->jack_present) { | |
10011 | /* mute internal speaker */ | |
10012 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10013 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
10014 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
10015 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
10016 | } else { | |
10017 | /* unmute internal speaker if necessary */ | |
10018 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
10019 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10020 | HDA_AMP_MUTE, mute); | |
10021 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
10022 | HDA_AMP_MUTE, mute); | |
10023 | } | |
10024 | } | |
10025 | ||
10026 | /* unsolicited event for HP jack sensing */ | |
10027 | static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, | |
10028 | unsigned int res) | |
10029 | { | |
10030 | if ((res >> 26) != ALC_HP_EVENT) | |
10031 | return; | |
10032 | alc262_lenovo_3000_automute(codec, 1); | |
10033 | } | |
10034 | ||
834be88d TI |
10035 | /* bind hp and internal speaker mute (with plug check) */ |
10036 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
10037 | struct snd_ctl_elem_value *ucontrol) | |
10038 | { | |
10039 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10040 | long *valp = ucontrol->value.integer.value; | |
10041 | int change; | |
10042 | ||
5d9fab2d TV |
10043 | change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
10044 | HDA_AMP_MUTE, | |
10045 | valp ? 0 : HDA_AMP_MUTE); | |
10046 | change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
10047 | HDA_AMP_MUTE, | |
10048 | valp ? 0 : HDA_AMP_MUTE); | |
10049 | ||
82beb8fd TI |
10050 | if (change) |
10051 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
10052 | return change; |
10053 | } | |
10054 | ||
10055 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 10056 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
10057 | { |
10058 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10059 | .name = "Master Playback Switch", | |
10060 | .info = snd_hda_mixer_amp_switch_info, | |
10061 | .get = snd_hda_mixer_amp_switch_get, | |
10062 | .put = alc262_fujitsu_master_sw_put, | |
10063 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
10064 | }, | |
10065 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10066 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10067 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10068 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10069 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
39d3ed38 TI |
10070 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), |
10071 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10072 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
834be88d TI |
10073 | { } /* end */ |
10074 | }; | |
10075 | ||
0e31daf7 J |
10076 | /* bind hp and internal speaker mute (with plug check) */ |
10077 | static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, | |
10078 | struct snd_ctl_elem_value *ucontrol) | |
10079 | { | |
10080 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10081 | long *valp = ucontrol->value.integer.value; | |
10082 | int change; | |
10083 | ||
10084 | change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
10085 | HDA_AMP_MUTE, | |
10086 | valp ? 0 : HDA_AMP_MUTE); | |
10087 | ||
10088 | if (change) | |
10089 | alc262_lenovo_3000_automute(codec, 0); | |
10090 | return change; | |
10091 | } | |
10092 | ||
10093 | static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { | |
10094 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
10095 | { | |
10096 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10097 | .name = "Master Playback Switch", | |
10098 | .info = snd_hda_mixer_amp_switch_info, | |
10099 | .get = snd_hda_mixer_amp_switch_get, | |
10100 | .put = alc262_lenovo_3000_master_sw_put, | |
10101 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
10102 | }, | |
10103 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10104 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10105 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10106 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10107 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10108 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
10109 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10110 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10111 | { } /* end */ | |
10112 | }; | |
10113 | ||
9f99a638 HM |
10114 | static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = { |
10115 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
10116 | { | |
10117 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10118 | .name = "Master Playback Switch", | |
10119 | .info = snd_hda_mixer_amp_switch_info, | |
10120 | .get = snd_hda_mixer_amp_switch_get, | |
10121 | .put = alc262_sony_master_sw_put, | |
10122 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
10123 | }, | |
10124 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10125 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10126 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10127 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
10128 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
10129 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10130 | { } /* end */ | |
10131 | }; | |
10132 | ||
304dcaac TI |
10133 | /* additional init verbs for Benq laptops */ |
10134 | static struct hda_verb alc262_EAPD_verbs[] = { | |
10135 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
10136 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
10137 | {} | |
10138 | }; | |
10139 | ||
83c34218 KY |
10140 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
10141 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10142 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10143 | ||
10144 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
10145 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
10146 | {} | |
10147 | }; | |
10148 | ||
f651b50b TD |
10149 | /* Samsung Q1 Ultra Vista model setup */ |
10150 | static struct snd_kcontrol_new alc262_ultra_mixer[] = { | |
bb9f76cd TI |
10151 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
10152 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
f651b50b TD |
10153 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
10154 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
10155 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
bb9f76cd | 10156 | HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT), |
f651b50b TD |
10157 | { } /* end */ |
10158 | }; | |
10159 | ||
10160 | static struct hda_verb alc262_ultra_verbs[] = { | |
bb9f76cd TI |
10161 | /* output mixer */ |
10162 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10163 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10164 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10165 | /* speaker */ | |
10166 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10167 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10168 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10169 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10170 | /* HP */ | |
f651b50b | 10171 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
bb9f76cd TI |
10172 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
10173 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10174 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10175 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10176 | /* internal mic */ | |
10177 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10178 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10179 | /* ADC, choose mic */ | |
10180 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10181 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10182 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10183 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10184 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10185 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10186 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10187 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
10188 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
10189 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)}, | |
f651b50b TD |
10190 | {} |
10191 | }; | |
10192 | ||
f651b50b TD |
10193 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
10194 | static void alc262_ultra_automute(struct hda_codec *codec) | |
10195 | { | |
10196 | struct alc_spec *spec = codec->spec; | |
10197 | unsigned int mute; | |
f651b50b | 10198 | |
bb9f76cd TI |
10199 | mute = 0; |
10200 | /* auto-mute only when HP is used as HP */ | |
10201 | if (!spec->cur_mux[0]) { | |
10202 | unsigned int present; | |
10203 | /* need to execute and sync at first */ | |
10204 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
10205 | present = snd_hda_codec_read(codec, 0x15, 0, | |
10206 | AC_VERB_GET_PIN_SENSE, 0); | |
10207 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
10208 | if (spec->jack_present) | |
10209 | mute = HDA_AMP_MUTE; | |
f651b50b | 10210 | } |
bb9f76cd TI |
10211 | /* mute/unmute internal speaker */ |
10212 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10213 | HDA_AMP_MUTE, mute); | |
10214 | /* mute/unmute HP */ | |
10215 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
10216 | HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE); | |
f651b50b TD |
10217 | } |
10218 | ||
10219 | /* unsolicited event for HP jack sensing */ | |
10220 | static void alc262_ultra_unsol_event(struct hda_codec *codec, | |
10221 | unsigned int res) | |
10222 | { | |
10223 | if ((res >> 26) != ALC880_HP_EVENT) | |
10224 | return; | |
10225 | alc262_ultra_automute(codec); | |
10226 | } | |
10227 | ||
bb9f76cd TI |
10228 | static struct hda_input_mux alc262_ultra_capture_source = { |
10229 | .num_items = 2, | |
10230 | .items = { | |
10231 | { "Mic", 0x1 }, | |
10232 | { "Headphone", 0x7 }, | |
10233 | }, | |
10234 | }; | |
10235 | ||
10236 | static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol, | |
10237 | struct snd_ctl_elem_value *ucontrol) | |
10238 | { | |
10239 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10240 | struct alc_spec *spec = codec->spec; | |
10241 | int ret; | |
10242 | ||
54cbc9ab | 10243 | ret = alc_mux_enum_put(kcontrol, ucontrol); |
bb9f76cd TI |
10244 | if (!ret) |
10245 | return 0; | |
10246 | /* reprogram the HP pin as mic or HP according to the input source */ | |
10247 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
10248 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10249 | spec->cur_mux[0] ? PIN_VREF80 : PIN_HP); | |
10250 | alc262_ultra_automute(codec); /* mute/unmute HP */ | |
10251 | return ret; | |
10252 | } | |
10253 | ||
10254 | static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |
10255 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
10256 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
10257 | { | |
10258 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10259 | .name = "Capture Source", | |
54cbc9ab TI |
10260 | .info = alc_mux_enum_info, |
10261 | .get = alc_mux_enum_get, | |
bb9f76cd TI |
10262 | .put = alc262_ultra_mux_enum_put, |
10263 | }, | |
10264 | { } /* end */ | |
10265 | }; | |
10266 | ||
df694daa | 10267 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
10268 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
10269 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
10270 | { |
10271 | hda_nid_t nid; | |
10272 | int err; | |
10273 | ||
10274 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
10275 | spec->multiout.dac_nids = spec->private_dac_nids; | |
10276 | spec->multiout.dac_nids[0] = 2; | |
10277 | ||
10278 | nid = cfg->line_out_pins[0]; | |
10279 | if (nid) { | |
f12ab1e0 TI |
10280 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10281 | "Front Playback Volume", | |
10282 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
10283 | if (err < 0) | |
df694daa | 10284 | return err; |
f12ab1e0 TI |
10285 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10286 | "Front Playback Switch", | |
10287 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
10288 | if (err < 0) | |
df694daa KY |
10289 | return err; |
10290 | } | |
10291 | ||
82bc955f | 10292 | nid = cfg->speaker_pins[0]; |
df694daa KY |
10293 | if (nid) { |
10294 | if (nid == 0x16) { | |
f12ab1e0 TI |
10295 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10296 | "Speaker Playback Volume", | |
10297 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
10298 | HDA_OUTPUT)); | |
10299 | if (err < 0) | |
df694daa | 10300 | return err; |
f12ab1e0 TI |
10301 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10302 | "Speaker Playback Switch", | |
10303 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10304 | HDA_OUTPUT)); | |
10305 | if (err < 0) | |
df694daa KY |
10306 | return err; |
10307 | } else { | |
f12ab1e0 TI |
10308 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10309 | "Speaker Playback Switch", | |
10310 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10311 | HDA_OUTPUT)); | |
10312 | if (err < 0) | |
df694daa KY |
10313 | return err; |
10314 | } | |
10315 | } | |
eb06ed8f | 10316 | nid = cfg->hp_pins[0]; |
df694daa KY |
10317 | if (nid) { |
10318 | /* spec->multiout.hp_nid = 2; */ | |
10319 | if (nid == 0x16) { | |
f12ab1e0 TI |
10320 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10321 | "Headphone Playback Volume", | |
10322 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
10323 | HDA_OUTPUT)); | |
10324 | if (err < 0) | |
df694daa | 10325 | return err; |
f12ab1e0 TI |
10326 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10327 | "Headphone Playback Switch", | |
10328 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10329 | HDA_OUTPUT)); | |
10330 | if (err < 0) | |
df694daa KY |
10331 | return err; |
10332 | } else { | |
f12ab1e0 TI |
10333 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10334 | "Headphone Playback Switch", | |
10335 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10336 | HDA_OUTPUT)); | |
10337 | if (err < 0) | |
df694daa KY |
10338 | return err; |
10339 | } | |
10340 | } | |
f12ab1e0 | 10341 | return 0; |
df694daa KY |
10342 | } |
10343 | ||
10344 | /* identical with ALC880 */ | |
f12ab1e0 TI |
10345 | #define alc262_auto_create_analog_input_ctls \ |
10346 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
10347 | |
10348 | /* | |
10349 | * generic initialization of ADC, input mixers and output mixers | |
10350 | */ | |
10351 | static struct hda_verb alc262_volume_init_verbs[] = { | |
10352 | /* | |
10353 | * Unmute ADC0-2 and set the default input to mic-in | |
10354 | */ | |
10355 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10356 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10357 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10358 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10359 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10360 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10361 | ||
cb53c626 | 10362 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 10363 | * mixer widget |
f12ab1e0 TI |
10364 | * Note: PASD motherboards uses the Line In 2 as the input for |
10365 | * front panel mic (mic 2) | |
df694daa KY |
10366 | */ |
10367 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10368 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10369 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10370 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10371 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10372 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
10373 | |
10374 | /* | |
10375 | * Set up output mixers (0x0c - 0x0f) | |
10376 | */ | |
10377 | /* set vol=0 to output mixers */ | |
10378 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10379 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10380 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
ea1fb29a | 10381 | |
df694daa KY |
10382 | /* set up input amps for analog loopback */ |
10383 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10384 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10385 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10386 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10387 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10388 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10389 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10390 | ||
10391 | /* FIXME: use matrix-type input source selection */ | |
10392 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10393 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10394 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10395 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10396 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10397 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10398 | /* Input mixer2 */ | |
10399 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10400 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10401 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10402 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10403 | /* Input mixer3 */ | |
10404 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10405 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10406 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10407 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10408 | ||
10409 | { } | |
10410 | }; | |
10411 | ||
9c7f852e TI |
10412 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
10413 | /* | |
10414 | * Unmute ADC0-2 and set the default input to mic-in | |
10415 | */ | |
10416 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10417 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10418 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10419 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10420 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10421 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10422 | ||
cb53c626 | 10423 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 10424 | * mixer widget |
f12ab1e0 TI |
10425 | * Note: PASD motherboards uses the Line In 2 as the input for |
10426 | * front panel mic (mic 2) | |
9c7f852e TI |
10427 | */ |
10428 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10429 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10430 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10431 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10432 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10433 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10434 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10435 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
ea1fb29a | 10436 | |
9c7f852e TI |
10437 | /* |
10438 | * Set up output mixers (0x0c - 0x0e) | |
10439 | */ | |
10440 | /* set vol=0 to output mixers */ | |
10441 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10442 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10443 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10444 | ||
10445 | /* set up input amps for analog loopback */ | |
10446 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10447 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10448 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10449 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10450 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10451 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10452 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10453 | ||
ce875f07 | 10454 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
9c7f852e TI |
10455 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
10456 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10457 | ||
10458 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10459 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10460 | ||
10461 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10462 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10463 | ||
10464 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10465 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10466 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10467 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10468 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10469 | ||
10470 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10471 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10472 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10473 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10474 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10475 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10476 | ||
10477 | ||
10478 | /* FIXME: use matrix-type input source selection */ | |
10479 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10480 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10481 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10482 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10483 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10484 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10485 | /* Input mixer2 */ | |
10486 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10487 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10488 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10489 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10490 | /* Input mixer3 */ | |
10491 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10492 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10493 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10494 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10495 | ||
ce875f07 TI |
10496 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10497 | ||
9c7f852e TI |
10498 | { } |
10499 | }; | |
10500 | ||
cd7509a4 KY |
10501 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
10502 | /* | |
10503 | * Unmute ADC0-2 and set the default input to mic-in | |
10504 | */ | |
10505 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10506 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10507 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10508 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10509 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10510 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10511 | ||
cb53c626 | 10512 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
10513 | * mixer widget |
10514 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
10515 | * panel mic (mic 2) | |
10516 | */ | |
10517 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10518 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10519 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10520 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10521 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10522 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10523 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10524 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
10525 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
10526 | /* |
10527 | * Set up output mixers (0x0c - 0x0e) | |
10528 | */ | |
10529 | /* set vol=0 to output mixers */ | |
10530 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10531 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10532 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10533 | ||
10534 | /* set up input amps for analog loopback */ | |
10535 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10536 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10537 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10538 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10539 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10540 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10541 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10542 | ||
10543 | ||
10544 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
10545 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
10546 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
10547 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
10548 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10549 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
10550 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
10551 | ||
10552 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10553 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10554 | ||
10555 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10556 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10557 | ||
10558 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
10559 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10560 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10561 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10562 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10563 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10564 | ||
10565 | /* FIXME: use matrix-type input source selection */ | |
10566 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10567 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10568 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
10569 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
10570 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
10571 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
10572 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
10573 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10574 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
10575 | /* Input mixer2 */ | |
10576 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10577 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10578 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10579 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10580 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10581 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10582 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10583 | /* Input mixer3 */ | |
10584 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10585 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10586 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10587 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10588 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10589 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10590 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10591 | ||
ce875f07 TI |
10592 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10593 | ||
cd7509a4 KY |
10594 | { } |
10595 | }; | |
10596 | ||
9f99a638 HM |
10597 | static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = { |
10598 | ||
10599 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */ | |
10600 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10601 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10602 | ||
10603 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */ | |
10604 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10605 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, | |
10606 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, | |
10607 | ||
10608 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */ | |
10609 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10610 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10611 | {} | |
10612 | }; | |
10613 | ||
10614 | ||
cb53c626 TI |
10615 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10616 | #define alc262_loopbacks alc880_loopbacks | |
10617 | #endif | |
10618 | ||
df694daa KY |
10619 | /* pcm configuration: identiacal with ALC880 */ |
10620 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
10621 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
10622 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
10623 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
10624 | ||
10625 | /* | |
10626 | * BIOS auto configuration | |
10627 | */ | |
10628 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
10629 | { | |
10630 | struct alc_spec *spec = codec->spec; | |
10631 | int err; | |
10632 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
10633 | ||
f12ab1e0 TI |
10634 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
10635 | alc262_ignore); | |
10636 | if (err < 0) | |
df694daa | 10637 | return err; |
e64f14f4 | 10638 | if (!spec->autocfg.line_outs) { |
0852d7a6 | 10639 | if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) { |
e64f14f4 TI |
10640 | spec->multiout.max_channels = 2; |
10641 | spec->no_analog = 1; | |
10642 | goto dig_only; | |
10643 | } | |
df694daa | 10644 | return 0; /* can't find valid BIOS pin config */ |
e64f14f4 | 10645 | } |
f12ab1e0 TI |
10646 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
10647 | if (err < 0) | |
10648 | return err; | |
10649 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10650 | if (err < 0) | |
df694daa KY |
10651 | return err; |
10652 | ||
10653 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
10654 | ||
e64f14f4 | 10655 | dig_only: |
0852d7a6 | 10656 | if (spec->autocfg.dig_outs) { |
df694daa | 10657 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; |
0852d7a6 | 10658 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
e64f14f4 | 10659 | } |
df694daa KY |
10660 | if (spec->autocfg.dig_in_pin) |
10661 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
10662 | ||
603c4019 | 10663 | if (spec->kctls.list) |
d88897ea | 10664 | add_mixer(spec, spec->kctls.list); |
df694daa | 10665 | |
d88897ea | 10666 | add_verb(spec, alc262_volume_init_verbs); |
a1e8d2da | 10667 | spec->num_mux_defs = 1; |
61b9b9b1 | 10668 | spec->input_mux = &spec->private_imux[0]; |
df694daa | 10669 | |
776e184e TI |
10670 | err = alc_auto_add_mic_boost(codec); |
10671 | if (err < 0) | |
10672 | return err; | |
10673 | ||
e044c39a | 10674 | store_pin_configs(codec); |
df694daa KY |
10675 | return 1; |
10676 | } | |
10677 | ||
10678 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
10679 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
10680 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
f511b01c | 10681 | #define alc262_auto_init_input_src alc882_auto_init_input_src |
df694daa KY |
10682 | |
10683 | ||
10684 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 10685 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 10686 | { |
f6c7e546 | 10687 | struct alc_spec *spec = codec->spec; |
df694daa KY |
10688 | alc262_auto_init_multi_out(codec); |
10689 | alc262_auto_init_hp_out(codec); | |
10690 | alc262_auto_init_analog_input(codec); | |
f511b01c | 10691 | alc262_auto_init_input_src(codec); |
f6c7e546 | 10692 | if (spec->unsol_event) |
7fb0d78f | 10693 | alc_inithook(codec); |
df694daa KY |
10694 | } |
10695 | ||
10696 | /* | |
10697 | * configuration and preset | |
10698 | */ | |
f5fcc13c TI |
10699 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
10700 | [ALC262_BASIC] = "basic", | |
10701 | [ALC262_HIPPO] = "hippo", | |
10702 | [ALC262_HIPPO_1] = "hippo_1", | |
10703 | [ALC262_FUJITSU] = "fujitsu", | |
10704 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 10705 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
61dc35de | 10706 | [ALC262_HP_TC_T5735] = "hp-tc-t5735", |
8c427226 | 10707 | [ALC262_HP_RP5700] = "hp-rp5700", |
f5fcc13c | 10708 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
10709 | [ALC262_BENQ_T31] = "benq-t31", |
10710 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
2922c9af | 10711 | [ALC262_TOSHIBA_S06] = "toshiba-s06", |
9f99a638 | 10712 | [ALC262_TOSHIBA_RX1] = "toshiba-rx1", |
f651b50b | 10713 | [ALC262_ULTRA] = "ultra", |
0e31daf7 | 10714 | [ALC262_LENOVO_3000] = "lenovo-3000", |
e8f9ae2a | 10715 | [ALC262_NEC] = "nec", |
ba340e82 | 10716 | [ALC262_TYAN] = "tyan", |
f5fcc13c TI |
10717 | [ALC262_AUTO] = "auto", |
10718 | }; | |
10719 | ||
10720 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
10721 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
e8f9ae2a | 10722 | SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), |
dea0a509 TI |
10723 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series", |
10724 | ALC262_HP_BPC), | |
10725 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series", | |
10726 | ALC262_HP_BPC), | |
cd7509a4 | 10727 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10728 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10729 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10730 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10731 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10732 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10733 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10734 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 TI |
10735 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), |
10736 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), | |
10737 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), | |
66d2a9d6 KY |
10738 | SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", |
10739 | ALC262_HP_TC_T5735), | |
8c427226 | 10740 | SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), |
ac3e3741 | 10741 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
f5fcc13c | 10742 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
5b31954e | 10743 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c | 10744 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
ac3e3741 | 10745 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
57a5ef48 TI |
10746 | SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN", |
10747 | ALC262_SONY_ASSAMD), | |
36ca6e13 | 10748 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
9f99a638 | 10749 | ALC262_TOSHIBA_RX1), |
80ffe869 | 10750 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), |
ac3e3741 | 10751 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), |
3f1eeaed | 10752 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), |
ba340e82 | 10753 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN), |
dea0a509 TI |
10754 | SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1", |
10755 | ALC262_ULTRA), | |
3e420e78 | 10756 | SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO), |
0e31daf7 | 10757 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), |
ac3e3741 TI |
10758 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), |
10759 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), | |
10760 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
df694daa KY |
10761 | {} |
10762 | }; | |
10763 | ||
10764 | static struct alc_config_preset alc262_presets[] = { | |
10765 | [ALC262_BASIC] = { | |
10766 | .mixers = { alc262_base_mixer }, | |
10767 | .init_verbs = { alc262_init_verbs }, | |
10768 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10769 | .dac_nids = alc262_dac_nids, | |
10770 | .hp_nid = 0x03, | |
10771 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10772 | .channel_mode = alc262_modes, | |
a3bcba38 | 10773 | .input_mux = &alc262_capture_source, |
df694daa | 10774 | }, |
ccc656ce KY |
10775 | [ALC262_HIPPO] = { |
10776 | .mixers = { alc262_base_mixer }, | |
10777 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
10778 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10779 | .dac_nids = alc262_dac_nids, | |
10780 | .hp_nid = 0x03, | |
10781 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10782 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10783 | .channel_mode = alc262_modes, | |
10784 | .input_mux = &alc262_capture_source, | |
10785 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10786 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
10787 | }, |
10788 | [ALC262_HIPPO_1] = { | |
10789 | .mixers = { alc262_hippo1_mixer }, | |
10790 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
10791 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10792 | .dac_nids = alc262_dac_nids, | |
10793 | .hp_nid = 0x02, | |
10794 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10795 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10796 | .channel_mode = alc262_modes, | |
10797 | .input_mux = &alc262_capture_source, | |
10798 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 10799 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 10800 | }, |
834be88d TI |
10801 | [ALC262_FUJITSU] = { |
10802 | .mixers = { alc262_fujitsu_mixer }, | |
39d3ed38 TI |
10803 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
10804 | alc262_fujitsu_unsol_verbs }, | |
834be88d TI |
10805 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10806 | .dac_nids = alc262_dac_nids, | |
10807 | .hp_nid = 0x03, | |
10808 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10809 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10810 | .channel_mode = alc262_modes, | |
10811 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 10812 | .unsol_event = alc262_fujitsu_unsol_event, |
ebc7a406 | 10813 | .init_hook = alc262_fujitsu_init_hook, |
834be88d | 10814 | }, |
9c7f852e TI |
10815 | [ALC262_HP_BPC] = { |
10816 | .mixers = { alc262_HP_BPC_mixer }, | |
10817 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
10818 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10819 | .dac_nids = alc262_dac_nids, | |
10820 | .hp_nid = 0x03, | |
10821 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10822 | .channel_mode = alc262_modes, | |
10823 | .input_mux = &alc262_HP_capture_source, | |
ce875f07 TI |
10824 | .unsol_event = alc262_hp_bpc_unsol_event, |
10825 | .init_hook = alc262_hp_bpc_automute, | |
f12ab1e0 | 10826 | }, |
cd7509a4 KY |
10827 | [ALC262_HP_BPC_D7000_WF] = { |
10828 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
10829 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10830 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10831 | .dac_nids = alc262_dac_nids, | |
10832 | .hp_nid = 0x03, | |
10833 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10834 | .channel_mode = alc262_modes, | |
accbe498 | 10835 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10836 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10837 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10838 | }, |
cd7509a4 KY |
10839 | [ALC262_HP_BPC_D7000_WL] = { |
10840 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
10841 | alc262_HP_BPC_WildWest_option_mixer }, | |
10842 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10843 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10844 | .dac_nids = alc262_dac_nids, | |
10845 | .hp_nid = 0x03, | |
10846 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10847 | .channel_mode = alc262_modes, | |
accbe498 | 10848 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10849 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10850 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10851 | }, |
66d2a9d6 KY |
10852 | [ALC262_HP_TC_T5735] = { |
10853 | .mixers = { alc262_hp_t5735_mixer }, | |
10854 | .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, | |
10855 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10856 | .dac_nids = alc262_dac_nids, | |
10857 | .hp_nid = 0x03, | |
10858 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10859 | .channel_mode = alc262_modes, | |
10860 | .input_mux = &alc262_capture_source, | |
10861 | .unsol_event = alc262_hp_t5735_unsol_event, | |
10862 | .init_hook = alc262_hp_t5735_init_hook, | |
8c427226 KY |
10863 | }, |
10864 | [ALC262_HP_RP5700] = { | |
10865 | .mixers = { alc262_hp_rp5700_mixer }, | |
10866 | .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, | |
10867 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10868 | .dac_nids = alc262_dac_nids, | |
10869 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10870 | .channel_mode = alc262_modes, | |
10871 | .input_mux = &alc262_hp_rp5700_capture_source, | |
66d2a9d6 | 10872 | }, |
304dcaac TI |
10873 | [ALC262_BENQ_ED8] = { |
10874 | .mixers = { alc262_base_mixer }, | |
10875 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
10876 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10877 | .dac_nids = alc262_dac_nids, | |
10878 | .hp_nid = 0x03, | |
10879 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10880 | .channel_mode = alc262_modes, | |
10881 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 10882 | }, |
272a527c KY |
10883 | [ALC262_SONY_ASSAMD] = { |
10884 | .mixers = { alc262_sony_mixer }, | |
10885 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
10886 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10887 | .dac_nids = alc262_dac_nids, | |
10888 | .hp_nid = 0x02, | |
10889 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10890 | .channel_mode = alc262_modes, | |
10891 | .input_mux = &alc262_capture_source, | |
10892 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10893 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
10894 | }, |
10895 | [ALC262_BENQ_T31] = { | |
10896 | .mixers = { alc262_benq_t31_mixer }, | |
10897 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
10898 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10899 | .dac_nids = alc262_dac_nids, | |
10900 | .hp_nid = 0x03, | |
10901 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10902 | .channel_mode = alc262_modes, | |
10903 | .input_mux = &alc262_capture_source, | |
10904 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10905 | .init_hook = alc262_hippo_automute, |
ea1fb29a | 10906 | }, |
f651b50b | 10907 | [ALC262_ULTRA] = { |
f9e336f6 TI |
10908 | .mixers = { alc262_ultra_mixer }, |
10909 | .cap_mixer = alc262_ultra_capture_mixer, | |
bb9f76cd | 10910 | .init_verbs = { alc262_ultra_verbs }, |
f651b50b TD |
10911 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10912 | .dac_nids = alc262_dac_nids, | |
f651b50b TD |
10913 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
10914 | .channel_mode = alc262_modes, | |
10915 | .input_mux = &alc262_ultra_capture_source, | |
bb9f76cd TI |
10916 | .adc_nids = alc262_adc_nids, /* ADC0 */ |
10917 | .capsrc_nids = alc262_capsrc_nids, | |
10918 | .num_adc_nids = 1, /* single ADC */ | |
f651b50b TD |
10919 | .unsol_event = alc262_ultra_unsol_event, |
10920 | .init_hook = alc262_ultra_automute, | |
10921 | }, | |
0e31daf7 J |
10922 | [ALC262_LENOVO_3000] = { |
10923 | .mixers = { alc262_lenovo_3000_mixer }, | |
10924 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, | |
10925 | alc262_lenovo_3000_unsol_verbs }, | |
10926 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10927 | .dac_nids = alc262_dac_nids, | |
10928 | .hp_nid = 0x03, | |
10929 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10930 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10931 | .channel_mode = alc262_modes, | |
10932 | .input_mux = &alc262_fujitsu_capture_source, | |
10933 | .unsol_event = alc262_lenovo_3000_unsol_event, | |
10934 | }, | |
e8f9ae2a PT |
10935 | [ALC262_NEC] = { |
10936 | .mixers = { alc262_nec_mixer }, | |
10937 | .init_verbs = { alc262_nec_verbs }, | |
10938 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10939 | .dac_nids = alc262_dac_nids, | |
10940 | .hp_nid = 0x03, | |
10941 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10942 | .channel_mode = alc262_modes, | |
10943 | .input_mux = &alc262_capture_source, | |
10944 | }, | |
4e555fe5 KY |
10945 | [ALC262_TOSHIBA_S06] = { |
10946 | .mixers = { alc262_toshiba_s06_mixer }, | |
10947 | .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs, | |
10948 | alc262_eapd_verbs }, | |
10949 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10950 | .capsrc_nids = alc262_dmic_capsrc_nids, | |
10951 | .dac_nids = alc262_dac_nids, | |
10952 | .adc_nids = alc262_dmic_adc_nids, /* ADC0 */ | |
10953 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10954 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10955 | .channel_mode = alc262_modes, | |
10956 | .input_mux = &alc262_dmic_capture_source, | |
10957 | .unsol_event = alc262_toshiba_s06_unsol_event, | |
10958 | .init_hook = alc262_toshiba_s06_init_hook, | |
10959 | }, | |
9f99a638 HM |
10960 | [ALC262_TOSHIBA_RX1] = { |
10961 | .mixers = { alc262_toshiba_rx1_mixer }, | |
10962 | .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs }, | |
10963 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10964 | .dac_nids = alc262_dac_nids, | |
10965 | .hp_nid = 0x03, | |
10966 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10967 | .channel_mode = alc262_modes, | |
10968 | .input_mux = &alc262_capture_source, | |
10969 | .unsol_event = alc262_hippo_unsol_event, | |
10970 | .init_hook = alc262_hippo_automute, | |
10971 | }, | |
ba340e82 TV |
10972 | [ALC262_TYAN] = { |
10973 | .mixers = { alc262_tyan_mixer }, | |
10974 | .init_verbs = { alc262_init_verbs, alc262_tyan_verbs}, | |
10975 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10976 | .dac_nids = alc262_dac_nids, | |
10977 | .hp_nid = 0x02, | |
10978 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10979 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10980 | .channel_mode = alc262_modes, | |
10981 | .input_mux = &alc262_capture_source, | |
10982 | .unsol_event = alc262_tyan_unsol_event, | |
10983 | .init_hook = alc262_tyan_automute, | |
10984 | }, | |
df694daa KY |
10985 | }; |
10986 | ||
10987 | static int patch_alc262(struct hda_codec *codec) | |
10988 | { | |
10989 | struct alc_spec *spec; | |
10990 | int board_config; | |
10991 | int err; | |
10992 | ||
dc041e0b | 10993 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
10994 | if (spec == NULL) |
10995 | return -ENOMEM; | |
10996 | ||
10997 | codec->spec = spec; | |
10998 | #if 0 | |
f12ab1e0 TI |
10999 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
11000 | * under-run | |
11001 | */ | |
df694daa KY |
11002 | { |
11003 | int tmp; | |
11004 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
11005 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
11006 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
11007 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
11008 | } | |
11009 | #endif | |
11010 | ||
2c3bf9ab TI |
11011 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
11012 | ||
f5fcc13c TI |
11013 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
11014 | alc262_models, | |
11015 | alc262_cfg_tbl); | |
cd7509a4 | 11016 | |
f5fcc13c | 11017 | if (board_config < 0) { |
9c7f852e TI |
11018 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
11019 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
11020 | board_config = ALC262_AUTO; |
11021 | } | |
11022 | ||
11023 | if (board_config == ALC262_AUTO) { | |
11024 | /* automatic parse from the BIOS config */ | |
11025 | err = alc262_parse_auto_config(codec); | |
11026 | if (err < 0) { | |
11027 | alc_free(codec); | |
11028 | return err; | |
f12ab1e0 | 11029 | } else if (!err) { |
9c7f852e TI |
11030 | printk(KERN_INFO |
11031 | "hda_codec: Cannot set up configuration " | |
11032 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
11033 | board_config = ALC262_BASIC; |
11034 | } | |
11035 | } | |
11036 | ||
680cd536 KK |
11037 | err = snd_hda_attach_beep_device(codec, 0x1); |
11038 | if (err < 0) { | |
11039 | alc_free(codec); | |
11040 | return err; | |
11041 | } | |
11042 | ||
df694daa KY |
11043 | if (board_config != ALC262_AUTO) |
11044 | setup_preset(spec, &alc262_presets[board_config]); | |
11045 | ||
11046 | spec->stream_name_analog = "ALC262 Analog"; | |
11047 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
11048 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
ea1fb29a | 11049 | |
df694daa KY |
11050 | spec->stream_name_digital = "ALC262 Digital"; |
11051 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
11052 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
11053 | ||
61b9b9b1 | 11054 | spec->capture_style = CAPT_MIX; |
f12ab1e0 | 11055 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 11056 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
11057 | unsigned int wcap = get_wcaps(codec, 0x07); |
11058 | ||
f12ab1e0 TI |
11059 | /* get type */ |
11060 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
11061 | if (wcap != AC_WID_AUD_IN) { |
11062 | spec->adc_nids = alc262_adc_nids_alt; | |
11063 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
88c71a99 | 11064 | spec->capsrc_nids = alc262_capsrc_nids_alt; |
df694daa KY |
11065 | } else { |
11066 | spec->adc_nids = alc262_adc_nids; | |
11067 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
88c71a99 | 11068 | spec->capsrc_nids = alc262_capsrc_nids; |
df694daa KY |
11069 | } |
11070 | } | |
e64f14f4 | 11071 | if (!spec->cap_mixer && !spec->no_analog) |
f9e336f6 | 11072 | set_capture_mixer(spec); |
45bdd1c1 | 11073 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
df694daa | 11074 | |
2134ea4f TI |
11075 | spec->vmaster_nid = 0x0c; |
11076 | ||
df694daa KY |
11077 | codec->patch_ops = alc_patch_ops; |
11078 | if (board_config == ALC262_AUTO) | |
ae6b813a | 11079 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
11080 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
11081 | if (!spec->loopback.amplist) | |
11082 | spec->loopback.amplist = alc262_loopbacks; | |
11083 | #endif | |
daead538 | 11084 | codec->proc_widget_hook = print_realtek_coef; |
ea1fb29a | 11085 | |
df694daa KY |
11086 | return 0; |
11087 | } | |
11088 | ||
a361d84b KY |
11089 | /* |
11090 | * ALC268 channel source setting (2 channel) | |
11091 | */ | |
11092 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
11093 | #define alc268_modes alc260_modes | |
ea1fb29a | 11094 | |
a361d84b KY |
11095 | static hda_nid_t alc268_dac_nids[2] = { |
11096 | /* front, hp */ | |
11097 | 0x02, 0x03 | |
11098 | }; | |
11099 | ||
11100 | static hda_nid_t alc268_adc_nids[2] = { | |
11101 | /* ADC0-1 */ | |
11102 | 0x08, 0x07 | |
11103 | }; | |
11104 | ||
11105 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
11106 | /* ADC0 */ | |
11107 | 0x08 | |
11108 | }; | |
11109 | ||
e1406348 TI |
11110 | static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 }; |
11111 | ||
a361d84b KY |
11112 | static struct snd_kcontrol_new alc268_base_mixer[] = { |
11113 | /* output mixer control */ | |
11114 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
11115 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11116 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
11117 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
11118 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
11119 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
11120 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
11121 | { } |
11122 | }; | |
11123 | ||
aef9d318 TI |
11124 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
11125 | static struct hda_bind_ctls alc268_bind_beep_sw = { | |
11126 | .ops = &snd_hda_bind_sw, | |
11127 | .values = { | |
11128 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), | |
11129 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), | |
11130 | 0 | |
11131 | }, | |
11132 | }; | |
11133 | ||
11134 | static struct snd_kcontrol_new alc268_beep_mixer[] = { | |
11135 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), | |
11136 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), | |
11137 | { } | |
11138 | }; | |
11139 | ||
d1a991a6 KY |
11140 | static struct hda_verb alc268_eapd_verbs[] = { |
11141 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11142 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11143 | { } | |
11144 | }; | |
11145 | ||
d273809e TI |
11146 | /* Toshiba specific */ |
11147 | #define alc268_toshiba_automute alc262_hippo_automute | |
11148 | ||
11149 | static struct hda_verb alc268_toshiba_verbs[] = { | |
11150 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11151 | { } /* end */ | |
11152 | }; | |
11153 | ||
8ef355da KY |
11154 | static struct hda_input_mux alc268_acer_lc_capture_source = { |
11155 | .num_items = 2, | |
11156 | .items = { | |
11157 | { "i-Mic", 0x6 }, | |
11158 | { "E-Mic", 0x0 }, | |
11159 | }, | |
11160 | }; | |
11161 | ||
d273809e | 11162 | /* Acer specific */ |
889c4395 | 11163 | /* bind volumes of both NID 0x02 and 0x03 */ |
6bc96857 TI |
11164 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
11165 | .ops = &snd_hda_bind_vol, | |
11166 | .values = { | |
11167 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
11168 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
11169 | 0 | |
11170 | }, | |
11171 | }; | |
11172 | ||
889c4395 TI |
11173 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
11174 | static void alc268_acer_automute(struct hda_codec *codec, int force) | |
11175 | { | |
11176 | struct alc_spec *spec = codec->spec; | |
11177 | unsigned int mute; | |
11178 | ||
11179 | if (force || !spec->sense_updated) { | |
11180 | unsigned int present; | |
11181 | present = snd_hda_codec_read(codec, 0x14, 0, | |
11182 | AC_VERB_GET_PIN_SENSE, 0); | |
11183 | spec->jack_present = (present & 0x80000000) != 0; | |
11184 | spec->sense_updated = 1; | |
11185 | } | |
11186 | if (spec->jack_present) | |
11187 | mute = HDA_AMP_MUTE; /* mute internal speaker */ | |
11188 | else /* unmute internal speaker if necessary */ | |
11189 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
11190 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
11191 | HDA_AMP_MUTE, mute); | |
11192 | } | |
11193 | ||
11194 | ||
11195 | /* bind hp and internal speaker mute (with plug check) */ | |
11196 | static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |
11197 | struct snd_ctl_elem_value *ucontrol) | |
11198 | { | |
11199 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
11200 | long *valp = ucontrol->value.integer.value; | |
11201 | int change; | |
11202 | ||
11203 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
11204 | HDA_AMP_MUTE, | |
11205 | valp[0] ? 0 : HDA_AMP_MUTE); | |
11206 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
11207 | HDA_AMP_MUTE, | |
11208 | valp[1] ? 0 : HDA_AMP_MUTE); | |
11209 | if (change) | |
11210 | alc268_acer_automute(codec, 0); | |
11211 | return change; | |
11212 | } | |
d273809e | 11213 | |
8ef355da KY |
11214 | static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = { |
11215 | /* output mixer control */ | |
11216 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11217 | { | |
11218 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11219 | .name = "Master Playback Switch", | |
11220 | .info = snd_hda_mixer_amp_switch_info, | |
11221 | .get = snd_hda_mixer_amp_switch_get, | |
11222 | .put = alc268_acer_master_sw_put, | |
11223 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11224 | }, | |
11225 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT), | |
11226 | { } | |
11227 | }; | |
11228 | ||
d273809e TI |
11229 | static struct snd_kcontrol_new alc268_acer_mixer[] = { |
11230 | /* output mixer control */ | |
11231 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11232 | { | |
11233 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11234 | .name = "Master Playback Switch", | |
11235 | .info = snd_hda_mixer_amp_switch_info, | |
11236 | .get = snd_hda_mixer_amp_switch_get, | |
11237 | .put = alc268_acer_master_sw_put, | |
11238 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11239 | }, | |
33bf17ab TI |
11240 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
11241 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11242 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
11243 | { } |
11244 | }; | |
11245 | ||
c238b4f4 TI |
11246 | static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = { |
11247 | /* output mixer control */ | |
11248 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11249 | { | |
11250 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11251 | .name = "Master Playback Switch", | |
11252 | .info = snd_hda_mixer_amp_switch_info, | |
11253 | .get = snd_hda_mixer_amp_switch_get, | |
11254 | .put = alc268_acer_master_sw_put, | |
11255 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11256 | }, | |
11257 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11258 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
11259 | { } | |
11260 | }; | |
11261 | ||
8ef355da KY |
11262 | static struct hda_verb alc268_acer_aspire_one_verbs[] = { |
11263 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11264 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11265 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11266 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11267 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x06}, | |
11268 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017}, | |
11269 | { } | |
11270 | }; | |
11271 | ||
d273809e | 11272 | static struct hda_verb alc268_acer_verbs[] = { |
0ccb541c TI |
11273 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */ |
11274 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
d273809e TI |
11275 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
11276 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
0ccb541c TI |
11277 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
11278 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
d273809e TI |
11279 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
11280 | { } | |
11281 | }; | |
11282 | ||
11283 | /* unsolicited event for HP jack sensing */ | |
11284 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
11285 | unsigned int res) | |
11286 | { | |
889c4395 | 11287 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
11288 | return; |
11289 | alc268_toshiba_automute(codec); | |
11290 | } | |
11291 | ||
11292 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
11293 | unsigned int res) | |
11294 | { | |
889c4395 | 11295 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
11296 | return; |
11297 | alc268_acer_automute(codec, 1); | |
11298 | } | |
11299 | ||
889c4395 TI |
11300 | static void alc268_acer_init_hook(struct hda_codec *codec) |
11301 | { | |
11302 | alc268_acer_automute(codec, 1); | |
11303 | } | |
11304 | ||
8ef355da KY |
11305 | /* toggle speaker-output according to the hp-jack state */ |
11306 | static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |
11307 | { | |
11308 | unsigned int present; | |
11309 | unsigned char bits; | |
11310 | ||
11311 | present = snd_hda_codec_read(codec, 0x15, 0, | |
11312 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11313 | bits = present ? AMP_IN_MUTE(0) : 0; | |
11314 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, | |
11315 | AMP_IN_MUTE(0), bits); | |
11316 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1, | |
11317 | AMP_IN_MUTE(0), bits); | |
11318 | } | |
11319 | ||
11320 | ||
11321 | static void alc268_acer_mic_automute(struct hda_codec *codec) | |
11322 | { | |
11323 | unsigned int present; | |
11324 | ||
11325 | present = snd_hda_codec_read(codec, 0x18, 0, | |
11326 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11327 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, | |
11328 | present ? 0x0 : 0x6); | |
11329 | } | |
11330 | ||
11331 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, | |
11332 | unsigned int res) | |
11333 | { | |
11334 | if ((res >> 26) == ALC880_HP_EVENT) | |
11335 | alc268_aspire_one_speaker_automute(codec); | |
11336 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11337 | alc268_acer_mic_automute(codec); | |
11338 | } | |
11339 | ||
11340 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) | |
11341 | { | |
11342 | alc268_aspire_one_speaker_automute(codec); | |
11343 | alc268_acer_mic_automute(codec); | |
11344 | } | |
11345 | ||
3866f0b0 TI |
11346 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
11347 | /* output mixer control */ | |
11348 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11349 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11350 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11351 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11352 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11353 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11354 | { } | |
11355 | }; | |
11356 | ||
11357 | static struct hda_verb alc268_dell_verbs[] = { | |
11358 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11359 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11360 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11361 | { } | |
11362 | }; | |
11363 | ||
11364 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
11365 | static void alc268_dell_automute(struct hda_codec *codec) | |
11366 | { | |
11367 | unsigned int present; | |
11368 | unsigned int mute; | |
11369 | ||
11370 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | |
11371 | if (present & 0x80000000) | |
11372 | mute = HDA_AMP_MUTE; | |
11373 | else | |
11374 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
11375 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
11376 | HDA_AMP_MUTE, mute); | |
11377 | } | |
11378 | ||
11379 | static void alc268_dell_unsol_event(struct hda_codec *codec, | |
11380 | unsigned int res) | |
11381 | { | |
11382 | if ((res >> 26) != ALC880_HP_EVENT) | |
11383 | return; | |
11384 | alc268_dell_automute(codec); | |
11385 | } | |
11386 | ||
11387 | #define alc268_dell_init_hook alc268_dell_automute | |
11388 | ||
eb5a6621 HRK |
11389 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
11390 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
11391 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11392 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
11393 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11394 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11395 | HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT), | |
11396 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), | |
11397 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
11398 | { } | |
11399 | }; | |
11400 | ||
11401 | static struct hda_verb alc267_quanta_il1_verbs[] = { | |
11402 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11403 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
11404 | { } | |
11405 | }; | |
11406 | ||
11407 | static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) | |
11408 | { | |
11409 | unsigned int present; | |
11410 | ||
11411 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
11412 | & AC_PINSENSE_PRESENCE; | |
11413 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
11414 | present ? 0 : PIN_OUT); | |
11415 | } | |
11416 | ||
11417 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | |
11418 | { | |
11419 | unsigned int present; | |
11420 | ||
11421 | present = snd_hda_codec_read(codec, 0x18, 0, | |
11422 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11423 | snd_hda_codec_write(codec, 0x23, 0, | |
11424 | AC_VERB_SET_CONNECT_SEL, | |
11425 | present ? 0x00 : 0x01); | |
11426 | } | |
11427 | ||
11428 | static void alc267_quanta_il1_automute(struct hda_codec *codec) | |
11429 | { | |
11430 | alc267_quanta_il1_hp_automute(codec); | |
11431 | alc267_quanta_il1_mic_automute(codec); | |
11432 | } | |
11433 | ||
11434 | static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | |
11435 | unsigned int res) | |
11436 | { | |
11437 | switch (res >> 26) { | |
11438 | case ALC880_HP_EVENT: | |
11439 | alc267_quanta_il1_hp_automute(codec); | |
11440 | break; | |
11441 | case ALC880_MIC_EVENT: | |
11442 | alc267_quanta_il1_mic_automute(codec); | |
11443 | break; | |
11444 | } | |
11445 | } | |
11446 | ||
a361d84b KY |
11447 | /* |
11448 | * generic initialization of ADC, input mixers and output mixers | |
11449 | */ | |
11450 | static struct hda_verb alc268_base_init_verbs[] = { | |
11451 | /* Unmute DAC0-1 and set vol = 0 */ | |
11452 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a361d84b | 11453 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
a361d84b KY |
11454 | |
11455 | /* | |
11456 | * Set up output mixers (0x0c - 0x0e) | |
11457 | */ | |
11458 | /* set vol=0 to output mixers */ | |
11459 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
a361d84b KY |
11460 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
11461 | ||
11462 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11463 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11464 | ||
11465 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
11466 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
11467 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
11468 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11469 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11470 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11471 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11472 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11473 | ||
11474 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11475 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11476 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11477 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
a361d84b | 11478 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
aef9d318 TI |
11479 | |
11480 | /* set PCBEEP vol = 0, mute connections */ | |
11481 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11482 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11483 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b | 11484 | |
a9b3aa8a | 11485 | /* Unmute Selector 23h,24h and set the default input to mic-in */ |
ea1fb29a | 11486 | |
a9b3aa8a JZ |
11487 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, |
11488 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11489 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11490 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
a361d84b | 11491 | |
a361d84b KY |
11492 | { } |
11493 | }; | |
11494 | ||
11495 | /* | |
11496 | * generic initialization of ADC, input mixers and output mixers | |
11497 | */ | |
11498 | static struct hda_verb alc268_volume_init_verbs[] = { | |
11499 | /* set output DAC */ | |
4cfb91c6 TI |
11500 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
11501 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a361d84b KY |
11502 | |
11503 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11504 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11505 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11506 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11507 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11508 | ||
a361d84b | 11509 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
a361d84b KY |
11510 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
11511 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11512 | ||
11513 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
a361d84b | 11514 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
a361d84b | 11515 | |
aef9d318 TI |
11516 | /* set PCBEEP vol = 0, mute connections */ |
11517 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11518 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11519 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b KY |
11520 | |
11521 | { } | |
11522 | }; | |
11523 | ||
a361d84b KY |
11524 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { |
11525 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11526 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
11527 | { | |
11528 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11529 | /* The multiple "Capture Source" controls confuse alsamixer | |
11530 | * So call somewhat different.. | |
a361d84b KY |
11531 | */ |
11532 | /* .name = "Capture Source", */ | |
11533 | .name = "Input Source", | |
11534 | .count = 1, | |
54cbc9ab TI |
11535 | .info = alc_mux_enum_info, |
11536 | .get = alc_mux_enum_get, | |
11537 | .put = alc_mux_enum_put, | |
a361d84b KY |
11538 | }, |
11539 | { } /* end */ | |
11540 | }; | |
11541 | ||
11542 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
11543 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11544 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
11545 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
11546 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
11547 | { | |
11548 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11549 | /* The multiple "Capture Source" controls confuse alsamixer | |
11550 | * So call somewhat different.. | |
a361d84b KY |
11551 | */ |
11552 | /* .name = "Capture Source", */ | |
11553 | .name = "Input Source", | |
11554 | .count = 2, | |
54cbc9ab TI |
11555 | .info = alc_mux_enum_info, |
11556 | .get = alc_mux_enum_get, | |
11557 | .put = alc_mux_enum_put, | |
a361d84b KY |
11558 | }, |
11559 | { } /* end */ | |
11560 | }; | |
11561 | ||
11562 | static struct hda_input_mux alc268_capture_source = { | |
11563 | .num_items = 4, | |
11564 | .items = { | |
11565 | { "Mic", 0x0 }, | |
11566 | { "Front Mic", 0x1 }, | |
11567 | { "Line", 0x2 }, | |
11568 | { "CD", 0x3 }, | |
11569 | }, | |
11570 | }; | |
11571 | ||
0ccb541c | 11572 | static struct hda_input_mux alc268_acer_capture_source = { |
c238b4f4 TI |
11573 | .num_items = 3, |
11574 | .items = { | |
11575 | { "Mic", 0x0 }, | |
11576 | { "Internal Mic", 0x1 }, | |
11577 | { "Line", 0x2 }, | |
11578 | }, | |
11579 | }; | |
11580 | ||
11581 | static struct hda_input_mux alc268_acer_dmic_capture_source = { | |
0ccb541c TI |
11582 | .num_items = 3, |
11583 | .items = { | |
11584 | { "Mic", 0x0 }, | |
11585 | { "Internal Mic", 0x6 }, | |
11586 | { "Line", 0x2 }, | |
11587 | }, | |
11588 | }; | |
11589 | ||
86c53bd2 JW |
11590 | #ifdef CONFIG_SND_DEBUG |
11591 | static struct snd_kcontrol_new alc268_test_mixer[] = { | |
86c53bd2 JW |
11592 | /* Volume widgets */ |
11593 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11594 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11595 | HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
11596 | HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), | |
11597 | HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), | |
11598 | HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), | |
11599 | HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), | |
11600 | HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), | |
11601 | HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), | |
11602 | HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), | |
11603 | HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), | |
11604 | HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), | |
11605 | HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), | |
f0747ee6 TI |
11606 | /* The below appears problematic on some hardwares */ |
11607 | /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ | |
86c53bd2 JW |
11608 | HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
11609 | HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), | |
11610 | HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), | |
11611 | HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), | |
11612 | ||
11613 | /* Modes for retasking pin widgets */ | |
11614 | ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
11615 | ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
11616 | ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), | |
11617 | ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), | |
11618 | ||
11619 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
11620 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
11621 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
11622 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
11623 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
11624 | ||
11625 | /* Switches to allow the digital SPDIF output pin to be enabled. | |
11626 | * The ALC268 does not have an SPDIF input. | |
11627 | */ | |
11628 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), | |
11629 | ||
11630 | /* A switch allowing EAPD to be enabled. Some laptops seem to use | |
11631 | * this output to turn on an external amplifier. | |
11632 | */ | |
11633 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
11634 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
11635 | ||
11636 | { } /* end */ | |
11637 | }; | |
11638 | #endif | |
11639 | ||
a361d84b KY |
11640 | /* create input playback/capture controls for the given pin */ |
11641 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
11642 | const char *ctlname, int idx) | |
11643 | { | |
11644 | char name[32]; | |
11645 | int err; | |
11646 | ||
11647 | sprintf(name, "%s Playback Volume", ctlname); | |
11648 | if (nid == 0x14) { | |
11649 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11650 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
11651 | HDA_OUTPUT)); | |
11652 | if (err < 0) | |
11653 | return err; | |
11654 | } else if (nid == 0x15) { | |
11655 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11656 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
11657 | HDA_OUTPUT)); | |
11658 | if (err < 0) | |
11659 | return err; | |
11660 | } else | |
11661 | return -1; | |
11662 | sprintf(name, "%s Playback Switch", ctlname); | |
11663 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
11664 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
11665 | if (err < 0) | |
11666 | return err; | |
11667 | return 0; | |
11668 | } | |
11669 | ||
11670 | /* add playback controls from the parsed DAC table */ | |
11671 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11672 | const struct auto_pin_cfg *cfg) | |
11673 | { | |
11674 | hda_nid_t nid; | |
11675 | int err; | |
11676 | ||
11677 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
11678 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11679 | spec->multiout.dac_nids[0] = 2; | |
11680 | spec->multiout.dac_nids[1] = 3; | |
11681 | ||
11682 | nid = cfg->line_out_pins[0]; | |
11683 | if (nid) | |
ea1fb29a | 11684 | alc268_new_analog_output(spec, nid, "Front", 0); |
a361d84b KY |
11685 | |
11686 | nid = cfg->speaker_pins[0]; | |
11687 | if (nid == 0x1d) { | |
11688 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11689 | "Speaker Playback Volume", | |
11690 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
11691 | if (err < 0) | |
11692 | return err; | |
11693 | } | |
11694 | nid = cfg->hp_pins[0]; | |
11695 | if (nid) | |
11696 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
11697 | ||
11698 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
11699 | if (nid == 0x16) { | |
11700 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11701 | "Mono Playback Switch", | |
11702 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
11703 | if (err < 0) | |
11704 | return err; | |
11705 | } | |
ea1fb29a | 11706 | return 0; |
a361d84b KY |
11707 | } |
11708 | ||
11709 | /* create playback/capture controls for input pins */ | |
11710 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
11711 | const struct auto_pin_cfg *cfg) | |
11712 | { | |
61b9b9b1 | 11713 | struct hda_input_mux *imux = &spec->private_imux[0]; |
a361d84b KY |
11714 | int i, idx1; |
11715 | ||
11716 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11717 | switch(cfg->input_pins[i]) { | |
11718 | case 0x18: | |
11719 | idx1 = 0; /* Mic 1 */ | |
11720 | break; | |
11721 | case 0x19: | |
11722 | idx1 = 1; /* Mic 2 */ | |
11723 | break; | |
11724 | case 0x1a: | |
11725 | idx1 = 2; /* Line In */ | |
11726 | break; | |
ea1fb29a | 11727 | case 0x1c: |
a361d84b KY |
11728 | idx1 = 3; /* CD */ |
11729 | break; | |
7194cae6 TI |
11730 | case 0x12: |
11731 | case 0x13: | |
11732 | idx1 = 6; /* digital mics */ | |
11733 | break; | |
a361d84b KY |
11734 | default: |
11735 | continue; | |
11736 | } | |
11737 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
11738 | imux->items[imux->num_items].index = idx1; | |
ea1fb29a | 11739 | imux->num_items++; |
a361d84b KY |
11740 | } |
11741 | return 0; | |
11742 | } | |
11743 | ||
11744 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
11745 | { | |
11746 | struct alc_spec *spec = codec->spec; | |
11747 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
11748 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
11749 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
11750 | unsigned int dac_vol1, dac_vol2; | |
11751 | ||
11752 | if (speaker_nid) { | |
11753 | snd_hda_codec_write(codec, speaker_nid, 0, | |
11754 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
11755 | snd_hda_codec_write(codec, 0x0f, 0, | |
11756 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11757 | AMP_IN_UNMUTE(1)); | |
11758 | snd_hda_codec_write(codec, 0x10, 0, | |
11759 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11760 | AMP_IN_UNMUTE(1)); | |
11761 | } else { | |
11762 | snd_hda_codec_write(codec, 0x0f, 0, | |
11763 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11764 | snd_hda_codec_write(codec, 0x10, 0, | |
11765 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11766 | } | |
11767 | ||
11768 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
ea1fb29a | 11769 | if (line_nid == 0x14) |
a361d84b KY |
11770 | dac_vol2 = AMP_OUT_ZERO; |
11771 | else if (line_nid == 0x15) | |
11772 | dac_vol1 = AMP_OUT_ZERO; | |
ea1fb29a | 11773 | if (hp_nid == 0x14) |
a361d84b KY |
11774 | dac_vol2 = AMP_OUT_ZERO; |
11775 | else if (hp_nid == 0x15) | |
11776 | dac_vol1 = AMP_OUT_ZERO; | |
11777 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
11778 | spec->autocfg.line_out_pins[1] != 0x16 || | |
11779 | spec->autocfg.line_out_pins[2] != 0x16) | |
11780 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
11781 | ||
11782 | snd_hda_codec_write(codec, 0x02, 0, | |
11783 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
11784 | snd_hda_codec_write(codec, 0x03, 0, | |
11785 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
11786 | } | |
11787 | ||
11788 | /* pcm configuration: identiacal with ALC880 */ | |
11789 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
11790 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 11791 | #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
a361d84b KY |
11792 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback |
11793 | ||
11794 | /* | |
11795 | * BIOS auto configuration | |
11796 | */ | |
11797 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
11798 | { | |
11799 | struct alc_spec *spec = codec->spec; | |
11800 | int err; | |
11801 | static hda_nid_t alc268_ignore[] = { 0 }; | |
11802 | ||
11803 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
11804 | alc268_ignore); | |
11805 | if (err < 0) | |
11806 | return err; | |
11807 | if (!spec->autocfg.line_outs) | |
11808 | return 0; /* can't find valid BIOS pin config */ | |
11809 | ||
11810 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11811 | if (err < 0) | |
11812 | return err; | |
11813 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11814 | if (err < 0) | |
11815 | return err; | |
11816 | ||
11817 | spec->multiout.max_channels = 2; | |
11818 | ||
11819 | /* digital only support output */ | |
0852d7a6 | 11820 | if (spec->autocfg.dig_outs) |
a361d84b KY |
11821 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; |
11822 | ||
603c4019 | 11823 | if (spec->kctls.list) |
d88897ea | 11824 | add_mixer(spec, spec->kctls.list); |
a361d84b | 11825 | |
aef9d318 | 11826 | if (spec->autocfg.speaker_pins[0] != 0x1d) |
d88897ea | 11827 | add_mixer(spec, alc268_beep_mixer); |
aef9d318 | 11828 | |
d88897ea | 11829 | add_verb(spec, alc268_volume_init_verbs); |
a361d84b | 11830 | spec->num_mux_defs = 1; |
61b9b9b1 | 11831 | spec->input_mux = &spec->private_imux[0]; |
a361d84b | 11832 | |
776e184e TI |
11833 | err = alc_auto_add_mic_boost(codec); |
11834 | if (err < 0) | |
11835 | return err; | |
11836 | ||
e044c39a | 11837 | store_pin_configs(codec); |
a361d84b KY |
11838 | return 1; |
11839 | } | |
11840 | ||
11841 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
11842 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
11843 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
11844 | ||
11845 | /* init callback for auto-configuration model -- overriding the default init */ | |
11846 | static void alc268_auto_init(struct hda_codec *codec) | |
11847 | { | |
f6c7e546 | 11848 | struct alc_spec *spec = codec->spec; |
a361d84b KY |
11849 | alc268_auto_init_multi_out(codec); |
11850 | alc268_auto_init_hp_out(codec); | |
11851 | alc268_auto_init_mono_speaker_out(codec); | |
11852 | alc268_auto_init_analog_input(codec); | |
f6c7e546 | 11853 | if (spec->unsol_event) |
7fb0d78f | 11854 | alc_inithook(codec); |
a361d84b KY |
11855 | } |
11856 | ||
11857 | /* | |
11858 | * configuration and preset | |
11859 | */ | |
11860 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
eb5a6621 | 11861 | [ALC267_QUANTA_IL1] = "quanta-il1", |
a361d84b | 11862 | [ALC268_3ST] = "3stack", |
983f8ae4 | 11863 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 11864 | [ALC268_ACER] = "acer", |
c238b4f4 | 11865 | [ALC268_ACER_DMIC] = "acer-dmic", |
8ef355da | 11866 | [ALC268_ACER_ASPIRE_ONE] = "acer-aspire", |
3866f0b0 | 11867 | [ALC268_DELL] = "dell", |
f12462c5 | 11868 | [ALC268_ZEPTO] = "zepto", |
86c53bd2 JW |
11869 | #ifdef CONFIG_SND_DEBUG |
11870 | [ALC268_TEST] = "test", | |
11871 | #endif | |
a361d84b KY |
11872 | [ALC268_AUTO] = "auto", |
11873 | }; | |
11874 | ||
11875 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
a0b8f7d8 | 11876 | SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER), |
ac3e3741 | 11877 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), |
dafc8357 | 11878 | SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), |
ac3e3741 | 11879 | SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), |
29a52c24 | 11880 | SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), |
8ef355da KY |
11881 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One", |
11882 | ALC268_ACER_ASPIRE_ONE), | |
3866f0b0 | 11883 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
57d13927 | 11884 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), |
ac3e3741 | 11885 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
a361d84b | 11886 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
d1a991a6 | 11887 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
8e7f00f9 | 11888 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), |
2346d0cd | 11889 | SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA), |
378bd6a5 | 11890 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
b875bf3a | 11891 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
eb5a6621 | 11892 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
f12462c5 | 11893 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
a361d84b KY |
11894 | {} |
11895 | }; | |
11896 | ||
11897 | static struct alc_config_preset alc268_presets[] = { | |
eb5a6621 | 11898 | [ALC267_QUANTA_IL1] = { |
22971e3a | 11899 | .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer }, |
eb5a6621 HRK |
11900 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11901 | alc267_quanta_il1_verbs }, | |
11902 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11903 | .dac_nids = alc268_dac_nids, | |
11904 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11905 | .adc_nids = alc268_adc_nids_alt, | |
11906 | .hp_nid = 0x03, | |
11907 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11908 | .channel_mode = alc268_modes, | |
11909 | .input_mux = &alc268_capture_source, | |
11910 | .unsol_event = alc267_quanta_il1_unsol_event, | |
11911 | .init_hook = alc267_quanta_il1_automute, | |
11912 | }, | |
a361d84b | 11913 | [ALC268_3ST] = { |
aef9d318 TI |
11914 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11915 | alc268_beep_mixer }, | |
a361d84b KY |
11916 | .init_verbs = { alc268_base_init_verbs }, |
11917 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11918 | .dac_nids = alc268_dac_nids, | |
11919 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11920 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11921 | .capsrc_nids = alc268_capsrc_nids, |
a361d84b KY |
11922 | .hp_nid = 0x03, |
11923 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11924 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11925 | .channel_mode = alc268_modes, | |
11926 | .input_mux = &alc268_capture_source, | |
11927 | }, | |
d1a991a6 | 11928 | [ALC268_TOSHIBA] = { |
aef9d318 TI |
11929 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11930 | alc268_beep_mixer }, | |
d273809e TI |
11931 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11932 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
11933 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
11934 | .dac_nids = alc268_dac_nids, | |
11935 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11936 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11937 | .capsrc_nids = alc268_capsrc_nids, |
d1a991a6 KY |
11938 | .hp_nid = 0x03, |
11939 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11940 | .channel_mode = alc268_modes, | |
11941 | .input_mux = &alc268_capture_source, | |
d273809e TI |
11942 | .unsol_event = alc268_toshiba_unsol_event, |
11943 | .init_hook = alc268_toshiba_automute, | |
11944 | }, | |
11945 | [ALC268_ACER] = { | |
aef9d318 TI |
11946 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, |
11947 | alc268_beep_mixer }, | |
d273809e TI |
11948 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11949 | alc268_acer_verbs }, | |
11950 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11951 | .dac_nids = alc268_dac_nids, | |
11952 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11953 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11954 | .capsrc_nids = alc268_capsrc_nids, |
d273809e TI |
11955 | .hp_nid = 0x02, |
11956 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11957 | .channel_mode = alc268_modes, | |
0ccb541c | 11958 | .input_mux = &alc268_acer_capture_source, |
d273809e | 11959 | .unsol_event = alc268_acer_unsol_event, |
889c4395 | 11960 | .init_hook = alc268_acer_init_hook, |
d1a991a6 | 11961 | }, |
c238b4f4 TI |
11962 | [ALC268_ACER_DMIC] = { |
11963 | .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer, | |
11964 | alc268_beep_mixer }, | |
11965 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11966 | alc268_acer_verbs }, | |
11967 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11968 | .dac_nids = alc268_dac_nids, | |
11969 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11970 | .adc_nids = alc268_adc_nids_alt, | |
11971 | .capsrc_nids = alc268_capsrc_nids, | |
11972 | .hp_nid = 0x02, | |
11973 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11974 | .channel_mode = alc268_modes, | |
11975 | .input_mux = &alc268_acer_dmic_capture_source, | |
11976 | .unsol_event = alc268_acer_unsol_event, | |
11977 | .init_hook = alc268_acer_init_hook, | |
11978 | }, | |
8ef355da KY |
11979 | [ALC268_ACER_ASPIRE_ONE] = { |
11980 | .mixers = { alc268_acer_aspire_one_mixer, | |
22971e3a TI |
11981 | alc268_beep_mixer, |
11982 | alc268_capture_alt_mixer }, | |
8ef355da KY |
11983 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11984 | alc268_acer_aspire_one_verbs }, | |
11985 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11986 | .dac_nids = alc268_dac_nids, | |
11987 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11988 | .adc_nids = alc268_adc_nids_alt, | |
11989 | .capsrc_nids = alc268_capsrc_nids, | |
11990 | .hp_nid = 0x03, | |
11991 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11992 | .channel_mode = alc268_modes, | |
11993 | .input_mux = &alc268_acer_lc_capture_source, | |
11994 | .unsol_event = alc268_acer_lc_unsol_event, | |
11995 | .init_hook = alc268_acer_lc_init_hook, | |
11996 | }, | |
3866f0b0 | 11997 | [ALC268_DELL] = { |
aef9d318 | 11998 | .mixers = { alc268_dell_mixer, alc268_beep_mixer }, |
3866f0b0 TI |
11999 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12000 | alc268_dell_verbs }, | |
12001 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
12002 | .dac_nids = alc268_dac_nids, | |
12003 | .hp_nid = 0x02, | |
12004 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
12005 | .channel_mode = alc268_modes, | |
12006 | .unsol_event = alc268_dell_unsol_event, | |
12007 | .init_hook = alc268_dell_init_hook, | |
12008 | .input_mux = &alc268_capture_source, | |
12009 | }, | |
f12462c5 | 12010 | [ALC268_ZEPTO] = { |
aef9d318 TI |
12011 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
12012 | alc268_beep_mixer }, | |
f12462c5 MT |
12013 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12014 | alc268_toshiba_verbs }, | |
12015 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
12016 | .dac_nids = alc268_dac_nids, | |
12017 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
12018 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 12019 | .capsrc_nids = alc268_capsrc_nids, |
f12462c5 MT |
12020 | .hp_nid = 0x03, |
12021 | .dig_out_nid = ALC268_DIGOUT_NID, | |
12022 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
12023 | .channel_mode = alc268_modes, | |
12024 | .input_mux = &alc268_capture_source, | |
12025 | .unsol_event = alc268_toshiba_unsol_event, | |
12026 | .init_hook = alc268_toshiba_automute | |
12027 | }, | |
86c53bd2 JW |
12028 | #ifdef CONFIG_SND_DEBUG |
12029 | [ALC268_TEST] = { | |
12030 | .mixers = { alc268_test_mixer, alc268_capture_mixer }, | |
12031 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
12032 | alc268_volume_init_verbs }, | |
12033 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
12034 | .dac_nids = alc268_dac_nids, | |
12035 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
12036 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 12037 | .capsrc_nids = alc268_capsrc_nids, |
86c53bd2 JW |
12038 | .hp_nid = 0x03, |
12039 | .dig_out_nid = ALC268_DIGOUT_NID, | |
12040 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
12041 | .channel_mode = alc268_modes, | |
12042 | .input_mux = &alc268_capture_source, | |
12043 | }, | |
12044 | #endif | |
a361d84b KY |
12045 | }; |
12046 | ||
12047 | static int patch_alc268(struct hda_codec *codec) | |
12048 | { | |
12049 | struct alc_spec *spec; | |
12050 | int board_config; | |
22971e3a | 12051 | int i, has_beep, err; |
a361d84b KY |
12052 | |
12053 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
12054 | if (spec == NULL) | |
12055 | return -ENOMEM; | |
12056 | ||
12057 | codec->spec = spec; | |
12058 | ||
12059 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
12060 | alc268_models, | |
12061 | alc268_cfg_tbl); | |
12062 | ||
12063 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
12064 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
12065 | "trying auto-probe from BIOS...\n"); | |
12066 | board_config = ALC268_AUTO; | |
12067 | } | |
12068 | ||
12069 | if (board_config == ALC268_AUTO) { | |
12070 | /* automatic parse from the BIOS config */ | |
12071 | err = alc268_parse_auto_config(codec); | |
12072 | if (err < 0) { | |
12073 | alc_free(codec); | |
12074 | return err; | |
12075 | } else if (!err) { | |
12076 | printk(KERN_INFO | |
12077 | "hda_codec: Cannot set up configuration " | |
12078 | "from BIOS. Using base mode...\n"); | |
12079 | board_config = ALC268_3ST; | |
12080 | } | |
12081 | } | |
12082 | ||
680cd536 KK |
12083 | err = snd_hda_attach_beep_device(codec, 0x1); |
12084 | if (err < 0) { | |
12085 | alc_free(codec); | |
12086 | return err; | |
12087 | } | |
12088 | ||
a361d84b KY |
12089 | if (board_config != ALC268_AUTO) |
12090 | setup_preset(spec, &alc268_presets[board_config]); | |
12091 | ||
2f893286 KY |
12092 | if (codec->vendor_id == 0x10ec0267) { |
12093 | spec->stream_name_analog = "ALC267 Analog"; | |
12094 | spec->stream_name_digital = "ALC267 Digital"; | |
12095 | } else { | |
12096 | spec->stream_name_analog = "ALC268 Analog"; | |
12097 | spec->stream_name_digital = "ALC268 Digital"; | |
12098 | } | |
12099 | ||
a361d84b KY |
12100 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
12101 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
6330079f | 12102 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; |
a361d84b | 12103 | |
a361d84b KY |
12104 | spec->stream_digital_playback = &alc268_pcm_digital_playback; |
12105 | ||
22971e3a TI |
12106 | has_beep = 0; |
12107 | for (i = 0; i < spec->num_mixers; i++) { | |
12108 | if (spec->mixers[i] == alc268_beep_mixer) { | |
12109 | has_beep = 1; | |
12110 | break; | |
12111 | } | |
12112 | } | |
12113 | ||
12114 | if (has_beep) { | |
12115 | err = snd_hda_attach_beep_device(codec, 0x1); | |
12116 | if (err < 0) { | |
12117 | alc_free(codec); | |
12118 | return err; | |
12119 | } | |
12120 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) | |
12121 | /* override the amp caps for beep generator */ | |
12122 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | |
aef9d318 TI |
12123 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
12124 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
12125 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
12126 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
22971e3a | 12127 | } |
aef9d318 | 12128 | |
3866f0b0 TI |
12129 | if (!spec->adc_nids && spec->input_mux) { |
12130 | /* check whether NID 0x07 is valid */ | |
12131 | unsigned int wcap = get_wcaps(codec, 0x07); | |
85860c06 | 12132 | int i; |
3866f0b0 TI |
12133 | |
12134 | /* get type */ | |
12135 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
67ebcb03 | 12136 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
3866f0b0 TI |
12137 | spec->adc_nids = alc268_adc_nids_alt; |
12138 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | |
d88897ea | 12139 | add_mixer(spec, alc268_capture_alt_mixer); |
3866f0b0 TI |
12140 | } else { |
12141 | spec->adc_nids = alc268_adc_nids; | |
12142 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | |
d88897ea | 12143 | add_mixer(spec, alc268_capture_mixer); |
a361d84b | 12144 | } |
e1406348 | 12145 | spec->capsrc_nids = alc268_capsrc_nids; |
85860c06 TI |
12146 | /* set default input source */ |
12147 | for (i = 0; i < spec->num_adc_nids; i++) | |
12148 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], | |
12149 | 0, AC_VERB_SET_CONNECT_SEL, | |
12150 | spec->input_mux->items[0].index); | |
a361d84b | 12151 | } |
2134ea4f TI |
12152 | |
12153 | spec->vmaster_nid = 0x02; | |
12154 | ||
a361d84b KY |
12155 | codec->patch_ops = alc_patch_ops; |
12156 | if (board_config == ALC268_AUTO) | |
12157 | spec->init_hook = alc268_auto_init; | |
ea1fb29a | 12158 | |
daead538 TI |
12159 | codec->proc_widget_hook = print_realtek_coef; |
12160 | ||
a361d84b KY |
12161 | return 0; |
12162 | } | |
12163 | ||
f6a92248 KY |
12164 | /* |
12165 | * ALC269 channel source setting (2 channel) | |
12166 | */ | |
12167 | #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID | |
12168 | ||
12169 | #define alc269_dac_nids alc260_dac_nids | |
12170 | ||
12171 | static hda_nid_t alc269_adc_nids[1] = { | |
12172 | /* ADC1 */ | |
f53281e6 KY |
12173 | 0x08, |
12174 | }; | |
12175 | ||
e01bf509 TI |
12176 | static hda_nid_t alc269_capsrc_nids[1] = { |
12177 | 0x23, | |
12178 | }; | |
12179 | ||
12180 | /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), | |
12181 | * not a mux! | |
12182 | */ | |
12183 | ||
f53281e6 KY |
12184 | static struct hda_input_mux alc269_eeepc_dmic_capture_source = { |
12185 | .num_items = 2, | |
12186 | .items = { | |
12187 | { "i-Mic", 0x5 }, | |
12188 | { "e-Mic", 0x0 }, | |
12189 | }, | |
12190 | }; | |
12191 | ||
12192 | static struct hda_input_mux alc269_eeepc_amic_capture_source = { | |
12193 | .num_items = 2, | |
12194 | .items = { | |
12195 | { "i-Mic", 0x1 }, | |
12196 | { "e-Mic", 0x0 }, | |
12197 | }, | |
f6a92248 KY |
12198 | }; |
12199 | ||
12200 | #define alc269_modes alc260_modes | |
12201 | #define alc269_capture_source alc880_lg_lw_capture_source | |
12202 | ||
12203 | static struct snd_kcontrol_new alc269_base_mixer[] = { | |
12204 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12205 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12206 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
12207 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
12208 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12209 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12210 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12211 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
12212 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
12213 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
12214 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12215 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
12216 | { } /* end */ | |
12217 | }; | |
12218 | ||
60db6b53 KY |
12219 | static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = { |
12220 | /* output mixer control */ | |
12221 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
12222 | { | |
12223 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12224 | .name = "Master Playback Switch", | |
12225 | .info = snd_hda_mixer_amp_switch_info, | |
12226 | .get = snd_hda_mixer_amp_switch_get, | |
12227 | .put = alc268_acer_master_sw_put, | |
12228 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
12229 | }, | |
12230 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12231 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12232 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12233 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
12234 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
12235 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
60db6b53 KY |
12236 | { } |
12237 | }; | |
12238 | ||
64154835 TV |
12239 | static struct snd_kcontrol_new alc269_lifebook_mixer[] = { |
12240 | /* output mixer control */ | |
12241 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
12242 | { | |
12243 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12244 | .name = "Master Playback Switch", | |
12245 | .info = snd_hda_mixer_amp_switch_info, | |
12246 | .get = snd_hda_mixer_amp_switch_get, | |
12247 | .put = alc268_acer_master_sw_put, | |
12248 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
12249 | }, | |
12250 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12251 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12252 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12253 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
12254 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
12255 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
12256 | HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
12257 | HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
12258 | HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT), | |
64154835 TV |
12259 | { } |
12260 | }; | |
12261 | ||
f53281e6 KY |
12262 | /* bind volumes of both NID 0x0c and 0x0d */ |
12263 | static struct hda_bind_ctls alc269_epc_bind_vol = { | |
12264 | .ops = &snd_hda_bind_vol, | |
12265 | .values = { | |
12266 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
12267 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
12268 | 0 | |
12269 | }, | |
12270 | }; | |
12271 | ||
12272 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | |
12273 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12274 | HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), | |
12275 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12276 | { } /* end */ | |
12277 | }; | |
12278 | ||
f53281e6 KY |
12279 | /* capture mixer elements */ |
12280 | static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { | |
12281 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12282 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
26f5df26 TI |
12283 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
12284 | { } /* end */ | |
12285 | }; | |
12286 | ||
12287 | /* FSC amilo */ | |
12288 | static struct snd_kcontrol_new alc269_fujitsu_mixer[] = { | |
12289 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12290 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12291 | HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol), | |
f53281e6 KY |
12292 | { } /* end */ |
12293 | }; | |
12294 | ||
60db6b53 KY |
12295 | static struct hda_verb alc269_quanta_fl1_verbs[] = { |
12296 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12297 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12298 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12299 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12300 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12301 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12302 | { } | |
12303 | }; | |
f6a92248 | 12304 | |
64154835 TV |
12305 | static struct hda_verb alc269_lifebook_verbs[] = { |
12306 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12307 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12308 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12309 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12310 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12311 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12312 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12313 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12314 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12315 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12316 | { } | |
12317 | }; | |
12318 | ||
60db6b53 KY |
12319 | /* toggle speaker-output according to the hp-jack state */ |
12320 | static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) | |
12321 | { | |
12322 | unsigned int present; | |
12323 | unsigned char bits; | |
f6a92248 | 12324 | |
60db6b53 KY |
12325 | present = snd_hda_codec_read(codec, 0x15, 0, |
12326 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12327 | bits = present ? AMP_IN_MUTE(0) : 0; | |
12328 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
12329 | AMP_IN_MUTE(0), bits); | |
12330 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
12331 | AMP_IN_MUTE(0), bits); | |
f6a92248 | 12332 | |
60db6b53 KY |
12333 | snd_hda_codec_write(codec, 0x20, 0, |
12334 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12335 | snd_hda_codec_write(codec, 0x20, 0, | |
12336 | AC_VERB_SET_PROC_COEF, 0x680); | |
f6a92248 | 12337 | |
60db6b53 KY |
12338 | snd_hda_codec_write(codec, 0x20, 0, |
12339 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12340 | snd_hda_codec_write(codec, 0x20, 0, | |
12341 | AC_VERB_SET_PROC_COEF, 0x480); | |
12342 | } | |
f6a92248 | 12343 | |
64154835 TV |
12344 | /* toggle speaker-output according to the hp-jacks state */ |
12345 | static void alc269_lifebook_speaker_automute(struct hda_codec *codec) | |
12346 | { | |
12347 | unsigned int present; | |
12348 | unsigned char bits; | |
12349 | ||
12350 | /* Check laptop headphone socket */ | |
12351 | present = snd_hda_codec_read(codec, 0x15, 0, | |
12352 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12353 | ||
12354 | /* Check port replicator headphone socket */ | |
12355 | present |= snd_hda_codec_read(codec, 0x1a, 0, | |
12356 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12357 | ||
12358 | bits = present ? AMP_IN_MUTE(0) : 0; | |
12359 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
12360 | AMP_IN_MUTE(0), bits); | |
12361 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
12362 | AMP_IN_MUTE(0), bits); | |
12363 | ||
12364 | snd_hda_codec_write(codec, 0x20, 0, | |
12365 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12366 | snd_hda_codec_write(codec, 0x20, 0, | |
12367 | AC_VERB_SET_PROC_COEF, 0x680); | |
12368 | ||
12369 | snd_hda_codec_write(codec, 0x20, 0, | |
12370 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12371 | snd_hda_codec_write(codec, 0x20, 0, | |
12372 | AC_VERB_SET_PROC_COEF, 0x480); | |
12373 | } | |
12374 | ||
60db6b53 KY |
12375 | static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) |
12376 | { | |
12377 | unsigned int present; | |
f6a92248 | 12378 | |
60db6b53 KY |
12379 | present = snd_hda_codec_read(codec, 0x18, 0, |
12380 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12381 | snd_hda_codec_write(codec, 0x23, 0, | |
12382 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); | |
12383 | } | |
f6a92248 | 12384 | |
64154835 TV |
12385 | static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) |
12386 | { | |
12387 | unsigned int present_laptop; | |
12388 | unsigned int present_dock; | |
12389 | ||
12390 | present_laptop = snd_hda_codec_read(codec, 0x18, 0, | |
12391 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12392 | ||
12393 | present_dock = snd_hda_codec_read(codec, 0x1b, 0, | |
12394 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12395 | ||
12396 | /* Laptop mic port overrides dock mic port, design decision */ | |
12397 | if (present_dock) | |
12398 | snd_hda_codec_write(codec, 0x23, 0, | |
12399 | AC_VERB_SET_CONNECT_SEL, 0x3); | |
12400 | if (present_laptop) | |
12401 | snd_hda_codec_write(codec, 0x23, 0, | |
12402 | AC_VERB_SET_CONNECT_SEL, 0x0); | |
12403 | if (!present_dock && !present_laptop) | |
12404 | snd_hda_codec_write(codec, 0x23, 0, | |
12405 | AC_VERB_SET_CONNECT_SEL, 0x1); | |
12406 | } | |
12407 | ||
60db6b53 KY |
12408 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, |
12409 | unsigned int res) | |
12410 | { | |
12411 | if ((res >> 26) == ALC880_HP_EVENT) | |
12412 | alc269_quanta_fl1_speaker_automute(codec); | |
12413 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12414 | alc269_quanta_fl1_mic_automute(codec); | |
12415 | } | |
f6a92248 | 12416 | |
64154835 TV |
12417 | static void alc269_lifebook_unsol_event(struct hda_codec *codec, |
12418 | unsigned int res) | |
12419 | { | |
12420 | if ((res >> 26) == ALC880_HP_EVENT) | |
12421 | alc269_lifebook_speaker_automute(codec); | |
12422 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12423 | alc269_lifebook_mic_autoswitch(codec); | |
12424 | } | |
12425 | ||
60db6b53 KY |
12426 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) |
12427 | { | |
12428 | alc269_quanta_fl1_speaker_automute(codec); | |
12429 | alc269_quanta_fl1_mic_automute(codec); | |
12430 | } | |
f6a92248 | 12431 | |
64154835 TV |
12432 | static void alc269_lifebook_init_hook(struct hda_codec *codec) |
12433 | { | |
12434 | alc269_lifebook_speaker_automute(codec); | |
12435 | alc269_lifebook_mic_autoswitch(codec); | |
12436 | } | |
12437 | ||
f53281e6 KY |
12438 | static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { |
12439 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12440 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, | |
12441 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
12442 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, | |
12443 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12444 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12445 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12446 | {} | |
12447 | }; | |
12448 | ||
12449 | static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |
12450 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12451 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12452 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
12453 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))}, | |
12454 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12455 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12456 | {} | |
12457 | }; | |
12458 | ||
12459 | /* toggle speaker-output according to the hp-jack state */ | |
12460 | static void alc269_speaker_automute(struct hda_codec *codec) | |
12461 | { | |
12462 | unsigned int present; | |
60db6b53 | 12463 | unsigned char bits; |
f53281e6 KY |
12464 | |
12465 | present = snd_hda_codec_read(codec, 0x15, 0, | |
60db6b53 | 12466 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
f53281e6 KY |
12467 | bits = present ? AMP_IN_MUTE(0) : 0; |
12468 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
60db6b53 | 12469 | AMP_IN_MUTE(0), bits); |
f53281e6 | 12470 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, |
60db6b53 | 12471 | AMP_IN_MUTE(0), bits); |
f53281e6 KY |
12472 | } |
12473 | ||
12474 | static void alc269_eeepc_dmic_automute(struct hda_codec *codec) | |
12475 | { | |
12476 | unsigned int present; | |
12477 | ||
60db6b53 KY |
12478 | present = snd_hda_codec_read(codec, 0x18, 0, |
12479 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12480 | snd_hda_codec_write(codec, 0x23, 0, | |
12481 | AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5)); | |
f53281e6 KY |
12482 | } |
12483 | ||
12484 | static void alc269_eeepc_amic_automute(struct hda_codec *codec) | |
12485 | { | |
12486 | unsigned int present; | |
12487 | ||
60db6b53 KY |
12488 | present = snd_hda_codec_read(codec, 0x18, 0, |
12489 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f53281e6 | 12490 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 12491 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
f53281e6 | 12492 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 12493 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); |
f53281e6 KY |
12494 | } |
12495 | ||
12496 | /* unsolicited event for HP jack sensing */ | |
12497 | static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, | |
60db6b53 | 12498 | unsigned int res) |
f53281e6 KY |
12499 | { |
12500 | if ((res >> 26) == ALC880_HP_EVENT) | |
12501 | alc269_speaker_automute(codec); | |
12502 | ||
12503 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12504 | alc269_eeepc_dmic_automute(codec); | |
12505 | } | |
12506 | ||
12507 | static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) | |
12508 | { | |
12509 | alc269_speaker_automute(codec); | |
12510 | alc269_eeepc_dmic_automute(codec); | |
12511 | } | |
12512 | ||
12513 | /* unsolicited event for HP jack sensing */ | |
12514 | static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, | |
ea1fb29a | 12515 | unsigned int res) |
f53281e6 KY |
12516 | { |
12517 | if ((res >> 26) == ALC880_HP_EVENT) | |
12518 | alc269_speaker_automute(codec); | |
12519 | ||
12520 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12521 | alc269_eeepc_amic_automute(codec); | |
12522 | } | |
12523 | ||
12524 | static void alc269_eeepc_amic_inithook(struct hda_codec *codec) | |
12525 | { | |
12526 | alc269_speaker_automute(codec); | |
12527 | alc269_eeepc_amic_automute(codec); | |
12528 | } | |
12529 | ||
60db6b53 KY |
12530 | /* |
12531 | * generic initialization of ADC, input mixers and output mixers | |
12532 | */ | |
12533 | static struct hda_verb alc269_init_verbs[] = { | |
12534 | /* | |
12535 | * Unmute ADC0 and set the default input to mic-in | |
12536 | */ | |
12537 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12538 | ||
12539 | /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the | |
12540 | * analog-loopback mixer widget | |
12541 | * Note: PASD motherboards uses the Line In 2 as the input for | |
12542 | * front panel mic (mic 2) | |
12543 | */ | |
12544 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
12545 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12546 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12547 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12548 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12549 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
12550 | ||
12551 | /* | |
12552 | * Set up output mixers (0x0c - 0x0e) | |
12553 | */ | |
12554 | /* set vol=0 to output mixers */ | |
12555 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12556 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12557 | ||
12558 | /* set up input amps for analog loopback */ | |
12559 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
12560 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12561 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12562 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12563 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12564 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12565 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12566 | ||
12567 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12568 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12569 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12570 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12571 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12572 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12573 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12574 | ||
12575 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12576 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12577 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12578 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12579 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12580 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12581 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12582 | ||
12583 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12584 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12585 | ||
12586 | /* FIXME: use matrix-type input source selection */ | |
12587 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ | |
12588 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
12589 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12590 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12591 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12592 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12593 | ||
12594 | /* set EAPD */ | |
12595 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
12596 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
12597 | { } | |
12598 | }; | |
12599 | ||
f6a92248 KY |
12600 | /* add playback controls from the parsed DAC table */ |
12601 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | |
12602 | const struct auto_pin_cfg *cfg) | |
12603 | { | |
12604 | hda_nid_t nid; | |
12605 | int err; | |
12606 | ||
12607 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
12608 | spec->multiout.dac_nids = spec->private_dac_nids; | |
12609 | spec->multiout.dac_nids[0] = 2; | |
12610 | ||
12611 | nid = cfg->line_out_pins[0]; | |
12612 | if (nid) { | |
12613 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12614 | "Front Playback Volume", | |
12615 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | |
12616 | if (err < 0) | |
12617 | return err; | |
12618 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12619 | "Front Playback Switch", | |
12620 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
12621 | if (err < 0) | |
12622 | return err; | |
12623 | } | |
12624 | ||
12625 | nid = cfg->speaker_pins[0]; | |
12626 | if (nid) { | |
12627 | if (!cfg->line_out_pins[0]) { | |
12628 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12629 | "Speaker Playback Volume", | |
12630 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
12631 | HDA_OUTPUT)); | |
12632 | if (err < 0) | |
12633 | return err; | |
12634 | } | |
12635 | if (nid == 0x16) { | |
12636 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12637 | "Speaker Playback Switch", | |
12638 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12639 | HDA_OUTPUT)); | |
12640 | if (err < 0) | |
12641 | return err; | |
12642 | } else { | |
12643 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12644 | "Speaker Playback Switch", | |
12645 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12646 | HDA_OUTPUT)); | |
12647 | if (err < 0) | |
12648 | return err; | |
12649 | } | |
12650 | } | |
12651 | nid = cfg->hp_pins[0]; | |
12652 | if (nid) { | |
12653 | /* spec->multiout.hp_nid = 2; */ | |
12654 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | |
12655 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12656 | "Headphone Playback Volume", | |
12657 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
12658 | HDA_OUTPUT)); | |
12659 | if (err < 0) | |
12660 | return err; | |
12661 | } | |
12662 | if (nid == 0x16) { | |
12663 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12664 | "Headphone Playback Switch", | |
12665 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12666 | HDA_OUTPUT)); | |
12667 | if (err < 0) | |
12668 | return err; | |
12669 | } else { | |
12670 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12671 | "Headphone Playback Switch", | |
12672 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12673 | HDA_OUTPUT)); | |
12674 | if (err < 0) | |
12675 | return err; | |
12676 | } | |
12677 | } | |
12678 | return 0; | |
12679 | } | |
12680 | ||
ee956e09 TI |
12681 | static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec, |
12682 | const struct auto_pin_cfg *cfg) | |
12683 | { | |
12684 | int err; | |
12685 | ||
12686 | err = alc880_auto_create_analog_input_ctls(spec, cfg); | |
12687 | if (err < 0) | |
12688 | return err; | |
12689 | /* digital-mic input pin is excluded in alc880_auto_create..() | |
12690 | * because it's under 0x18 | |
12691 | */ | |
12692 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | |
12693 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | |
61b9b9b1 | 12694 | struct hda_input_mux *imux = &spec->private_imux[0]; |
ee956e09 TI |
12695 | imux->items[imux->num_items].label = "Int Mic"; |
12696 | imux->items[imux->num_items].index = 0x05; | |
12697 | imux->num_items++; | |
12698 | } | |
12699 | return 0; | |
12700 | } | |
f6a92248 KY |
12701 | |
12702 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12703 | #define alc269_loopbacks alc880_loopbacks | |
12704 | #endif | |
12705 | ||
12706 | /* pcm configuration: identiacal with ALC880 */ | |
12707 | #define alc269_pcm_analog_playback alc880_pcm_analog_playback | |
12708 | #define alc269_pcm_analog_capture alc880_pcm_analog_capture | |
12709 | #define alc269_pcm_digital_playback alc880_pcm_digital_playback | |
12710 | #define alc269_pcm_digital_capture alc880_pcm_digital_capture | |
12711 | ||
12712 | /* | |
12713 | * BIOS auto configuration | |
12714 | */ | |
12715 | static int alc269_parse_auto_config(struct hda_codec *codec) | |
12716 | { | |
12717 | struct alc_spec *spec = codec->spec; | |
cfb9fb55 | 12718 | int err; |
f6a92248 KY |
12719 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
12720 | ||
12721 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
12722 | alc269_ignore); | |
12723 | if (err < 0) | |
12724 | return err; | |
12725 | ||
12726 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
12727 | if (err < 0) | |
12728 | return err; | |
12729 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
12730 | if (err < 0) | |
12731 | return err; | |
12732 | ||
12733 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
12734 | ||
0852d7a6 | 12735 | if (spec->autocfg.dig_outs) |
f6a92248 KY |
12736 | spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; |
12737 | ||
603c4019 | 12738 | if (spec->kctls.list) |
d88897ea | 12739 | add_mixer(spec, spec->kctls.list); |
f6a92248 | 12740 | |
d88897ea | 12741 | add_verb(spec, alc269_init_verbs); |
f6a92248 | 12742 | spec->num_mux_defs = 1; |
61b9b9b1 | 12743 | spec->input_mux = &spec->private_imux[0]; |
e01bf509 TI |
12744 | /* set default input source */ |
12745 | snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], | |
12746 | 0, AC_VERB_SET_CONNECT_SEL, | |
12747 | spec->input_mux->items[0].index); | |
f6a92248 KY |
12748 | |
12749 | err = alc_auto_add_mic_boost(codec); | |
12750 | if (err < 0) | |
12751 | return err; | |
12752 | ||
f9e336f6 TI |
12753 | if (!spec->cap_mixer) |
12754 | set_capture_mixer(spec); | |
f53281e6 | 12755 | |
e044c39a | 12756 | store_pin_configs(codec); |
f6a92248 KY |
12757 | return 1; |
12758 | } | |
12759 | ||
12760 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | |
12761 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | |
12762 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | |
12763 | ||
12764 | ||
12765 | /* init callback for auto-configuration model -- overriding the default init */ | |
12766 | static void alc269_auto_init(struct hda_codec *codec) | |
12767 | { | |
f6c7e546 | 12768 | struct alc_spec *spec = codec->spec; |
f6a92248 KY |
12769 | alc269_auto_init_multi_out(codec); |
12770 | alc269_auto_init_hp_out(codec); | |
12771 | alc269_auto_init_analog_input(codec); | |
f6c7e546 | 12772 | if (spec->unsol_event) |
7fb0d78f | 12773 | alc_inithook(codec); |
f6a92248 KY |
12774 | } |
12775 | ||
12776 | /* | |
12777 | * configuration and preset | |
12778 | */ | |
12779 | static const char *alc269_models[ALC269_MODEL_LAST] = { | |
60db6b53 | 12780 | [ALC269_BASIC] = "basic", |
2922c9af TI |
12781 | [ALC269_QUANTA_FL1] = "quanta", |
12782 | [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", | |
26f5df26 | 12783 | [ALC269_ASUS_EEEPC_P901] = "eeepc-p901", |
64154835 TV |
12784 | [ALC269_FUJITSU] = "fujitsu", |
12785 | [ALC269_LIFEBOOK] = "lifebook" | |
f6a92248 KY |
12786 | }; |
12787 | ||
12788 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | |
60db6b53 | 12789 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), |
f53281e6 KY |
12790 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
12791 | ALC269_ASUS_EEEPC_P703), | |
12792 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | |
12793 | ALC269_ASUS_EEEPC_P901), | |
60db6b53 KY |
12794 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", |
12795 | ALC269_ASUS_EEEPC_P901), | |
26f5df26 | 12796 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), |
64154835 | 12797 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), |
f6a92248 KY |
12798 | {} |
12799 | }; | |
12800 | ||
12801 | static struct alc_config_preset alc269_presets[] = { | |
12802 | [ALC269_BASIC] = { | |
f9e336f6 | 12803 | .mixers = { alc269_base_mixer }, |
f6a92248 KY |
12804 | .init_verbs = { alc269_init_verbs }, |
12805 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12806 | .dac_nids = alc269_dac_nids, | |
12807 | .hp_nid = 0x03, | |
12808 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12809 | .channel_mode = alc269_modes, | |
12810 | .input_mux = &alc269_capture_source, | |
12811 | }, | |
60db6b53 KY |
12812 | [ALC269_QUANTA_FL1] = { |
12813 | .mixers = { alc269_quanta_fl1_mixer }, | |
12814 | .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs }, | |
12815 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12816 | .dac_nids = alc269_dac_nids, | |
12817 | .hp_nid = 0x03, | |
12818 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12819 | .channel_mode = alc269_modes, | |
12820 | .input_mux = &alc269_capture_source, | |
12821 | .unsol_event = alc269_quanta_fl1_unsol_event, | |
12822 | .init_hook = alc269_quanta_fl1_init_hook, | |
12823 | }, | |
f53281e6 | 12824 | [ALC269_ASUS_EEEPC_P703] = { |
f9e336f6 TI |
12825 | .mixers = { alc269_eeepc_mixer }, |
12826 | .cap_mixer = alc269_epc_capture_mixer, | |
f53281e6 KY |
12827 | .init_verbs = { alc269_init_verbs, |
12828 | alc269_eeepc_amic_init_verbs }, | |
12829 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12830 | .dac_nids = alc269_dac_nids, | |
12831 | .hp_nid = 0x03, | |
12832 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12833 | .channel_mode = alc269_modes, | |
12834 | .input_mux = &alc269_eeepc_amic_capture_source, | |
12835 | .unsol_event = alc269_eeepc_amic_unsol_event, | |
12836 | .init_hook = alc269_eeepc_amic_inithook, | |
12837 | }, | |
12838 | [ALC269_ASUS_EEEPC_P901] = { | |
f9e336f6 TI |
12839 | .mixers = { alc269_eeepc_mixer }, |
12840 | .cap_mixer = alc269_epc_capture_mixer, | |
f53281e6 KY |
12841 | .init_verbs = { alc269_init_verbs, |
12842 | alc269_eeepc_dmic_init_verbs }, | |
12843 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12844 | .dac_nids = alc269_dac_nids, | |
12845 | .hp_nid = 0x03, | |
12846 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12847 | .channel_mode = alc269_modes, | |
12848 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
12849 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
12850 | .init_hook = alc269_eeepc_dmic_inithook, | |
12851 | }, | |
26f5df26 | 12852 | [ALC269_FUJITSU] = { |
45bdd1c1 | 12853 | .mixers = { alc269_fujitsu_mixer }, |
26f5df26 TI |
12854 | .cap_mixer = alc269_epc_capture_mixer, |
12855 | .init_verbs = { alc269_init_verbs, | |
12856 | alc269_eeepc_dmic_init_verbs }, | |
12857 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12858 | .dac_nids = alc269_dac_nids, | |
12859 | .hp_nid = 0x03, | |
12860 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12861 | .channel_mode = alc269_modes, | |
12862 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
12863 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
12864 | .init_hook = alc269_eeepc_dmic_inithook, | |
12865 | }, | |
64154835 TV |
12866 | [ALC269_LIFEBOOK] = { |
12867 | .mixers = { alc269_lifebook_mixer }, | |
12868 | .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs }, | |
12869 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12870 | .dac_nids = alc269_dac_nids, | |
12871 | .hp_nid = 0x03, | |
12872 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12873 | .channel_mode = alc269_modes, | |
12874 | .input_mux = &alc269_capture_source, | |
12875 | .unsol_event = alc269_lifebook_unsol_event, | |
12876 | .init_hook = alc269_lifebook_init_hook, | |
12877 | }, | |
f6a92248 KY |
12878 | }; |
12879 | ||
12880 | static int patch_alc269(struct hda_codec *codec) | |
12881 | { | |
12882 | struct alc_spec *spec; | |
12883 | int board_config; | |
12884 | int err; | |
12885 | ||
12886 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
12887 | if (spec == NULL) | |
12888 | return -ENOMEM; | |
12889 | ||
12890 | codec->spec = spec; | |
12891 | ||
2c3bf9ab TI |
12892 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
12893 | ||
f6a92248 KY |
12894 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
12895 | alc269_models, | |
12896 | alc269_cfg_tbl); | |
12897 | ||
12898 | if (board_config < 0) { | |
12899 | printk(KERN_INFO "hda_codec: Unknown model for ALC269, " | |
12900 | "trying auto-probe from BIOS...\n"); | |
12901 | board_config = ALC269_AUTO; | |
12902 | } | |
12903 | ||
12904 | if (board_config == ALC269_AUTO) { | |
12905 | /* automatic parse from the BIOS config */ | |
12906 | err = alc269_parse_auto_config(codec); | |
12907 | if (err < 0) { | |
12908 | alc_free(codec); | |
12909 | return err; | |
12910 | } else if (!err) { | |
12911 | printk(KERN_INFO | |
12912 | "hda_codec: Cannot set up configuration " | |
12913 | "from BIOS. Using base mode...\n"); | |
12914 | board_config = ALC269_BASIC; | |
12915 | } | |
12916 | } | |
12917 | ||
680cd536 KK |
12918 | err = snd_hda_attach_beep_device(codec, 0x1); |
12919 | if (err < 0) { | |
12920 | alc_free(codec); | |
12921 | return err; | |
12922 | } | |
12923 | ||
f6a92248 KY |
12924 | if (board_config != ALC269_AUTO) |
12925 | setup_preset(spec, &alc269_presets[board_config]); | |
12926 | ||
12927 | spec->stream_name_analog = "ALC269 Analog"; | |
12928 | spec->stream_analog_playback = &alc269_pcm_analog_playback; | |
12929 | spec->stream_analog_capture = &alc269_pcm_analog_capture; | |
12930 | ||
12931 | spec->stream_name_digital = "ALC269 Digital"; | |
12932 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | |
12933 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | |
12934 | ||
12935 | spec->adc_nids = alc269_adc_nids; | |
12936 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | |
e01bf509 | 12937 | spec->capsrc_nids = alc269_capsrc_nids; |
f9e336f6 TI |
12938 | if (!spec->cap_mixer) |
12939 | set_capture_mixer(spec); | |
45bdd1c1 | 12940 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
f6a92248 KY |
12941 | |
12942 | codec->patch_ops = alc_patch_ops; | |
12943 | if (board_config == ALC269_AUTO) | |
12944 | spec->init_hook = alc269_auto_init; | |
12945 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12946 | if (!spec->loopback.amplist) | |
12947 | spec->loopback.amplist = alc269_loopbacks; | |
12948 | #endif | |
daead538 | 12949 | codec->proc_widget_hook = print_realtek_coef; |
f6a92248 KY |
12950 | |
12951 | return 0; | |
12952 | } | |
12953 | ||
df694daa KY |
12954 | /* |
12955 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
12956 | */ | |
12957 | ||
12958 | /* | |
12959 | * set the path ways for 2 channel output | |
12960 | * need to set the codec line out and mic 1 pin widgets to inputs | |
12961 | */ | |
12962 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
12963 | /* set pin widget 1Ah (line in) for input */ | |
12964 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12965 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12966 | * the vref | |
12967 | */ | |
df694daa KY |
12968 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12969 | ||
9c7f852e TI |
12970 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
12971 | #if 0 | |
12972 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12973 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12974 | #endif | |
df694daa KY |
12975 | { } /* end */ |
12976 | }; | |
12977 | /* | |
12978 | * 6ch mode | |
12979 | * need to set the codec line out and mic 1 pin widgets to outputs | |
12980 | */ | |
12981 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
12982 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12983 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12984 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12985 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12986 | ||
12987 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 12988 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 12989 | |
9c7f852e TI |
12990 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
12991 | #if 0 | |
12992 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12993 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12994 | #endif | |
df694daa KY |
12995 | { } /* end */ |
12996 | }; | |
12997 | ||
12998 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
12999 | { 2, alc861_threestack_ch2_init }, | |
13000 | { 6, alc861_threestack_ch6_init }, | |
13001 | }; | |
22309c3e TI |
13002 | /* Set mic1 as input and unmute the mixer */ |
13003 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
13004 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13005 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
13006 | { } /* end */ | |
13007 | }; | |
13008 | /* Set mic1 as output and mute mixer */ | |
13009 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
13010 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13011 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
13012 | { } /* end */ | |
13013 | }; | |
13014 | ||
13015 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
13016 | { 2, alc861_uniwill_m31_ch2_init }, | |
13017 | { 4, alc861_uniwill_m31_ch4_init }, | |
13018 | }; | |
df694daa | 13019 | |
7cdbff94 MD |
13020 | /* Set mic1 and line-in as input and unmute the mixer */ |
13021 | static struct hda_verb alc861_asus_ch2_init[] = { | |
13022 | /* set pin widget 1Ah (line in) for input */ | |
13023 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
13024 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
13025 | * the vref | |
13026 | */ | |
7cdbff94 MD |
13027 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
13028 | ||
13029 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
13030 | #if 0 | |
13031 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
13032 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
13033 | #endif | |
13034 | { } /* end */ | |
13035 | }; | |
13036 | /* Set mic1 nad line-in as output and mute mixer */ | |
13037 | static struct hda_verb alc861_asus_ch6_init[] = { | |
13038 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
13039 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13040 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
13041 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
13042 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13043 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
13044 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13045 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13046 | ||
13047 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
13048 | #if 0 | |
13049 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
13050 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
13051 | #endif | |
13052 | { } /* end */ | |
13053 | }; | |
13054 | ||
13055 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
13056 | { 2, alc861_asus_ch2_init }, | |
13057 | { 6, alc861_asus_ch6_init }, | |
13058 | }; | |
13059 | ||
df694daa KY |
13060 | /* patch-ALC861 */ |
13061 | ||
13062 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
13063 | /* output mixer control */ | |
13064 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
13065 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
13066 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
13067 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
13068 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
13069 | ||
13070 | /*Input mixer control */ | |
13071 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
13072 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
13073 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
13074 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
13075 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
13076 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
13077 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
13078 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
13079 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
13080 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 13081 | |
df694daa KY |
13082 | { } /* end */ |
13083 | }; | |
13084 | ||
13085 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
13086 | /* output mixer control */ | |
13087 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
13088 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
13089 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
13090 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
13091 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
13092 | ||
13093 | /* Input mixer control */ | |
13094 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
13095 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
13096 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
13097 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
13098 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
13099 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
13100 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
13101 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
13102 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
13103 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 13104 | |
df694daa KY |
13105 | { |
13106 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13107 | .name = "Channel Mode", | |
13108 | .info = alc_ch_mode_info, | |
13109 | .get = alc_ch_mode_get, | |
13110 | .put = alc_ch_mode_put, | |
13111 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
13112 | }, | |
13113 | { } /* end */ | |
a53d1aec TD |
13114 | }; |
13115 | ||
d1d985f0 | 13116 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
13117 | /* output mixer control */ |
13118 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
13119 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
13120 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
ea1fb29a | 13121 | |
a53d1aec | 13122 | { } /* end */ |
f12ab1e0 | 13123 | }; |
a53d1aec | 13124 | |
22309c3e TI |
13125 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
13126 | /* output mixer control */ | |
13127 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
13128 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
13129 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
13130 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
13131 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
13132 | ||
13133 | /* Input mixer control */ | |
13134 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
13135 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
13136 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
13137 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
13138 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
13139 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
13140 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
13141 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
13142 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
13143 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 13144 | |
22309c3e TI |
13145 | { |
13146 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13147 | .name = "Channel Mode", | |
13148 | .info = alc_ch_mode_info, | |
13149 | .get = alc_ch_mode_get, | |
13150 | .put = alc_ch_mode_put, | |
13151 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
13152 | }, | |
13153 | { } /* end */ | |
f12ab1e0 | 13154 | }; |
7cdbff94 MD |
13155 | |
13156 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
13157 | /* output mixer control */ | |
13158 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
13159 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
13160 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
13161 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
13162 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
13163 | ||
13164 | /* Input mixer control */ | |
13165 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
13166 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
13167 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
13168 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
13169 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
13170 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
13171 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
13172 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
13173 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
13174 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
13175 | ||
7cdbff94 MD |
13176 | { |
13177 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13178 | .name = "Channel Mode", | |
13179 | .info = alc_ch_mode_info, | |
13180 | .get = alc_ch_mode_get, | |
13181 | .put = alc_ch_mode_put, | |
13182 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
13183 | }, | |
13184 | { } | |
56bb0cab TI |
13185 | }; |
13186 | ||
13187 | /* additional mixer */ | |
d1d985f0 | 13188 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
13189 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
13190 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
56bb0cab TI |
13191 | { } |
13192 | }; | |
7cdbff94 | 13193 | |
df694daa KY |
13194 | /* |
13195 | * generic initialization of ADC, input mixers and output mixers | |
13196 | */ | |
13197 | static struct hda_verb alc861_base_init_verbs[] = { | |
13198 | /* | |
13199 | * Unmute ADC0 and set the default input to mic-in | |
13200 | */ | |
13201 | /* port-A for surround (rear panel) */ | |
13202 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13203 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13204 | /* port-B for mic-in (rear panel) with vref */ | |
13205 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13206 | /* port-C for line-in (rear panel) */ | |
13207 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13208 | /* port-D for Front */ | |
13209 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13210 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13211 | /* port-E for HP out (front panel) */ | |
13212 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
13213 | /* route front PCM to HP */ | |
9dece1d7 | 13214 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
13215 | /* port-F for mic-in (front panel) with vref */ |
13216 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13217 | /* port-G for CLFE (rear panel) */ | |
13218 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13219 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13220 | /* port-H for side (rear panel) */ | |
13221 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13222 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13223 | /* CD-in */ | |
13224 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13225 | /* route front mic to ADC1*/ | |
13226 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13227 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 13228 | |
df694daa KY |
13229 | /* Unmute DAC0~3 & spdif out*/ |
13230 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13231 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13232 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13233 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13234 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13235 | |
df694daa KY |
13236 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13237 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13238 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13239 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13240 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13241 | |
df694daa KY |
13242 | /* Unmute Stereo Mixer 15 */ |
13243 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13244 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13245 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13246 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
13247 | |
13248 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13249 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13250 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13251 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13252 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13253 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13254 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13255 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13256 | /* hp used DAC 3 (Front) */ |
13257 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13258 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13259 | ||
13260 | { } | |
13261 | }; | |
13262 | ||
13263 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
13264 | /* | |
13265 | * Unmute ADC0 and set the default input to mic-in | |
13266 | */ | |
13267 | /* port-A for surround (rear panel) */ | |
13268 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13269 | /* port-B for mic-in (rear panel) with vref */ | |
13270 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13271 | /* port-C for line-in (rear panel) */ | |
13272 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13273 | /* port-D for Front */ | |
13274 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13275 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13276 | /* port-E for HP out (front panel) */ | |
13277 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
13278 | /* route front PCM to HP */ | |
9dece1d7 | 13279 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
13280 | /* port-F for mic-in (front panel) with vref */ |
13281 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13282 | /* port-G for CLFE (rear panel) */ | |
13283 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13284 | /* port-H for side (rear panel) */ | |
13285 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13286 | /* CD-in */ | |
13287 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13288 | /* route front mic to ADC1*/ | |
13289 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13290 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13291 | /* Unmute DAC0~3 & spdif out*/ | |
13292 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13293 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13294 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13295 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13296 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13297 | |
df694daa KY |
13298 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13299 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13300 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13301 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13302 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13303 | |
df694daa KY |
13304 | /* Unmute Stereo Mixer 15 */ |
13305 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13306 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13307 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13308 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
13309 | |
13310 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13311 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13312 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13313 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13314 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13315 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13316 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13317 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13318 | /* hp used DAC 3 (Front) */ |
13319 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13320 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13321 | { } | |
13322 | }; | |
22309c3e TI |
13323 | |
13324 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
13325 | /* | |
13326 | * Unmute ADC0 and set the default input to mic-in | |
13327 | */ | |
13328 | /* port-A for surround (rear panel) */ | |
13329 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13330 | /* port-B for mic-in (rear panel) with vref */ | |
13331 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13332 | /* port-C for line-in (rear panel) */ | |
13333 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13334 | /* port-D for Front */ | |
13335 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13336 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13337 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
13338 | /* this has to be set to VREF80 */ |
13339 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 13340 | /* route front PCM to HP */ |
9dece1d7 | 13341 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
13342 | /* port-F for mic-in (front panel) with vref */ |
13343 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13344 | /* port-G for CLFE (rear panel) */ | |
13345 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13346 | /* port-H for side (rear panel) */ | |
13347 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13348 | /* CD-in */ | |
13349 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13350 | /* route front mic to ADC1*/ | |
13351 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13352 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13353 | /* Unmute DAC0~3 & spdif out*/ | |
13354 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13355 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13356 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13357 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13358 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13359 | |
22309c3e TI |
13360 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13361 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13362 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13363 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13364 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13365 | |
22309c3e TI |
13366 | /* Unmute Stereo Mixer 15 */ |
13367 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13368 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13369 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13370 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
13371 | |
13372 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13373 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13374 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13375 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13376 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13377 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13378 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13379 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13380 | /* hp used DAC 3 (Front) */ |
13381 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
13382 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13383 | { } | |
13384 | }; | |
13385 | ||
7cdbff94 MD |
13386 | static struct hda_verb alc861_asus_init_verbs[] = { |
13387 | /* | |
13388 | * Unmute ADC0 and set the default input to mic-in | |
13389 | */ | |
f12ab1e0 TI |
13390 | /* port-A for surround (rear panel) |
13391 | * according to codec#0 this is the HP jack | |
13392 | */ | |
7cdbff94 MD |
13393 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
13394 | /* route front PCM to HP */ | |
13395 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
13396 | /* port-B for mic-in (rear panel) with vref */ | |
13397 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13398 | /* port-C for line-in (rear panel) */ | |
13399 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13400 | /* port-D for Front */ | |
13401 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13402 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13403 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
13404 | /* this has to be set to VREF80 */ |
13405 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 13406 | /* route front PCM to HP */ |
9dece1d7 | 13407 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
13408 | /* port-F for mic-in (front panel) with vref */ |
13409 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13410 | /* port-G for CLFE (rear panel) */ | |
13411 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13412 | /* port-H for side (rear panel) */ | |
13413 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13414 | /* CD-in */ | |
13415 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13416 | /* route front mic to ADC1*/ | |
13417 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13418 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13419 | /* Unmute DAC0~3 & spdif out*/ | |
13420 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13421 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13422 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13423 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13424 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13425 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
13426 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13427 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13428 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13429 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13430 | |
7cdbff94 MD |
13431 | /* Unmute Stereo Mixer 15 */ |
13432 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13433 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13434 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13435 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
13436 | |
13437 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13438 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13439 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13440 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13441 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13442 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13443 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13444 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13445 | /* hp used DAC 3 (Front) */ |
13446 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
13447 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13448 | { } | |
13449 | }; | |
13450 | ||
56bb0cab TI |
13451 | /* additional init verbs for ASUS laptops */ |
13452 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
13453 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
13454 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
13455 | { } | |
13456 | }; | |
7cdbff94 | 13457 | |
df694daa KY |
13458 | /* |
13459 | * generic initialization of ADC, input mixers and output mixers | |
13460 | */ | |
13461 | static struct hda_verb alc861_auto_init_verbs[] = { | |
13462 | /* | |
13463 | * Unmute ADC0 and set the default input to mic-in | |
13464 | */ | |
f12ab1e0 | 13465 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa | 13466 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
ea1fb29a | 13467 | |
df694daa KY |
13468 | /* Unmute DAC0~3 & spdif out*/ |
13469 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13470 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13471 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13472 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13473 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13474 | |
df694daa KY |
13475 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13476 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13477 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13478 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13479 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13480 | |
df694daa KY |
13481 | /* Unmute Stereo Mixer 15 */ |
13482 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13483 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13484 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
13485 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
13486 | ||
13487 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13488 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13489 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13490 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13491 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13492 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13493 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13494 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13495 | ||
13496 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13497 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
13498 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13499 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13500 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13501 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
13502 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13503 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 13504 | |
f12ab1e0 | 13505 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
13506 | |
13507 | { } | |
13508 | }; | |
13509 | ||
a53d1aec TD |
13510 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
13511 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 13512 | |
a53d1aec TD |
13513 | { } |
13514 | }; | |
13515 | ||
13516 | /* toggle speaker-output according to the hp-jack state */ | |
13517 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
13518 | { | |
13519 | unsigned int present; | |
13520 | ||
13521 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
13522 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13523 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
13524 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
13525 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
13526 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
13527 | } |
13528 | ||
13529 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
13530 | unsigned int res) | |
13531 | { | |
a53d1aec TD |
13532 | if ((res >> 26) == ALC880_HP_EVENT) |
13533 | alc861_toshiba_automute(codec); | |
13534 | } | |
13535 | ||
df694daa KY |
13536 | /* pcm configuration: identiacal with ALC880 */ |
13537 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
13538 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
13539 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
13540 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
13541 | ||
13542 | ||
13543 | #define ALC861_DIGOUT_NID 0x07 | |
13544 | ||
13545 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
13546 | { 8, NULL } | |
13547 | }; | |
13548 | ||
13549 | static hda_nid_t alc861_dac_nids[4] = { | |
13550 | /* front, surround, clfe, side */ | |
13551 | 0x03, 0x06, 0x05, 0x04 | |
13552 | }; | |
13553 | ||
9c7f852e TI |
13554 | static hda_nid_t alc660_dac_nids[3] = { |
13555 | /* front, clfe, surround */ | |
13556 | 0x03, 0x05, 0x06 | |
13557 | }; | |
13558 | ||
df694daa KY |
13559 | static hda_nid_t alc861_adc_nids[1] = { |
13560 | /* ADC0-2 */ | |
13561 | 0x08, | |
13562 | }; | |
13563 | ||
13564 | static struct hda_input_mux alc861_capture_source = { | |
13565 | .num_items = 5, | |
13566 | .items = { | |
13567 | { "Mic", 0x0 }, | |
13568 | { "Front Mic", 0x3 }, | |
13569 | { "Line", 0x1 }, | |
13570 | { "CD", 0x4 }, | |
13571 | { "Mixer", 0x5 }, | |
13572 | }, | |
13573 | }; | |
13574 | ||
13575 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
13576 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
13577 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
13578 | { |
13579 | int i; | |
13580 | hda_nid_t nid; | |
13581 | ||
13582 | spec->multiout.dac_nids = spec->private_dac_nids; | |
13583 | for (i = 0; i < cfg->line_outs; i++) { | |
13584 | nid = cfg->line_out_pins[i]; | |
13585 | if (nid) { | |
13586 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
13587 | continue; | |
13588 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
13589 | } | |
13590 | } | |
13591 | spec->multiout.num_dacs = cfg->line_outs; | |
13592 | return 0; | |
13593 | } | |
13594 | ||
13595 | /* add playback controls from the parsed DAC table */ | |
13596 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
13597 | const struct auto_pin_cfg *cfg) | |
13598 | { | |
13599 | char name[32]; | |
f12ab1e0 TI |
13600 | static const char *chname[4] = { |
13601 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
13602 | }; | |
df694daa KY |
13603 | hda_nid_t nid; |
13604 | int i, idx, err; | |
13605 | ||
13606 | for (i = 0; i < cfg->line_outs; i++) { | |
13607 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 13608 | if (!nid) |
df694daa KY |
13609 | continue; |
13610 | if (nid == 0x05) { | |
13611 | /* Center/LFE */ | |
f12ab1e0 TI |
13612 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13613 | "Center Playback Switch", | |
13614 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
13615 | HDA_OUTPUT)); | |
13616 | if (err < 0) | |
df694daa | 13617 | return err; |
f12ab1e0 TI |
13618 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13619 | "LFE Playback Switch", | |
13620 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
13621 | HDA_OUTPUT)); | |
13622 | if (err < 0) | |
df694daa KY |
13623 | return err; |
13624 | } else { | |
f12ab1e0 TI |
13625 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
13626 | idx++) | |
df694daa KY |
13627 | if (nid == alc861_dac_nids[idx]) |
13628 | break; | |
13629 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
13630 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
13631 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
13632 | HDA_OUTPUT)); | |
13633 | if (err < 0) | |
df694daa KY |
13634 | return err; |
13635 | } | |
13636 | } | |
13637 | return 0; | |
13638 | } | |
13639 | ||
13640 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
13641 | { | |
13642 | int err; | |
13643 | hda_nid_t nid; | |
13644 | ||
f12ab1e0 | 13645 | if (!pin) |
df694daa KY |
13646 | return 0; |
13647 | ||
13648 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
13649 | nid = 0x03; | |
f12ab1e0 TI |
13650 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
13651 | "Headphone Playback Switch", | |
13652 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
13653 | if (err < 0) | |
df694daa KY |
13654 | return err; |
13655 | spec->multiout.hp_nid = nid; | |
13656 | } | |
13657 | return 0; | |
13658 | } | |
13659 | ||
13660 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
13661 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
13662 | const struct auto_pin_cfg *cfg) | |
df694daa | 13663 | { |
61b9b9b1 | 13664 | struct hda_input_mux *imux = &spec->private_imux[0]; |
df694daa KY |
13665 | int i, err, idx, idx1; |
13666 | ||
13667 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 13668 | switch (cfg->input_pins[i]) { |
df694daa KY |
13669 | case 0x0c: |
13670 | idx1 = 1; | |
f12ab1e0 | 13671 | idx = 2; /* Line In */ |
df694daa KY |
13672 | break; |
13673 | case 0x0f: | |
13674 | idx1 = 2; | |
f12ab1e0 | 13675 | idx = 2; /* Line In */ |
df694daa KY |
13676 | break; |
13677 | case 0x0d: | |
13678 | idx1 = 0; | |
f12ab1e0 | 13679 | idx = 1; /* Mic In */ |
df694daa | 13680 | break; |
f12ab1e0 | 13681 | case 0x10: |
df694daa | 13682 | idx1 = 3; |
f12ab1e0 | 13683 | idx = 1; /* Mic In */ |
df694daa KY |
13684 | break; |
13685 | case 0x11: | |
13686 | idx1 = 4; | |
f12ab1e0 | 13687 | idx = 0; /* CD */ |
df694daa KY |
13688 | break; |
13689 | default: | |
13690 | continue; | |
13691 | } | |
13692 | ||
4a471b7d TI |
13693 | err = new_analog_input(spec, cfg->input_pins[i], |
13694 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
13695 | if (err < 0) |
13696 | return err; | |
13697 | ||
4a471b7d | 13698 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 13699 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 13700 | imux->num_items++; |
df694daa KY |
13701 | } |
13702 | return 0; | |
13703 | } | |
13704 | ||
f12ab1e0 TI |
13705 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
13706 | hda_nid_t nid, | |
df694daa KY |
13707 | int pin_type, int dac_idx) |
13708 | { | |
564c5bea JL |
13709 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
13710 | pin_type); | |
13711 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
13712 | AMP_OUT_UNMUTE); | |
df694daa KY |
13713 | } |
13714 | ||
13715 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
13716 | { | |
13717 | struct alc_spec *spec = codec->spec; | |
13718 | int i; | |
13719 | ||
bc9f98a9 | 13720 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
13721 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
13722 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 13723 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 13724 | if (nid) |
baba8ee9 | 13725 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 13726 | spec->multiout.dac_nids[i]); |
df694daa KY |
13727 | } |
13728 | } | |
13729 | ||
13730 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
13731 | { | |
13732 | struct alc_spec *spec = codec->spec; | |
13733 | hda_nid_t pin; | |
13734 | ||
eb06ed8f | 13735 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 13736 | if (pin) /* connect to front */ |
f12ab1e0 TI |
13737 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
13738 | spec->multiout.dac_nids[0]); | |
f6c7e546 TI |
13739 | pin = spec->autocfg.speaker_pins[0]; |
13740 | if (pin) | |
13741 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
13742 | } |
13743 | ||
13744 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
13745 | { | |
13746 | struct alc_spec *spec = codec->spec; | |
13747 | int i; | |
13748 | ||
13749 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13750 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
13751 | if (nid >= 0x0c && nid <= 0x11) { |
13752 | snd_hda_codec_write(codec, nid, 0, | |
13753 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
13754 | i <= AUTO_PIN_FRONT_MIC ? | |
13755 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
13756 | } |
13757 | } | |
13758 | } | |
13759 | ||
13760 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
13761 | /* return 1 if successful, 0 if the proper config is not found, |
13762 | * or a negative error code | |
13763 | */ | |
df694daa KY |
13764 | static int alc861_parse_auto_config(struct hda_codec *codec) |
13765 | { | |
13766 | struct alc_spec *spec = codec->spec; | |
13767 | int err; | |
13768 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
13769 | ||
f12ab1e0 TI |
13770 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
13771 | alc861_ignore); | |
13772 | if (err < 0) | |
df694daa | 13773 | return err; |
f12ab1e0 | 13774 | if (!spec->autocfg.line_outs) |
df694daa KY |
13775 | return 0; /* can't find valid BIOS pin config */ |
13776 | ||
f12ab1e0 TI |
13777 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
13778 | if (err < 0) | |
13779 | return err; | |
13780 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
13781 | if (err < 0) | |
13782 | return err; | |
13783 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
13784 | if (err < 0) | |
13785 | return err; | |
13786 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
13787 | if (err < 0) | |
df694daa KY |
13788 | return err; |
13789 | ||
13790 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
13791 | ||
0852d7a6 | 13792 | if (spec->autocfg.dig_outs) |
df694daa KY |
13793 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; |
13794 | ||
603c4019 | 13795 | if (spec->kctls.list) |
d88897ea | 13796 | add_mixer(spec, spec->kctls.list); |
df694daa | 13797 | |
d88897ea | 13798 | add_verb(spec, alc861_auto_init_verbs); |
df694daa | 13799 | |
a1e8d2da | 13800 | spec->num_mux_defs = 1; |
61b9b9b1 | 13801 | spec->input_mux = &spec->private_imux[0]; |
df694daa KY |
13802 | |
13803 | spec->adc_nids = alc861_adc_nids; | |
13804 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
f9e336f6 | 13805 | set_capture_mixer(spec); |
df694daa | 13806 | |
e044c39a | 13807 | store_pin_configs(codec); |
df694daa KY |
13808 | return 1; |
13809 | } | |
13810 | ||
ae6b813a TI |
13811 | /* additional initialization for auto-configuration model */ |
13812 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 13813 | { |
f6c7e546 | 13814 | struct alc_spec *spec = codec->spec; |
df694daa KY |
13815 | alc861_auto_init_multi_out(codec); |
13816 | alc861_auto_init_hp_out(codec); | |
13817 | alc861_auto_init_analog_input(codec); | |
f6c7e546 | 13818 | if (spec->unsol_event) |
7fb0d78f | 13819 | alc_inithook(codec); |
df694daa KY |
13820 | } |
13821 | ||
cb53c626 TI |
13822 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13823 | static struct hda_amp_list alc861_loopbacks[] = { | |
13824 | { 0x15, HDA_INPUT, 0 }, | |
13825 | { 0x15, HDA_INPUT, 1 }, | |
13826 | { 0x15, HDA_INPUT, 2 }, | |
13827 | { 0x15, HDA_INPUT, 3 }, | |
13828 | { } /* end */ | |
13829 | }; | |
13830 | #endif | |
13831 | ||
df694daa KY |
13832 | |
13833 | /* | |
13834 | * configuration and preset | |
13835 | */ | |
f5fcc13c TI |
13836 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
13837 | [ALC861_3ST] = "3stack", | |
13838 | [ALC660_3ST] = "3stack-660", | |
13839 | [ALC861_3ST_DIG] = "3stack-dig", | |
13840 | [ALC861_6ST_DIG] = "6stack-dig", | |
13841 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
13842 | [ALC861_TOSHIBA] = "toshiba", | |
13843 | [ALC861_ASUS] = "asus", | |
13844 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
13845 | [ALC861_AUTO] = "auto", | |
13846 | }; | |
13847 | ||
13848 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 13849 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
13850 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
13851 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
13852 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), | |
ac3e3741 | 13853 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 13854 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 13855 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
13856 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
13857 | * Any other models that need this preset? | |
13858 | */ | |
13859 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
ac3e3741 TI |
13860 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
13861 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
4147dab6 | 13862 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
ac3e3741 TI |
13863 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
13864 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), | |
13865 | /* FIXME: the below seems conflict */ | |
13866 | /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ | |
07e038b3 | 13867 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 13868 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
13869 | {} |
13870 | }; | |
13871 | ||
13872 | static struct alc_config_preset alc861_presets[] = { | |
13873 | [ALC861_3ST] = { | |
13874 | .mixers = { alc861_3ST_mixer }, | |
13875 | .init_verbs = { alc861_threestack_init_verbs }, | |
13876 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13877 | .dac_nids = alc861_dac_nids, | |
13878 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13879 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13880 | .need_dac_fix = 1, |
df694daa KY |
13881 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13882 | .adc_nids = alc861_adc_nids, | |
13883 | .input_mux = &alc861_capture_source, | |
13884 | }, | |
13885 | [ALC861_3ST_DIG] = { | |
13886 | .mixers = { alc861_base_mixer }, | |
13887 | .init_verbs = { alc861_threestack_init_verbs }, | |
13888 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13889 | .dac_nids = alc861_dac_nids, | |
13890 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13891 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13892 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13893 | .need_dac_fix = 1, |
df694daa KY |
13894 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13895 | .adc_nids = alc861_adc_nids, | |
13896 | .input_mux = &alc861_capture_source, | |
13897 | }, | |
13898 | [ALC861_6ST_DIG] = { | |
13899 | .mixers = { alc861_base_mixer }, | |
13900 | .init_verbs = { alc861_base_init_verbs }, | |
13901 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13902 | .dac_nids = alc861_dac_nids, | |
13903 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13904 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
13905 | .channel_mode = alc861_8ch_modes, | |
13906 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13907 | .adc_nids = alc861_adc_nids, | |
13908 | .input_mux = &alc861_capture_source, | |
13909 | }, | |
9c7f852e TI |
13910 | [ALC660_3ST] = { |
13911 | .mixers = { alc861_3ST_mixer }, | |
13912 | .init_verbs = { alc861_threestack_init_verbs }, | |
13913 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
13914 | .dac_nids = alc660_dac_nids, | |
13915 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13916 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13917 | .need_dac_fix = 1, |
9c7f852e TI |
13918 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13919 | .adc_nids = alc861_adc_nids, | |
13920 | .input_mux = &alc861_capture_source, | |
13921 | }, | |
22309c3e TI |
13922 | [ALC861_UNIWILL_M31] = { |
13923 | .mixers = { alc861_uniwill_m31_mixer }, | |
13924 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
13925 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13926 | .dac_nids = alc861_dac_nids, | |
13927 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13928 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
13929 | .channel_mode = alc861_uniwill_m31_modes, | |
13930 | .need_dac_fix = 1, | |
13931 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13932 | .adc_nids = alc861_adc_nids, | |
13933 | .input_mux = &alc861_capture_source, | |
13934 | }, | |
a53d1aec TD |
13935 | [ALC861_TOSHIBA] = { |
13936 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
13937 | .init_verbs = { alc861_base_init_verbs, |
13938 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
13939 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
13940 | .dac_nids = alc861_dac_nids, | |
13941 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13942 | .channel_mode = alc883_3ST_2ch_modes, | |
13943 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13944 | .adc_nids = alc861_adc_nids, | |
13945 | .input_mux = &alc861_capture_source, | |
13946 | .unsol_event = alc861_toshiba_unsol_event, | |
13947 | .init_hook = alc861_toshiba_automute, | |
13948 | }, | |
7cdbff94 MD |
13949 | [ALC861_ASUS] = { |
13950 | .mixers = { alc861_asus_mixer }, | |
13951 | .init_verbs = { alc861_asus_init_verbs }, | |
13952 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13953 | .dac_nids = alc861_dac_nids, | |
13954 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13955 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
13956 | .channel_mode = alc861_asus_modes, | |
13957 | .need_dac_fix = 1, | |
13958 | .hp_nid = 0x06, | |
13959 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13960 | .adc_nids = alc861_adc_nids, | |
13961 | .input_mux = &alc861_capture_source, | |
13962 | }, | |
56bb0cab TI |
13963 | [ALC861_ASUS_LAPTOP] = { |
13964 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
13965 | .init_verbs = { alc861_asus_init_verbs, | |
13966 | alc861_asus_laptop_init_verbs }, | |
13967 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13968 | .dac_nids = alc861_dac_nids, | |
13969 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13970 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13971 | .channel_mode = alc883_3ST_2ch_modes, | |
13972 | .need_dac_fix = 1, | |
13973 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13974 | .adc_nids = alc861_adc_nids, | |
13975 | .input_mux = &alc861_capture_source, | |
13976 | }, | |
13977 | }; | |
df694daa KY |
13978 | |
13979 | ||
13980 | static int patch_alc861(struct hda_codec *codec) | |
13981 | { | |
13982 | struct alc_spec *spec; | |
13983 | int board_config; | |
13984 | int err; | |
13985 | ||
dc041e0b | 13986 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
13987 | if (spec == NULL) |
13988 | return -ENOMEM; | |
13989 | ||
f12ab1e0 | 13990 | codec->spec = spec; |
df694daa | 13991 | |
f5fcc13c TI |
13992 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
13993 | alc861_models, | |
13994 | alc861_cfg_tbl); | |
9c7f852e | 13995 | |
f5fcc13c | 13996 | if (board_config < 0) { |
9c7f852e TI |
13997 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
13998 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
13999 | board_config = ALC861_AUTO; |
14000 | } | |
14001 | ||
14002 | if (board_config == ALC861_AUTO) { | |
14003 | /* automatic parse from the BIOS config */ | |
14004 | err = alc861_parse_auto_config(codec); | |
14005 | if (err < 0) { | |
14006 | alc_free(codec); | |
14007 | return err; | |
f12ab1e0 | 14008 | } else if (!err) { |
9c7f852e TI |
14009 | printk(KERN_INFO |
14010 | "hda_codec: Cannot set up configuration " | |
14011 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
14012 | board_config = ALC861_3ST_DIG; |
14013 | } | |
14014 | } | |
14015 | ||
680cd536 KK |
14016 | err = snd_hda_attach_beep_device(codec, 0x23); |
14017 | if (err < 0) { | |
14018 | alc_free(codec); | |
14019 | return err; | |
14020 | } | |
14021 | ||
df694daa KY |
14022 | if (board_config != ALC861_AUTO) |
14023 | setup_preset(spec, &alc861_presets[board_config]); | |
14024 | ||
14025 | spec->stream_name_analog = "ALC861 Analog"; | |
14026 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
14027 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
14028 | ||
14029 | spec->stream_name_digital = "ALC861 Digital"; | |
14030 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
14031 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
14032 | ||
45bdd1c1 TI |
14033 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
14034 | ||
2134ea4f TI |
14035 | spec->vmaster_nid = 0x03; |
14036 | ||
df694daa KY |
14037 | codec->patch_ops = alc_patch_ops; |
14038 | if (board_config == ALC861_AUTO) | |
ae6b813a | 14039 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
14040 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14041 | if (!spec->loopback.amplist) | |
14042 | spec->loopback.amplist = alc861_loopbacks; | |
14043 | #endif | |
daead538 | 14044 | codec->proc_widget_hook = print_realtek_coef; |
ea1fb29a | 14045 | |
1da177e4 LT |
14046 | return 0; |
14047 | } | |
14048 | ||
f32610ed JS |
14049 | /* |
14050 | * ALC861-VD support | |
14051 | * | |
14052 | * Based on ALC882 | |
14053 | * | |
14054 | * In addition, an independent DAC | |
14055 | */ | |
14056 | #define ALC861VD_DIGOUT_NID 0x06 | |
14057 | ||
14058 | static hda_nid_t alc861vd_dac_nids[4] = { | |
14059 | /* front, surr, clfe, side surr */ | |
14060 | 0x02, 0x03, 0x04, 0x05 | |
14061 | }; | |
14062 | ||
14063 | /* dac_nids for ALC660vd are in a different order - according to | |
14064 | * Realtek's driver. | |
14065 | * This should probably tesult in a different mixer for 6stack models | |
14066 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
14067 | * - and it is the same as in 861vd. | |
14068 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
14069 | */ | |
14070 | static hda_nid_t alc660vd_dac_nids[3] = { | |
14071 | /* front, rear, clfe, rear_surr */ | |
14072 | 0x02, 0x04, 0x03 | |
14073 | }; | |
14074 | ||
14075 | static hda_nid_t alc861vd_adc_nids[1] = { | |
14076 | /* ADC0 */ | |
14077 | 0x09, | |
14078 | }; | |
14079 | ||
e1406348 TI |
14080 | static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 }; |
14081 | ||
f32610ed JS |
14082 | /* input MUX */ |
14083 | /* FIXME: should be a matrix-type input source selection */ | |
14084 | static struct hda_input_mux alc861vd_capture_source = { | |
14085 | .num_items = 4, | |
14086 | .items = { | |
14087 | { "Mic", 0x0 }, | |
14088 | { "Front Mic", 0x1 }, | |
14089 | { "Line", 0x2 }, | |
14090 | { "CD", 0x4 }, | |
14091 | }, | |
14092 | }; | |
14093 | ||
272a527c | 14094 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
b419f346 | 14095 | .num_items = 2, |
272a527c | 14096 | .items = { |
b419f346 TD |
14097 | { "Ext Mic", 0x0 }, |
14098 | { "Int Mic", 0x1 }, | |
272a527c KY |
14099 | }, |
14100 | }; | |
14101 | ||
d1a991a6 KY |
14102 | static struct hda_input_mux alc861vd_hp_capture_source = { |
14103 | .num_items = 2, | |
14104 | .items = { | |
14105 | { "Front Mic", 0x0 }, | |
14106 | { "ATAPI Mic", 0x1 }, | |
14107 | }, | |
14108 | }; | |
14109 | ||
f32610ed JS |
14110 | /* |
14111 | * 2ch mode | |
14112 | */ | |
14113 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
14114 | { 2, NULL } | |
14115 | }; | |
14116 | ||
14117 | /* | |
14118 | * 6ch mode | |
14119 | */ | |
14120 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
14121 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14122 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14123 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14124 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14125 | { } /* end */ | |
14126 | }; | |
14127 | ||
14128 | /* | |
14129 | * 8ch mode | |
14130 | */ | |
14131 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
14132 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14133 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14134 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14135 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14136 | { } /* end */ | |
14137 | }; | |
14138 | ||
14139 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
14140 | { 6, alc861vd_6stack_ch6_init }, | |
14141 | { 8, alc861vd_6stack_ch8_init }, | |
14142 | }; | |
14143 | ||
14144 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
14145 | { | |
14146 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
14147 | .name = "Channel Mode", | |
14148 | .info = alc_ch_mode_info, | |
14149 | .get = alc_ch_mode_get, | |
14150 | .put = alc_ch_mode_put, | |
14151 | }, | |
14152 | { } /* end */ | |
14153 | }; | |
14154 | ||
f32610ed JS |
14155 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
14156 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
14157 | */ | |
14158 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
14159 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14160 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
14161 | ||
14162 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
14163 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
14164 | ||
14165 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
14166 | HDA_OUTPUT), | |
14167 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
14168 | HDA_OUTPUT), | |
14169 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
14170 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
14171 | ||
14172 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
14173 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
14174 | ||
14175 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
14176 | ||
14177 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
14178 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14179 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14180 | ||
14181 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
14182 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14183 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14184 | ||
14185 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14186 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14187 | ||
14188 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14189 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14190 | ||
f32610ed JS |
14191 | { } /* end */ |
14192 | }; | |
14193 | ||
14194 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
14195 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14196 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
14197 | ||
14198 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
14199 | ||
14200 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
14201 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14202 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14203 | ||
14204 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
14205 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14206 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14207 | ||
14208 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14209 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14210 | ||
14211 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14212 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14213 | ||
f32610ed JS |
14214 | { } /* end */ |
14215 | }; | |
14216 | ||
bdd148a3 KY |
14217 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
14218 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14219 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
14220 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
14221 | ||
14222 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
14223 | ||
14224 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
14225 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14226 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14227 | ||
14228 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
14229 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14230 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14231 | ||
14232 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14233 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14234 | ||
14235 | { } /* end */ | |
14236 | }; | |
14237 | ||
b419f346 TD |
14238 | /* Pin assignment: Speaker=0x14, HP = 0x15, |
14239 | * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d | |
272a527c KY |
14240 | */ |
14241 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
b419f346 TD |
14242 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14243 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
272a527c KY |
14244 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
14245 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
b419f346 TD |
14246 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), |
14247 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14248 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14249 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
14250 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14251 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
272a527c KY |
14252 | { } /* end */ |
14253 | }; | |
14254 | ||
d1a991a6 KY |
14255 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
14256 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
14257 | */ | |
14258 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
14259 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14260 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
14261 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
14262 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
14263 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14264 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14265 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14266 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ea1fb29a | 14267 | |
d1a991a6 KY |
14268 | { } /* end */ |
14269 | }; | |
14270 | ||
f32610ed JS |
14271 | /* |
14272 | * generic initialization of ADC, input mixers and output mixers | |
14273 | */ | |
14274 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
14275 | /* | |
14276 | * Unmute ADC0 and set the default input to mic-in | |
14277 | */ | |
14278 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14279 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14280 | ||
14281 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
14282 | * the analog-loopback mixer widget | |
14283 | */ | |
14284 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
14285 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14286 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14287 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14288 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14289 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
14290 | |
14291 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
14292 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
14293 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14294 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 14295 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
14296 | |
14297 | /* | |
14298 | * Set up output mixers (0x02 - 0x05) | |
14299 | */ | |
14300 | /* set vol=0 to output mixers */ | |
14301 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14302 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14303 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14304 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14305 | ||
14306 | /* set up input amps for analog loopback */ | |
14307 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
14308 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14309 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14310 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14311 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14312 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14313 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14314 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14315 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14316 | ||
14317 | { } | |
14318 | }; | |
14319 | ||
14320 | /* | |
14321 | * 3-stack pin configuration: | |
14322 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
14323 | */ | |
14324 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
14325 | /* | |
14326 | * Set pin mode and muting | |
14327 | */ | |
14328 | /* set front pin widgets 0x14 for output */ | |
14329 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14330 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14331 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14332 | ||
14333 | /* Mic (rear) pin: input vref at 80% */ | |
14334 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14335 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14336 | /* Front Mic pin: input vref at 80% */ | |
14337 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14338 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14339 | /* Line In pin: input */ | |
14340 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14341 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14342 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
14343 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14344 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14345 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14346 | /* CD pin widget for input */ | |
14347 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14348 | ||
14349 | { } | |
14350 | }; | |
14351 | ||
14352 | /* | |
14353 | * 6-stack pin configuration: | |
14354 | */ | |
14355 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
14356 | /* | |
14357 | * Set pin mode and muting | |
14358 | */ | |
14359 | /* set front pin widgets 0x14 for output */ | |
14360 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14361 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14362 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14363 | ||
14364 | /* Rear Pin: output 1 (0x0d) */ | |
14365 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14366 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14367 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
14368 | /* CLFE Pin: output 2 (0x0e) */ | |
14369 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14370 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14371 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
14372 | /* Side Pin: output 3 (0x0f) */ | |
14373 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14374 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14375 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
14376 | ||
14377 | /* Mic (rear) pin: input vref at 80% */ | |
14378 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14379 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14380 | /* Front Mic pin: input vref at 80% */ | |
14381 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14382 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14383 | /* Line In pin: input */ | |
14384 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14385 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14386 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
14387 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14388 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14389 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14390 | /* CD pin widget for input */ | |
14391 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14392 | ||
14393 | { } | |
14394 | }; | |
14395 | ||
bdd148a3 KY |
14396 | static struct hda_verb alc861vd_eapd_verbs[] = { |
14397 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14398 | { } | |
14399 | }; | |
14400 | ||
f9423e7a KY |
14401 | static struct hda_verb alc660vd_eapd_verbs[] = { |
14402 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14403 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14404 | { } | |
14405 | }; | |
14406 | ||
bdd148a3 KY |
14407 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { |
14408 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14409 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14410 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
14411 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
ea1fb29a | 14412 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
bdd148a3 KY |
14413 | {} |
14414 | }; | |
14415 | ||
14416 | /* toggle speaker-output according to the hp-jack state */ | |
14417 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
14418 | { | |
14419 | unsigned int present; | |
14420 | unsigned char bits; | |
14421 | ||
14422 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
14423 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14424 | bits = present ? HDA_AMP_MUTE : 0; |
14425 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
14426 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
14427 | } |
14428 | ||
14429 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
14430 | { | |
14431 | unsigned int present; | |
14432 | unsigned char bits; | |
14433 | ||
14434 | present = snd_hda_codec_read(codec, 0x18, 0, | |
14435 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14436 | bits = present ? HDA_AMP_MUTE : 0; |
14437 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
14438 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
14439 | } |
14440 | ||
14441 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
14442 | { | |
14443 | alc861vd_lenovo_hp_automute(codec); | |
14444 | alc861vd_lenovo_mic_automute(codec); | |
14445 | } | |
14446 | ||
14447 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
14448 | unsigned int res) | |
14449 | { | |
14450 | switch (res >> 26) { | |
14451 | case ALC880_HP_EVENT: | |
14452 | alc861vd_lenovo_hp_automute(codec); | |
14453 | break; | |
14454 | case ALC880_MIC_EVENT: | |
14455 | alc861vd_lenovo_mic_automute(codec); | |
14456 | break; | |
14457 | } | |
14458 | } | |
14459 | ||
272a527c KY |
14460 | static struct hda_verb alc861vd_dallas_verbs[] = { |
14461 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14462 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14463 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14464 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14465 | ||
14466 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14467 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14468 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14469 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14470 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14471 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14472 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14473 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
ea1fb29a | 14474 | |
272a527c KY |
14475 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
14476 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14477 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14478 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14479 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14480 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14481 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14482 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14483 | ||
14484 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
14485 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14486 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
14487 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14488 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14489 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14490 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14491 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14492 | ||
14493 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14494 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14495 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14496 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
14497 | ||
14498 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 14499 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
272a527c KY |
14500 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
14501 | ||
14502 | { } /* end */ | |
14503 | }; | |
14504 | ||
14505 | /* toggle speaker-output according to the hp-jack state */ | |
14506 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
14507 | { | |
14508 | unsigned int present; | |
14509 | ||
14510 | present = snd_hda_codec_read(codec, 0x15, 0, | |
14511 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14512 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
14513 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
14514 | } |
14515 | ||
14516 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
14517 | { | |
14518 | if ((res >> 26) == ALC880_HP_EVENT) | |
14519 | alc861vd_dallas_automute(codec); | |
14520 | } | |
14521 | ||
cb53c626 TI |
14522 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14523 | #define alc861vd_loopbacks alc880_loopbacks | |
14524 | #endif | |
14525 | ||
f32610ed JS |
14526 | /* pcm configuration: identiacal with ALC880 */ |
14527 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
14528 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
14529 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
14530 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
14531 | ||
14532 | /* | |
14533 | * configuration and preset | |
14534 | */ | |
14535 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
14536 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 14537 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
13c94744 | 14538 | [ALC660VD_ASUS_V1S] = "asus-v1s", |
f32610ed JS |
14539 | [ALC861VD_3ST] = "3stack", |
14540 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
14541 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 14542 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 14543 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 14544 | [ALC861VD_HP] = "hp", |
f32610ed JS |
14545 | [ALC861VD_AUTO] = "auto", |
14546 | }; | |
14547 | ||
14548 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
ac3e3741 TI |
14549 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), |
14550 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), | |
07e038b3 | 14551 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 14552 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
13c94744 | 14553 | SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S), |
6963f84c | 14554 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed | 14555 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
ac3e3741 | 14556 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
38baf5ad | 14557 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 14558 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
542d7c66 | 14559 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
b419f346 | 14560 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), |
39c5d41f | 14561 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
dea0a509 | 14562 | SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO), |
625dc0bf | 14563 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
f32610ed JS |
14564 | {} |
14565 | }; | |
14566 | ||
14567 | static struct alc_config_preset alc861vd_presets[] = { | |
14568 | [ALC660VD_3ST] = { | |
14569 | .mixers = { alc861vd_3st_mixer }, | |
14570 | .init_verbs = { alc861vd_volume_init_verbs, | |
14571 | alc861vd_3stack_init_verbs }, | |
14572 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14573 | .dac_nids = alc660vd_dac_nids, | |
f32610ed JS |
14574 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14575 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14576 | .input_mux = &alc861vd_capture_source, | |
14577 | }, | |
6963f84c MC |
14578 | [ALC660VD_3ST_DIG] = { |
14579 | .mixers = { alc861vd_3st_mixer }, | |
14580 | .init_verbs = { alc861vd_volume_init_verbs, | |
14581 | alc861vd_3stack_init_verbs }, | |
14582 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14583 | .dac_nids = alc660vd_dac_nids, | |
14584 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
6963f84c MC |
14585 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14586 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14587 | .input_mux = &alc861vd_capture_source, | |
14588 | }, | |
f32610ed JS |
14589 | [ALC861VD_3ST] = { |
14590 | .mixers = { alc861vd_3st_mixer }, | |
14591 | .init_verbs = { alc861vd_volume_init_verbs, | |
14592 | alc861vd_3stack_init_verbs }, | |
14593 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14594 | .dac_nids = alc861vd_dac_nids, | |
14595 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14596 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14597 | .input_mux = &alc861vd_capture_source, | |
14598 | }, | |
14599 | [ALC861VD_3ST_DIG] = { | |
14600 | .mixers = { alc861vd_3st_mixer }, | |
14601 | .init_verbs = { alc861vd_volume_init_verbs, | |
14602 | alc861vd_3stack_init_verbs }, | |
14603 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14604 | .dac_nids = alc861vd_dac_nids, | |
14605 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14606 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14607 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14608 | .input_mux = &alc861vd_capture_source, | |
14609 | }, | |
14610 | [ALC861VD_6ST_DIG] = { | |
14611 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
14612 | .init_verbs = { alc861vd_volume_init_verbs, | |
14613 | alc861vd_6stack_init_verbs }, | |
14614 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14615 | .dac_nids = alc861vd_dac_nids, | |
14616 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14617 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
14618 | .channel_mode = alc861vd_6stack_modes, | |
14619 | .input_mux = &alc861vd_capture_source, | |
14620 | }, | |
bdd148a3 KY |
14621 | [ALC861VD_LENOVO] = { |
14622 | .mixers = { alc861vd_lenovo_mixer }, | |
14623 | .init_verbs = { alc861vd_volume_init_verbs, | |
14624 | alc861vd_3stack_init_verbs, | |
14625 | alc861vd_eapd_verbs, | |
14626 | alc861vd_lenovo_unsol_verbs }, | |
14627 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14628 | .dac_nids = alc660vd_dac_nids, | |
bdd148a3 KY |
14629 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14630 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14631 | .input_mux = &alc861vd_capture_source, | |
14632 | .unsol_event = alc861vd_lenovo_unsol_event, | |
14633 | .init_hook = alc861vd_lenovo_automute, | |
14634 | }, | |
272a527c KY |
14635 | [ALC861VD_DALLAS] = { |
14636 | .mixers = { alc861vd_dallas_mixer }, | |
14637 | .init_verbs = { alc861vd_dallas_verbs }, | |
14638 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14639 | .dac_nids = alc861vd_dac_nids, | |
272a527c KY |
14640 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14641 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14642 | .input_mux = &alc861vd_dallas_capture_source, | |
14643 | .unsol_event = alc861vd_dallas_unsol_event, | |
14644 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
14645 | }, |
14646 | [ALC861VD_HP] = { | |
14647 | .mixers = { alc861vd_hp_mixer }, | |
14648 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
14649 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14650 | .dac_nids = alc861vd_dac_nids, | |
d1a991a6 | 14651 | .dig_out_nid = ALC861VD_DIGOUT_NID, |
d1a991a6 KY |
14652 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14653 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14654 | .input_mux = &alc861vd_hp_capture_source, | |
14655 | .unsol_event = alc861vd_dallas_unsol_event, | |
14656 | .init_hook = alc861vd_dallas_automute, | |
ea1fb29a | 14657 | }, |
13c94744 TI |
14658 | [ALC660VD_ASUS_V1S] = { |
14659 | .mixers = { alc861vd_lenovo_mixer }, | |
14660 | .init_verbs = { alc861vd_volume_init_verbs, | |
14661 | alc861vd_3stack_init_verbs, | |
14662 | alc861vd_eapd_verbs, | |
14663 | alc861vd_lenovo_unsol_verbs }, | |
14664 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14665 | .dac_nids = alc660vd_dac_nids, | |
14666 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14667 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14668 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14669 | .input_mux = &alc861vd_capture_source, | |
14670 | .unsol_event = alc861vd_lenovo_unsol_event, | |
14671 | .init_hook = alc861vd_lenovo_automute, | |
14672 | }, | |
f32610ed JS |
14673 | }; |
14674 | ||
14675 | /* | |
14676 | * BIOS auto configuration | |
14677 | */ | |
14678 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
14679 | hda_nid_t nid, int pin_type, int dac_idx) | |
14680 | { | |
f6c7e546 | 14681 | alc_set_pin_output(codec, nid, pin_type); |
f32610ed JS |
14682 | } |
14683 | ||
14684 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
14685 | { | |
14686 | struct alc_spec *spec = codec->spec; | |
14687 | int i; | |
14688 | ||
bc9f98a9 | 14689 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
14690 | for (i = 0; i <= HDA_SIDE; i++) { |
14691 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 14692 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
14693 | if (nid) |
14694 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 14695 | pin_type, i); |
f32610ed JS |
14696 | } |
14697 | } | |
14698 | ||
14699 | ||
14700 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
14701 | { | |
14702 | struct alc_spec *spec = codec->spec; | |
14703 | hda_nid_t pin; | |
14704 | ||
14705 | pin = spec->autocfg.hp_pins[0]; | |
14706 | if (pin) /* connect to front and use dac 0 */ | |
14707 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
14708 | pin = spec->autocfg.speaker_pins[0]; |
14709 | if (pin) | |
14710 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
f32610ed JS |
14711 | } |
14712 | ||
14713 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
14714 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
14715 | ||
14716 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
14717 | { | |
14718 | struct alc_spec *spec = codec->spec; | |
14719 | int i; | |
14720 | ||
14721 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
14722 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
14723 | if (alc861vd_is_input_pin(nid)) { | |
14724 | snd_hda_codec_write(codec, nid, 0, | |
14725 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
14726 | i <= AUTO_PIN_FRONT_MIC ? | |
14727 | PIN_VREF80 : PIN_IN); | |
14728 | if (nid != ALC861VD_PIN_CD_NID) | |
14729 | snd_hda_codec_write(codec, nid, 0, | |
14730 | AC_VERB_SET_AMP_GAIN_MUTE, | |
14731 | AMP_OUT_MUTE); | |
14732 | } | |
14733 | } | |
14734 | } | |
14735 | ||
f511b01c TI |
14736 | #define alc861vd_auto_init_input_src alc882_auto_init_input_src |
14737 | ||
f32610ed JS |
14738 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) |
14739 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
14740 | ||
14741 | /* add playback controls from the parsed DAC table */ | |
14742 | /* Based on ALC880 version. But ALC861VD has separate, | |
14743 | * different NIDs for mute/unmute switch and volume control */ | |
14744 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
14745 | const struct auto_pin_cfg *cfg) | |
14746 | { | |
14747 | char name[32]; | |
14748 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
14749 | hda_nid_t nid_v, nid_s; | |
14750 | int i, err; | |
14751 | ||
14752 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 14753 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
14754 | continue; |
14755 | nid_v = alc861vd_idx_to_mixer_vol( | |
14756 | alc880_dac_to_idx( | |
14757 | spec->multiout.dac_nids[i])); | |
14758 | nid_s = alc861vd_idx_to_mixer_switch( | |
14759 | alc880_dac_to_idx( | |
14760 | spec->multiout.dac_nids[i])); | |
14761 | ||
14762 | if (i == 2) { | |
14763 | /* Center/LFE */ | |
f12ab1e0 TI |
14764 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14765 | "Center Playback Volume", | |
14766 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
14767 | HDA_OUTPUT)); | |
14768 | if (err < 0) | |
f32610ed | 14769 | return err; |
f12ab1e0 TI |
14770 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14771 | "LFE Playback Volume", | |
14772 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
14773 | HDA_OUTPUT)); | |
14774 | if (err < 0) | |
f32610ed | 14775 | return err; |
f12ab1e0 TI |
14776 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14777 | "Center Playback Switch", | |
14778 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
14779 | HDA_INPUT)); | |
14780 | if (err < 0) | |
f32610ed | 14781 | return err; |
f12ab1e0 TI |
14782 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14783 | "LFE Playback Switch", | |
14784 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
14785 | HDA_INPUT)); | |
14786 | if (err < 0) | |
f32610ed JS |
14787 | return err; |
14788 | } else { | |
14789 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
14790 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14791 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
14792 | HDA_OUTPUT)); | |
14793 | if (err < 0) | |
f32610ed JS |
14794 | return err; |
14795 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 14796 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 14797 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
14798 | HDA_INPUT)); |
14799 | if (err < 0) | |
f32610ed JS |
14800 | return err; |
14801 | } | |
14802 | } | |
14803 | return 0; | |
14804 | } | |
14805 | ||
14806 | /* add playback controls for speaker and HP outputs */ | |
14807 | /* Based on ALC880 version. But ALC861VD has separate, | |
14808 | * different NIDs for mute/unmute switch and volume control */ | |
14809 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
14810 | hda_nid_t pin, const char *pfx) | |
14811 | { | |
14812 | hda_nid_t nid_v, nid_s; | |
14813 | int err; | |
14814 | char name[32]; | |
14815 | ||
f12ab1e0 | 14816 | if (!pin) |
f32610ed JS |
14817 | return 0; |
14818 | ||
14819 | if (alc880_is_fixed_pin(pin)) { | |
14820 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
14821 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 14822 | if (!spec->multiout.hp_nid) |
f32610ed JS |
14823 | spec->multiout.hp_nid = nid_v; |
14824 | else | |
14825 | spec->multiout.extra_out_nid[0] = nid_v; | |
14826 | /* control HP volume/switch on the output mixer amp */ | |
14827 | nid_v = alc861vd_idx_to_mixer_vol( | |
14828 | alc880_fixed_pin_idx(pin)); | |
14829 | nid_s = alc861vd_idx_to_mixer_switch( | |
14830 | alc880_fixed_pin_idx(pin)); | |
14831 | ||
14832 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
14833 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14834 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
14835 | if (err < 0) | |
f32610ed JS |
14836 | return err; |
14837 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14838 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
14839 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
14840 | if (err < 0) | |
f32610ed JS |
14841 | return err; |
14842 | } else if (alc880_is_multi_pin(pin)) { | |
14843 | /* set manual connection */ | |
14844 | /* we have only a switch on HP-out PIN */ | |
14845 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14846 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
14847 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
14848 | if (err < 0) | |
f32610ed JS |
14849 | return err; |
14850 | } | |
14851 | return 0; | |
14852 | } | |
14853 | ||
14854 | /* parse the BIOS configuration and set up the alc_spec | |
14855 | * return 1 if successful, 0 if the proper config is not found, | |
14856 | * or a negative error code | |
14857 | * Based on ALC880 version - had to change it to override | |
14858 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
14859 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
14860 | { | |
14861 | struct alc_spec *spec = codec->spec; | |
14862 | int err; | |
14863 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
14864 | ||
f12ab1e0 TI |
14865 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
14866 | alc861vd_ignore); | |
14867 | if (err < 0) | |
f32610ed | 14868 | return err; |
f12ab1e0 | 14869 | if (!spec->autocfg.line_outs) |
f32610ed JS |
14870 | return 0; /* can't find valid BIOS pin config */ |
14871 | ||
f12ab1e0 TI |
14872 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
14873 | if (err < 0) | |
14874 | return err; | |
14875 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
14876 | if (err < 0) | |
14877 | return err; | |
14878 | err = alc861vd_auto_create_extra_out(spec, | |
14879 | spec->autocfg.speaker_pins[0], | |
14880 | "Speaker"); | |
14881 | if (err < 0) | |
14882 | return err; | |
14883 | err = alc861vd_auto_create_extra_out(spec, | |
14884 | spec->autocfg.hp_pins[0], | |
14885 | "Headphone"); | |
14886 | if (err < 0) | |
14887 | return err; | |
14888 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
14889 | if (err < 0) | |
f32610ed JS |
14890 | return err; |
14891 | ||
14892 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
14893 | ||
0852d7a6 | 14894 | if (spec->autocfg.dig_outs) |
f32610ed JS |
14895 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; |
14896 | ||
603c4019 | 14897 | if (spec->kctls.list) |
d88897ea | 14898 | add_mixer(spec, spec->kctls.list); |
f32610ed | 14899 | |
d88897ea | 14900 | add_verb(spec, alc861vd_volume_init_verbs); |
f32610ed JS |
14901 | |
14902 | spec->num_mux_defs = 1; | |
61b9b9b1 | 14903 | spec->input_mux = &spec->private_imux[0]; |
f32610ed | 14904 | |
776e184e TI |
14905 | err = alc_auto_add_mic_boost(codec); |
14906 | if (err < 0) | |
14907 | return err; | |
14908 | ||
e044c39a | 14909 | store_pin_configs(codec); |
f32610ed JS |
14910 | return 1; |
14911 | } | |
14912 | ||
14913 | /* additional initialization for auto-configuration model */ | |
14914 | static void alc861vd_auto_init(struct hda_codec *codec) | |
14915 | { | |
f6c7e546 | 14916 | struct alc_spec *spec = codec->spec; |
f32610ed JS |
14917 | alc861vd_auto_init_multi_out(codec); |
14918 | alc861vd_auto_init_hp_out(codec); | |
14919 | alc861vd_auto_init_analog_input(codec); | |
f511b01c | 14920 | alc861vd_auto_init_input_src(codec); |
f6c7e546 | 14921 | if (spec->unsol_event) |
7fb0d78f | 14922 | alc_inithook(codec); |
f32610ed JS |
14923 | } |
14924 | ||
14925 | static int patch_alc861vd(struct hda_codec *codec) | |
14926 | { | |
14927 | struct alc_spec *spec; | |
14928 | int err, board_config; | |
14929 | ||
14930 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
14931 | if (spec == NULL) | |
14932 | return -ENOMEM; | |
14933 | ||
14934 | codec->spec = spec; | |
14935 | ||
14936 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
14937 | alc861vd_models, | |
14938 | alc861vd_cfg_tbl); | |
14939 | ||
14940 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
14941 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
14942 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
14943 | board_config = ALC861VD_AUTO; | |
14944 | } | |
14945 | ||
14946 | if (board_config == ALC861VD_AUTO) { | |
14947 | /* automatic parse from the BIOS config */ | |
14948 | err = alc861vd_parse_auto_config(codec); | |
14949 | if (err < 0) { | |
14950 | alc_free(codec); | |
14951 | return err; | |
f12ab1e0 | 14952 | } else if (!err) { |
f32610ed JS |
14953 | printk(KERN_INFO |
14954 | "hda_codec: Cannot set up configuration " | |
14955 | "from BIOS. Using base mode...\n"); | |
14956 | board_config = ALC861VD_3ST; | |
14957 | } | |
14958 | } | |
14959 | ||
680cd536 KK |
14960 | err = snd_hda_attach_beep_device(codec, 0x23); |
14961 | if (err < 0) { | |
14962 | alc_free(codec); | |
14963 | return err; | |
14964 | } | |
14965 | ||
f32610ed JS |
14966 | if (board_config != ALC861VD_AUTO) |
14967 | setup_preset(spec, &alc861vd_presets[board_config]); | |
14968 | ||
2f893286 KY |
14969 | if (codec->vendor_id == 0x10ec0660) { |
14970 | spec->stream_name_analog = "ALC660-VD Analog"; | |
14971 | spec->stream_name_digital = "ALC660-VD Digital"; | |
f9423e7a | 14972 | /* always turn on EAPD */ |
d88897ea | 14973 | add_verb(spec, alc660vd_eapd_verbs); |
2f893286 KY |
14974 | } else { |
14975 | spec->stream_name_analog = "ALC861VD Analog"; | |
14976 | spec->stream_name_digital = "ALC861VD Digital"; | |
14977 | } | |
14978 | ||
f32610ed JS |
14979 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; |
14980 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
14981 | ||
f32610ed JS |
14982 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; |
14983 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
14984 | ||
14985 | spec->adc_nids = alc861vd_adc_nids; | |
14986 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
e1406348 | 14987 | spec->capsrc_nids = alc861vd_capsrc_nids; |
61b9b9b1 | 14988 | spec->capture_style = CAPT_MIX; |
f32610ed | 14989 | |
f9e336f6 | 14990 | set_capture_mixer(spec); |
45bdd1c1 | 14991 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
f32610ed | 14992 | |
2134ea4f TI |
14993 | spec->vmaster_nid = 0x02; |
14994 | ||
f32610ed JS |
14995 | codec->patch_ops = alc_patch_ops; |
14996 | ||
14997 | if (board_config == ALC861VD_AUTO) | |
14998 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
14999 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
15000 | if (!spec->loopback.amplist) | |
15001 | spec->loopback.amplist = alc861vd_loopbacks; | |
15002 | #endif | |
daead538 | 15003 | codec->proc_widget_hook = print_realtek_coef; |
f32610ed JS |
15004 | |
15005 | return 0; | |
15006 | } | |
15007 | ||
bc9f98a9 KY |
15008 | /* |
15009 | * ALC662 support | |
15010 | * | |
15011 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
15012 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
15013 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
15014 | * 6-channel independent captures. | |
15015 | * | |
15016 | * In addition, an independent DAC for the multi-playback (not used in this | |
15017 | * driver yet). | |
15018 | */ | |
15019 | #define ALC662_DIGOUT_NID 0x06 | |
15020 | #define ALC662_DIGIN_NID 0x0a | |
15021 | ||
15022 | static hda_nid_t alc662_dac_nids[4] = { | |
15023 | /* front, rear, clfe, rear_surr */ | |
15024 | 0x02, 0x03, 0x04 | |
15025 | }; | |
15026 | ||
15027 | static hda_nid_t alc662_adc_nids[1] = { | |
15028 | /* ADC1-2 */ | |
15029 | 0x09, | |
15030 | }; | |
e1406348 | 15031 | |
77a261b7 | 15032 | static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; |
e1406348 | 15033 | |
bc9f98a9 KY |
15034 | /* input MUX */ |
15035 | /* FIXME: should be a matrix-type input source selection */ | |
bc9f98a9 KY |
15036 | static struct hda_input_mux alc662_capture_source = { |
15037 | .num_items = 4, | |
15038 | .items = { | |
15039 | { "Mic", 0x0 }, | |
15040 | { "Front Mic", 0x1 }, | |
15041 | { "Line", 0x2 }, | |
15042 | { "CD", 0x4 }, | |
15043 | }, | |
15044 | }; | |
15045 | ||
15046 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
15047 | .num_items = 2, | |
15048 | .items = { | |
15049 | { "Mic", 0x1 }, | |
15050 | { "Line", 0x2 }, | |
15051 | }, | |
15052 | }; | |
291702f0 KY |
15053 | |
15054 | static struct hda_input_mux alc662_eeepc_capture_source = { | |
15055 | .num_items = 2, | |
15056 | .items = { | |
15057 | { "i-Mic", 0x1 }, | |
15058 | { "e-Mic", 0x0 }, | |
15059 | }, | |
15060 | }; | |
15061 | ||
6dda9f4a KY |
15062 | static struct hda_input_mux alc663_capture_source = { |
15063 | .num_items = 3, | |
15064 | .items = { | |
15065 | { "Mic", 0x0 }, | |
15066 | { "Front Mic", 0x1 }, | |
15067 | { "Line", 0x2 }, | |
15068 | }, | |
15069 | }; | |
15070 | ||
15071 | static struct hda_input_mux alc663_m51va_capture_source = { | |
15072 | .num_items = 2, | |
15073 | .items = { | |
15074 | { "Ext-Mic", 0x0 }, | |
15075 | { "D-Mic", 0x9 }, | |
15076 | }, | |
15077 | }; | |
15078 | ||
bc9f98a9 KY |
15079 | /* |
15080 | * 2ch mode | |
15081 | */ | |
15082 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
15083 | { 2, NULL } | |
15084 | }; | |
15085 | ||
15086 | /* | |
15087 | * 2ch mode | |
15088 | */ | |
15089 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
15090 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
15091 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
15092 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
15093 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
15094 | { } /* end */ | |
15095 | }; | |
15096 | ||
15097 | /* | |
15098 | * 6ch mode | |
15099 | */ | |
15100 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
15101 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
15102 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
15103 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
15104 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
15105 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
15106 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
15107 | { } /* end */ | |
15108 | }; | |
15109 | ||
15110 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
15111 | { 2, alc662_3ST_ch2_init }, | |
15112 | { 6, alc662_3ST_ch6_init }, | |
15113 | }; | |
15114 | ||
15115 | /* | |
15116 | * 2ch mode | |
15117 | */ | |
15118 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
15119 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
15120 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
15121 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
15122 | { } /* end */ | |
15123 | }; | |
15124 | ||
15125 | /* | |
15126 | * 6ch mode | |
15127 | */ | |
15128 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
15129 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
15130 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
15131 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
15132 | { } /* end */ | |
15133 | }; | |
15134 | ||
15135 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
15136 | { 2, alc662_sixstack_ch6_init }, | |
15137 | { 6, alc662_sixstack_ch8_init }, | |
15138 | }; | |
15139 | ||
15140 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
15141 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
15142 | */ | |
15143 | ||
15144 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
15145 | /* output mixer control */ | |
15146 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
7055ad8a | 15147 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 15148 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), |
7055ad8a | 15149 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
15150 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
15151 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
15152 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
15153 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
15154 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15155 | ||
15156 | /*Input mixer control */ | |
15157 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
15158 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
15159 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
15160 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
15161 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
15162 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
15163 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
15164 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
bc9f98a9 KY |
15165 | { } /* end */ |
15166 | }; | |
15167 | ||
15168 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
15169 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 15170 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 KY |
15171 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15172 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
15173 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
15174 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15175 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15176 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15177 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15178 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15179 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
15180 | { } /* end */ |
15181 | }; | |
15182 | ||
15183 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
15184 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 15185 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 15186 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
7055ad8a | 15187 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
15188 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
15189 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
15190 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
15191 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
15192 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15193 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
15194 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
15195 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15196 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15197 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15198 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15199 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15200 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
15201 | { } /* end */ |
15202 | }; | |
15203 | ||
15204 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
15205 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15206 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
86cd9298 TI |
15207 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
15208 | HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), | |
bc9f98a9 KY |
15209 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15210 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15211 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15212 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15213 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
15214 | { } /* end */ |
15215 | }; | |
15216 | ||
291702f0 | 15217 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
86cd9298 | 15218 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
291702f0 | 15219 | |
b4818494 HRK |
15220 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15221 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
291702f0 KY |
15222 | |
15223 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | |
15224 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15225 | HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15226 | ||
15227 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
15228 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15229 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15230 | { } /* end */ | |
15231 | }; | |
15232 | ||
8c427226 | 15233 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { |
31bffaa9 TI |
15234 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15235 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8c427226 KY |
15236 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
15237 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
15238 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
15239 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
15240 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
15241 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
86cd9298 | 15242 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
8c427226 KY |
15243 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), |
15244 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15245 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15246 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15247 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15248 | { } /* end */ | |
15249 | }; | |
15250 | ||
f1d4e28b KY |
15251 | static struct hda_bind_ctls alc663_asus_bind_master_vol = { |
15252 | .ops = &snd_hda_bind_vol, | |
15253 | .values = { | |
15254 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
15255 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
15256 | 0 | |
15257 | }, | |
15258 | }; | |
15259 | ||
15260 | static struct hda_bind_ctls alc663_asus_one_bind_switch = { | |
15261 | .ops = &snd_hda_bind_sw, | |
15262 | .values = { | |
15263 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15264 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
15265 | 0 | |
15266 | }, | |
15267 | }; | |
15268 | ||
6dda9f4a | 15269 | static struct snd_kcontrol_new alc663_m51va_mixer[] = { |
f1d4e28b KY |
15270 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), |
15271 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch), | |
15272 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15273 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15274 | { } /* end */ | |
15275 | }; | |
15276 | ||
15277 | static struct hda_bind_ctls alc663_asus_tree_bind_switch = { | |
15278 | .ops = &snd_hda_bind_sw, | |
15279 | .values = { | |
15280 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15281 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
15282 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
15283 | 0 | |
15284 | }, | |
15285 | }; | |
15286 | ||
15287 | static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = { | |
15288 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15289 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch), | |
15290 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15291 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15292 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15293 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15294 | ||
15295 | { } /* end */ | |
15296 | }; | |
15297 | ||
15298 | static struct hda_bind_ctls alc663_asus_four_bind_switch = { | |
15299 | .ops = &snd_hda_bind_sw, | |
15300 | .values = { | |
15301 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15302 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
15303 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
15304 | 0 | |
15305 | }, | |
15306 | }; | |
15307 | ||
15308 | static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = { | |
15309 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15310 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch), | |
15311 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15312 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15313 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15314 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15315 | { } /* end */ | |
15316 | }; | |
15317 | ||
15318 | static struct snd_kcontrol_new alc662_1bjd_mixer[] = { | |
6dda9f4a KY |
15319 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15320 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
f1d4e28b KY |
15321 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15322 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15323 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15324 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15325 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15326 | { } /* end */ | |
15327 | }; | |
15328 | ||
15329 | static struct hda_bind_ctls alc663_asus_two_bind_master_vol = { | |
15330 | .ops = &snd_hda_bind_vol, | |
15331 | .values = { | |
15332 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
15333 | HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT), | |
15334 | 0 | |
15335 | }, | |
15336 | }; | |
15337 | ||
15338 | static struct hda_bind_ctls alc663_asus_two_bind_switch = { | |
15339 | .ops = &snd_hda_bind_sw, | |
15340 | .values = { | |
15341 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15342 | HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT), | |
15343 | 0 | |
15344 | }, | |
15345 | }; | |
15346 | ||
15347 | static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = { | |
15348 | HDA_BIND_VOL("Master Playback Volume", | |
15349 | &alc663_asus_two_bind_master_vol), | |
15350 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
15351 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
6dda9f4a KY |
15352 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
15353 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15354 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f1d4e28b KY |
15355 | { } /* end */ |
15356 | }; | |
15357 | ||
15358 | static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = { | |
15359 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15360 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
15361 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
15362 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
15363 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15364 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6dda9f4a KY |
15365 | { } /* end */ |
15366 | }; | |
15367 | ||
15368 | static struct snd_kcontrol_new alc663_g71v_mixer[] = { | |
15369 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15370 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
15371 | HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
15372 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
15373 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
15374 | ||
15375 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15376 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15377 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15378 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15379 | { } /* end */ | |
15380 | }; | |
15381 | ||
15382 | static struct snd_kcontrol_new alc663_g50v_mixer[] = { | |
15383 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15384 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
15385 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
15386 | ||
15387 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15388 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15389 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15390 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15391 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15392 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15393 | { } /* end */ | |
15394 | }; | |
15395 | ||
bc9f98a9 KY |
15396 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
15397 | { | |
15398 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
15399 | .name = "Channel Mode", | |
15400 | .info = alc_ch_mode_info, | |
15401 | .get = alc_ch_mode_get, | |
15402 | .put = alc_ch_mode_put, | |
15403 | }, | |
15404 | { } /* end */ | |
15405 | }; | |
15406 | ||
15407 | static struct hda_verb alc662_init_verbs[] = { | |
15408 | /* ADC: mute amp left and right */ | |
15409 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15410 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15411 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
15412 | ||
cb53c626 TI |
15413 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
15414 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
15415 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
15416 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
15417 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 | 15418 | |
b60dd394 KY |
15419 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
15420 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15421 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15422 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15423 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15424 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
15425 | |
15426 | /* Front Pin: output 0 (0x0c) */ | |
15427 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15428 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15429 | ||
15430 | /* Rear Pin: output 1 (0x0d) */ | |
15431 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15432 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15433 | ||
15434 | /* CLFE Pin: output 2 (0x0e) */ | |
15435 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15436 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15437 | ||
15438 | /* Mic (rear) pin: input vref at 80% */ | |
15439 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
15440 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15441 | /* Front Mic pin: input vref at 80% */ | |
15442 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
15443 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15444 | /* Line In pin: input */ | |
15445 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15446 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15447 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
15448 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15449 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15450 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15451 | /* CD pin widget for input */ | |
15452 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15453 | ||
15454 | /* FIXME: use matrix-type input source selection */ | |
15455 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
15456 | /* Input mixer */ | |
15457 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15458 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15459 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
15460 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
291702f0 KY |
15461 | |
15462 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15463 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15464 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
15465 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6dda9f4a KY |
15466 | |
15467 | /* always trun on EAPD */ | |
15468 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
15469 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
15470 | ||
bc9f98a9 KY |
15471 | { } |
15472 | }; | |
15473 | ||
15474 | static struct hda_verb alc662_sue_init_verbs[] = { | |
15475 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
15476 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
291702f0 KY |
15477 | {} |
15478 | }; | |
15479 | ||
15480 | static struct hda_verb alc662_eeepc_sue_init_verbs[] = { | |
15481 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15482 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15483 | {} | |
bc9f98a9 KY |
15484 | }; |
15485 | ||
8c427226 KY |
15486 | /* Set Unsolicited Event*/ |
15487 | static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { | |
15488 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15489 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15490 | {} | |
15491 | }; | |
15492 | ||
bc9f98a9 KY |
15493 | /* |
15494 | * generic initialization of ADC, input mixers and output mixers | |
15495 | */ | |
15496 | static struct hda_verb alc662_auto_init_verbs[] = { | |
15497 | /* | |
15498 | * Unmute ADC and set the default input to mic-in | |
15499 | */ | |
15500 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15501 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15502 | ||
15503 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
15504 | * mixer widget | |
15505 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
15506 | * panel mic (mic 2) | |
15507 | */ | |
15508 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
15509 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
15510 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
15511 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
15512 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
15513 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
15514 | |
15515 | /* | |
15516 | * Set up output mixers (0x0c - 0x0f) | |
15517 | */ | |
15518 | /* set vol=0 to output mixers */ | |
15519 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15520 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15521 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15522 | ||
15523 | /* set up input amps for analog loopback */ | |
15524 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
b60dd394 KY |
15525 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
15526 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15527 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15528 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15529 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15530 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
15531 | |
15532 | ||
15533 | /* FIXME: use matrix-type input source selection */ | |
15534 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
15535 | /* Input mixer */ | |
15536 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 15537 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
15538 | { } |
15539 | }; | |
15540 | ||
24fb9173 TI |
15541 | /* additional verbs for ALC663 */ |
15542 | static struct hda_verb alc663_auto_init_verbs[] = { | |
15543 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15544 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15545 | { } | |
15546 | }; | |
15547 | ||
6dda9f4a | 15548 | static struct hda_verb alc663_m51va_init_verbs[] = { |
f1d4e28b KY |
15549 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
15550 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6dda9f4a KY |
15551 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
15552 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f1d4e28b KY |
15553 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ |
15554 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15555 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | |
15556 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15557 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15558 | {} | |
15559 | }; | |
15560 | ||
15561 | static struct hda_verb alc663_21jd_amic_init_verbs[] = { | |
15562 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15563 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15564 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15565 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15566 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15567 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15568 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15569 | {} | |
15570 | }; | |
15571 | ||
15572 | static struct hda_verb alc662_1bjd_amic_init_verbs[] = { | |
15573 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15574 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15575 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15576 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15577 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15578 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15579 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15580 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15581 | {} | |
15582 | }; | |
6dda9f4a | 15583 | |
f1d4e28b KY |
15584 | static struct hda_verb alc663_15jd_amic_init_verbs[] = { |
15585 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15586 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15587 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15588 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15589 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15590 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15591 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15592 | {} | |
15593 | }; | |
6dda9f4a | 15594 | |
f1d4e28b KY |
15595 | static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = { |
15596 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15597 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15598 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15599 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
15600 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15601 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15602 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
15603 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15604 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6dda9f4a KY |
15605 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
15606 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f1d4e28b KY |
15607 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
15608 | {} | |
15609 | }; | |
15610 | ||
15611 | static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = { | |
15612 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15613 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15614 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15615 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15616 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15617 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15618 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15619 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15620 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15621 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15622 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15623 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
6dda9f4a KY |
15624 | {} |
15625 | }; | |
15626 | ||
15627 | static struct hda_verb alc663_g71v_init_verbs[] = { | |
15628 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15629 | /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
15630 | /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */ | |
15631 | ||
15632 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15633 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15634 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15635 | ||
15636 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
15637 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT}, | |
15638 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
15639 | {} | |
15640 | }; | |
15641 | ||
15642 | static struct hda_verb alc663_g50v_init_verbs[] = { | |
15643 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15644 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15645 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15646 | ||
15647 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15648 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15649 | {} | |
15650 | }; | |
15651 | ||
f1d4e28b KY |
15652 | static struct hda_verb alc662_ecs_init_verbs[] = { |
15653 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f}, | |
15654 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15655 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15656 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15657 | {} | |
15658 | }; | |
15659 | ||
f1d4e28b KY |
15660 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { |
15661 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
15662 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
15663 | { } /* end */ | |
15664 | }; | |
15665 | ||
bc9f98a9 KY |
15666 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
15667 | { | |
15668 | unsigned int present; | |
f12ab1e0 | 15669 | unsigned char bits; |
bc9f98a9 KY |
15670 | |
15671 | present = snd_hda_codec_read(codec, 0x14, 0, | |
15672 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
15673 | bits = present ? HDA_AMP_MUTE : 0; |
15674 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15675 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
15676 | } |
15677 | ||
15678 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
15679 | { | |
15680 | unsigned int present; | |
f12ab1e0 | 15681 | unsigned char bits; |
bc9f98a9 KY |
15682 | |
15683 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15684 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
15685 | bits = present ? HDA_AMP_MUTE : 0; |
15686 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15687 | HDA_AMP_MUTE, bits); | |
15688 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15689 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
15690 | } |
15691 | ||
15692 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
15693 | unsigned int res) | |
15694 | { | |
15695 | if ((res >> 26) == ALC880_HP_EVENT) | |
15696 | alc662_lenovo_101e_all_automute(codec); | |
15697 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
15698 | alc662_lenovo_101e_ispeaker_automute(codec); | |
15699 | } | |
15700 | ||
291702f0 KY |
15701 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) |
15702 | { | |
15703 | unsigned int present; | |
15704 | ||
15705 | present = snd_hda_codec_read(codec, 0x18, 0, | |
15706 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
15707 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15708 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
15709 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15710 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
15711 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15712 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
15713 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15714 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
15715 | } | |
15716 | ||
15717 | /* unsolicited event for HP jack sensing */ | |
15718 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | |
15719 | unsigned int res) | |
15720 | { | |
15721 | if ((res >> 26) == ALC880_HP_EVENT) | |
15722 | alc262_hippo1_automute( codec ); | |
15723 | ||
15724 | if ((res >> 26) == ALC880_MIC_EVENT) | |
15725 | alc662_eeepc_mic_automute(codec); | |
15726 | } | |
15727 | ||
15728 | static void alc662_eeepc_inithook(struct hda_codec *codec) | |
15729 | { | |
15730 | alc262_hippo1_automute( codec ); | |
15731 | alc662_eeepc_mic_automute(codec); | |
15732 | } | |
15733 | ||
8c427226 KY |
15734 | static void alc662_eeepc_ep20_automute(struct hda_codec *codec) |
15735 | { | |
15736 | unsigned int mute; | |
15737 | unsigned int present; | |
15738 | ||
15739 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
15740 | present = snd_hda_codec_read(codec, 0x14, 0, | |
15741 | AC_VERB_GET_PIN_SENSE, 0); | |
15742 | present = (present & 0x80000000) != 0; | |
15743 | if (present) { | |
15744 | /* mute internal speaker */ | |
15745 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15746 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
8c427226 KY |
15747 | } else { |
15748 | /* unmute internal speaker if necessary */ | |
15749 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
15750 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15751 | HDA_AMP_MUTE, mute); |
8c427226 KY |
15752 | } |
15753 | } | |
15754 | ||
15755 | /* unsolicited event for HP jack sensing */ | |
15756 | static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, | |
15757 | unsigned int res) | |
15758 | { | |
15759 | if ((res >> 26) == ALC880_HP_EVENT) | |
15760 | alc662_eeepc_ep20_automute(codec); | |
15761 | } | |
15762 | ||
15763 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | |
15764 | { | |
15765 | alc662_eeepc_ep20_automute(codec); | |
15766 | } | |
15767 | ||
6dda9f4a KY |
15768 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
15769 | { | |
15770 | unsigned int present; | |
15771 | unsigned char bits; | |
15772 | ||
15773 | present = snd_hda_codec_read(codec, 0x21, 0, | |
f1d4e28b KY |
15774 | AC_VERB_GET_PIN_SENSE, 0) |
15775 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15776 | bits = present ? HDA_AMP_MUTE : 0; |
f1d4e28b KY |
15777 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
15778 | AMP_IN_MUTE(0), bits); | |
15779 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15780 | AMP_IN_MUTE(0), bits); | |
15781 | } | |
15782 | ||
15783 | static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) | |
15784 | { | |
15785 | unsigned int present; | |
15786 | unsigned char bits; | |
15787 | ||
15788 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15789 | AC_VERB_GET_PIN_SENSE, 0) | |
15790 | & AC_PINSENSE_PRESENCE; | |
15791 | bits = present ? HDA_AMP_MUTE : 0; | |
15792 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15793 | AMP_IN_MUTE(0), bits); | |
15794 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15795 | AMP_IN_MUTE(0), bits); | |
15796 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15797 | AMP_IN_MUTE(0), bits); | |
15798 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15799 | AMP_IN_MUTE(0), bits); | |
15800 | } | |
15801 | ||
15802 | static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) | |
15803 | { | |
15804 | unsigned int present; | |
15805 | unsigned char bits; | |
15806 | ||
15807 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15808 | AC_VERB_GET_PIN_SENSE, 0) | |
15809 | & AC_PINSENSE_PRESENCE; | |
15810 | bits = present ? HDA_AMP_MUTE : 0; | |
15811 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15812 | AMP_IN_MUTE(0), bits); | |
15813 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15814 | AMP_IN_MUTE(0), bits); | |
15815 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15816 | AMP_IN_MUTE(0), bits); | |
15817 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15818 | AMP_IN_MUTE(0), bits); | |
15819 | } | |
15820 | ||
15821 | static void alc662_f5z_speaker_automute(struct hda_codec *codec) | |
15822 | { | |
15823 | unsigned int present; | |
15824 | unsigned char bits; | |
15825 | ||
15826 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15827 | AC_VERB_GET_PIN_SENSE, 0) | |
15828 | & AC_PINSENSE_PRESENCE; | |
15829 | bits = present ? 0 : PIN_OUT; | |
15830 | snd_hda_codec_write(codec, 0x14, 0, | |
15831 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
15832 | } | |
15833 | ||
15834 | static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec) | |
15835 | { | |
15836 | unsigned int present1, present2; | |
15837 | ||
15838 | present1 = snd_hda_codec_read(codec, 0x21, 0, | |
15839 | AC_VERB_GET_PIN_SENSE, 0) | |
15840 | & AC_PINSENSE_PRESENCE; | |
15841 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15842 | AC_VERB_GET_PIN_SENSE, 0) | |
15843 | & AC_PINSENSE_PRESENCE; | |
15844 | ||
15845 | if (present1 || present2) { | |
15846 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15847 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | |
15848 | } else { | |
15849 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15850 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
15851 | } | |
15852 | } | |
15853 | ||
15854 | static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |
15855 | { | |
15856 | unsigned int present1, present2; | |
15857 | ||
15858 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | |
15859 | AC_VERB_GET_PIN_SENSE, 0) | |
15860 | & AC_PINSENSE_PRESENCE; | |
15861 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15862 | AC_VERB_GET_PIN_SENSE, 0) | |
15863 | & AC_PINSENSE_PRESENCE; | |
15864 | ||
15865 | if (present1 || present2) { | |
15866 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15867 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15868 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15869 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15870 | } else { | |
15871 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15872 | AMP_IN_MUTE(0), 0); | |
15873 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15874 | AMP_IN_MUTE(0), 0); | |
15875 | } | |
6dda9f4a KY |
15876 | } |
15877 | ||
15878 | static void alc663_m51va_mic_automute(struct hda_codec *codec) | |
15879 | { | |
15880 | unsigned int present; | |
15881 | ||
15882 | present = snd_hda_codec_read(codec, 0x18, 0, | |
ea1fb29a KY |
15883 | AC_VERB_GET_PIN_SENSE, 0) |
15884 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15885 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15886 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15887 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15888 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15889 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15890 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a | 15891 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15892 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a KY |
15893 | } |
15894 | ||
15895 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | |
15896 | unsigned int res) | |
15897 | { | |
15898 | switch (res >> 26) { | |
15899 | case ALC880_HP_EVENT: | |
15900 | alc663_m51va_speaker_automute(codec); | |
15901 | break; | |
15902 | case ALC880_MIC_EVENT: | |
15903 | alc663_m51va_mic_automute(codec); | |
15904 | break; | |
15905 | } | |
15906 | } | |
15907 | ||
15908 | static void alc663_m51va_inithook(struct hda_codec *codec) | |
15909 | { | |
15910 | alc663_m51va_speaker_automute(codec); | |
15911 | alc663_m51va_mic_automute(codec); | |
15912 | } | |
15913 | ||
f1d4e28b KY |
15914 | /* ***************** Mode1 ******************************/ |
15915 | static void alc663_mode1_unsol_event(struct hda_codec *codec, | |
15916 | unsigned int res) | |
15917 | { | |
15918 | switch (res >> 26) { | |
15919 | case ALC880_HP_EVENT: | |
15920 | alc663_m51va_speaker_automute(codec); | |
15921 | break; | |
15922 | case ALC880_MIC_EVENT: | |
15923 | alc662_eeepc_mic_automute(codec); | |
15924 | break; | |
15925 | } | |
15926 | } | |
15927 | ||
15928 | static void alc663_mode1_inithook(struct hda_codec *codec) | |
15929 | { | |
15930 | alc663_m51va_speaker_automute(codec); | |
15931 | alc662_eeepc_mic_automute(codec); | |
15932 | } | |
15933 | /* ***************** Mode2 ******************************/ | |
15934 | static void alc662_mode2_unsol_event(struct hda_codec *codec, | |
15935 | unsigned int res) | |
15936 | { | |
15937 | switch (res >> 26) { | |
15938 | case ALC880_HP_EVENT: | |
15939 | alc662_f5z_speaker_automute(codec); | |
15940 | break; | |
15941 | case ALC880_MIC_EVENT: | |
15942 | alc662_eeepc_mic_automute(codec); | |
15943 | break; | |
15944 | } | |
15945 | } | |
15946 | ||
15947 | static void alc662_mode2_inithook(struct hda_codec *codec) | |
15948 | { | |
15949 | alc662_f5z_speaker_automute(codec); | |
15950 | alc662_eeepc_mic_automute(codec); | |
15951 | } | |
15952 | /* ***************** Mode3 ******************************/ | |
15953 | static void alc663_mode3_unsol_event(struct hda_codec *codec, | |
15954 | unsigned int res) | |
15955 | { | |
15956 | switch (res >> 26) { | |
15957 | case ALC880_HP_EVENT: | |
15958 | alc663_two_hp_m1_speaker_automute(codec); | |
15959 | break; | |
15960 | case ALC880_MIC_EVENT: | |
15961 | alc662_eeepc_mic_automute(codec); | |
15962 | break; | |
15963 | } | |
15964 | } | |
15965 | ||
15966 | static void alc663_mode3_inithook(struct hda_codec *codec) | |
15967 | { | |
15968 | alc663_two_hp_m1_speaker_automute(codec); | |
15969 | alc662_eeepc_mic_automute(codec); | |
15970 | } | |
15971 | /* ***************** Mode4 ******************************/ | |
15972 | static void alc663_mode4_unsol_event(struct hda_codec *codec, | |
15973 | unsigned int res) | |
15974 | { | |
15975 | switch (res >> 26) { | |
15976 | case ALC880_HP_EVENT: | |
15977 | alc663_21jd_two_speaker_automute(codec); | |
15978 | break; | |
15979 | case ALC880_MIC_EVENT: | |
15980 | alc662_eeepc_mic_automute(codec); | |
15981 | break; | |
15982 | } | |
15983 | } | |
15984 | ||
15985 | static void alc663_mode4_inithook(struct hda_codec *codec) | |
15986 | { | |
15987 | alc663_21jd_two_speaker_automute(codec); | |
15988 | alc662_eeepc_mic_automute(codec); | |
15989 | } | |
15990 | /* ***************** Mode5 ******************************/ | |
15991 | static void alc663_mode5_unsol_event(struct hda_codec *codec, | |
15992 | unsigned int res) | |
15993 | { | |
15994 | switch (res >> 26) { | |
15995 | case ALC880_HP_EVENT: | |
15996 | alc663_15jd_two_speaker_automute(codec); | |
15997 | break; | |
15998 | case ALC880_MIC_EVENT: | |
15999 | alc662_eeepc_mic_automute(codec); | |
16000 | break; | |
16001 | } | |
16002 | } | |
16003 | ||
16004 | static void alc663_mode5_inithook(struct hda_codec *codec) | |
16005 | { | |
16006 | alc663_15jd_two_speaker_automute(codec); | |
16007 | alc662_eeepc_mic_automute(codec); | |
16008 | } | |
16009 | /* ***************** Mode6 ******************************/ | |
16010 | static void alc663_mode6_unsol_event(struct hda_codec *codec, | |
16011 | unsigned int res) | |
16012 | { | |
16013 | switch (res >> 26) { | |
16014 | case ALC880_HP_EVENT: | |
16015 | alc663_two_hp_m2_speaker_automute(codec); | |
16016 | break; | |
16017 | case ALC880_MIC_EVENT: | |
16018 | alc662_eeepc_mic_automute(codec); | |
16019 | break; | |
16020 | } | |
16021 | } | |
16022 | ||
16023 | static void alc663_mode6_inithook(struct hda_codec *codec) | |
16024 | { | |
16025 | alc663_two_hp_m2_speaker_automute(codec); | |
16026 | alc662_eeepc_mic_automute(codec); | |
16027 | } | |
16028 | ||
6dda9f4a KY |
16029 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
16030 | { | |
16031 | unsigned int present; | |
16032 | unsigned char bits; | |
16033 | ||
16034 | present = snd_hda_codec_read(codec, 0x21, 0, | |
16035 | AC_VERB_GET_PIN_SENSE, 0) | |
16036 | & AC_PINSENSE_PRESENCE; | |
16037 | bits = present ? HDA_AMP_MUTE : 0; | |
16038 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
16039 | HDA_AMP_MUTE, bits); | |
16040 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
16041 | HDA_AMP_MUTE, bits); | |
16042 | } | |
16043 | ||
16044 | static void alc663_g71v_front_automute(struct hda_codec *codec) | |
16045 | { | |
16046 | unsigned int present; | |
16047 | unsigned char bits; | |
16048 | ||
16049 | present = snd_hda_codec_read(codec, 0x15, 0, | |
16050 | AC_VERB_GET_PIN_SENSE, 0) | |
16051 | & AC_PINSENSE_PRESENCE; | |
16052 | bits = present ? HDA_AMP_MUTE : 0; | |
16053 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
16054 | HDA_AMP_MUTE, bits); | |
16055 | } | |
16056 | ||
16057 | static void alc663_g71v_unsol_event(struct hda_codec *codec, | |
16058 | unsigned int res) | |
16059 | { | |
16060 | switch (res >> 26) { | |
16061 | case ALC880_HP_EVENT: | |
16062 | alc663_g71v_hp_automute(codec); | |
16063 | break; | |
16064 | case ALC880_FRONT_EVENT: | |
16065 | alc663_g71v_front_automute(codec); | |
16066 | break; | |
16067 | case ALC880_MIC_EVENT: | |
16068 | alc662_eeepc_mic_automute(codec); | |
16069 | break; | |
16070 | } | |
16071 | } | |
16072 | ||
16073 | static void alc663_g71v_inithook(struct hda_codec *codec) | |
16074 | { | |
16075 | alc663_g71v_front_automute(codec); | |
16076 | alc663_g71v_hp_automute(codec); | |
16077 | alc662_eeepc_mic_automute(codec); | |
16078 | } | |
16079 | ||
16080 | static void alc663_g50v_unsol_event(struct hda_codec *codec, | |
16081 | unsigned int res) | |
16082 | { | |
16083 | switch (res >> 26) { | |
16084 | case ALC880_HP_EVENT: | |
16085 | alc663_m51va_speaker_automute(codec); | |
16086 | break; | |
16087 | case ALC880_MIC_EVENT: | |
16088 | alc662_eeepc_mic_automute(codec); | |
16089 | break; | |
16090 | } | |
16091 | } | |
16092 | ||
16093 | static void alc663_g50v_inithook(struct hda_codec *codec) | |
16094 | { | |
16095 | alc663_m51va_speaker_automute(codec); | |
16096 | alc662_eeepc_mic_automute(codec); | |
16097 | } | |
16098 | ||
f1d4e28b KY |
16099 | /* bind hp and internal speaker mute (with plug check) */ |
16100 | static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol, | |
16101 | struct snd_ctl_elem_value *ucontrol) | |
16102 | { | |
16103 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
16104 | long *valp = ucontrol->value.integer.value; | |
16105 | int change; | |
16106 | ||
16107 | change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, | |
16108 | HDA_AMP_MUTE, | |
16109 | valp[0] ? 0 : HDA_AMP_MUTE); | |
16110 | change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, | |
16111 | HDA_AMP_MUTE, | |
16112 | valp[1] ? 0 : HDA_AMP_MUTE); | |
16113 | if (change) | |
16114 | alc262_hippo1_automute(codec); | |
16115 | return change; | |
16116 | } | |
16117 | ||
16118 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { | |
16119 | HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
16120 | { | |
16121 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
16122 | .name = "Master Playback Switch", | |
16123 | .info = snd_hda_mixer_amp_switch_info, | |
16124 | .get = snd_hda_mixer_amp_switch_get, | |
16125 | .put = alc662_ecs_master_sw_put, | |
16126 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
16127 | }, | |
16128 | ||
16129 | HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), | |
16130 | HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
16131 | HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16132 | ||
16133 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
16134 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
16135 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
16136 | { } /* end */ | |
16137 | }; | |
16138 | ||
cb53c626 TI |
16139 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
16140 | #define alc662_loopbacks alc880_loopbacks | |
16141 | #endif | |
16142 | ||
bc9f98a9 KY |
16143 | |
16144 | /* pcm configuration: identiacal with ALC880 */ | |
16145 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
16146 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
16147 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
16148 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
16149 | ||
16150 | /* | |
16151 | * configuration and preset | |
16152 | */ | |
16153 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
16154 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
16155 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
16156 | [ALC662_3ST_6ch] = "3stack-6ch", | |
16157 | [ALC662_5ST_DIG] = "6stack-dig", | |
16158 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
b995d76d | 16159 | [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", |
8c427226 | 16160 | [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", |
f1d4e28b | 16161 | [ALC662_ECS] = "ecs", |
6dda9f4a KY |
16162 | [ALC663_ASUS_M51VA] = "m51va", |
16163 | [ALC663_ASUS_G71V] = "g71v", | |
16164 | [ALC663_ASUS_H13] = "h13", | |
16165 | [ALC663_ASUS_G50V] = "g50v", | |
f1d4e28b KY |
16166 | [ALC663_ASUS_MODE1] = "asus-mode1", |
16167 | [ALC662_ASUS_MODE2] = "asus-mode2", | |
16168 | [ALC663_ASUS_MODE3] = "asus-mode3", | |
16169 | [ALC663_ASUS_MODE4] = "asus-mode4", | |
16170 | [ALC663_ASUS_MODE5] = "asus-mode5", | |
16171 | [ALC663_ASUS_MODE6] = "asus-mode6", | |
bc9f98a9 KY |
16172 | [ALC662_AUTO] = "auto", |
16173 | }; | |
16174 | ||
16175 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
dea0a509 | 16176 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS), |
f1d4e28b | 16177 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), |
dea0a509 TI |
16178 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), |
16179 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3), | |
f1d4e28b | 16180 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), |
dea0a509 | 16181 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), |
f1d4e28b | 16182 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), |
f1d4e28b | 16183 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), |
dea0a509 TI |
16184 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), |
16185 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), | |
16186 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), | |
16187 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), | |
16188 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), | |
f1d4e28b | 16189 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2), |
dea0a509 TI |
16190 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5), |
16191 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6), | |
16192 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2), | |
f1d4e28b | 16193 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2), |
dea0a509 TI |
16194 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2), |
16195 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), | |
16196 | /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/ | |
f1d4e28b | 16197 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), |
f1d4e28b | 16198 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), |
dea0a509 TI |
16199 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1), |
16200 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), | |
16201 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2), | |
16202 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1), | |
16203 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3), | |
16204 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1), | |
16205 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V), | |
16206 | /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/ | |
16207 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1), | |
16208 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2), | |
16209 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1), | |
f1d4e28b | 16210 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4), |
dea0a509 TI |
16211 | SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), |
16212 | SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), | |
16213 | SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), | |
16214 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), | |
95fe5f2c HRK |
16215 | SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", |
16216 | ALC662_3ST_6ch_DIG), | |
cb55974c HRK |
16217 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", |
16218 | ALC662_3ST_6ch_DIG), | |
19c009aa | 16219 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), |
dea0a509 | 16220 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), |
238713d4 | 16221 | SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0", |
19c009aa | 16222 | ALC662_3ST_6ch_DIG), |
dea0a509 TI |
16223 | SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x", |
16224 | ALC663_ASUS_H13), | |
bc9f98a9 KY |
16225 | {} |
16226 | }; | |
16227 | ||
16228 | static struct alc_config_preset alc662_presets[] = { | |
16229 | [ALC662_3ST_2ch_DIG] = { | |
f9e336f6 | 16230 | .mixers = { alc662_3ST_2ch_mixer }, |
bc9f98a9 KY |
16231 | .init_verbs = { alc662_init_verbs }, |
16232 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16233 | .dac_nids = alc662_dac_nids, | |
16234 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16235 | .dig_in_nid = ALC662_DIGIN_NID, |
16236 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16237 | .channel_mode = alc662_3ST_2ch_modes, | |
16238 | .input_mux = &alc662_capture_source, | |
16239 | }, | |
16240 | [ALC662_3ST_6ch_DIG] = { | |
f9e336f6 | 16241 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16242 | .init_verbs = { alc662_init_verbs }, |
16243 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16244 | .dac_nids = alc662_dac_nids, | |
16245 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16246 | .dig_in_nid = ALC662_DIGIN_NID, |
16247 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
16248 | .channel_mode = alc662_3ST_6ch_modes, | |
16249 | .need_dac_fix = 1, | |
16250 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 16251 | }, |
bc9f98a9 | 16252 | [ALC662_3ST_6ch] = { |
f9e336f6 | 16253 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16254 | .init_verbs = { alc662_init_verbs }, |
16255 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16256 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
16257 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
16258 | .channel_mode = alc662_3ST_6ch_modes, | |
16259 | .need_dac_fix = 1, | |
16260 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 16261 | }, |
bc9f98a9 | 16262 | [ALC662_5ST_DIG] = { |
f9e336f6 | 16263 | .mixers = { alc662_base_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16264 | .init_verbs = { alc662_init_verbs }, |
16265 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16266 | .dac_nids = alc662_dac_nids, | |
16267 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16268 | .dig_in_nid = ALC662_DIGIN_NID, |
16269 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
16270 | .channel_mode = alc662_5stack_modes, | |
16271 | .input_mux = &alc662_capture_source, | |
16272 | }, | |
16273 | [ALC662_LENOVO_101E] = { | |
f9e336f6 | 16274 | .mixers = { alc662_lenovo_101e_mixer }, |
bc9f98a9 KY |
16275 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, |
16276 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16277 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
16278 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16279 | .channel_mode = alc662_3ST_2ch_modes, | |
16280 | .input_mux = &alc662_lenovo_101e_capture_source, | |
16281 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
16282 | .init_hook = alc662_lenovo_101e_all_automute, | |
16283 | }, | |
291702f0 | 16284 | [ALC662_ASUS_EEEPC_P701] = { |
f9e336f6 | 16285 | .mixers = { alc662_eeepc_p701_mixer }, |
291702f0 KY |
16286 | .init_verbs = { alc662_init_verbs, |
16287 | alc662_eeepc_sue_init_verbs }, | |
16288 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16289 | .dac_nids = alc662_dac_nids, | |
291702f0 KY |
16290 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16291 | .channel_mode = alc662_3ST_2ch_modes, | |
16292 | .input_mux = &alc662_eeepc_capture_source, | |
16293 | .unsol_event = alc662_eeepc_unsol_event, | |
16294 | .init_hook = alc662_eeepc_inithook, | |
16295 | }, | |
8c427226 | 16296 | [ALC662_ASUS_EEEPC_EP20] = { |
f9e336f6 | 16297 | .mixers = { alc662_eeepc_ep20_mixer, |
8c427226 KY |
16298 | alc662_chmode_mixer }, |
16299 | .init_verbs = { alc662_init_verbs, | |
16300 | alc662_eeepc_ep20_sue_init_verbs }, | |
16301 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16302 | .dac_nids = alc662_dac_nids, | |
8c427226 KY |
16303 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
16304 | .channel_mode = alc662_3ST_6ch_modes, | |
16305 | .input_mux = &alc662_lenovo_101e_capture_source, | |
16306 | .unsol_event = alc662_eeepc_ep20_unsol_event, | |
16307 | .init_hook = alc662_eeepc_ep20_inithook, | |
16308 | }, | |
f1d4e28b | 16309 | [ALC662_ECS] = { |
f9e336f6 | 16310 | .mixers = { alc662_ecs_mixer }, |
f1d4e28b KY |
16311 | .init_verbs = { alc662_init_verbs, |
16312 | alc662_ecs_init_verbs }, | |
16313 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16314 | .dac_nids = alc662_dac_nids, | |
16315 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16316 | .channel_mode = alc662_3ST_2ch_modes, | |
16317 | .input_mux = &alc662_eeepc_capture_source, | |
16318 | .unsol_event = alc662_eeepc_unsol_event, | |
16319 | .init_hook = alc662_eeepc_inithook, | |
16320 | }, | |
6dda9f4a | 16321 | [ALC663_ASUS_M51VA] = { |
f9e336f6 | 16322 | .mixers = { alc663_m51va_mixer }, |
6dda9f4a KY |
16323 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, |
16324 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16325 | .dac_nids = alc662_dac_nids, | |
16326 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16327 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16328 | .channel_mode = alc662_3ST_2ch_modes, | |
16329 | .input_mux = &alc663_m51va_capture_source, | |
16330 | .unsol_event = alc663_m51va_unsol_event, | |
16331 | .init_hook = alc663_m51va_inithook, | |
16332 | }, | |
16333 | [ALC663_ASUS_G71V] = { | |
f9e336f6 | 16334 | .mixers = { alc663_g71v_mixer }, |
6dda9f4a KY |
16335 | .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, |
16336 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16337 | .dac_nids = alc662_dac_nids, | |
16338 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16339 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16340 | .channel_mode = alc662_3ST_2ch_modes, | |
16341 | .input_mux = &alc662_eeepc_capture_source, | |
16342 | .unsol_event = alc663_g71v_unsol_event, | |
16343 | .init_hook = alc663_g71v_inithook, | |
16344 | }, | |
16345 | [ALC663_ASUS_H13] = { | |
f9e336f6 | 16346 | .mixers = { alc663_m51va_mixer }, |
6dda9f4a KY |
16347 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, |
16348 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16349 | .dac_nids = alc662_dac_nids, | |
16350 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16351 | .channel_mode = alc662_3ST_2ch_modes, | |
16352 | .input_mux = &alc663_m51va_capture_source, | |
16353 | .unsol_event = alc663_m51va_unsol_event, | |
16354 | .init_hook = alc663_m51va_inithook, | |
16355 | }, | |
16356 | [ALC663_ASUS_G50V] = { | |
f9e336f6 | 16357 | .mixers = { alc663_g50v_mixer }, |
6dda9f4a KY |
16358 | .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, |
16359 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16360 | .dac_nids = alc662_dac_nids, | |
16361 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16362 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
16363 | .channel_mode = alc662_3ST_6ch_modes, | |
16364 | .input_mux = &alc663_capture_source, | |
16365 | .unsol_event = alc663_g50v_unsol_event, | |
16366 | .init_hook = alc663_g50v_inithook, | |
16367 | }, | |
f1d4e28b | 16368 | [ALC663_ASUS_MODE1] = { |
f9e336f6 TI |
16369 | .mixers = { alc663_m51va_mixer }, |
16370 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16371 | .init_verbs = { alc662_init_verbs, |
16372 | alc663_21jd_amic_init_verbs }, | |
16373 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16374 | .hp_nid = 0x03, | |
16375 | .dac_nids = alc662_dac_nids, | |
16376 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16377 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16378 | .channel_mode = alc662_3ST_2ch_modes, | |
16379 | .input_mux = &alc662_eeepc_capture_source, | |
16380 | .unsol_event = alc663_mode1_unsol_event, | |
16381 | .init_hook = alc663_mode1_inithook, | |
16382 | }, | |
16383 | [ALC662_ASUS_MODE2] = { | |
f9e336f6 TI |
16384 | .mixers = { alc662_1bjd_mixer }, |
16385 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16386 | .init_verbs = { alc662_init_verbs, |
16387 | alc662_1bjd_amic_init_verbs }, | |
16388 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16389 | .dac_nids = alc662_dac_nids, | |
16390 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16391 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16392 | .channel_mode = alc662_3ST_2ch_modes, | |
16393 | .input_mux = &alc662_eeepc_capture_source, | |
16394 | .unsol_event = alc662_mode2_unsol_event, | |
16395 | .init_hook = alc662_mode2_inithook, | |
16396 | }, | |
16397 | [ALC663_ASUS_MODE3] = { | |
f9e336f6 TI |
16398 | .mixers = { alc663_two_hp_m1_mixer }, |
16399 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16400 | .init_verbs = { alc662_init_verbs, |
16401 | alc663_two_hp_amic_m1_init_verbs }, | |
16402 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16403 | .hp_nid = 0x03, | |
16404 | .dac_nids = alc662_dac_nids, | |
16405 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16406 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16407 | .channel_mode = alc662_3ST_2ch_modes, | |
16408 | .input_mux = &alc662_eeepc_capture_source, | |
16409 | .unsol_event = alc663_mode3_unsol_event, | |
16410 | .init_hook = alc663_mode3_inithook, | |
16411 | }, | |
16412 | [ALC663_ASUS_MODE4] = { | |
f9e336f6 TI |
16413 | .mixers = { alc663_asus_21jd_clfe_mixer }, |
16414 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16415 | .init_verbs = { alc662_init_verbs, |
16416 | alc663_21jd_amic_init_verbs}, | |
16417 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16418 | .hp_nid = 0x03, | |
16419 | .dac_nids = alc662_dac_nids, | |
16420 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16421 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16422 | .channel_mode = alc662_3ST_2ch_modes, | |
16423 | .input_mux = &alc662_eeepc_capture_source, | |
16424 | .unsol_event = alc663_mode4_unsol_event, | |
16425 | .init_hook = alc663_mode4_inithook, | |
16426 | }, | |
16427 | [ALC663_ASUS_MODE5] = { | |
f9e336f6 TI |
16428 | .mixers = { alc663_asus_15jd_clfe_mixer }, |
16429 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16430 | .init_verbs = { alc662_init_verbs, |
16431 | alc663_15jd_amic_init_verbs }, | |
16432 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16433 | .hp_nid = 0x03, | |
16434 | .dac_nids = alc662_dac_nids, | |
16435 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16436 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16437 | .channel_mode = alc662_3ST_2ch_modes, | |
16438 | .input_mux = &alc662_eeepc_capture_source, | |
16439 | .unsol_event = alc663_mode5_unsol_event, | |
16440 | .init_hook = alc663_mode5_inithook, | |
16441 | }, | |
16442 | [ALC663_ASUS_MODE6] = { | |
f9e336f6 TI |
16443 | .mixers = { alc663_two_hp_m2_mixer }, |
16444 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16445 | .init_verbs = { alc662_init_verbs, |
16446 | alc663_two_hp_amic_m2_init_verbs }, | |
16447 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16448 | .hp_nid = 0x03, | |
16449 | .dac_nids = alc662_dac_nids, | |
16450 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16451 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16452 | .channel_mode = alc662_3ST_2ch_modes, | |
16453 | .input_mux = &alc662_eeepc_capture_source, | |
16454 | .unsol_event = alc663_mode6_unsol_event, | |
16455 | .init_hook = alc663_mode6_inithook, | |
16456 | }, | |
bc9f98a9 KY |
16457 | }; |
16458 | ||
16459 | ||
16460 | /* | |
16461 | * BIOS auto configuration | |
16462 | */ | |
16463 | ||
16464 | /* add playback controls from the parsed DAC table */ | |
16465 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
16466 | const struct auto_pin_cfg *cfg) | |
16467 | { | |
16468 | char name[32]; | |
16469 | static const char *chname[4] = { | |
16470 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
16471 | }; | |
16472 | hda_nid_t nid; | |
16473 | int i, err; | |
16474 | ||
16475 | for (i = 0; i < cfg->line_outs; i++) { | |
16476 | if (!spec->multiout.dac_nids[i]) | |
16477 | continue; | |
b60dd394 | 16478 | nid = alc880_idx_to_dac(i); |
bc9f98a9 KY |
16479 | if (i == 2) { |
16480 | /* Center/LFE */ | |
16481 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
16482 | "Center Playback Volume", | |
f12ab1e0 TI |
16483 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
16484 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16485 | if (err < 0) |
16486 | return err; | |
16487 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
16488 | "LFE Playback Volume", | |
f12ab1e0 TI |
16489 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
16490 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16491 | if (err < 0) |
16492 | return err; | |
b69ce01a | 16493 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
bc9f98a9 | 16494 | "Center Playback Switch", |
b69ce01a | 16495 | HDA_COMPOSE_AMP_VAL(0x0e, 1, 0, |
f12ab1e0 | 16496 | HDA_INPUT)); |
bc9f98a9 KY |
16497 | if (err < 0) |
16498 | return err; | |
b69ce01a | 16499 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
bc9f98a9 | 16500 | "LFE Playback Switch", |
b69ce01a | 16501 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, |
f12ab1e0 | 16502 | HDA_INPUT)); |
bc9f98a9 KY |
16503 | if (err < 0) |
16504 | return err; | |
16505 | } else { | |
16506 | sprintf(name, "%s Playback Volume", chname[i]); | |
16507 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
16508 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
16509 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16510 | if (err < 0) |
16511 | return err; | |
16512 | sprintf(name, "%s Playback Switch", chname[i]); | |
b69ce01a HRK |
16513 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
16514 | HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), | |
16515 | 3, 0, HDA_INPUT)); | |
bc9f98a9 KY |
16516 | if (err < 0) |
16517 | return err; | |
16518 | } | |
16519 | } | |
16520 | return 0; | |
16521 | } | |
16522 | ||
16523 | /* add playback controls for speaker and HP outputs */ | |
16524 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
16525 | const char *pfx) | |
16526 | { | |
16527 | hda_nid_t nid; | |
16528 | int err; | |
16529 | char name[32]; | |
16530 | ||
16531 | if (!pin) | |
16532 | return 0; | |
16533 | ||
24fb9173 TI |
16534 | if (pin == 0x17) { |
16535 | /* ALC663 has a mono output pin on 0x17 */ | |
16536 | sprintf(name, "%s Playback Switch", pfx); | |
16537 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
16538 | HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT)); | |
16539 | return err; | |
16540 | } | |
16541 | ||
bc9f98a9 KY |
16542 | if (alc880_is_fixed_pin(pin)) { |
16543 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
939778ae | 16544 | /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */ |
bc9f98a9 KY |
16545 | /* specify the DAC as the extra output */ |
16546 | if (!spec->multiout.hp_nid) | |
16547 | spec->multiout.hp_nid = nid; | |
16548 | else | |
16549 | spec->multiout.extra_out_nid[0] = nid; | |
16550 | /* control HP volume/switch on the output mixer amp */ | |
16551 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
16552 | sprintf(name, "%s Playback Volume", pfx); | |
16553 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
16554 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
16555 | if (err < 0) | |
16556 | return err; | |
16557 | sprintf(name, "%s Playback Switch", pfx); | |
16558 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
16559 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
16560 | if (err < 0) | |
16561 | return err; | |
16562 | } else if (alc880_is_multi_pin(pin)) { | |
16563 | /* set manual connection */ | |
16564 | /* we have only a switch on HP-out PIN */ | |
16565 | sprintf(name, "%s Playback Switch", pfx); | |
16566 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
16567 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
16568 | if (err < 0) | |
16569 | return err; | |
16570 | } | |
16571 | return 0; | |
16572 | } | |
16573 | ||
16574 | /* create playback/capture controls for input pins */ | |
16575 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
16576 | const struct auto_pin_cfg *cfg) | |
16577 | { | |
61b9b9b1 | 16578 | struct hda_input_mux *imux = &spec->private_imux[0]; |
bc9f98a9 KY |
16579 | int i, err, idx; |
16580 | ||
16581 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
16582 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
16583 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
16584 | err = new_analog_input(spec, cfg->input_pins[i], | |
16585 | auto_pin_cfg_labels[i], | |
16586 | idx, 0x0b); | |
16587 | if (err < 0) | |
16588 | return err; | |
16589 | imux->items[imux->num_items].label = | |
16590 | auto_pin_cfg_labels[i]; | |
16591 | imux->items[imux->num_items].index = | |
16592 | alc880_input_pin_idx(cfg->input_pins[i]); | |
16593 | imux->num_items++; | |
16594 | } | |
16595 | } | |
16596 | return 0; | |
16597 | } | |
16598 | ||
16599 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
16600 | hda_nid_t nid, int pin_type, | |
16601 | int dac_idx) | |
16602 | { | |
f6c7e546 | 16603 | alc_set_pin_output(codec, nid, pin_type); |
bc9f98a9 KY |
16604 | /* need the manual connection? */ |
16605 | if (alc880_is_multi_pin(nid)) { | |
16606 | struct alc_spec *spec = codec->spec; | |
16607 | int idx = alc880_multi_pin_idx(nid); | |
16608 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
16609 | AC_VERB_SET_CONNECT_SEL, | |
16610 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
16611 | } | |
16612 | } | |
16613 | ||
16614 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
16615 | { | |
16616 | struct alc_spec *spec = codec->spec; | |
16617 | int i; | |
16618 | ||
8c427226 | 16619 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
bc9f98a9 KY |
16620 | for (i = 0; i <= HDA_SIDE; i++) { |
16621 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 16622 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 16623 | if (nid) |
baba8ee9 | 16624 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
16625 | i); |
16626 | } | |
16627 | } | |
16628 | ||
16629 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
16630 | { | |
16631 | struct alc_spec *spec = codec->spec; | |
16632 | hda_nid_t pin; | |
16633 | ||
16634 | pin = spec->autocfg.hp_pins[0]; | |
16635 | if (pin) /* connect to front */ | |
16636 | /* use dac 0 */ | |
16637 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
16638 | pin = spec->autocfg.speaker_pins[0]; |
16639 | if (pin) | |
16640 | alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
bc9f98a9 KY |
16641 | } |
16642 | ||
16643 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
16644 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
16645 | ||
16646 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
16647 | { | |
16648 | struct alc_spec *spec = codec->spec; | |
16649 | int i; | |
16650 | ||
16651 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
16652 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
16653 | if (alc662_is_input_pin(nid)) { | |
16654 | snd_hda_codec_write(codec, nid, 0, | |
16655 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
16656 | (i <= AUTO_PIN_FRONT_MIC ? | |
16657 | PIN_VREF80 : PIN_IN)); | |
16658 | if (nid != ALC662_PIN_CD_NID) | |
16659 | snd_hda_codec_write(codec, nid, 0, | |
16660 | AC_VERB_SET_AMP_GAIN_MUTE, | |
16661 | AMP_OUT_MUTE); | |
16662 | } | |
16663 | } | |
16664 | } | |
16665 | ||
f511b01c TI |
16666 | #define alc662_auto_init_input_src alc882_auto_init_input_src |
16667 | ||
bc9f98a9 KY |
16668 | static int alc662_parse_auto_config(struct hda_codec *codec) |
16669 | { | |
16670 | struct alc_spec *spec = codec->spec; | |
16671 | int err; | |
16672 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
16673 | ||
16674 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
16675 | alc662_ignore); | |
16676 | if (err < 0) | |
16677 | return err; | |
16678 | if (!spec->autocfg.line_outs) | |
16679 | return 0; /* can't find valid BIOS pin config */ | |
16680 | ||
f12ab1e0 TI |
16681 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
16682 | if (err < 0) | |
16683 | return err; | |
16684 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
16685 | if (err < 0) | |
16686 | return err; | |
16687 | err = alc662_auto_create_extra_out(spec, | |
16688 | spec->autocfg.speaker_pins[0], | |
16689 | "Speaker"); | |
16690 | if (err < 0) | |
16691 | return err; | |
16692 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
16693 | "Headphone"); | |
16694 | if (err < 0) | |
16695 | return err; | |
16696 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
16697 | if (err < 0) | |
bc9f98a9 KY |
16698 | return err; |
16699 | ||
16700 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
16701 | ||
0852d7a6 | 16702 | if (spec->autocfg.dig_outs) |
bc9f98a9 KY |
16703 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; |
16704 | ||
603c4019 | 16705 | if (spec->kctls.list) |
d88897ea | 16706 | add_mixer(spec, spec->kctls.list); |
bc9f98a9 KY |
16707 | |
16708 | spec->num_mux_defs = 1; | |
61b9b9b1 | 16709 | spec->input_mux = &spec->private_imux[0]; |
ea1fb29a | 16710 | |
d88897ea | 16711 | add_verb(spec, alc662_auto_init_verbs); |
24fb9173 | 16712 | if (codec->vendor_id == 0x10ec0663) |
d88897ea | 16713 | add_verb(spec, alc663_auto_init_verbs); |
ee979a14 TI |
16714 | |
16715 | err = alc_auto_add_mic_boost(codec); | |
16716 | if (err < 0) | |
16717 | return err; | |
16718 | ||
e044c39a | 16719 | store_pin_configs(codec); |
8c87286f | 16720 | return 1; |
bc9f98a9 KY |
16721 | } |
16722 | ||
16723 | /* additional initialization for auto-configuration model */ | |
16724 | static void alc662_auto_init(struct hda_codec *codec) | |
16725 | { | |
f6c7e546 | 16726 | struct alc_spec *spec = codec->spec; |
bc9f98a9 KY |
16727 | alc662_auto_init_multi_out(codec); |
16728 | alc662_auto_init_hp_out(codec); | |
16729 | alc662_auto_init_analog_input(codec); | |
f511b01c | 16730 | alc662_auto_init_input_src(codec); |
f6c7e546 | 16731 | if (spec->unsol_event) |
7fb0d78f | 16732 | alc_inithook(codec); |
bc9f98a9 KY |
16733 | } |
16734 | ||
16735 | static int patch_alc662(struct hda_codec *codec) | |
16736 | { | |
16737 | struct alc_spec *spec; | |
16738 | int err, board_config; | |
16739 | ||
16740 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
16741 | if (!spec) | |
16742 | return -ENOMEM; | |
16743 | ||
16744 | codec->spec = spec; | |
16745 | ||
2c3bf9ab TI |
16746 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
16747 | ||
bc9f98a9 KY |
16748 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, |
16749 | alc662_models, | |
16750 | alc662_cfg_tbl); | |
16751 | if (board_config < 0) { | |
16752 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
16753 | "trying auto-probe from BIOS...\n"); | |
16754 | board_config = ALC662_AUTO; | |
16755 | } | |
16756 | ||
16757 | if (board_config == ALC662_AUTO) { | |
16758 | /* automatic parse from the BIOS config */ | |
16759 | err = alc662_parse_auto_config(codec); | |
16760 | if (err < 0) { | |
16761 | alc_free(codec); | |
16762 | return err; | |
8c87286f | 16763 | } else if (!err) { |
bc9f98a9 KY |
16764 | printk(KERN_INFO |
16765 | "hda_codec: Cannot set up configuration " | |
16766 | "from BIOS. Using base mode...\n"); | |
16767 | board_config = ALC662_3ST_2ch_DIG; | |
16768 | } | |
16769 | } | |
16770 | ||
680cd536 KK |
16771 | err = snd_hda_attach_beep_device(codec, 0x1); |
16772 | if (err < 0) { | |
16773 | alc_free(codec); | |
16774 | return err; | |
16775 | } | |
16776 | ||
bc9f98a9 KY |
16777 | if (board_config != ALC662_AUTO) |
16778 | setup_preset(spec, &alc662_presets[board_config]); | |
16779 | ||
6dda9f4a KY |
16780 | if (codec->vendor_id == 0x10ec0663) { |
16781 | spec->stream_name_analog = "ALC663 Analog"; | |
16782 | spec->stream_name_digital = "ALC663 Digital"; | |
01afd41f KY |
16783 | } else if (codec->vendor_id == 0x10ec0272) { |
16784 | spec->stream_name_analog = "ALC272 Analog"; | |
16785 | spec->stream_name_digital = "ALC272 Digital"; | |
6dda9f4a KY |
16786 | } else { |
16787 | spec->stream_name_analog = "ALC662 Analog"; | |
16788 | spec->stream_name_digital = "ALC662 Digital"; | |
16789 | } | |
16790 | ||
bc9f98a9 KY |
16791 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
16792 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
16793 | ||
bc9f98a9 KY |
16794 | spec->stream_digital_playback = &alc662_pcm_digital_playback; |
16795 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
16796 | ||
e1406348 TI |
16797 | spec->adc_nids = alc662_adc_nids; |
16798 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
16799 | spec->capsrc_nids = alc662_capsrc_nids; | |
61b9b9b1 | 16800 | spec->capture_style = CAPT_MIX; |
bc9f98a9 | 16801 | |
f9e336f6 TI |
16802 | if (!spec->cap_mixer) |
16803 | set_capture_mixer(spec); | |
45bdd1c1 | 16804 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
f9e336f6 | 16805 | |
2134ea4f TI |
16806 | spec->vmaster_nid = 0x02; |
16807 | ||
bc9f98a9 KY |
16808 | codec->patch_ops = alc_patch_ops; |
16809 | if (board_config == ALC662_AUTO) | |
16810 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
16811 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
16812 | if (!spec->loopback.amplist) | |
16813 | spec->loopback.amplist = alc662_loopbacks; | |
16814 | #endif | |
daead538 | 16815 | codec->proc_widget_hook = print_realtek_coef; |
bc9f98a9 KY |
16816 | |
16817 | return 0; | |
16818 | } | |
16819 | ||
1da177e4 LT |
16820 | /* |
16821 | * patch entries | |
16822 | */ | |
1289e9e8 | 16823 | static struct hda_codec_preset snd_hda_preset_realtek[] = { |
1da177e4 | 16824 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
df694daa | 16825 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f6a92248 | 16826 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
a361d84b | 16827 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f6a92248 | 16828 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
01afd41f | 16829 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
f32610ed | 16830 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 16831 | .patch = patch_alc861 }, |
f32610ed JS |
16832 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
16833 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
16834 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
16835 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
16836 | .patch = patch_alc883 }, | |
16837 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
16838 | .patch = patch_alc662 }, | |
6dda9f4a | 16839 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
f32610ed | 16840 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 16841 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 16842 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
669faba2 CM |
16843 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
16844 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | |
cb308f97 | 16845 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
7943a8ab | 16846 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ |
df694daa | 16847 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
a385a529 | 16848 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, |
4442608d KY |
16849 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
16850 | .patch = patch_alc883 }, | |
3fea2cb0 | 16851 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
f6a92248 | 16852 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, |
1da177e4 LT |
16853 | {} /* terminator */ |
16854 | }; | |
1289e9e8 TI |
16855 | |
16856 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); | |
16857 | ||
16858 | MODULE_LICENSE("GPL"); | |
16859 | MODULE_DESCRIPTION("Realtek HD-audio codec"); | |
16860 | ||
16861 | static struct hda_codec_preset_list realtek_list = { | |
16862 | .preset = snd_hda_preset_realtek, | |
16863 | .owner = THIS_MODULE, | |
16864 | }; | |
16865 | ||
16866 | static int __init patch_realtek_init(void) | |
16867 | { | |
16868 | return snd_hda_add_codec_preset(&realtek_list); | |
16869 | } | |
16870 | ||
16871 | static void __exit patch_realtek_exit(void) | |
16872 | { | |
16873 | snd_hda_delete_codec_preset(&realtek_list); | |
16874 | } | |
16875 | ||
16876 | module_init(patch_realtek_init) | |
16877 | module_exit(patch_realtek_exit) |